コード例 #1
0
ファイル: Game.cs プロジェクト: mathjeff/SCGSim
        public ReadableCard Get_ReadableSnapshot(ID <ReadableCard> cardId)
        {
            // request read-only access to a particular card
            ReadableCard card = this.cardsDrawn.GetReadable(cardId);

            return(card);
        }
コード例 #2
0
 public void AddCard(ReadableCard card)
 {
     if (this.mainDeck.Contains(card))
     {
         Console.WriteLine("Error: cannot add the same instance of a card that is already in the deck");
     }
     this.mainDeck.AddLast(card);
     this.sortedDeck = null;
     this.NumWins    = this.NumLosses = 0;
 }
コード例 #3
0
ファイル: WritableCard.cs プロジェクト: mathjeff/SCGSim
 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));
     }
 }
コード例 #4
0
 public void AddCardToHand(ReadableCard card, Writable_GamePlayer player, Game game)
 {
     if (player.Get_ReadableHand().Count >= this.Max_HandSize)
     {
         return;
     }
     if (card == null)
     {
         // take damage for having no cards left
         player.NumDrawsSkipped++;
         player.AddHealth(new Specific_LifeEffect(null, -player.NumDrawsSkipped), game);
     }
     else
     {
         player.DrawCard(card, game);
     }
 }
コード例 #5
0
        public void Print(Game game)
        {
            Console.WriteLine("Player " + this.ID + " : " + this.Health + " health, " + this.CurrentResources.ToNumber() + "/" + this.ResourcesPerTurn.ToNumber() + " resources");
            IEnumerable <ID <ReadableCard> > hand = this.hand.GetReadable();

            Console.WriteLine(" Hand:(" + hand.Count() + ")");
            foreach (ID <ReadableCard> cardId in this.hand.GetReadable())
            {
                ReadableCard card = game.Get_ReadableSnapshot(cardId);
                Console.WriteLine(card.ToString(game));
            }
            Console.WriteLine(" Field:");
            foreach (ID <Readable_MonsterCard> cardId in this.MonsterIDsInPlay.GetReadable())
            {
                ReadableCard card = game.Get_ReadableSnapshot(cardId);
                Console.WriteLine(card.ToString(game));
            }
        }
コード例 #6
0
ファイル: Game.cs プロジェクト: mathjeff/SCGSim
        public Readable_LifeTarget Get_ReadableSnapshot(ID <Readable_LifeTarget> targetId)
        {
            // First check whether this is a player
            Readable_GamePlayer player;
            bool isPlayer = this.players.TryGetReadable(new ID <Readable_GamePlayer>(targetId.ToInt()), out player);

            if (isPlayer)
            {
                return(player);
            }

            // If a life target isn't a player, then it's a card
            ReadableCard card   = this.cardsDrawn.GetReadable(targetId.AsType((ReadableCard)null));
            bool         isCard = this.cardsDrawn.TryGetReadable(targetId.AsType((ReadableCard)null), out card);

            if (isCard)
            {
                return(card as Readable_LifeTarget);
            }
            // error: not found
            return(null);
        }
コード例 #7
0
ファイル: DrawEffect.cs プロジェクト: mathjeff/SCGSim
        public override void Process(Game game)
        {
            Writable_GamePlayer player = null;
            int numCards = this.numCards_provider.GetValue(this, game, default(int));

            if (numCards >= 1)
            {
                player = this.playerProvider.GetValue(this, game, (Writable_GamePlayer)null);
            }
            for (int i = 0; i < numCards; i++)
            {
                // draw another card
                ReadableCard card = this.cardProvider.GetValue(this, game, (ReadableCard)null);
                if (card != null && card.Get_ControllerID() == null)
                {
                    // This only ever happens if the card isn't in the game yet, so it works to just clone it here
                    WritableCard writable = card.Clone((WritableCard)null);
                    writable.ControllerID = this.ControllerID;
                    card = writable;
                }
                player.TryToDrawCard(card, game);
            }
        }
コード例 #8
0
        public override string ToString(Game game)
        {
            ReadableCard card = game.Get_ReadableSnapshot(this.cardId);

            return("Play " + card.ToString(game));
        }
コード例 #9
0
        public override bool IsProcessable(Game game)
        {
            ReadableCard card = game.Get_ReadableSnapshot(this.cardId);

            return(card.IsPlayable(game));
        }
コード例 #10
0
        public override void Process(Game game)
        {
            ReadableCard card = game.Get_ReadableSnapshot(this.cardId);

            card.Play(game);
        }
コード例 #11
0
ファイル: Game.cs プロジェクト: mathjeff/SCGSim
 public void AddCard(ReadableCard card)
 {
     this.cardsDrawn.PutReadonly(card);
 }
コード例 #12
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);
        }
コード例 #13
0
 public void RemoveCard(ReadableCard card)
 {
     this.mainDeck.Remove(card);
     this.sortedDeck = null;
     this.NumWins    = this.NumLosses = 0;
 }
コード例 #14
0
ファイル: WritableCard.cs プロジェクト: mathjeff/SCGSim
 public ID <ReadableCard> GetID(ReadableCard outputType)
 {
     return(new ID <ReadableCard>(this.ID));
 }
コード例 #15
0
 public void DrawCard(ReadableCard card, Game game)
 {
     this.hand.GetWritable().Add(card.GetID((ReadableCard)null));
     game.AddCard(card);
 }
コード例 #16
0
 public void TryToDrawCard(ReadableCard card, Game game)
 {
     this.Referee.AddCardToHand(card, this, game);
 }