Esempio n. 1
0
 public AbstractAttackCard(string name, int baseCost, int baseDamage, int baseMagicNumber, int bonusCost,
                           string img, Dictionary <Keyword, int> keywords, AbstractCharacter owner, CardModifier modifier, CardRarity rarity,
                           CardTarget target)
     : base(name, baseCost, bonusCost, baseDamage, baseMagicNumber, img, keywords, owner,
            CardType.Attack, modifier, rarity, target)
 {
 }
Esempio n. 2
0
        public override int Visit(DamageDependingOnCreatureNumberAbility ability)
        {
            //Log(OwnerCard.Name + " used DamageDependingOnCreatureNumberAbility");
            int attackPower = ability.myZone == Place.INNER ? GameManager.UserDict[Owner].Player.Inner.Count : GameManager.UserDict[Owner].Player.Outer.Count;

            // Case target is Creature
            if (Targets[0] is CardTarget)
            {
                CardTarget   t          = (CardTarget)Targets[0];
                CreatureCard targetCard = (CreatureCard)(GameManager.UserDict[t.Character].Player.GetCardFromId(t.CardId, Place.INNER) ?? GameManager.UserDict[t.Character].Player.GetCardFromId(t.CardId, Place.OUTER));
                targetCard.Health -= attackPower + ability.bonusDmg;
                foreach (CharacterEnum c in GameManager.UserDict.Keys.ToList())
                {
                    AddResponse(c, new CardsModifiedResponse(targetCard));
                }
            }
            // Case target is Player
            else
            {
                Player targetPlayer = GameManager.UserDict[Targets[0].Character].Player;
                targetPlayer.Health -= attackPower + ability.bonusDmg;
                foreach (CharacterEnum c in GameManager.UserDict.Keys.ToList())
                {
                    AddResponse(c, new PlayerModifiedResponse(targetPlayer.Character, targetPlayer.Mana, targetPlayer.Health));
                }
            }
            return(0);
        }
Esempio n. 3
0
 public TargetAdjacent(CardTarget a)
 {
     this.A              = a;
     TargetDescription   = "Adjacent to a " + A.TargetDescription;
     CheckTargetableFunc = (int id) => id >= 0 &&
                           (A.CheckTargetableFunc(id.NextLocation()) || A.CheckTargetableFunc(id.PrevLocation()));
 }
Esempio n. 4
0
 public TargetOr(CardTarget a, CardTarget b)
 {
     this.A              = a;
     this.B              = b;
     TargetDescription   = A.TargetDescription + " or " + B.TargetDescription;
     CheckTargetableFunc = (int id) => A.CheckTargetableFunc(id) || B.CheckTargetableFunc(id);
 }
Esempio n. 5
0
 public AbstractCard(string _cardId, string _name, string _imgURL, int _cost, string _rawDescription, CardType _cardType, CardRarity _cardRarity, CardTarget _cardTarget, DamageType _damageType)
 {
     ChargeCost            = -1;
     IsCostModified        = false;
     IsCostModifiedForTurn = false;
     IsRetain          = false;
     IsNotTriggerOnUse = false;
     IsInnate          = false;
     IsLocked          = false;
     IsShowEvokeValue  = false;
     ShowEvokeOrbCount = 0;
     KeyWords          = new List <string>();
     IsSelected        = false;
     IsExhaust         = false;
     IsEthereal        = false;
     IsUsed            = false;
     IsUpgraded        = false;
     TimesUpgraded     = 0;
     Misc                  = 0;
     IsSeen                = true;
     IsUpgradeCost         = false;
     IsUpgradeDamage       = false;
     IsUpgradeBlock        = false;
     IsUpgradeMagicNumber  = false;
     IsMultiDamage         = false;
     BaseDamage            = -1;
     BaseBlock             = -1;
     BaseMagicNumber       = -1;
     BaseHeal              = -1;
     BaseDraw              = -1;
     BaseDiscard           = -1;
     Damage                = -1;
     Block                 = -1;
     MagicNumber           = -1;
     Heal                  = -1;
     Draw                  = -1;
     Discard               = -1;
     IsDamageModified      = false;
     IsBlockModified       = false;
     IsMagicNumberModified = false;
     Target                = CardTarget.Enemy;
     IsPurgeOnUse          = false;
     IsExhaustOnUseOnce    = false;
     IsExhaustOnFire       = false;
     IsFreeToPlayOnce      = false;
     IsInBottleFlame       = false;
     IsInBottleLightning   = false;
     IsInBottleTornado     = false;
     Name                  = _name;
     CardID                = _cardId;
     Cost                  = _cost;
     CostForTurn           = _cost;
     RawDescription        = _rawDescription;
     Type                  = _cardType;
     Rarity                = _cardRarity;
     Target                = _cardTarget;
     CardDamageType        = _damageType;
     DamageTypeForTurn     = _damageType;
     CreateCardImage();
 }
