Example #1
0
        public static void SaveGame(int slot)
        {
            var    path = PathFinder(slot);
            string message;
            var    state = StateBuilder.GetGameState();
            var    meta  = new SaveGameMetaData();

            using (var stream = new StreamWriter(path))
            {
                try
                {
                    var json = JsonConvert.SerializeObject(state);
                    stream.Write(json);
                    message = "Save was successful";
                    meta.UpdateMeta(slot);
                    meta.SaveMeta();
                    BoardBuilder.LoadTerritoryNeighbours();
                }
                catch (Exception e)
                {
                    message = "Error, save game failed : " + e;
                    BoardBuilder.LoadTerritoryNeighbours();
                }
            }
            GameEngine.Timer("Saving game");
            Console.WriteLine("\r\t" + message + "\n\tPress any key to continue");
            Console.ReadKey();
        }
Example #2
0
        private void TroopMovementPhase()
        {
            var player = GameBoard.GetBoard().CurrentPlayer;

            player.GameEntryPoint = 3;
            GameEngine.Timer("Fortification phase about to begin");
            TeritoriesFortification.FortificationMenu();
        }
Example #3
0
        private void BattlePhase()
        {
            var player = GameBoard.GetBoard().CurrentPlayer;

            player.GameEntryPoint = 2;
            GameEngine.Timer("Battle phase about to begin");
            var battle = new Battle();

            battle.BattleMenu();
        }
Example #4
0
        private static void AssignStartingPlayer()
        {
            var starter = GameEngine.HighestRoll(GameBoard.GetBoard().GetPlayerList());

            GameEngine.Timer();
            Colour.PrintPlayer(starter.Colour, "\r\t" + starter.Name);
            Console.Write(" won the roll and will play first.\n");
            Console.WriteLine("\tPress any key to continue.");
            Console.ReadKey();
            GameBoard.GetBoard().SetPlayerTurnQueue(GameEngine.CreateTurnQueue(starter));
        }
Example #5
0
        public override void AssignStartingPlayer()
        {
            var board   = GameBoard.GetBoard();
            var starter = GameEngine.HighestRoll(board.GetPlayerList());

            GameEngine.Timer("Rolling dice");
            Colour.PrintPlayer(starter.Colour, "\r\t" + starter.Name);
            Console.Write(" won the roll and will play first.\n");
            Console.WriteLine("\tPress any key to continue.");
            Console.ReadKey();
            board.SetPlayerTurnQueue(GameEngine.CreateTurnQueue(starter));
            board.SetCurrentPlayer();
        }
Example #6
0
        public void Populate()
        {
            var confirmed = false;

            while (confirmed == false)
            {
                var armyCount = GameBoard.GetBoard().GetPlayerByIndex(0).Armies;
                BoardPopulator.AutoPopulate();
                MapBuilder.ShowEntireWorld();
                Console.WriteLine("\n\t==========================");
                Console.WriteLine("\t1. Confirm board layout");
                Console.WriteLine("\t2. Change board layout");
                Console.WriteLine("\t3. Quit Game");
                Console.WriteLine("\t==========================");
                var option = GameEngine.UserInputTest("\t(1-3)>", "\tInvalid input, please try again!", 1, 3);

                switch (option)
                {
                case 1:
                    confirmed = true;
                    break;

                case 2:
                    GameEngine.Timer("Building new board");
                    Console.WriteLine("\r\tPress any key to continue.");
                    Console.ReadKey();
                    foreach (var player in GameBoard.GetBoard().GetPlayerList())
                    {
                        player.Armies = armyCount;
                    }
                    break;

                case 3:
                    Console.Clear();
                    Console.WriteLine("\tThank you and goodbye!\n\tPress any key to exit.......");
                    Console.ReadKey();
                    Environment.Exit(0);
                    break;

                default:
                    Console.WriteLine("Error");
                    break;
                }
            }
        }
Example #7
0
        public void GamePlay()
        {
            var board      = GameBoard.GetBoard();
            var playerList = board.GetPlayerList();

            while (playerList.Count > 1)
            {
                var player = board.CurrentPlayer;
                if (player.GameEntryPoint == 0)
                {
                    player.ConqueredDuringTurn = 0;
                }
                GameEngine.Timer(player.Name + " Your turn is about to begin ");

                if (player.GameEntryPoint != 2 && player.GameEntryPoint != 3)
                {
                    ReinforcementsPhase(board);
                }
                if (player.GameEntryPoint != 3)
                {
                    BattlePhase();
                }
                TroopMovementPhase();

                if (player.ConqueredDuringTurn > 0)
                {
                    GameEngine.Timer("You conquered a territory, receiving a Game Card.");
                    var card = board.GetGameCard();
                    if (player.Cards == null)
                    {
                        player.Cards = new List <Card> {
                            card
                        };
                    }
                    else
                    {
                        player.Cards.Add(card);
                    }
                }

                player.GameEntryPoint = 0;
                board.SetCurrentPlayer();
            }
        }
Example #8
0
        public void BeginBattle(Attack attack)
        {
            var           dell       = new TerritoryConqueredHandler(TerritoryConquered);
            BattleOutcome singleDie  = new DiceSingleBattle();
            BattleOutcome doubleDie  = new DiceDoubleBattle();
            BattleOutcome trippleDie = new DiceTrippleBattle();

            singleDie.SetSuccessor(doubleDie);
            doubleDie.SetSuccessor(trippleDie);

            GameEngine.Timer("Rolling dice");

            singleDie.Fight(attack);

            if (attack.DefendingTerritory.Armies == 0)
            {
                dell(attack);
            }
        }