public void ReturnValue() { _character.Hp = 50; TakeDamageCommand command = new TakeDamageCommand(_character, 0); IMediatorCommandResponse response = _mediator.Execute(command); NoResponse _response = response as NoResponse; Assert.IsNotNull(_response); }
public override ApplyDamageResultListResponse Execute(IMediatorCommand command) { ApplyDamageResultListCommand _command = base.cast_command(command); if (false == _command.DamageList.Any()) { return(null); } PlayableEntity target = _command.GetEntity(); int total = 0; console.Value.AddEntry($"{target.DisplayName}", fontWeightProvider.Value.Bold); console.Value.AddEntry(" takes "); int i = 1; foreach (Damage damage in _command.DamageList) { int final_damage = damage.RawAmount; if (final_damage < 0) { Console.WriteLine($"WARNING : Trying to inflict {final_damage} damage on {target.DisplayName}," + $" will be treated as 0."); final_damage = 0; } applyDamageAffinity(ref final_damage, damage.TypeAffinity); if (_command.LastSavingWasSuccessfull) { applySavingModifier(ref final_damage, damage.SavingModifer); } total += final_damage; if (i == _command.DamageList.Count && i != 1) { console.Value.AddEntry("and "); } console.Value.AddEntry($"{final_damage} {damage.Type}", fontWeightProvider.Value.Bold, colorProvider.Value.GetColorByKey(damage.Type.ToString())); console.Value.AddEntry($"{(i == _command.DamageList.Count ? " damage" : " damage, ")}"); i += 1; } console.Value.AddEntry("\r\n"); TakeDamageCommand inner_command = new TakeDamageCommand(target, total); base._mediator.Value.Execute(inner_command); _command.AddToInnerCommands(inner_command); return(new ApplyDamageResultListResponse(total)); }
public void EmptyTemp() { _character.TempHp = 10; TakeDamageCommand command = new TakeDamageCommand(_character, 10); _mediator.Execute(command); Assert.AreEqual(50, _character.Hp); Assert.AreEqual(0, _character.TempHp); _mediator.Undo(command); Assert.AreEqual(50, _character.Hp); Assert.AreEqual(10, _character.TempHp); }
public void KoOverflow() { _character.TempHp = 0; TakeDamageCommand command = new TakeDamageCommand(_character, 60); _mediator.Execute(command); Assert.AreEqual(0, _character.Hp); Assert.AreEqual(0, _character.TempHp); _mediator.Undo(command); Assert.AreEqual(50, _character.Hp); Assert.AreEqual(0, _character.TempHp); }