Esempio n. 6
0
 public Card(string name, int cost, CardPersistency cardPersistency, CardTarget cardTarget, int castDistance, IsCastOn cardIsCastOn, Dictionary <ParamType, int> param, Dictionary <Effect, Card[]> effects = null)
 {
     Name            = name;
     Cost            = cost;
     CardPersistency = cardPersistency;
     CardTarget      = cardTarget;
     Animation       = Resources.Load <Sprite>("Images/Cards/" + name);
     Params          = param;
     Effects         = effects != null?effects:new Dictionary <Effect, Card[]>();
     CastDistance    = castDistance;
     IsCastOn        = cardIsCastOn;
 }
        public AbstractCard(string inp_ID, CardRarity crarity, CardType ctype, CardTarget ctarget, int ccost, string cdescription)
        {
            ID               = inp_ID;
            card_rarity      = crarity;
            card_target      = ctarget;
            card_type        = ctype;
            card_cost        = ccost;
            card_description = cdescription;
            card_tags        = "";

            if (cardutilities.CardIDUtilities.IsValidCardID(this))
            {
                card_name = ID.Split(':')[1];
            }
        }
Esempio n. 8
0
    public AbstractCard(string id, string cardName, int cost, CardRarity rarity, List <CardType> type, string imageName, string cardText, string cardFlavor = "")
    {
        this.ID     = id;
        this.NAME   = cardName;
        this.COST   = cost;
        this.RARITY = rarity;
        this.TYPE   = type;
        this.IMAGE  = Resources.Load <Sprite>((string)"Images/Card Art/" + imageName);
        this.TEXT   = cardText;
        this.FLAVOR = cardFlavor;
        switch (this.TYPE[0])
        {
        case CardType.ATTACK:
            this.TARGETING = CardTarget.ENEMIES_ONLY;
            break;

        default:
            this.TARGETING = CardTarget.NON_TARGETED;
            break;
        }
    }
Esempio n. 9
0
 public Barricade(string _cardId, string _name, string _imgURL, int _cost, string _rawDescription, CardType _cardType, CardRarity _cardRarity, CardTarget _cardTarget) : base(_cardId, _name, _imgURL, _cost, _rawDescription, _cardType, _cardRarity, _cardTarget)
 {
 }
Esempio n. 10
0
 public HeavyBlade(string _cardId, string _name, string _imgURL, int _cost, string _rawDescription, CardType _cardType, CardRarity _cardRarity, CardTarget _cardTarget, DamageType _damageType) : base(_cardId, _name, _imgURL, _cost, _rawDescription, _cardType, _cardRarity, _cardTarget, _damageType)
 {
 }
