Dominion.PlayerState.AttackOtherPlayers C# (CSharp) Method

AttackOtherPlayers() private method

private AttackOtherPlayers ( GameState gameState, AttackAction action ) : void
gameState GameState
action AttackAction
return void
        internal void AttackOtherPlayers(GameState gameState, AttackAction action)
        {
            Card currentAttackCard = gameState.cardContextStack.CurrentCard;
            foreach (PlayerState otherPlayer in gameState.players.OtherPlayers)
            {
                gameState.cardContextStack.PushCardContext(otherPlayer, currentAttackCard, CardContextReason.CardAttacking);
                if (otherPlayer.IsAffectedByAttacks(gameState))
                {
                    action(gameState.players.CurrentPlayer, otherPlayer, gameState);
                }
                gameState.cardContextStack.Pop();
            }
        }

Usage Example

Ejemplo n.º 1
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            Card revealedCard = currentPlayer.RequestPlayerRevealCardFromHand(acceptableCard => true, gameState);
            PlayerState.AttackAction attackAction = this.DoEmptyAttack;

            if (revealedCard != null && !revealedCard.isShelter)
            {
                int maxReturnCount = Math.Max(currentPlayer.Hand.CountOf(revealedCard), 2);

                int returnCount = currentPlayer.actions.GetCountToReturnToSupply(revealedCard, gameState);
                returnCount = Math.Min(returnCount, maxReturnCount);
                returnCount = Math.Max(returnCount, 0);

                for (int i = 0; i < returnCount; ++i)
                {
                    if (currentPlayer.hand.HasCard(revealedCard))
                    {
                        currentPlayer.ReturnCardFromHandToSupply(revealedCard, gameState);
                    }
                }

                attackAction = delegate(PlayerState currentPlayer2, PlayerState otherPlayer, GameState gameState2)
                {
                    otherPlayer.GainCardFromSupply(gameState, revealedCard);
                };
            }

            currentPlayer.AttackOtherPlayers(gameState, attackAction);
        }
All Usage Examples Of Dominion.PlayerState::AttackOtherPlayers
PlayerState