示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
 public VolatileHandler(IVolatileContext volatileContext, IPawContext context)
 {
     this.volatileContext = volatileContext;
     this.context         = context;
 }
示例#5
0
 /// <summary>
 /// Initializes a new volatile instance.
 /// </summary>
 /// <param name="context">Volatile context.</param>
 public Volatile(IVolatileContext context)
 {
     _context = context;
 }