Esempio n. 11
0
        public override void Visit(PlayASpellFromHandAction action)
        {
            // Ignore check if caller not AMARU
            // TODO: Remove
            if (action.Caller != CharacterEnum.AMARU)
            {
                return;
            }

            // Check caller player is alive and it is its main turn
            Player caller = this.GameManager.GetPlayer(action.Caller);

            if (!caller.IsAlive || GameManager.ActiveCharacter != action.Caller || !GameManager.IsMainTurn)
            {
                throw new CallerCannotPlayException();
            }

            //Check if caller player has enough CPs to play the card
            Card cardPlaying = caller.GetCardFromId(action.PlayedCardId, Place.HAND);

            if (cardPlaying.Cost > caller.Mana)
            {
                throw new NotEnoughManaAvailableException();
            }

            //check if the Card is a Creature
            if (!(cardPlaying is SpellCard))
            {
                throw new InvalidCardTypeException();
            }

            //Check if target is alive, if the spell has a target or more than one target
            List <Target> target    = action.Targets;
            SpellAbility  effect    = ((SpellCard)cardPlaying).Effect;
            int           numTarget = effect.NumTarget;
            KindOfTarget  acceptableTypeOfTarget = effect.kindOfTarget;

            if (target is null)
            {
                return;
            }

            if (numTarget != 0 || target.Count > numTarget)
            {
                //Check targets are not immune, and that the right number of target has been chosen. BUT it depends on the card!ù
                throw new InvalidTargetException();
            }

            foreach (Target t in target)
            {
                if (t is PlayerTarget && acceptableTypeOfTarget != KindOfTarget.PLAYER && acceptableTypeOfTarget != KindOfTarget.MIXED)
                {
                    throw new InvalidTargetException();
                }
                if (t is CardTarget && acceptableTypeOfTarget != KindOfTarget.MIXED && acceptableTypeOfTarget != KindOfTarget.CREATURE)
                {
                    throw new InvalidTargetException();
                }
                if (t is PlayerTarget && GameManager.UserDict[((PlayerTarget)t).Character].Player.IsImmune)
                {
                    throw new InvalidTargetException();
                }
                if (t is CardTarget)
                {
                    CardTarget cardTarget = (CardTarget)t;
                    Card       cardOuter  = GameManager.UserDict[((CardTarget)t).Character].Player.GetCardFromId(cardTarget.CardId, Place.OUTER);
                    Card       cardInner  = GameManager.UserDict[((CardTarget)t).Character].Player.GetCardFromId(cardTarget.CardId, Place.INNER);
                    if (cardOuter != null && cardOuter is CreatureCard)
                    {
                        if (((CreatureCard)cardOuter).creatureEffect is ImmunityCreatureEffect)
                        {
                            throw new InvalidTargetException();
                        }
                    }
                    if (cardInner != null && cardInner is CreatureCard)
                    {
                        if (((CreatureCard)cardInner).creatureEffect is ImmunityCreatureEffect)
                        {
                            throw new InvalidTargetException();
                        }
                    }
                }
            }//*/
        }
Esempio n. 12
0
 public DEBUG_Card(string inp_ID, CardRarity crarity, CardType ctype, CardTarget ctarget, int ccost, string cdescription)
     : base(inp_ID, crarity, ctype, ctarget, ccost, cdescription)
 {
 }
