Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
MegaWays3
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public static class PlateDirection { public const int Vertical = 1; // 直 public const int Horizontal = 2; // 橫 } public struct PlateSetting { // 盤面編號方向 public int direction; // 幾個symbol一組 public List<int> seperateCount; } public class Program { public static void Main(string[] args) { MegaWays3PlateManager manager = new MegaWays3PlateManager(); PlateSetting plateSetting = manager.GetPlateSetting("G14A,0456,35,56,9012,123"); foreach (int count in plateSetting.seperateCount) { Console.Write(count+" "); } Console.WriteLine(); //test plate List<List<int>> plate = manager.ConvertStringToPlate("G14A,0456,35,56,9012,123"); foreach (List<int> column in plate) { foreach (int symbol in column) { Console.Write(symbol+" "); } Console.WriteLine(); } //test award List<int> awardGrids = manager.CheckAward(9, 0, plate); foreach (int grid in awardGrids) { Console.WriteLine(grid); } //test lamp List<int> lampTag = manager.GetLampTag("10,2,5,50"); foreach (int n in lampTag) { Console.WriteLine(n); } } } public class MegaWays3PlateManager { private int columnCount = 6; private int symbolWild = 16; private string colorIdMain = "#BFBFBF"; private string colorIdFree = "#D3351C"; // Constructor 設定盤面資料 public MegaWays3PlateManager() {} // 取得盤面設定 public PlateSetting GetPlateSetting(string plateStr) { PlateSetting setting; setting.direction = PlateDirection.Vertical; setting.seperateCount = new List<int>(); string[] tempStrArray = plateStr.Split(','); int seperateCount = 0; for( int i = 0 ; i < tempStrArray.Length; ++i ) { char[] chars = tempStrArray[i].ToCharArray(); setting.seperateCount.Add(chars.Length); } return setting; } // 轉換盤面字串成List<List<int>> public List<List<int>> ConvertStringToPlate(string plateStr) { List<List<int>> plate = new List<List<int>>(); string[] tempStrArray = plateStr.Split(','); foreach (string str in tempStrArray) { char[] columnArray = str.ToCharArray(); List<int> tempList = new List<int>(); for( int i = 0 ; i < columnArray.Length; ++i ) { int intValue = (int)columnArray[i]; if (intValue < 58) { intValue = (int)columnArray[i]-48; } else { intValue = (int)columnArray[i]-55; } tempList.Add(intValue); } plate.Add(tempList); } return plate; } // CheckAward // @symbol 中獎符號 // @connect 連線長度 // @plate 盤面 public List<int> CheckAward(int symbol, int connect, List<List<int>> plate) { List<int> award = new List<int>(); int sumCol = 0; if (connect > 0) //一般線獎 { for (int i = 0 ; i < connect; ++i) { for (int j = 0 ; j < plate[i].Count; ++j) { if (IsSameSymbol(plate[i][j], symbol) || plate[i][j] == symbolWild) { award.Add(sumCol+j); } if(j == plate[i].Count-1) { sumCol += plate[i].Count; } } } } else { //神燈獎 for (int i = 0 ; i < columnCount; ++i) { for (int j = 0 ; j < plate[i].Count; ++j) { if (IsLamp(plate[i][j]) || plate[i][j] == symbolWild) { award.Add(sumCol+j); } if(j == plate[i].Count-1) { sumCol += plate[i].Count; } } } } return award; } public bool IsSameSymbol(int a, int b) { if (a == b) return true; if (IsLamp(a) && IsLamp(b)) return true; return false; } public bool IsLamp(int symbol) { if (symbol >= 9 && symbol <= 15) return true; return false; } // 轉換盤面字串成List<List<int>> public List<int> GetLampTag(string lampTagStr) { List<int> lampTag = new List<int>(); string[] tempStrArray = lampTagStr.Split(','); foreach (string str in tempStrArray) { int result = Int32.Parse(str); lampTag.Add(result); } return lampTag; } // 取得色碼 public string GetColorString(int colorId) { if (colorId == 1 ) { return colorIdMain; } return colorIdFree; } } }
run
|
edit
|
history
|
help
0
Funzpoint
Random number guessing game v1
Plt-D v.0.9.3.1
Flipping a bit
rekenmachine in c#
a5
length
Delegate & anonymous method
.heap sort
cff