示例#1
0
        public void Execute(IChoosableAction type, Player player)
        {
            PropertyTile tile = type as PropertyTile;

            ObjectValidator.NullObjectValidation(tile, "The instance type should a be PropertyTile");
            this.Sell(player, tile);
        }
        public void Execute(IChoosableAction type, Player player)
        {
            Card card = type as Card;

            ObjectValidator.NullObjectValidation(card, "The instance type should a be Card");
            player.WidthdrawMoney(card.Money);
        }
示例#3
0
        private void ExecuteActionFromTile(IChoosableAction tile, Player player)
        {
            if (tile.Actions.Count > 1)
            {
                ChoosableActionTile actionTile = tile as ChoosableActionTile;
                ObjectValidator.NullObjectValidation(actionTile);

                ICollection <IAction> availableActions = this.GetAvailableActions(actionTile, player);

                Console.WriteLine("Choose Action");
                Console.WriteLine(this.AvailableActionsToString(availableActions));

                string actionString = Console.ReadLine();

                IAction chosenAction = this.ChooseAction(availableActions, actionString);
                chosenAction.Execute(tile, player);

                if (player.IsBankrupt)
                {
                    this.players.Remove(player);
                }
            }
            else
            {
                Console.WriteLine("Continue...");
                Console.ReadLine();

                tile.Actions.First().Execute(tile, player);

                if (player.IsBankrupt)
                {
                    this.players.Remove(player);
                }
            }
        }
示例#4
0
        public void Execute(IChoosableAction type, Player player)
        {
            TaxTile tile = type as TaxTile;

            ObjectValidator.NullObjectValidation(tile, "The instance type should a be TaxTile");
            this.PayTax(player, tile.Tax);
        }
示例#5
0
        public void PlayerTurn(Player player, Board boar, int firstRoll, int secondRoll)
        {
            Tile currentTile;

            this.MovePlayer(player, firstDice, secondDice, board);
            currentTile = board.GetTileAtPosition(player.Position);

            Console.WriteLine("Current tile {0}", currentTile);
            IChoosableAction actionTile = currentTile as IChoosableAction;

            if (actionTile != null)
            {
                this.ExecuteActionFromTile(actionTile, player);
            }

            if (currentTile is CommunityTile)
            {
                CommunityCard card = CardHelpers.DrawCard(this.communityCards);

                Console.WriteLine("Community Card");
                Console.WriteLine("Card Desciption: {0}", card.Description);
                Console.ReadLine();

                this.ExecuteActionFromCard(card, player);
            }
            else if (currentTile is ChanceTile)
            {
                ChanceCard card = CardHelpers.DrawCard(this.chanceCards);

                Console.WriteLine("Chance Card");
                Console.WriteLine("Card Desciption: {0}", card.Description);
                Console.ReadLine();

                this.ExecuteActionFromCard(card, player);
            }
        }
示例#6
0
 public void Execute(IChoosableAction type, Player player)
 {
     PropertyTile tile = type as PropertyTile;
     ObjectValidator.NullObjectValidation(tile, "The instance type should a be PropertyTile");
     this.PayRent(player, tile);
 }
示例#7
0
文件: Engine.cs 项目: GAlex7/TA
        private void ExecuteActionFromTile(IChoosableAction tile, Player player)
        {
            if (tile.Actions.Count > 1)
            {
                ChoosableActionTile actionTile = tile as ChoosableActionTile;
                ObjectValidator.NullObjectValidation(actionTile);

                ICollection<IAction> availableActions = this.GetAvailableActions(actionTile, player);

                Console.WriteLine("Choose Action");
                Console.WriteLine(this.AvailableActionsToString(availableActions));

                string actionString = Console.ReadLine();

                IAction chosenAction = this.ChooseAction(availableActions, actionString);
                chosenAction.Execute(tile, player);

                if (player.IsBankrupt)
                {
                    this.players.Remove(player);
                }
            }
            else
            {
                Console.WriteLine("Continue...");
                Console.ReadLine();

                tile.Actions.First().Execute(tile, player);

                if (player.IsBankrupt)
                {
                    this.players.Remove(player);
                }
            }
        }
示例#8
0
文件: WinAction.cs 项目: GAlex7/TA
 public void Execute(IChoosableAction type, Player player)
 {
     Card card = type as Card;
     ObjectValidator.NullObjectValidation(card, "The instance type should a be Card");
     player.AddMoney(card.Money);
 }
示例#9
0
文件: TaxAction.cs 项目: GAlex7/TA
 public void Execute(IChoosableAction type, Player player)
 {
     TaxTile tile = type as TaxTile;
     ObjectValidator.NullObjectValidation(tile, "The instance type should a be TaxTile");
     this.PayTax(player, tile.Tax);
 }