//Variables private static void Main(string[] args) { //Use bubble up catches try { Console.WriteLine("Please Select a Game mode"); Console.WriteLine("(1) Networked"); Console.WriteLine("(2) Offline Multiplayer"); Console.WriteLine("(3) Vs Computer"); string mode; bool validMode = false; // keep taking user input until a valid mode is selected (ie. validMode == true) do { mode = Console.ReadLine(); //Might get an Format exception here switch ((Enums.gameType)int.Parse(mode)) { case Enums.gameType.Networked: Console.WriteLine("Sorry, this feature had yet to be implemented"); break; /* Network Game Pseudo Code * 1) Pick port and ipaddress * 2) See if a connection can be made, * 3) Exchange Player Objects * 4) Start exchanging Lua Scripts */ case Enums.gameType.Offline: validMode = true; //Get the game started. Game theGame = new Game(Enums.gameType.Offline); theGame.Main(); break; case Enums.gameType.Computer: Console.WriteLine("Sorry, this feature had yet to be implemented"); break; default: Console.WriteLine("Sorry, you must select one of the options."); break; } } while(validMode == false); } //TODO: Make the game continue if this is thrown catch (NotImplementedException e) { Console.WriteLine("woops forgot to add code for {0}", e.ToString()); Console.ReadLine(); } catch (FormatException e) { Console.WriteLine("Invalid game type. Exception: {0}", e.Message); Console.Read(); } }
/// <summary> /// Creates a new "player", sets the name, Loads the players deck /// Shuffles it 7 times, and adds 7 cards to it /// </summary> /// <param name="name">The Name of the player</param> public Player(string name, Game gInst) { //Set up the properties for the Lists this.name = name; //Choose A Deck file try { this.deckname = gInstance.chooseDeck(deckpath); } catch (myExceptions.DeckNotFoundException e) { Console.WriteLine(e.CustomMessage); } //Instanate the deck //this.deck = new Deck(deckpath, deckname); //Make sure the deck is nice and shuffled for (int i = 0; i < 7; i++) { //deck.Shuffle(); } //Need to draw 7 cards for the hand //If there are less than 7 cards in the deck if (deck.Count < 7) { for (int i = 0; i < deck.Count; i++) { //Draw all the cards in the deck Card tmp; this.draw(out tmp); this.Hand.Add(tmp); } } //Otherwise, else { for (int i = 0; i < 7; i++) { Card tmp; this.draw(out tmp); this.Hand.Add(tmp); } } }
public void exTrainer(string scriptPath, Player player1, Player player2, Game gInst) { ScriptEngine engine = Python.CreateEngine(); ScriptRuntime runtime = engine.Runtime; ScriptScope scope = runtime.CreateScope(); ScriptSource source = engine.CreateScriptSourceFromFile(scriptPath); scope.SetVariable("player1", player1); scope.SetVariable("player2", player2); scope.SetVariable("game", gInst); source.Execute(scope); }
//Player may get a key section for encrypting and decryting keys //Methods //Constructor public Player(string name, Card[] deck, Game gInst) { this.name = name; this.deck = new Deck(); this.deck.AddRange(deck); }