Esempio n. 1
0
 public override void RemoveCard(CardInstance c, bool anim = true)
 {
     base.RemoveCard(c, anim);
     if (c.HasType(CardTypes.Creature))
     {
         c.RemovePointOverlay();
     }
 }
Esempio n. 2
0
 public MagicAction(CardInstance _source)
 {
     if (_source == null)
     {
         return;
     }
     CardSource = _source;
     if (CardSource.HasType(CardTypes.Land))
     {
         GoesOnStack = false;
     }
 }
Esempio n. 3
0
        public void ClickOnCard(CardInstance c)
        {
            //Magic.CurrentGameWin.CursorVisible = true;

            if (pp != ip)
            {
                return;
            }

            if (MagicStack.TryToHandleClick(c))
            {
                return;
            }

            switch (c.CurrentGroup.GroupName)
            {
            case CardGroupEnum.Library:
                break;

            case CardGroupEnum.Hand:
                #region hand
                //player controling interface may only click in his own hand
                if (c.Controler != ip)
                {
                    return;
                }
                if (!MagicStack.CancelLastActionOnStack())
                {
                    return;
                }
                if (CurrentPhase == GamePhases.Main1 || CurrentPhase == GamePhases.Main2)
                {
                    if (c.HasType(CardTypes.Land))
                    {
                        if (cp.AllowedLandsToBePlayed > 0)
                        {
                            c.ChangeZone(CardGroupEnum.InPlay);
                            cp.AllowedLandsToBePlayed--;
                            MagicEvent(new MagicEventArg(MagicEventType.PlayLand, c));
                        }
                    }
                    else
                    {
                        //Magic.CurrentGameWin.CursorVisible = true;
                        MagicStack.PushOnStack(new Spell(c));
                    }
                }
                else if (CurrentPhase != GamePhases.CleanUp && CurrentPhase != GamePhases.Untap)
                {
                    //play instant and abilities
                    if (c.HasType(CardTypes.Instant))
                    {
                        MagicStack.PushOnStack(new Spell(c));
                    }
                }
                break;

                #endregion
            case CardGroupEnum.InPlay:
                #region inPlay
                if (CurrentPhase == GamePhases.DeclareAttacker)
                {
                    if (c.CanAttack && ip == cp && c.Controler == ip)
                    {
                        c.Combating = !c.Combating;
                        c.CurrentGroup.UpdateLayout();
                        return;
                    }
                }
                else if (CurrentPhase == GamePhases.DeclareBlocker)
                {
                    if (ip != cp)                     //ip may declare blockers if it's not the current player
                    {
                        if (c.Controler == ip)
                        {
                            if (c.CanBlock())
                            {
                                if (c.Combating)
                                {
                                    c.Combating = false;
                                    c.BlockedCreature.BlockingCreatures.Remove(c);
                                    c.BlockedCreature = null;
                                    c.Controler.InPlay.UpdateLayout();
                                }
                                c.Controler.CurrentBlockingCreature = c;
                                return;
                            }
                        }
                        else if (ip.CurrentBlockingCreature != null && c.Combating)
                        {
                            //TODO:there's a redundant test here
                            if (ip.CurrentBlockingCreature.Combating)
                            {
                                //remove blocker
                                ip.CurrentBlockingCreature.Combating = false;
                                ip.CurrentBlockingCreature.BlockedCreature.BlockingCreatures.Remove(ip.CurrentBlockingCreature);
                                ip.CurrentBlockingCreature.BlockedCreature = null;
                            }
                            else if (ip.CurrentBlockingCreature.CanBlock(c))
                            {
                                //try to add blocker
                                c.BlockingCreatures.Add(ip.CurrentBlockingCreature);
                                ip.CurrentBlockingCreature.BlockedCreature = c;
                                ip.CurrentBlockingCreature.Combating       = true;
                                ip.CurrentBlockingCreature = null;
                            }
                            ip.InPlay.UpdateLayout();
                            return;
                        }
                    }
                }
                else if (CurrentPhase == GamePhases.CombatDamage)
                {
                }
                if (c.Controler == ip)
                {
                    #region activable abilities
                    if (!(c.IsTapped || c.HasSummoningSickness))
                    {
                        Ability[] activableAbs = c.Model.Abilities.Where(
                            sma => sma.IsActivatedAbility).ToArray();

                        if (activableAbs.Count() == 1)
                        {
                            MagicStack.PushOnStack(new AbilityActivation(c, activableAbs[0]));
                        }
                        else if (activableAbs.Count() > 1)
                        {
                            MagicChoice aachoice = new MagicChoice()
                            {
                                Player = ip
                            };
                            foreach (Ability aa in activableAbs)
                            {
                                aachoice.Choices.Add(new AbilityActivation(c, aa, true));
                            }

                            MagicStack.PushOnStack(aachoice);
                        }
                    }
                    #endregion
                }
                #endregion
                break;

            case CardGroupEnum.Graveyard:
                c.CurrentGroup.toogleShowAll();
                break;

            case CardGroupEnum.Exhiled:
                c.CurrentGroup.toogleShowAll();
                break;

            default:
                break;
            }
        }