Exemple #1
0
        public bool StealingMana(Battler user, Monster mon, int monIndex)
        {
            BattleCardEventArgs args = new BattleCardEventArgs(user, GetOpponent(user), mon, monIndex);

            ManaSteal?.Invoke(this, args);

            if (args.DestroyTriggerer)
            {
                DestroyingMonster(args.TriggeringPlayer, (Monster)args.TriggeringCard, null, args.TriggeringCardIndex, -1);
            }
            if (args.Cancel || args.DestroyTriggerer)
            {
                return(false);
            }

            args.TriggeringPlayer.Mana    += mon.Level;
            args.NonTriggeringPlayer.Mana -= mon.Level;
            if (args.TriggeringCard is Monster)
            {
                ((Monster)args.TriggeringCard).CanAttack = false;
            }
            ShowText(args.TriggeringPlayer.Name + "'s " + args.TriggeringCard.Name + " stole " +
                     args.TriggeringCard.Level + " Mana from " + args.NonTriggeringPlayer.Name);
            args.TriggeringPlayer.HasMoved = true;

            return(true);
        }
Exemple #2
0
        public bool ActivatingSpell(Battler user, Spell spl, int splIndex)
        {
            BattleCardEventArgs args = new BattleCardEventArgs(user, GetOpponent(user), spl, splIndex);

            SpellActivate?.Invoke(this, args);

            if (args.DestroyTriggerer || (args.Cancel && spl.SpellType != CardEffectType.CONTINUOUS))
            {
                DestroyingSpell(args.NonTriggeringPlayer, args.TargetedCard, args.TriggeringCard, args.TargetedCardIndex, args.TriggeringCardIndex);
            }
            if (args.Cancel || args.DestroyTriggerer)
            {
                return(false);
            }


            Spell spell = (Spell)args.TriggeringCard;

            ShowText(args.TriggeringPlayer.Name + " activated " + args.TriggeringCard.Name + "!");
            spell.ResolveEffects(this, args.TriggeringCard);
            if (spell.SpellType == CardEffectType.INSTANT || spell.SpellType == CardEffectType.COUNTER)
            {
                RemovingSpell(args.TriggeringPlayer, spell, args.TriggeringCardIndex);
            }
            return(true);
        }
Exemple #3
0
        public bool SummoningMonster(Battler user, Monster mon, int monIndex)
        {
            BattleCardEventArgs args = new BattleCardEventArgs(user, GetOpponent(user), mon, monIndex);

            Summon?.Invoke(this, args);

            if (args.DestroyTriggerer)
            {
                user.DestroyCard(monIndex);
            }
            if (args.Cancel || args.DestroyTriggerer)
            {
                return(false);
            }

            return(user.Summon(mon, monIndex));
        }
Exemple #4
0
        public bool DestroyingMonster(BattleCardEventArgs args)
        {
            MonsterDestroyed?.Invoke(this, args);

            if (args.DestroyTriggerer)
            {
                DestroyingMonster(args.TriggeringPlayer, (Monster)args.TriggeringCard, null, args.TriggeringCardIndex, -1);
            }
            if (args.Cancel || args.DestroyTriggerer)
            {
                return(false);
            }

            ShowText(args.NonTriggeringPlayer.Name + "'s " + args.TargetedCard.Name + " was destroyed!");
            args.NonTriggeringPlayer.DestroyCard(args.TargetedCardIndex);

            return(true);
        }
Exemple #5
0
        public bool DrawingCard(Battler user, Card card)
        {
            if (card == null)
            {
                Random random = new Random();
                card = user.PlayDeck[random.Next(user.PlayDeck.Count)];
            }

            BattleCardEventArgs args = new BattleCardEventArgs(user, GetOpponent(user), card);

            Draw?.Invoke(this, args);
            if (args.Cancel)
            {
                return(false);
            }
            user.Draw(card);
            return(true);
        }
Exemple #6
0
        public bool SettingMonster(Battler user, Monster setMon, int setMonIndex)
        {
            BattleCardEventArgs args = new BattleCardEventArgs(user, GetOpponent(user), setMon, setMonIndex);

            SetMonster?.Invoke(this, args);

            if (args.DestroyTriggerer)
            {
                args.TriggeringPlayer.DestroyCard(args.TriggeringCardIndex);
            }
            if (args.Cancel || args.DestroyTriggerer)
            {
                return(false);
            }

            args.TriggeringPlayer.Set((Monster)args.TriggeringCard, args.TriggeringCardIndex);

            return(true);
        }
Exemple #7
0
        public bool DestroyingSpell(Battler user, Card triggerer, Card target, int triggererindex, int targetindex)
        {
            BattleCardEventArgs args = new BattleCardEventArgs(user, GetOpponent(user), triggerer, target, triggererindex, targetindex);

            SpellDestroyed?.Invoke(this, args);

            if (args.DestroyTriggerer)
            {
                DestroyingSpell(args.NonTriggeringPlayer, args.DestroyingCard, args.TriggeringCard, args.DestroyingCardIndex, args.TriggeringCardIndex);
            }
            if (args.DestroyTriggerer || args.Cancel)
            {
                return(false);
            }

            ShowText(args.NonTriggeringPlayer + "'s " + args.TargetedCard.Name + " was destroyed!");
            RemovingSpell(args.NonTriggeringPlayer, (Spell)args.TargetedCard, args.TargetedCardIndex);

            return(true);
        }
