Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
SevenSevenSeven
//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) { SevenSevenSevenPlateManager manager = new SevenSevenSevenPlateManager(); List<List<int>> plate = manager.ConvertStringToPlate("010000020"); List<int> symbolPosition = manager.CheckLine(0); foreach (int index in symbolPosition) { Console.WriteLine(index); } } } public class SevenSevenSevenPlateManager { private int columnCount = 3; private int rowCount = 3; private PlateSetting plateSetting; private string colorIdMain = "#12345678"; private string colorIdBonus = "#12345678"; private List<int>[] lineInfo = new List<int>[5]; private List<int>[] bonusLineInfo = new List<int>[2]; // Constructor 設定盤面資料 public SevenSevenSevenPlateManager() { plateSetting.seperateCount = new List<int>(); plateSetting.direction = PlateDirection.Vertical; for (int i = 0 ; i < columnCount ; ++i) { plateSetting.seperateCount.Add(rowCount); } for (int i = 0 ; i < 5 ; i++) { if (i == 0) { lineInfo[i] = new List<int>{ 0, 3, 6 }; } else if (i == 1) { lineInfo[i] = new List<int>{ 1, 4, 7 }; } else if (i == 2) { lineInfo[i] = new List<int>{ 2, 5, 8 }; } else if (i == 3) { lineInfo[i] = new List<int>{ 0, 4, 8 }; } else if (i == 4) { lineInfo[i] = new List<int>{ 2, 4, 6 }; } } for (int i = 0 ; i < 2 ; i++) { if (i == 0) { bonusLineInfo[i] = new List<int>{ 1, 4, 7 }; } else if (i == 1) { bonusLineInfo[i] = new List<int>{ 1, 3, 5, 7 }; } } } // 轉換盤面字串成List<List<int>> public List<List<int>> ConvertStringToPlate(string plateStr) { List<List<int>> plate = new List<List<int>>(); if (plateSetting.seperateCount.Count < 1) { return plate; } char[] plateArray = plateStr.ToCharArray(); int currentCount = 0; foreach (int count in plateSetting.seperateCount) { List<int> tempList = new List<int>(); for( int i = currentCount ; i < currentCount+count; ++i ) { int intValue = int.Parse(plateArray[i].ToString(), System.Globalization.NumberStyles.HexNumber); tempList.Add(intValue); } plate.Add(tempList); currentCount += count; } return plate; } public List<int> CheckLine(int gameType, int lineIndex) { List<int> temp = new List<int>(); if (gameType == 0) { for (int i = 0 ; i < rowCount; ++i) { temp.Add(lineInfo[lineIndex][i]); } } else if (gameType == 1) { if (lineIndex == 1) { for (int i = 0 ; i < 4; ++i) { temp.Add(bonusLineInfo[lineIndex][i]); } } else { for (int i = 0 ; i < rowCount; ++i) { temp.Add(bonusLineInfo[lineIndex][i]); } } } else { for (int i = 0 ; i < rowCount; ++i) { temp.Add(bonusLineInfo[lineIndex][i]); } } return temp; } // 取得盤面設定 public PlateSetting GetPlateSetting() { return plateSetting; } // 取得色碼 public string GetColorString(int colorId) { if (colorId == 1 ) { return colorIdMain; } return colorIdBonus; } } }
run
|
edit
|
history
|
help
0
IntToExcelColumnNotation
Arrange Hex string in a new one as a byte array declaration
Daily Coding Problem: Problem #2
Dungeon Game
ternary function
Fórum ➡ Calculate the Sum of Values in List of KeyValuePair<> objects ♦
mysrc.tcl
from Base or Derived
occurance of charecter
Dependency Injection - with class