Esempio n. 13
0
 List<int> GetPotentialTargets(CardTarget targetType, int from, int inheritedTarget)
 {
     List<int> potentialTargets = new List<int>( players.Length );
     switch ( targetType ) {
         case CardTarget.CARD_TARGET_NONE: {
             potentialTargets.Add( -1 );
             break;
         }
         case CardTarget.CARD_TARGET_INHERIT: {
             potentialTargets.Add( inheritedTarget );
             break;
         }
         case CardTarget.CARD_TARGET_SELF: {
             potentialTargets.Add( from );
             break;
         }
         case CardTarget.CARD_TARGET_ANY_PLAYER: {
             foreach (Player p in players) {
                 potentialTargets.Add(p.playerID);
             }
             break;
         }
         case CardTarget.CARD_TARGET_OTHER_PLAYER: {
             foreach (Player p in players) {
                 if (p.playerID != GameplayManager.SharedInstance.Game.LocalPlayer.Id) {
                     potentialTargets.Add(p.playerID);
                 }
             }
             break;
         }
         case CardTarget.CARD_TARGET_ON_MISSION: {
             List<int> playersOnTeam = GameplayManager.SharedInstance.Game.GameState.CurrentMission.Team;
             foreach (Player p in players) {
                 if (playersOnTeam.Contains(p.playerID)) {
                     potentialTargets.Add(p.playerID);
                 }
             }
             break;
         }
         case CardTarget.CARD_TARGET_WITH_CARDS: {
             foreach (Player p in players) {
                 if (GameplayManager.SharedInstance.Game.GameState.Players[p.playerID].NumCards > 0) {
                     potentialTargets.Add(p.playerID);
                 }
             }
             break;
         }
         case CardTarget.CARD_TARGET_WITHOUT_CARDS: {
             foreach (Player p in players) {
                 if (GameplayManager.SharedInstance.Game.GameState.Players[p.playerID].NumCards == 0) {
                     potentialTargets.Add(p.playerID);
                 }
             }
             break;
         }
         case CardTarget.CARD_TARGET_WITH_CONFIDENCE_TOKENS: {
             foreach (Player p in players) {
                 if (GameplayManager.SharedInstance.Game.GameState.Players[p.playerID].NumConfidenceTokens > 0) {
                     potentialTargets.Add(p.playerID);
                 }
             }
             break;
         }
         case CardTarget.CARD_TARGET_WITHOUT_CONFIDENCE_TOKENS: {
             foreach (Player p in players) {
                 if (GameplayManager.SharedInstance.Game.GameState.Players[p.playerID].NumConfidenceTokens == 0) {
                     potentialTargets.Add(p.playerID);
                 }
             }
             break;
         }
         case CardTarget.CARD_TARGET_WITH_POSITIVE_CONFIDENCE: {
             foreach (Player p in players) {
                 if (GameplayManager.SharedInstance.Game.GameState.Players[p.playerID].ConfidencePositive > 0) {
                     potentialTargets.Add(p.playerID);
                 }
             }
             break;
         }
         case CardTarget.CARD_TARGET_WITH_NEGATIVE_CONFIDENCE: {
             foreach (Player p in players) {
                 if (GameplayManager.SharedInstance.Game.GameState.Players[p.playerID].ConfidenceNegative > 0) {
                     potentialTargets.Add(p.playerID);
                 }
             }
             break;
         }
         case CardTarget.CARD_TARGET_WITH_CONFIDENCE_FROM_ME: {
             foreach (Player p in players) {
                 foreach (ConfidenceEventModel cem in GameplayManager.SharedInstance.Game.GameState.Players[p.playerID].ConfidenceEvents) {
                     if (cem.From == GameplayManager.SharedInstance.Game.LocalPlayer.Id) {
                         potentialTargets.Add(p.playerID);
                         break;
                     }
                 }
             }
             break;
         }
     }
     return potentialTargets;
 }
