Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
MegaWays
//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 class Program { public static void Main(string[] args) { MegaWaysPlateManager manager = new MegaWaysPlateManager(); //test plate List<List<int>> plate = manager.ConvertStringToPlate("18C1,J10,813,5566,4V4588,PTT"); foreach (List<int> column in plate) { foreach (int symbol in column) { Console.Write(symbol+" "); } Console.WriteLine(); } //test award List<int> awardGrids = manager.CheckAward(1, 3, plate); foreach (int grid in awardGrids) { Console.WriteLine(grid); } } } public class MegaWaysPlateManager { private int columnCount = 6; private int symbolWild = 10; private string colorIdMain = "#BFBFBF"; private string colorIdFree = "#D3351C"; // Constructor 設定盤面資料 public MegaWaysPlateManager() { } // 轉換盤面字串成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 紀錄獎項位置座標,十位數為column,個位數為row ex: 第一行第三列 -> 2, 第三行第一列-> 20 // 由於此遊戲每局每個column長度不定,無法以序列表示中獎位置,改以座標方式呈現 // 座標起始點以左下為(0,0) // @symbol 中獎符號 // @connect 連線長度 // @plate 盤面 public List<int> CheckAward(int symbol, int connect, List<List<int>> plate) { List<int> awardGrids = new List<int>(); for (int i = 0 ; i < connect; ++i) { for (int j = 0 ; j < plate[i].Count; ++j) { if (plate[i][j] == symbol || plate[i][j] == symbolWild) { awardGrids.Add(i*10+j); } } } return awardGrids; } // 取得色碼 public string GetColorString(int colorId) { if (colorId == 1 ) { return colorIdMain; } return colorIdFree; } } }
run
|
edit
|
history
|
help
0
test
Array value changer?
Par ou ímpar
NumsToVars
Output to get sum = 5 in given array of integers
Bid Status
Sorting String Problem need help
Compiler
sdcasdcasdcsadxcd
Bubble Sort