public async Task <bool> CheckCD(long unitId, int spellId, IVolatileContext volatileContext) { if (await volatileContext.Cooldowns.AnyAsync(c => c.UnitId == unitId && c.SpellId == spellId)) { return(false); } return(true); }
public async Task SetCD(long unitId, double cooldownDuration, int spellId, IVolatileContext volatileContext) { volatileContext.Cooldowns.Add(new Cooldown { UnitId = unitId, SpellId = spellId, EndsOn = DateTime.UtcNow.AddSeconds(cooldownDuration), }); await volatileContext.SaveChangesAsync(CancellationToken.None); }
public async Task SetDuration(long unitId, double effectDuration, double effectPower, string effectType, IVolatileContext volatileContext, IPawContext context) { volatileContext.Durations.Add(new Duration { UnitId = unitId, EffectType = effectType, EffectPower = effectPower, EndsOn = DateTime.UtcNow.AddSeconds(effectDuration), }); await this.BuffHandler(unitId, effectType, effectPower, "+", context); await volatileContext.SaveChangesAsync(CancellationToken.None); await context.SaveChangesAsync(CancellationToken.None); }
public VolatileHandler(IVolatileContext volatileContext, IPawContext context) { this.volatileContext = volatileContext; this.context = context; }
/// <summary> /// Initializes a new volatile instance. /// </summary> /// <param name="context">Volatile context.</param> public Volatile(IVolatileContext context) { _context = context; }