public int AttackDamage(Combatant combatant) { int strength = combatant.Strength; int equipmentDamage = GetCombatantTotalAttack(combatant); if (equipmentDamage < strength) { return randomGenerator.Next(equipmentDamage, equipmentDamage + (strength / 2) + 1); } else { return randomGenerator.Next(strength, strength + (equipmentDamage / 2) + 1); } }
public int DefenseValue(Combatant combatant) { int strength = combatant.Strength; int equipmentDefense = GetCombatantTotalDefense(combatant); if (equipmentDefense < strength) { return randomGenerator.Next(equipmentDefense, equipmentDefense + (strength / 4) + 1); } else { return randomGenerator.Next(strength, strength + (equipmentDefense / 4) + 1); } }
public int GetCombatantTotalAttack(Combatant combatant) { int armorAttack = 0; if (combatant.ArmorID != null) { armorAttack += Service.GetEquipmentStats(null, null, combatant.ArmorID).Damage; } if (combatant.WeaponID != null) { armorAttack += Service.GetEquipmentStats(null, null, combatant.WeaponID).Damage; } if (combatant.ShieldID != null) { armorAttack += Service.GetEquipmentStats(null, null, combatant.ShieldID).Damage; } return armorAttack; }
public int GetCombatantTotalDefense(Combatant combatant) { int armorDefense = 0; if (combatant.ArmorID != null) { armorDefense += Service.GetEquipmentStats(null, null, combatant.ArmorID).Defense; } if (combatant.WeaponID != null) { armorDefense += Service.GetEquipmentStats(null, null, combatant.WeaponID).Defense; } if (combatant.ShieldID != null) { armorDefense += Service.GetEquipmentStats(null, null, combatant.ShieldID).Defense; } return armorDefense; }
public void AttackCleanUp(ref Combatant attacker, ref Combatant defender, ref List<Combatant> combatants) { // Both combatants lose stanima for their participation in the attack. attacker.Stanima -= 1; defender.Stanima -= 1; if (defender.Stanima <= 0 || ((double)defender.Health / defender.MaxHealth) <= defender.GiveUpPercent) { combatantsGiveUp.Add(defender); if(((double)defender.Health / defender.MaxHealth) <= defender.GiveUpPercent) { combatLog.Add(new CombatLog(combatLogID, String.Format(strings.GetString("GiveUpString"), defender.Name), null, null, null, null)); } else { combatLog.Add(new CombatLog(combatLogID, String.Format(strings.GetString("GiveUpStanimaString"), defender.Name), null, null, null, null)); } combatLogID++; Combatant defenderToRemove = defender; combatants.Remove(combatants.Find(x => x.CombatantID == defenderToRemove.CombatantID)); } if (attacker.Stanima <= 0 || ((double)attacker.Health / attacker.MaxHealth) <= attacker.GiveUpPercent) { combatantsGiveUp.Add(attacker); if (((double)attacker.Health / attacker.MaxHealth) <= attacker.GiveUpPercent) { combatLog.Add(new CombatLog(combatLogID, String.Format(strings.GetString("GiveUpString"), attacker.Name), null, null, null, null)); } else { combatLog.Add(new CombatLog(combatLogID, String.Format(strings.GetString("GiveUpStanimaString"), attacker.Name), null, null, null, null)); } combatLogID++; Combatant attackerToRemove = attacker; combatants.Remove(combatants.Find(x => x.CombatantID == attackerToRemove.CombatantID)); } }
public Combatant CopyCombatant(Combatant combatantToCopy) { return new Combatant { CharID = combatantToCopy.CharID, UserID = combatantToCopy.UserID, Race = combatantToCopy.Race, Name = combatantToCopy.Name, Level = combatantToCopy.Level, Experience = combatantToCopy.Experience, Health = combatantToCopy.Health, MaxHealth = combatantToCopy.MaxHealth, Stanima = combatantToCopy.Stanima, MaxStanima = combatantToCopy.MaxStanima, Strength = combatantToCopy.Strength, Speed = combatantToCopy.Speed, Dexterity = combatantToCopy.Dexterity, Agility = combatantToCopy.Agility, WeaponID = combatantToCopy.WeaponID, ShieldID = combatantToCopy.ShieldID, ArmorID = combatantToCopy.ArmorID, GiveUpPercent = combatantToCopy.GiveUpPercent, TeamNumber = combatantToCopy.TeamNumber, CombatantID = combatantToCopy.CombatantID }; }
// Only used by CloneCombatantList public static Combatant ReturnCombatant(Combatant combatant) { return combatant; }