//Called when the oppoenent is selected public void DoAttack() { Attacker.Target.currentMana -= SelectedMove.getCost(); foreach (CreatureBattleStatusController Defender in Defenders) { string message; if (SelectedMove.execute(Attacker, Defender)) { //attack hit message = Attacker.GetCreature().GetName() + " used " + SelectedMove.name + " on " + Defender.GetCreature().GetName() + "."; messageBoxActions.Enqueue(() => ShowMessage(message)); //faint? if (Defender.GetCreature().currentActiveHealth <= 0) { if (Defender.GetCreature().currentCriticalHealth <= 0) { messageBoxActions.Enqueue(() => ShowMessage(Defender.GetCreature().GetName() + " died!")); messageBoxActions.Enqueue(() => Defender.Die()); } else { messageBoxActions.Enqueue(() => ShowMessage(Defender.GetCreature().GetName() + " fainted!")); messageBoxActions.Enqueue(() => Defender.Faint()); } } } else { //attack missed message = SelectedMove.name + " missed" + Defender.GetCreature().GetName() + "."; messageBoxActions.Enqueue(() => ShowMessage(message)); } } resetSelection(); messageBoxActions.Enqueue(() => EndTurn()); }
public float getModifier() { Type attackingPType = Attacker.GetCreature().getPType(); Type attackingSType = Attacker.GetCreature().getSType(); Type defendingPType = Defender.GetCreature().getPType(); Type defendingSType = Defender.GetCreature().getSType(); //Debug.Log(attackingPType); //Debug.Log(defendingPType); List <Type> strongMatchups = Matchups.getStrongTypeEffectiveness(this.Type); float weakTypeMultiplier = 1.0f; //default if (strongMatchups.Contains(defendingPType) && strongMatchups.Contains(defendingSType)) { //if BOTH defending types are weak to attacking move type weakTypeMultiplier = 4.0f; } else if (strongMatchups.Contains(defendingPType) || strongMatchups.Contains(defendingSType)) { //if ONE of the defending types is weak to the attacking move type weakTypeMultiplier = 2.0f; } List <Type> weakMatchups = Matchups.getWeakTypeEffectiveness(this.Type); float resistantTypeMultiplier = 1.0f; //default if (weakMatchups.Contains(defendingPType) && weakMatchups.Contains(defendingSType)) { //if BOTH defending types are resistant to attacking move type resistantTypeMultiplier = 0.25f; } else if (weakMatchups.Contains(defendingPType) || weakMatchups.Contains(defendingSType)) { //if ONE of the defending types is resistant to the attacking move type resistantTypeMultiplier = 0.5f; } float stabMultiplier = 1.0f; //default if (attackingPType == this.Type || attackingSType == this.Type) { //since moves only have 1 type only need to do an OR check stabMultiplier = 1.5f; } //dont need this /* else if (Matchups.getLinkedTypes(attackingType).Contains(this.Type)) { * stabMultiplier = 1.5f; * } else if (Matchups.getUnlinkedTypes(attackingType).Contains(this.Type)) { * stabMultiplier = 0.75f; * } */ float critMultiplier = 1.0f; float random = Random.Range(0, 1); if (this.CritChance > random) { critMultiplier = 2.0f; } Debug.Log("modifier values: " + resistantTypeMultiplier.ToString() + " " + weakTypeMultiplier.ToString() + " " + stabMultiplier.ToString() + " " + critMultiplier.ToString()); return(resistantTypeMultiplier * weakTypeMultiplier * stabMultiplier * critMultiplier); }