コード例 #1
0
ファイル: Market.cs プロジェクト: mfenniak/dominion-engine
 void IActionCard.Play(Dominion.Engine.Game game, Player player, Turn turn, object sidedata)
 {
     turn.AddBuys(1);
     turn.AddTreasure(1);
     turn.AddActions(1);
     turn.AddCards(1);
 }
コード例 #2
0
        void IActionCard.Play(Dominion.Engine.Game game, Player player, Turn turn, object sidedata)
        {
            Copper copper = sidedata as Copper;
            if (copper == null)
                throw new Exception("Moneylender needs a copper");

            player.TrashCard(copper);
            turn.AddTreasure(3);
        }
コード例 #3
0
ファイル: Cellar.cs プロジェクト: mfenniak/dominion-engine
 void IActionCard.Play(Dominion.Engine.Game game, Player player, Turn turn, object sidedata)
 {
     IEnumerable<ICard> cards = (IEnumerable<ICard>)sidedata;
     int count = 0;
     foreach (ICard card in cards)
     {
         if (Object.ReferenceEquals(card, this))
             throw new Exception("Attempted to discard the Cellar card that was being played");
         player.DiscardFromHand(card);
         ++count;
     }
     player.Draw(count);
 }
コード例 #4
0
ファイル: Workshop.cs プロジェクト: mfenniak/dominion-engine
        void IActionCard.Play(Dominion.Engine.Game game, Player player, Turn turn, object sidedata)
        {
            Enum newCardType = (Enum)sidedata;

            ICard newCard = game.DrawCard(newCardType);
            if (newCard == null)
                throw new Exception("Selected target type is not available");

            if (newCard.Cost > 4)
                throw new Exception("Target card is too expensive for Workshop");

            player.AddDiscard(newCard);
        }
コード例 #5
0
ファイル: Chapel.cs プロジェクト: mfenniak/dominion-engine
 void IActionCard.Play(Dominion.Engine.Game game, Player player, Turn turn, object sidedata)
 {
     IEnumerable<ICard> cards = (IEnumerable<ICard>)sidedata;
     int count = 0;
     foreach (ICard card in cards)
     {
         if (Object.ReferenceEquals(card, this))
             throw new Exception("Attempted to trash the Chapel card that was being played");
         if (count == 4)
             throw new Exception("Attempted to trash more than 4 cards permitted by Chapel");
         player.TrashCard(card);
         ++count;
     }
 }
コード例 #6
0
ファイル: Remodel.cs プロジェクト: mfenniak/dominion-engine
        void IActionCard.Play(Dominion.Engine.Game game, Player player, Turn turn, object sidedata)
        {
            RemodelData upgradeData = (RemodelData)sidedata;
            ICard origCard = (ICard)upgradeData.Card;

            ICard newCard = game.DrawCard(upgradeData.TargetType);
            if (newCard == null)
                throw new Exception("Selected target type is not available");

            if ((origCard.Cost + 2) < newCard.Cost)
                throw new Exception("Target card is too expensive to remodel");

            game.TrashCard(origCard);
            player.AddDiscard(newCard);
        }
コード例 #7
0
ファイル: Mine.cs プロジェクト: mfenniak/dominion-engine
        void IActionCard.Play(Dominion.Engine.Game game, Player player, Turn turn, object sidedata)
        {
            MineData upgradeData = (MineData)sidedata;
            ICard origCard = (ICard)upgradeData.Card;

            if ((origCard.Type & CardType.Treasure) != CardType.Treasure)
                throw new Exception("Mine attempted on a non-treasure card");

            ICard newCard = game.DrawCard(upgradeData.TargetType);
            if (newCard == null)
                throw new Exception("Selected target type is not available for Mine");

            if ((origCard.Cost + 3) < newCard.Cost)
                throw new Exception("Target card is too expensive to mine into");

            player.TrashCard(origCard);
            player.AddToHand(newCard);
        }
コード例 #8
0
ファイル: Militia.cs プロジェクト: mfenniak/dominion-engine
        void IActionCard.Play(Dominion.Engine.Game game, Player player, Turn turn, object sidedata)
        {
            turn.AddTreasure(2);

            foreach (KeyValuePair<IAI, Player> opponent in game.Players)
            {
                if (object.ReferenceEquals(opponent.Value, player))
                    continue;

                // FIXME: should have a better way of handling reaction cards that puts
                // the reaction in the reaction card, not the attack card
                bool safe = false;
                foreach (ICard card in opponent.Value.Hand)
                {
                    if (card is Moat)
                    {
                        safe = true;
                        break;
                    }
                }
                if (safe)
                    continue;

                int expectedDiscards = opponent.Value.Hand.Count() - 3;
                if (expectedDiscards != 0)
                {
                    IEnumerable<ICard> discards = opponent.Key.ChooseExternalDiscard(opponent.Value, opponent.Value.Hand.Count() - 3);
                    int count = 0;
                    foreach (ICard card in discards)
                    {
                        opponent.Value.DiscardFromHand(card);
                        ++count;
                    }
                    if (count != expectedDiscards)
                        throw new Exception("ChooseExternalDiscard did not choose correct card count");
                }
            }
        }
コード例 #9
0
 void IActionCard.Play(Dominion.Engine.Game game, Player player, Turn turn, object sidedata)
 {
     turn.AddTreasure(2);
     if ((bool)sidedata)
         player.PlaceDeckInDiscard();
 }
コード例 #10
0
ファイル: Smithy.cs プロジェクト: mfenniak/dominion-engine
 void IActionCard.Play(Dominion.Engine.Game game, Player player, Turn turn, object sidedata)
 {
     player.Draw(3);
 }
コード例 #11
0
ファイル: Turn.cs プロジェクト: mfenniak/dominion-engine
 public Turn(Game game, Player player)
 {
     this.game = game;
     this.player = player;
 }