Esempio n. 1
0
 public void CopyFrom(ReadableCard other)
 {
     this.name               = other.Name;
     this.cost               = other.GetCost();
     this.ControllerID       = other.Get_ControllerID();
     this.OwnerID            = other.Get_OwnerID();
     this.ID                 = other.GetID((ReadableCard)null).ToInt();
     this.afterPlay_triggers = new LinkedList <GameTrigger <GameEffect> >();
     foreach (GameTrigger <GameEffect> trigger in other.Get_AfterPlay_Triggers())
     {
         this.afterPlay_triggers.AddLast(trigger.Clone((GameTrigger <GameEffect>)null));
     }
 }
Esempio n. 2
0
        public List <GameEffect> Get_AvailableGameActions(Game game, Readable_GamePlayer player)
        {
            // This function only gets called when there are no effects in progress (like choosing the target of a triggered effect).
            List <GameEffect> options = new List <GameEffect>();

            // So, a player has these types of options: 1. Play a card. 2. Attack with a monster. 3. Activate their special ability. 4. End their turn
            // Let the player play any card
            foreach (ID <ReadableCard> cardId in player.Get_ReadableHand())
            {
                ReadableCard card = game.Get_ReadableSnapshot(cardId);
                if (card.IsPlayable(game))
                {
                    options.Add(new PlayCard_Effect(card.GetID((ReadableCard)null)));
                }
            }
            // Let the player attack with any monster
            IEnumerable <ID <Readable_MonsterCard> > availableAttacker_IDs = player.Get_MonsterIDsInPlay();

            // first figure out which monsters can be attacked (if any monsters have Taunt, they are the only ones that may be attacked)
            foreach (ID <Readable_GamePlayer> playerId in game.TurnOrder)
            {
                // make sure this is a different player
                if (!playerId.Equals(player.GetID((Readable_GamePlayer)null)))
                {
                    LinkedList <ID <Readable_LifeTarget> > requiredTarget_IDs = new LinkedList <ID <Readable_LifeTarget> >();
                    LinkedList <ID <Readable_LifeTarget> > allTarget_Ids      = new LinkedList <ID <Readable_LifeTarget> >();
                    Readable_GamePlayer controller = game.Get_ReadableSnapshot(playerId);
                    foreach (ID <Readable_MonsterCard> monsterId in controller.Get_MonsterIDsInPlay())
                    {
                        Readable_MonsterCard     monster     = game.Get_ReadableSnapshot(monsterId);
                        ID <Readable_LifeTarget> convertedID = monster.GetID((Readable_LifeTarget)null);
                        allTarget_Ids.AddLast(convertedID);
                        if (monster.Get_MustBeAttacked())
                        {
                            requiredTarget_IDs.AddLast(convertedID);
                        }
                    }
                    if (requiredTarget_IDs.Count != 0)
                    {
                        // There is a monster with taunt, so the only valid targets are the monsters with taunt
                        allTarget_Ids = requiredTarget_IDs;
                    }
                    else
                    {
                        // There are no monsters with taunt, so the valid targets are all monsters and the opponent too
                        allTarget_Ids.AddLast(controller.GetID((Readable_LifeTarget)null));
                    }
                    // Now allow each monster to attack each available target
                    foreach (ID <Readable_MonsterCard> attackerId in availableAttacker_IDs)
                    {
                        if (game.Get_ReadableSnapshot(attackerId).Get_CanAttack())
                        {
                            foreach (ID <Readable_LifeTarget> targetId in allTarget_Ids)
                            {
                                options.Add(new AttackEffect(attackerId.AsType((Readable_LifeTarget)null), targetId));
                            }
                        }
                    }
                }
            }

            // Let the player end their turn
            options.Add(new EndTurn_Effect(player.GetID((Readable_GamePlayer)null)));
            return(options);
        }
Esempio n. 3
0
 public void DrawCard(ReadableCard card, Game game)
 {
     this.hand.GetWritable().Add(card.GetID((ReadableCard)null));
     game.AddCard(card);
 }