Exemplo n.º 1
0
 public void add_or_remove_piece(bool add, Piece p)
 {
     if (Pawns.IndexOf(p) == -1)
     {
         Pawns.Remove(p);
     }
     else
     {
         MajorPieces.Remove(p);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Increases budget of player parameter by number of their pawns in this Node
        /// </summary>
        /// <param name="playerP">The player who wants to increase their budget</param>
        /// <returns>a message log denoting amount of budget increase and the player given it.</returns>
        public override String DoAction(Player playerP)
        {
            Int32   _playerID           = playerP.PlayerID;
            Boolean _playerHasPawnsHere = base.Pawns.Exists(_playerPawn => _playerPawn.PawnID == _playerID);

            if (!_playerHasPawnsHere || Pawns.Count == 0)
            {
                return($"{playerP.PlayerName} Failed to increase their budget. Reason: No Pawns");
            }
            if (Pawns[0].PawnID == playerP.PlayerID)
            {
                playerP.IncreaseBudget(1);
                playerP.GivePawn(Pawns[0]);
                Pawns.Remove(Pawns[0]);
            }
            return($"{playerP.PlayerName} has 1 more budget!");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Attempt to take the top Card from this node
        /// </summary>
        /// <param name="playerP">the acting player</param>
        /// <returns>a string log denoting the acting player and the result</returns>
        public override String DoAction(Player playerP)
        {
            // Preliminary checks
            if (Deck.Count == 0)
            {
                return($"There are no cards left in {NodeName}.");
            }
            if (Pawns.Count < 1)
            {
                return($"{playerP.PlayerName} had no pawns in {NodeName} to claim a card.");
            }
            Pawn _pawn = Pawns[0];

            if (_pawn.PawnID != playerP.PlayerID)
            {
                return($"{playerP.PlayerName} had no pawns in {NodeName} to claim a card.");
            }


            // return pawn
            playerP.GivePawn(_pawn);
            Pawns.Remove(_pawn);
            // Check required resources
            Boolean _gainCard = CheckCardCost(playerP);

            if (!_gainCard)
            {
                return($"{playerP.PlayerName} failed to obtain a card due to lack of resources.");
            }

            // Give card
            String cardType = "";

            cardType = Deck.Peek().CardType();
            playerP.AddToCards(TakeCard(playerP));
            return($"{playerP.PlayerName} obtained a new {cardType} Card!");
        }
Exemplo n.º 4
0
 /// <summary>
 /// Removes a pawn from the node's inventory.
 /// </summary>
 /// <param name="pawn">The pawn to be removed</param>
 public void RemovePawn(Pawn pawn)
 {
     Pawns.Remove(pawn);
 }
Exemplo n.º 5
0
 public void RemovePawn(Pawn pawn)
 {
     Pawns.Remove(Pawns.FirstOrDefault(x => x.PlayerId == Id && x.Type == pawn.Type));
 }