Exemplo n.º 1
0
        protected override void OnPlayVirtually(Card card, Card extraCard)
        {
            Player owner = card.Owner;
            Player current = owner;
            Game.GameTable.PlayerPlayCard(card, this.Type);
            Game.GameTable.PlayerDiscardCard(extraCard);

            if(!includeSelf)
                current = Game.NextPlayer(current);

            List<ResponseHandler> handlers = new List<ResponseHandler>();
            do
            {
                if(current == owner || current.HasCardEffect(this))
                {
                    ResponseHandler h = OnPlay(owner, current);
                    if(h != null)
                        handlers.Add(h);
                }
                current = Game.NextPlayer(current);
            }
            while(current != owner);
            if(handlers.Count != 0)
                Game.GameCycle.PushTempHandler(new QueueResponseHandler(handlers));
        }
Exemplo n.º 2
0
        protected override void OnRespondCard(Card card)
        {
            if(card.Owner != RequestedPlayer)
                throw new BadCardException();

            card.AssertInHand();

            Game.GameTable.PlayerDiscardCard(card);

            if(RequestedPlayer.Hand.Count <= RequestedPlayer.MaxCardCount)
                End();
        }
Exemplo n.º 3
0
        protected override void OnRespondCard(Card card)
        {
            if(card.Owner != RequestedPlayer)
                throw new BadCardException();

            if(barrelsChecked.Contains(card))
                throw new BadCardException();

            canEndImmediately = false;
            RequestedPlayer.CheckMissed(card, OnResult);
            canEndImmediately = true;
            if(power == 0)
                End();
        }
Exemplo n.º 4
0
 protected override void OnPlayVirtually(Card card)
 {
     PlayFromTableVirtually(card);
 }
Exemplo n.º 5
0
 private bool RemoveCardFromSelection(Card card)
 {
     return selection.Remove(card);
 }
Exemplo n.º 6
0
 private void PutCardToDeck(Card card)
 {
     card.Owner = null;
     deck.Push(card);
 }
Exemplo n.º 7
0
 public void UndrawFromSelection(Card card)
 {
     if(!selection.Remove(card))
         throw new InvalidOperationException();
     PutCardToDeck(card);
     game.Session.EventManager.OnUndrawnFromSelection(card, selectionOwner);
 }
Exemplo n.º 8
0
        public void PlayerStealCard(Player player, Card card, bool revealCard)
        {
            Player owner = card.Owner;
            if(owner == null)
                throw new InvalidOperationException();
            if(!owner.RemoveCardFromHand(card))
                if(!owner.RemoveCardFromTable(card as TableCard))
                    throw new InvalidOperationException();

            player.AddCardToHand(card);
            game.Session.EventManager.OnPlayerStoleCard(player, owner, card, revealCard);
            owner.CheckEmptyHand();
        }
Exemplo n.º 9
0
        public void PlayerPlayCard(Card card, Player targetPlayer)
        {
            Player owner = card.Owner;
            if(owner == null)
                throw new InvalidOperationException();

            if(!owner.RemoveCardFromHand(card))
                if(!owner.RemoveCardFromTable(card as TableCard))
                    throw new InvalidOperationException();
            PutCardToGraveyard(card);

            game.Session.EventManager.OnPlayerPlayedCard(owner, card, targetPlayer);
            owner.OnPlayedCard(card);
            owner.CheckEmptyHand();
        }
Exemplo n.º 10
0
 public void PlayerPickFromSelection(Player player, Card card, bool revealCard)
 {
     if(selectionOwner != null && selectionOwner != player)
         throw new InvalidOperationException();
     if(!selection.Remove(card))
         throw new InvalidOperationException();
     player.AddCardToHand(card);
     game.Session.EventManager.OnPlayerPickedFromSelection(player, card, selectionOwner == null || revealCard);
 }
Exemplo n.º 11
0
 public virtual void CheckDeck(Card causedBy, CheckDeckCallback checkCallback, CardResultCallback resultCallback)
 {
     Card checkedCard = player.Game.GameTable.CheckDeck();
     bool result = checkCallback(checkedCard);
     Game.Session.EventManager.OnPlayerCheckedDeck(player, checkedCard, causedBy, result);
     resultCallback(causedBy, result);
 }
