public virtual void Act(CharacterStats player, Stats enemy) // Always call when overriding { EndTurn(player, enemy); }
public string BattleDescription(CharacterStats player, Stats enemy) { return($"{Name} ({Cost} mana) - {SpecificBattleDescription(player, enemy)}{(CurrentCooldown > 0 ? "| Cooldown: " + CurrentCooldown : "")}"); }
protected abstract void EndTurn(CharacterStats player, Stats enemy);
// Skill specific description for battle protected abstract string SpecificBattleDescription(CharacterStats player, Stats enemy);
// Sets effect values and checks casting conditions // Returns true on valid usage condition (e.g. player has enough soul shards to cast draw soul) protected virtual bool SetSkillEffectValues(CharacterStats player, Stats enemy) { SkillEffectValues = new EffectValues(Power(player, enemy), source: this); return(true); }
protected override int Power(CharacterStats player, Stats enemy) => player.SpellPower / 4 + Level * 10;
// The actual effect of the skill (everything except usage conditions and damage/healing calculations) protected abstract void SkillEffect(CharacterStats player, Stats enemy);
protected override void SkillEffect(CharacterStats player, Stats enemy) { shard.SetStacks(-soulShardCost); shard.WriteStacks(); }
protected override string SpecificBattleDescription(CharacterStats player, Stats enemy) { int power = Math.Abs(Power(player, enemy)); return($"Deals ({power}) damage to your enemy and heals you for ({power}). (Requires {soulShardCost} {shard.Name})"); }
protected virtual bool AttackUseEffect(CharacterStats player, Stats enemy, EffectValues attackValues) => true; // Don't call when overriding // Item effect for usable and consumable items for when used protected virtual void ActiveEffect(CharacterStats player, Stats enemy) { } // Don't call when overriding
protected virtual bool SkillHitEffect(CharacterStats player, Stats enemy, EffectValues attackValues) => true; // Don't call when overriding // Returns true if skill should continue; False on interrupted (e.g. miss, resist, etc.) protected virtual bool SkillUseEffect(CharacterStats player, Stats enemy, EffectValues attackValues) => true; // Don't call when overriding
// Called at the start of the battle; Always call base when overriding public virtual void OnBattleStart(CharacterStats player, Stats enemy) // Always call when overriding { checkSet(player, Set); CurrentCooldown = 0; }
protected override string SpecificBattleDescription(CharacterStats player, Stats enemy) => $"Drains ({Power(player, enemy)}) health from your enemy and generates a {shard.Name}.";
protected override void SkillEffect(CharacterStats player, Stats enemy) { shard = Buff.AddBuff <SoulShard>(player); shard.SetStacks(); // Add one stack shard.WriteStacks(); }
// Used for general initialization prior to battle start -> stat resets, skill refreshing and other preparations public virtual void Initialize(CharacterStats player, Stats enemy) { }
// Used to calculate the power of the skill protected abstract int Power(CharacterStats player, Stats enemy);
public virtual bool OnSkillHit(CharacterStats player, Stats enemy, EffectValues skillEffectValues) { return(true); }
// Returns false on completed turn. True if it is still player's turn public static bool Show(CharacterStats player, Stats enemy) { try { Menu.Announce($"{enemy.OwnerUnit.Name}: {enemy.Health}/{enemy.MaxHealth} health"); Console.WriteLine($"Your health: {player.Health}/{player.MaxHealth}\n"); Menu.ShowOptions(options); int command = Command.ParseIntCommand(); switch (command) { case 1: player.OwnerUnit.AttackEnemy(player, enemy); return(false); case 2: Skill skill = chooseSkill(player, enemy); if (skill != null) { if (skill.Use(player, enemy)) { return(false); // Successful usage } else { player.Mana += skill.Cost; // Replenish mana on failed usage } } return(true); // No skill has been used (e.g. back command) case 3: if (player.ActiveItems.Count > 0) { if (player.HasUsedItem) { Console.WriteLine(Constants.ItemUsedMessage); } else { chooseItem(player, enemy); } } else { Console.WriteLine("There are no usable items.\n"); } return(true); // Items don't end the turn (not considered actions) case 4: enemy.ShowBuffs(); player.ShowBuffs(); return(true); // This does not end player's turn case 5: Console.WriteLine(enemy); Console.WriteLine(player); return(true); // This does not end player's turn case 6: Console.WriteLine("You concede\n"); player.Health = 0; return(false); default: Console.WriteLine(Constants.InvalidCommand); return(true); } } catch (NotImplementedException) { Console.WriteLine("Option is not yet implemented. (NYI)\n"); return(true); } }