public override AddressStateMap Execute(Address from, Address to, AddressStateMap states) { var result = new BattleResult(); if (states.TryGetValue(to, out object value)) { var previousResult = (BattleResult)value; result.UsedWeapons = previousResult.UsedWeapons; result.Targets = previousResult.Targets; } result.UsedWeapons.Add(Weapon); result.Targets.Add(Target); return((AddressStateMap)states.SetItem(to, result)); }
public override AddressStateMap Execute(IActionContext context) { var result = new BattleResult(); AddressStateMap previousStates = context.PreviousStates; Address to = context.To; if (previousStates.TryGetValue(to, out object value)) { var previousResult = (BattleResult)value; result.UsedWeapons = previousResult.UsedWeapons; result.Targets = previousResult.Targets; } result.UsedWeapons.Add(Weapon); result.Targets.Add(Target); return((AddressStateMap)previousStates.SetItem(to, result)); }