static void Main(string[] args) { Console.SetWindowSize(90, 25); DisplayLogo(); ipaddr = SetIP(); Shuffler shuffler = new Shuffler(); Console.WriteLine("\nThis is the server window. \n"); Console.WriteLine("Hit enter for a standard game, otherwise enter 'custom'"); if (Console.ReadLine().ToLower() == "custom") { Console.WriteLine("Set the server port (enter d for default) :"); string temp = Console.ReadLine(); if(temp.ToLower().Trim() != "d") { port = int.Parse(temp); } Console.WriteLine("Max cards: (recommended 5-15)"); int maxCards = int.Parse(Console.ReadLine()); Console.WriteLine("Win threshold: (recommended 10-30) points"); int pointThresh = int.Parse(Console.ReadLine()); bool[] CardsToUse = new bool[whiteCardFilePaths.Length]; for (int i = 1; i < CardsToUse.Length; i++ ) { string name = whiteCardFilePaths[i].Substring(whiteCardFilePaths[i].LastIndexOf('\\')+1); Console.WriteLine("Would you like to use the " + name.Substring(0,name.IndexOf('.')) + " card set: (y or n)"); if (Console.ReadLine().ToLower() == "y") { CardsToUse[i] = true; } else { CardsToUse[i] = false; } } gameManager = new GameManager(maxCards,pointThresh); List<CardSet> whiteCardSets = new List<CardSet>(); List<CardSet> blackCardSets = new List<CardSet>(); List<Card> AllWhiteCards = new List<Card>(); List<Card> AllBlackCards = new List<Card>(); for (int i = 0; i < CardsToUse.Length; i++) { if (CardsToUse[i] == true) { whiteCardSets.Add(DeserializeCards(whiteCardFilePaths[i])); blackCardSets.Add(DeserializeCards(blackCardFilePaths[i])); } } for (int i = 0; i < whiteCardSets.Count; i++) { AllWhiteCards.AddRange(whiteCardSets[i].cards); AllBlackCards.AddRange(blackCardSets[i].cards); } shuffler.Shuffle(AllWhiteCards); shuffler.Shuffle(AllBlackCards); foreach (Card c in AllWhiteCards) { gameManager.whiteDeck.Push(c); } foreach (Card c in AllBlackCards) { gameManager.blackDeck.Push(c); } } else { gameManager = new GameManager(); CardSet whiteCardSet = DeserializeCards(Path.Combine(cardDirectory, "white/all.json")); CardSet blackCardSet = DeserializeCards(Path.Combine(cardDirectory, "black/all.json")); shuffler.Shuffle(whiteCardSet.cards); shuffler.Shuffle(blackCardSet.cards); foreach (Card c in whiteCardSet.cards) { gameManager.whiteDeck.Push(c); } foreach (Card c in blackCardSet.cards) { gameManager.blackDeck.Push(c); } } Console.WriteLine("All players will be asked to input the host IP, which is: " + ipaddr.ToString() + "\n"); Console.WriteLine("This window will now keep a log of all connections and server actions.\n"); Console.WriteLine("If anything unexpected happens ; check here. \n"); Console.WriteLine("If you are unsure of any server commands, use !help to display a list of commands and their function \n"); AInames = File.ReadAllLines(Path.Combine(Environment.CurrentDirectory, "AInames.txt")).ToList(); Thread tcplistener = new Thread(listener); tcplistener.Start(); string responce = ""; while (true) { if (gameManager.players.Count > 0) { responce = parseCommand(Console.ReadLine()); Console.WriteLine(responce); } } }
static void Main(string[] args) { DisplayLogo(); ipaddr = SetIP(); Console.WriteLine("\nThis is the server window. \n"); Console.WriteLine("Hit enter for a standard game, otherwise enter 'custom'"); if (Console.ReadLine().ToLower() == "custom") { //do custom setup gameManager = new GameManager(); } else { gameManager = new GameManager(); } Console.WriteLine("All players will be asked to input the host IP, which is: " + ipaddr.ToString() + "\n"); Console.WriteLine("This window will now keep a log of all connections and server actions.\n"); Console.WriteLine("If anything unexpected happens ; check here."); Console.ReadLine(); Random r = new Random(); Random random = new Random(); Shuffler shuffler = new Shuffler(); whiteCardSet = DeserializeCards(Path.Combine(cardDirectory, "white/base.json")); blackCardSet = DeserializeCards(Path.Combine(cardDirectory, "black/base.json")); int[] whiteList = Enumerable.Range(0, whiteCardSet.cards.Count - 1).ToArray(); int[] blackList = Enumerable.Range(0, blackCardSet.cards.Count - 1).ToArray(); shuffler.Shuffle(whiteList); shuffler.Shuffle(blackList); foreach (int value in whiteList) { gameManager.whiteDeck.push(whiteCardSet.cards[value]); } foreach (int value in blackList) { gameManager.blackDeck.push(blackCardSet.cards[value]); } gameManager.blackDeck.display(); Thread tcplistener = new Thread(listener); tcplistener.Start(); Thread AiLoop = new Thread(AIloop); AiLoop.Start(); while (true) { if (gameManager.players.Count > 0) { string responce = parseCommand(Console.ReadLine()); Console.WriteLine(responce); } } }