// play statues // public static void Attack(Unit attacker, Unit target) { if (attacker.HP == 0) { return; } BattleRecord record = new BattleRecord(attacker, target, null); foreach (Effect effect in target.Effects) { if (effect.stopAttach(record)) { new BattleRecord(attacker, target, "").Show(); return; } } foreach (Effect effect in attacker.Effects) { effect.applyBeforeAttack(record); } // Hit Rate test. if (!common.TestOdd(target.HitRate)) { record.Information = "#from# missed."; } // Parray Rate test. else if (common.TestOdd(target.ParryRate)) { new BattleRecord(attacker, target, "#to# Dodged.").Show(); return; } else { // Basic damage. record.Damage = attacker.GetDamage() - target.Defense; record.Damage = record.Damage < 0 ? 0 : record.Damage; // Critial Hit test. if (common.TestOdd(target.CriticalRate)) { record.Damage *= (int)(1 + target.CriticalDamage); record.Information = "#from# critical hit #to#, caused #damage# damage."; } else { record.Information = "#from# hit #to#, caused #damage# damage."; } // Reduce HP. target.HP -= record.Damage; } foreach (Effect effect in attacker.Effects) { effect.applyAfterAttack(record); } // return record; }