Exemple #8
0
        public bool MonsterAttacking(Battler user, Monster attacker, Monster defender, int attackerIndex, int defenderIndex)
        {
            user.HasMoved = true;
            BattleCardEventArgs args = new BattleCardEventArgs(user, GetOpponent(user), attacker, defender, attackerIndex, defenderIndex);

            ShowText(user.Name + "'s " + attacker.Name + " attacked " + GetOpponent(user).Name + "'s " + defender.Name + "!");

            MonsterAttack?.Invoke(this, args);

            if (args.DestroyTriggerer)
            {
                DestroyingMonster(args.TriggeringPlayer, (Monster)args.TriggeringCard, null, args.TriggeringCardIndex, -1);
            }
            if (args.Cancel || args.DestroyTriggerer)
            {
                return(false);
            }

            switch (((Monster)args.TriggeringCard).Battle((Monster)args.TargetedCard))
            {
            case MonsterAttackOutcome.WIN:
                if (DestroyingMonster(args))
                {
                    ChangingMana(args.TriggeringPlayer, args.TargetedCard.Level);
                }
                break;

            case MonsterAttackOutcome.LOSS:
                if (DestroyingMonster(args.NonTriggeringPlayer, args.TargetedCard, (Monster)args.TriggeringCard, args.TargetedCardIndex, args.TriggeringCardIndex))
                {
                    ChangingMana(args.NonTriggeringPlayer, args.TriggeringCard.Level);
                }
                break;

            case MonsterAttackOutcome.TIE:
                ShowText("...but neither claimed victory.");
                break;
            }

            return(true);
        }
Exemple #9
0
        public bool FlippingMonster(Battler user, Monster mon, int monIndex)
        {
            BattleCardEventArgs args = new BattleCardEventArgs(user, GetOpponent(user), mon, monIndex);

            FlipMonster?.Invoke(this, args);

            if (args.DestroyTriggerer)
            {
                DestroyingMonster(args.TriggeringPlayer, (Monster)args.TriggeringCard, null, args.TriggeringCardIndex, -1);
            }
            if (args.Cancel || args.DestroyTriggerer)
            {
                return(false);
            }

            if (args.TriggeringCard is Monster)
            {
                ((Monster)args.TriggeringCard).Flip();
                ShowText("Flipped " + args.TriggeringCard.Name + " face-up.");
            }

            return(true);
        }
Exemple #10
0
        public bool SettingSpell(Battler user, Spell setSpl, int setSplIndex)
        {
            BattleCardEventArgs args = new BattleCardEventArgs(user, GetOpponent(user), setSpl);

            SetSpell?.Invoke(this, args);

            if (args.DestroyTriggerer)
            {
                args.TriggeringPlayer.DestroyCard(args.TriggeringCardIndex, false);
            }
            if (args.Cancel || args.DestroyTriggerer)
            {
                return(false);
            }

            Spell spell = (Spell)args.TriggeringCard;

            switch (spell.Trigger)
            {
            case CardEffectTrigger.DRAW:
                Draw += spell.TriggerEffects;
                break;

            case CardEffectTrigger.SUMMON:
                Summon += spell.TriggerEffects;
                break;

            case CardEffectTrigger.SPELL:
                SpellActivate += spell.TriggerEffects;
                break;

            case CardEffectTrigger.SETMONSTER:
                SetMonster += spell.TriggerEffects;
                break;

            case CardEffectTrigger.FLIPMONSTER:
                FlipMonster += spell.TriggerEffects;
                break;

            case CardEffectTrigger.SETSPELL:
                SetSpell += spell.TriggerEffects;
                break;

            case CardEffectTrigger.TURNSTART:
                TurnStart += spell.TriggerEffects;
                break;

            case CardEffectTrigger.TURNEND:
                TurnEnd += spell.TriggerEffects;
                break;

            case CardEffectTrigger.MONSTERDESTROYED:
                MonsterDestroyed += spell.TriggerEffects;
                break;

            case CardEffectTrigger.MANASTEAL:
                ManaSteal += spell.TriggerEffects;
                break;

            case CardEffectTrigger.MONSTERATTACK:
                MonsterAttack += spell.TriggerEffects;
                break;

            case CardEffectTrigger.MANAALLOTMENT:
            case CardEffectTrigger.MANA:
            case CardEffectTrigger.MANACHANGE:
                ManaChange += spell.TriggerEffects;
                break;
            }

            args.TriggeringPlayer.Set(spell, setSplIndex);

            return(true);
        }
Exemple #11
0
        public bool DestroyingMonster(Battler destroyerOwner, Card destroyer, Monster target, int destroyingMonIndex, int destroyedMonIndex)
        {
            BattleCardEventArgs args = new BattleCardEventArgs(destroyerOwner, GetOpponent(destroyerOwner), destroyer, target, destroyingMonIndex, destroyedMonIndex);

            return(DestroyingMonster(args));
        }