Exemplo n.º 12
0
        private void OnResult(Card card, bool result)
        {
            if(card != null)
                if(card.Type == CardType.Barrel)
                    barrelsChecked.Add(card);
            if(result)
            {
                if(card != null && card.Type != CardType.Barrel)
                    if(card.Type != CardType.Missed)
                        Game.GameTable.PlayerRespondWithCard(card, CardType.Missed);
                    else
                        Game.GameTable.PlayerRespondWithCard(card);

                if(card != null && CausedBy != null && !CausedBy.HasCardEffect(card))
                    return;
                if(--power == 0)
                {
                    if(canEndImmediately)
                        End();
                }
                else
                {
                    barrelsChecked.Clear();
                    abilityUsed = false;
                }
            }
        }
Exemplo n.º 13
0
 public EmptyCard(Card parent)
 {
     this.id = parent.id;
 }
Exemplo n.º 14
0
 public virtual void PlayVirtually(Card card)
 {
     throw new BadUsageException();
 }
Exemplo n.º 15
0
 protected virtual void PlayFromTableVirtually(Card card)
 {
     throw new BadUsageException();
 }
Exemplo n.º 16
0
 public virtual void PlayCard(Card card)
 {
     card.Play();
 }
Exemplo n.º 17
0
        public void PlayerCancelCard(Player player, Card card)
        {
            Player owner = card.Owner;
            if(owner == null)
                throw new InvalidOperationException();
            if(!owner.RemoveCardFromHand(card))
                if(!owner.RemoveCardFromTable(card as TableCard))
                    throw new InvalidOperationException();

            PutCardToGraveyard(card);
            game.Session.EventManager.OnPlayerCancelledCard(player, owner, card);
            owner.CheckEmptyHand();
        }
Exemplo n.º 18
0
 public virtual bool HasCardEffect(Card card)
 {
     return true;
 }
Exemplo n.º 19
0
 public void PlayerPickFromSelection(Player player, Card card)
 {
     PlayerPickFromSelection(player, card, false);
 }
Exemplo n.º 20
0
 public virtual bool IsBang(Card card)
 {
     return card.Type == CardType.Bang;
 }
Exemplo n.º 21
0
        public void PlayerRespondWithCard(Card card, CardType asCard)
        {
            Player owner = card.Owner;
            if(owner == null)
                throw new InvalidOperationException();

            if(!owner.RemoveCardFromHand(card))
                if(!owner.RemoveCardFromTable(card as TableCard))
                    throw new InvalidOperationException();
            PutCardToGraveyard(card);

            game.Session.EventManager.OnPlayerRespondedWithCard(owner, card, asCard);
            owner.OnRespondedWithCard(card);
            owner.CheckEmptyHand();
        }
Exemplo n.º 22
0
 public virtual bool IsMissed(Card card)
 {
     return card.Type == CardType.Missed;
 }
Exemplo n.º 23
0
 public void PlayerStealCard(Player player, Card card)
 {
     PlayerStealCard(player, card, false);
 }
Exemplo n.º 24
0
 public virtual void OnDrewFirstCard(Card card)
 {
 }
Exemplo n.º 25
0
 private void AddCardToSelection(Card card)
 {
     selection.Add(card);
 }
Exemplo n.º 26
0
 public virtual void OnDrewSecondCard(Card card)
 {
 }
Exemplo n.º 27
0
 private void PutCardToGraveyard(Card card)
 {
     card.Owner = null;
     graveyard.Push(card);
 }
Exemplo n.º 28
0
 public virtual void OnPlayedCard(Card card)
 {
 }
Exemplo n.º 29
0
        public void CancelCard(Card card)
        {
            Player owner = card.Owner;
            if(owner == null)
            {
                if(!selection.Remove(card))
                    throw new InvalidOperationException();
            }
            else if(!owner.RemoveCardFromHand(card))
                if(!owner.RemoveCardFromTable(card as TableCard))
                    throw new InvalidOperationException();

            PutCardToGraveyard(card);
            game.Session.EventManager.OnCardCancelled(card);
            if(owner != null)
                owner.CheckEmptyHand();
        }
Exemplo n.º 30
0
 public virtual void OnRespondedWithCard(Card card)
 {
 }