Exemplo n.º 1
0
        public Game NewGame(List <TournamentPlayer> players)
        {
            if (players.Count != 2)
            {
                throw new ArgumentException("Hearthstone games must have exactly 2 players");
            }
            Game game          = new Game(this);
            int  numBonusCards = 0;

            foreach (TournamentPlayer templatePlayer in players)
            {
                if (templatePlayer.MainDeck.Count() != this.Starting_DeckSize)
                {
                    throw new ArgumentException("Hearthstone decks must start with exactly 30 cards");
                }
                Writable_GamePlayer newPlayer = new Writable_GamePlayer(templatePlayer);
                newPlayer.InitializeHealth(30);
                game.AddPlayer(newPlayer);
                // draw a bunch of cards from the player's deck
                DrawEffect drawEffect = new DrawEffect(new ConstantValueProvider <Writable_GamePlayer, Controlled>(newPlayer), DrawFromDeck_Provider.FromController(),
                                                       new ConstantValueProvider <int, Controlled>(this.Starting_HandSize + numBonusCards));
                drawEffect.ControllerID = newPlayer.GetID((Readable_GamePlayer)null);
                drawEffect.Process(game);
                // potentially draw a Coin too
                DrawEffect bonusCards = new DrawEffect(new ConstantValueProvider <Writable_GamePlayer, Controlled>(newPlayer), new ConstantValueProvider <ReadableCard, Controlled>(HearthstoneReferee.Coin),
                                                       new ConstantValueProvider <int, Controlled>(numBonusCards));
                bonusCards.ControllerID = newPlayer.GetID((Readable_GamePlayer)null);
                bonusCards.Process(game);
                // each player gets one more card than the previous and one additional Coin
                numBonusCards++;
            }
            return(game);
        }
Exemplo n.º 2
0
        public void Destroy(GameEffect cause, Game game)
        {
            // inform the controller
            Writable_GamePlayer controller = game.GetWritable(this.ControllerID);

            controller.MonsterIDsInPlay.GetWritable().Remove(this.GetID((Readable_MonsterCard)null));
            // process any on-death effects
            GameTrigger_Factory.TriggerAll <GameEffect>(this.afterDeath_triggers, cause, this.ControllerID, game);
        }
Exemplo n.º 3
0
        public override void Play(Game game)
        {
            // Put this card in play
            Writable_GamePlayer controller = game.GetWritable(this.ControllerID);

            controller.MonsterIDsInPlay.GetWritable().Add(this.GetID((Readable_MonsterCard)null));
            // Pay for this card, remove it from hand, and trigger its abilities
            base.Play(game);
        }
Exemplo n.º 4
0
        public void AddHealth(int amount, Writable_GamePlayer player)
        {
            int newHealth = player.Health + amount;

            if (newHealth > this.MaxHealth)
            {
                newHealth = this.MaxHealth;
            }
            player.Health = newHealth;
            // we'll check afterward for game losses, in case multiple players lose during the same effect
        }
Exemplo n.º 5
0
        public virtual void Play(Game game)
        {
            // pay the resources for this card
            Writable_GamePlayer controller = game.GetWritable(this.ControllerID);

            controller.CurrentResources = controller.CurrentResources.Minus(this.cost);
            // remove this card from hand
            List <ID <ReadableCard> > hand = controller.Get_WritableHand();

            hand.Remove(this.GetID((ReadableCard)null));
            // Trigger anything that happens when playing this card
            this.AfterPlay(game);
        }
Exemplo n.º 6
0
        public override void Process(Game game)
        {
            Writable_GamePlayer writablePlayer = this.playerProvider.GetValue(this.Cause, game, (Writable_GamePlayer)null);

            Resource newResources = writablePlayer.CurrentResources.Plus(this.resourcesToGain_provider.GetValue(this.Cause, game, (Resource)null));

            if (newResources.IsValid)
            {
                writablePlayer.CurrentResources = newResources;
            }
            else
            {
                writablePlayer.CurrentResources = new Resource(0);
            }
        }
Exemplo n.º 7
0
        public override void Process(Game game)
        {
            Writable_GamePlayer monsterController = this.monsterController_provider.GetValue(this, game, (Writable_GamePlayer)null);
            int numberToSpawn = this.countProvider.GetValue(this, game, default(int));
            //monsterController.get
            List <ID <Readable_MonsterCard> > territory = monsterController.MonsterIDsInPlay.GetWritable();

            for (int i = 0; i < numberToSpawn; i++)
            {
                Writable_MonsterCard monster = this.monsterToSpawn.Clone((Writable_MonsterCard)null);
                monster.ID           = IDFactory.NewID();
                monster.ControllerID = monsterController.GetID((Readable_GamePlayer)null);
                territory.Add(monster.GetID((Readable_MonsterCard)null));
                game.AddCard(monster);
            }
        }
Exemplo n.º 8
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);
     }
 }
Exemplo n.º 9
0
        public void NewTurn(ID <Readable_GamePlayer> playerID, Game game)
        {
            Writable_GamePlayer player = game.GetWritable(playerID);

            // gain 1 crystal
            if (player.ResourcesPerTurn.ToNumber() < 10)
            {
                player.ResourcesPerTurn = player.ResourcesPerTurn.Plus(new Resource(1));
            }
            // replenish existing crystals
            player.CurrentResources = player.ResourcesPerTurn;
            // give one attack to each monster
            foreach (ID <Readable_MonsterCard> monsterId in player.MonsterIDsInPlay.GetReadable())
            {
                Writable_MonsterCard card = game.GetWritable(monsterId);
                card.NumAttacksRemaining = card.NumAttacksPerTurn;
            }
            // draw a card if there's room
            this.AddCardToHand(player.Deck.Dequeue(), player, game);
        }
Exemplo n.º 10
0
        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);
            }
        }
Exemplo n.º 11
0
 public ID <Writable_GamePlayer> GetID(Writable_GamePlayer outputType)
 {
     return(new ID <Writable_GamePlayer>(this.ID));
 }
Exemplo n.º 12
0
 public Writable_GamePlayer Clone(Writable_GamePlayer outputType)
 {
     return(new Writable_GamePlayer(this));
 }
Exemplo n.º 13
0
 public Writable_GamePlayer(Writable_GamePlayer original)
 {
     this.CopyFrom(original);
 }