Esempio n. 1
0
        public bool IsPlayable(Readable_MonsterCard card, Game game)
        {
            Readable_GamePlayer controller = game.Get_ReadableSnapshot(card.Get_ControllerID());
            IEnumerable <ID <Readable_MonsterCard> > cardsInPlay = controller.Get_MonsterIDsInPlay();

            if (cardsInPlay.Count() < 7)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        // returns all monsters in play
        public IList <Readable_MonsterCard> Get_MonstersInPlay()
        {
            List <Readable_MonsterCard> targets = new List <Readable_MonsterCard>();

            foreach (ID <Readable_GamePlayer> playerId in this.players.GetKeys())
            {
                Readable_GamePlayer player = this.players.GetReadable(playerId);
                foreach (ID <Readable_MonsterCard> monsterId in player.Get_MonsterIDsInPlay())
                {
                    Readable_MonsterCard monster = this.Get_ReadableSnapshot(monsterId);
                    targets.Add(monster);
                }
            }
            return(targets);
        }
Esempio n. 3
0
 public void CopyFrom(Readable_GamePlayer original)
 {
     // the hand should be small enough that we can just clone it for the moment
     this.hand.PutReadonly(original.Get_ReadableHand());
     this.Deck            = original.GetDeck().Clone();
     this.Health          = original.GetHealth();
     this.MaxHealth       = original.GetMaxHealth();
     this.NumDrawsSkipped = original.Get_NumDrawsSkipped();
     this.sourcePlayer    = original.SourcePlayer;
     this.ID = original.GetID((Readable_GamePlayer)null).ToInt();
     this.MonsterIDsInPlay = new WriteControlled_Item <IReadOnlyList <ID <Readable_MonsterCard> >, List <ID <Readable_MonsterCard> > >(new ListConverter <ID <Readable_MonsterCard> >());
     this.MonsterIDsInPlay.PutReadonly(original.Get_MonsterIDsInPlay());
     this.CurrentResources = original.Get_CurrentResources();
     this.ResourcesPerTurn = original.Get_ResourcesPerTurn();
 }
Esempio n. 4
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);
        }