public override void Execute(IUnitImpactBuff data) { var contextImpact = _context.ContextImpact; var value = (int)_logic.Calculate(data.Value); var member = _battle.GetMember(_context.ContextImpact.CurrentTarget); if (!member.Buffs.TryGetValue(data.BuffId, out var buffData)) { if (value < 0) { return; } var buff = _battle.Static.Buffs[data.BuffId]; _impact.ExecuteImpact(buff.ImpactInit); buffData = _battle.Factory.CreateBuff(contextImpact.OwnerId, false); if (contextImpact.OwnerId == contextImpact.CurrentTarget && (_context.TurnType == BattleTurnResultType.ActiveAbility || _context.TurnType == BattleTurnResultType.StartTurn)) { buffData.NeededRemove = true; } _buffs.ChangeBuff(member, buffData, data.BuffId, value); member.Buffs[data.BuffId] = buffData; } else { if (!_buffs.ChangeBuff(member, buffData, data.BuffId, value)) { _impact.ExecuteImpact(_battle.Static.Buffs[data.BuffId].ImpactTakeOff); } } }
public override void Execute(IUnitImpactBuffType data) { var targetId = _context.ContextImpact.CurrentTarget; var member = _battle.GetMember(targetId); if (member == null) { Logger.Error($"No member in battle CurrentTarget = {targetId} ", this); return; } var buffs = member.Buffs //.Where(x => _battle.Static.Buffs[x.Key].BuffType.Values.Contains(data.BuffTypeId)) .Select(x => x.Key).ToArray(); var value = (int)_logic.Calculate(data.Value); foreach (var id in buffs) { var buffTypeValues = _battle.Static.Buffs[id].BuffType.Values; var contains = false; foreach (var buffType in buffTypeValues) { if (data.BuffTypeIds.Values.Contains(buffType)) { contains = true; break; } } if (contains) { if (!_buffs.ChangeBuff(member, member.Buffs[id], id, value)) { _impacts.ExecuteImpact(_battle.Static.Buffs[id].ImpactTakeOff); } } } }