Esempio n. 14
0
        protected virtual void ApplySingle(CardInstance _source, object _target = null)
        {
            player = _target as Player;
            CardInstance cardTarget = _target as CardInstance;

            if (cardTarget == null)
            {
                cardTarget = _source;
            }
            if (player == null && _source != null)
            {
                player = _source.Controler;
            }

            switch (TypeOfEffect)
            {
            case EffectType.GainLife:
                player.LifePoints += (this as NumericEffect).Amount.GetValue(_source);
                break;

            case EffectType.LoseLife:
                player.LifePoints -= (this as NumericEffect).Amount.GetValue(_source);
                break;

            case EffectType.Unset:
                break;

            case EffectType.Loose:
                break;

            case EffectType.LooseAllAbilities:
                break;

            case EffectType.Gain:

                break;

            case EffectType.Discard:
                cardTarget?.ChangeZone(CardGroupEnum.Graveyard);
                break;

            case EffectType.Pump:
                break;

            case EffectType.Effect:
                break;

            case EffectType.Counter:
                (_target as MagicAction).IsCountered = true;
                break;

            case EffectType.Destroy:
                cardTarget.PutIntoGraveyard();
                break;

            case EffectType.Tap:
                cardTarget.tappedWithoutEvent = true;
                break;

            case EffectType.DoesNotUntap:
                break;

            case EffectType.TapAll:
                break;

            case EffectType.PreventDamage:
                break;

            case EffectType.Charm:
                break;

            case EffectType.DealDamage:
                MagicEngine.CurrentEngine.MagicStack.PushOnStack(new Damage(_target as IDamagable, _source, (this as NumericEffect).Amount.GetValue(_source)));
                break;

            case EffectType.ChangeZone:
                if ((this as ChangeZoneEffect).Destination == CardGroupEnum.Reveal)
                {
                    CardGroup cg = player.allGroups.Where(ag => ag.GroupName == (this as ChangeZoneEffect).Origin).FirstOrDefault();
                    for (int i = 0; i < (this as ChangeZoneEffect).NumCards; i++)
                    {
                        cg.Cards [cg.Cards.Count - 1].SwitchFocus();
                    }
                    break;
                }
                cardTarget.Reset();
                cardTarget.ChangeZone((this as ChangeZoneEffect).Destination);
                if ((this as ChangeZoneEffect).Tapped)
                {
                    cardTarget.tappedWithoutEvent = true;
                }
                else
                {
                    cardTarget.tappedWithoutEvent = false;
                }
                break;

            case EffectType.Draw:
                Animation.DelayMs = 300;
                for (int i = 0; i < (this as NumericEffect).Amount.GetValue(_source); i++)
                {
                    player.DrawOneCard();
                    Animation.DelayMs += i * 100;
                }
                Animation.DelayMs = 0;
                break;

            case EffectType.DestroyAll:
                break;

            case EffectType.RepeatEach:
                break;

            case EffectType.Token:
                TokenEffect tkEff = this as TokenEffect;
                MagicCard   tk    = new MagicCard()
                {
                    Name      = tkEff.Name,
                    Power     = tkEff.Power.GetValue(_source, _target),
                    Toughness = tkEff.Toughness.GetValue(_source, _target),
                    Colors    = tkEff.Colors,
                    Types     = tkEff.Types,
                };
                string picPath = System.IO.Path.Combine(MagicData.cardsArtPath, "tokens");
                if (string.IsNullOrEmpty(tkEff.Image))
                {
                    picPath = System.IO.Path.Combine(picPath,
                                                     new Mana(tkEff.Colors.FirstOrDefault()).ToString().ToLower() + "_" + tk.Power.ToString() + "_" + tk.Toughness.ToString() +
                                                     tk.Types.Where(tkt => tkt != CardTypes.Creature).
                                                     Aggregate <CardTypes, string> (String.Empty, (a, b) => a.ToString().ToLower() + '_' + b.ToString().ToLower()) + ".jpg");
                }
                else
                {
                    picPath = System.IO.Path.Combine(picPath, tkEff.Image + ".jpg").Replace(' ', '_').ToLower();
                }

                tk.picturePath = picPath;

                Player[] players;

                switch (tkEff.Owner)
                {
                case ControlerType.All:
                    players = MagicEngine.CurrentEngine.Players;
                    break;

                case ControlerType.You:
                    players = new Player[] { _source.Controler };
                    break;

                case ControlerType.Opponent:
                    players = new Player[] { _source.Controler.Opponent };
                    break;

                case ControlerType.Targeted:
                    players = new Player[] { _target as Player };
                    break;

                default:
                    players = new Player[] { _source.Controler };
                    break;
                }

                foreach (Player p in players)
                {
                    for (int i = 0; i < tkEff.Amount.GetValue(_source, _target); i++)
                    {
                        CardInstance tkinst = new CardInstance(tk)
                        {
                            Controler = p, IsToken = true, HasSummoningSickness = true
                        };
                        tkinst.CreateGLCard();
                        p.InPlay.AddCard(tkinst);
                    }
                    p.InPlay.UpdateLayout();
                    //engine.UpdateOverlays ();
                }

                break;

            case EffectType.GainControl:
                break;

            case EffectType.Repeat:
                break;

            case EffectType.Debuff:
                break;

            case EffectType.ChooseColor:
                break;

            case EffectType.Dig:
                break;

            case EffectType.PumpAll:
                break;

            case EffectType.RemoveCounterAll:
                break;

            case EffectType.ChangeZoneAll:
                CardGroup orig = cardTarget.Controler.allGroups.Where(ag => ag.GroupName == (this as ChangeZoneEffect).Origin).FirstOrDefault();
                while (orig.Cards.Count > 0)
                {
                    CardInstance cc = orig.Cards.FirstOrDefault();
                    cc.Reset();
                    cc.ChangeZone((this as ChangeZoneEffect).Destination);
                    if ((this as ChangeZoneEffect).Tapped)
                    {
                        cc.tappedWithoutEvent = true;
                    }
                    else
                    {
                        cc.tappedWithoutEvent = false;
                    }
                }
                orig.UpdateLayout();
                cardTarget.Controler.allGroups.Where(ag => ag.GroupName == (this as ChangeZoneEffect).Destination).FirstOrDefault().UpdateLayout();
                break;

            case EffectType.DamageAll:
                break;

            case EffectType.UntapAll:
                break;

            case EffectType.PutCounter:
                AddOrRemoveCounter pce = this as AddOrRemoveCounter;
                if (pce.Type == AddOrRemoveCounter.CounterType.P1P1)
                {
                    EffectGroup eg = new EffectGroup();
                    //eg.Mode = ModeEnum.Continuous;
                    eg.Affected = new CardTarget(TargetType.Self);
                    eg.Add(new NumericEffect(EffectType.AddTouchness, 1));
                    eg.Add(new NumericEffect(EffectType.AddPower, 1));
                    cardTarget.Effects.Add(eg);
                }
                break;

            case EffectType.PutCounterAll:
                break;

            case EffectType.StoreSVar:
                break;

            case EffectType.FlipACoin:
                break;

            case EffectType.SacrificeAll:
                break;

            case EffectType.Untap:
                break;

            case EffectType.Mill:
                break;

            case EffectType.Animate:
                break;

            case EffectType.Fog:
                break;

            case EffectType.RemoveCounter:
                break;

            case EffectType.ExchangeZone:
                break;

            case EffectType.AnimateAll:
                break;

            case EffectType.ChooseCard:
                break;

            case EffectType.Reveal:
                break;

            case EffectType.ChooseSource:
                break;

            case EffectType.MustBlock:
                break;

            case EffectType.ExchangeControl:
                break;

            case EffectType.RearrangeTopOfLibrary:
                break;

            case EffectType.CopyPermanent:
                break;

            case EffectType.SetState:
                break;

            case EffectType.Balance:
                break;

            case EffectType.RevealHand:
                break;

            case EffectType.Sacrifice:
                break;

            case EffectType.AddTurn:
                break;

            case EffectType.TwoPiles:
                break;

            case EffectType.ManaReflected:
                break;

            case EffectType.SetLife:
                break;

            case EffectType.DebuffAll:
                break;

            case EffectType.Fight:
                break;

            case EffectType.ChooseType:
                break;

            case EffectType.Shuffle:
                break;

            case EffectType.NameCard:
                break;

            case EffectType.PermanentNoncreature:
                break;

            case EffectType.PermanentCreature:
                break;

            case EffectType.TapOrUntap:
                break;

            case EffectType.GenericChoice:
                break;

            case EffectType.Play:
                break;

            case EffectType.BecomesBlocked:
                break;

            case EffectType.WinsGame:
                break;

            case EffectType.Proliferate:
                break;

            case EffectType.Scry:
                break;

            case EffectType.MoveCounter:
                break;

            case EffectType.GainOwnership:
                break;

            case EffectType.ChangeTargets:
                break;

            case EffectType.UnattachAll:
                break;

            case EffectType.PeekAndReveal:
                break;

            case EffectType.LosesGame:
                break;

            case EffectType.DigUntil:
                break;

            case EffectType.CopySpellAbility:
                break;

            case EffectType.RollPlanarDice:
                break;

            case EffectType.RegenerateAll:
                break;

            case EffectType.DelayedTrigger:
                break;

            case EffectType.MustAttack:
                break;

            case EffectType.ProtectionAll:
                break;

            case EffectType.RemoveFromCombat:
                break;

            case EffectType.RestartGame:
                break;

            case EffectType.PreventDamageAll:
                break;

            case EffectType.ExchangeLife:
                break;

            case EffectType.DeclareCombatants:
                break;

            case EffectType.ControlPlayer:
                break;

            case EffectType.Phases:
                break;

            case EffectType.Clone:
                break;

            case EffectType.Clash:
                break;

            case EffectType.ChooseNumber:
                break;

            case EffectType.EachDamage:
                break;

            case EffectType.ReorderZone:
                break;

            case EffectType.ChoosePlayer:
                break;

            case EffectType.EndTurn:
                break;

            case EffectType.MultiplePiles:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Esempio n. 15
0
 public AbstractCard(string _cardId, string _name, string _imgURL, int _cost, string _rawDescription, CardType _cardType, CardRarity _cardRarity, CardTarget _cardTarget) : this(_cardId, _name, _imgURL, _cost, _rawDescription, _cardType, _cardRarity, _cardTarget, DamageType.Normal)
 {
 }
Esempio n. 16
0
 public AttackCreatureAction(CharacterEnum caller, int playedCardId, Property playedProperty, CardTarget target) : base(caller, playedCardId)
 {
     this.Target         = target;
     this.PlayedProperty = PlayedProperty;
 }