private void UseSpells() { foreach (CardInstance card in aiPlayerData.hand) { if (card.card.type == CardType.Spell) { SpellAbility ability = ((SpellAbility)card.card.ability); int numberOfTargets = ability.numberOfTargets; List <Target> targets = new List <Target>(); if (ability.validTargets == TargetOptions.EnemyCard) { targets = findCardsToDamage(numberOfTargets); } if (ability.validTargets == TargetOptions.AllyCard) { targets = findCardsToHeal(numberOfTargets); } if (targets.Count > 0) { ability.ActivateAbility(targets, card.abilityInstance); } } } }
void Update() { SpellAbility.Condition c = (SpellAbility.Condition)condition.value; condition_data.SetActive(SpellAbility.CheckDataCondition(c)); SpellAbility.Ability a = (SpellAbility.Ability)ability.value; ability_data.SetActive(SpellAbility.CheckDataAbility(a)); string s = ""; s += "[" + c.ToString() + "]"; if (condition_data.activeSelf) { s += "[" + c_data1.text + "]"; s += "[" + c_data2.text + "]"; s += "[" + c_data3.text + "]"; } s += "[" + a.ToString() + "]"; if (ability_data.activeSelf) { s += "[" + a_data1.text + "]"; s += "[" + a_data2.text + "]"; s += "[" + a_data3.text + "]"; } outData.text = s; }
public void OnLeftMouseClick() { card = owner.activeCardViewVar.value.GetComponent <CardView>().cardInstance; ability = (SpellAbility)card.card.ability; if (!owner.missUpdate) { if (chosenTargetsList.Count < ability.numberOfTargets) { AddTarget(); } } else { owner.missUpdate = false; } }
public SpellAbility(SpellAbility ability) : base(ability) { }
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(); } } } }//*/ }
public SpellCard(CardEnum cardEnum, string name, int cost, SpellAbility effect = null, int id = AmaruConstants.AUTO_ID) : base(id, cardEnum, name, cost) { this.Effect = effect; }