Пример #1
0
 /// <summary>
 /// concatenate two phaseList together
 /// </summary>
 /// <param name="added"></param>
 public void pushList(PhaseList added)
 {
     if (isEmpty())
     {
         head = added.head;
         tail = added.tail;
     }
     else if (added.isEmpty())
     {
     }
     else
     {
         added.tail.next = head;
         head            = added.head;
     }
 }
Пример #2
0
        /// <summary>
        /// construct a game given player and cardlist
        /// It uses dependency injection, so players and carlist can be easily tested.
        public Game(Player[] players, ICardSet cardList)
        {
            if (cardList == null)
            {
                throw new NotDefinedException(Legends_of_the_Three_Kingdoms.Properties.Resources.CardList_is_not_defined);
            }
            cards = cardList;

            if (players == null)
            {
                throw new NotDefinedException(Legends_of_the_Three_Kingdoms.Properties.Resources.CardList_is_not_defined);
            }
            this.players = players;

            status = GameStatus.NotFinish;
            stages = new PhaseList();
        }
Пример #3
0
 public sealed override PhaseList advance(UserAction userAction, IGame game)
 {
     if (userAction != null)
     {
         return(handleUserAction(userAction, game));
     }
     timer++;
     if (timer >= timeOutTime)
     {
         PhaseList ls = timeOutAdvance(game);
         if (ls == null)
         {
             throw new InvalidOperationException(Legends_of_the_Three_Kingdoms.Properties.Resources.timeOutAdvance_cannot_return_n);
         }
         return(ls);
     }
     return(autoAdvance(game));
 }
Пример #4
0
 public PhaseListEnumerator(PhaseList phaseList)
 {
     this.phaseList = phaseList;
     Reset();
 }
        public override PhaseList responseUseCardAction(Card card, Player[] targets, IGame game)
        {
            PhaseList ret = new PhaseList(this);

            if (card is BasicCard)
            {
                Attack attack = card as Attack;
                if (attack != null)
                {
                    ret.push(new AttackPhase(player, attack, targets, this));
                    return(ret);
                }
                Wine wine = card as Wine;
                if (wine != null)
                {
                    if (drunk)
                    {
                        return(null);
                    }
                    player.discardCard(wine, game);
                    drunk = true;
                    return(ret);
                }
                Peach peach = card as Peach;
                if (peach != null)
                {
                    if (player.health == player.healthLimit)
                    {
                        return(null);
                    }
                    player.discardCard(peach, game);
                    ret.push(new RecoverPhase(player, 1));
                    return(ret);
                }
            }
            else if (card is ToolCard)
            {
                Wealth wealth = card as Wealth;
                if (wealth != null)
                {
                    player.drawCards(2, game);
                    player.discardCard(wealth, game);
                    return(ret);
                }

                PeachGarden peachgarden = card as PeachGarden;
                if (peachgarden != null)
                {
                    player.discardCard(peachgarden, game);

                    foreach (Player x in game.players)
                    {
                        ret.push(new RecoverPhase(x, 1));
                    }

                    return(ret);
                }
            }
            else if (card is Equipment)
            {
                throw new NotImplementedException();
                //return new PhaseList(new UseEquipmentPhase(player, card as Equipment), this);
            }
            game.log("" + card + Legends_of_the_Three_Kingdoms.Properties.Resources.Cannot_be_uese);
            return(null);
        }