Пример #1
0
 public void CopyFrom(Readable_MonsterCard original)
 {
     this.Damage         = this.originalDamage = original.GetDamage();
     this.Health         = original.GetHealth();
     this.originalHealth = original.GetMaxHealth();
     this.beforeReceivingDamage_Triggers = new List <GameTrigger <Specific_LifeEffect> >(original.Get_BeforeReceivingDamage_Triggers());
     this.afterDeath_triggers            = new List <GameTrigger <GameEffect> >(original.Get_AfterDeath_Triggers());
     this.MustBeAttacked    = original.Get_MustBeAttacked();
     this.NumAttacksPerTurn = original.Get_NumAttacksPerTurn();
     base.CopyFrom(original);
 }
Пример #2
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);
        }
Пример #3
0
        public int Get_Total_MonsterHealth(Game game)
        {
            int total = 0;

            foreach (ID <Readable_MonsterCard> monsterId in this.MonsterIDsInPlay.GetReadable())
            {
                Readable_MonsterCard monster = game.Get_ReadableSnapshot(monsterId);
                total += monster.GetHealth();
            }
            return(total);
        }
Пример #4
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);
        }
Пример #5
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);
        }
Пример #6
0
 public ID <Readable_MonsterCard> GetID(Readable_MonsterCard outputType)
 {
     return(new ID <Readable_MonsterCard>(this.ID));
 }
Пример #7
0
 private void Initialize(Readable_MonsterCard monsterToSpawn, ValueProvider <Writable_GamePlayer, Controlled> monsterController_provider, ValueProvider <int, Controlled> countProvider)
 {
     this.monsterToSpawn             = monsterToSpawn;
     this.monsterController_provider = monsterController_provider;
     this.countProvider = countProvider;
 }
Пример #8
0
 public SpawnMonster_Effect(Readable_MonsterCard monsterToSpawn, ValueProvider <Writable_GamePlayer, Controlled> monsterController_provider, ValueProvider <int, Controlled> countProvider)
 {
     this.Initialize(monsterToSpawn, monsterController_provider, countProvider);
 }
Пример #9
0
 public SpawnMonster_Effect(Readable_MonsterCard monsterToSpawn)
 {
     this.Initialize(monsterToSpawn, new WritableController_Provider(), new ConstantValueProvider <int, Controlled>(1));
 }