Exemplo n.º 1
0
        /// <summary>
        /// Removes a buff by various means.
        /// </summary>
        /// <param name="type">Type of removal.</param>
        /// <param name="buff">Buff to remove.</param>
        public void RemoveBuff(RemovalType type, Buff buff)
        {
            switch (type)
            {
            case RemovalType.TIMED_OUT:
                buff.OnTimeOut(ownerStats);
                break;

            case RemovalType.DISPEL:
                buff.OnDispell(ownerStats);
                break;

            default:
                Util.Assert(false, "Unknown removal type: " + type);
                break;
            }

            // Remove if possible
            if (buff.IsDispellable || type == RemovalType.TIMED_OUT)
            {
                foreach (KeyValuePair <StatType, int> statBonus in buff)
                {
                    int amountToRecover = -statBonus.Value;
                    AddStatBonus(statBonus.Key, amountToRecover);
                    AddSplat(new SplatDetails(statBonus.Key, amountToRecover, "%"));
                }
                set.Remove(buff);
                AddSplat(new SplatDetails(Color.red, string.Format("-"), buff.Sprite));
            }
        }
        public async Task <Car> GetCarByEntityType(int id, RemovalType removalType)
        {
            switch (removalType)
            {
            case RemovalType.Manufacturer:
                return(await Context.Set <Car>().FirstOrDefaultAsync(x => x.ManufacturerId == id));

            case RemovalType.Typ:
                return(await Context.Set <Car>().FirstOrDefaultAsync(x => x.TypId == id));

            case RemovalType.Fuel:
                return(await Context.Set <Car>().FirstOrDefaultAsync(x => x.CarSpec.FuelId == id));

            case RemovalType.EngineOil:
                return(await Context.Set <Car>().FirstOrDefaultAsync(x => x.CarSpec.EngineOilId == id));

            case RemovalType.GearOil:
                return(await Context.Set <Car>().FirstOrDefaultAsync(x => x.CarSpec.GearOilId == id));

            case RemovalType.User:
                return(await Context.Set <Car>().FirstOrDefaultAsync(x => x.CarBusiness.UserId.HasValue && x.CarBusiness.UserId.Value == id));
            }
            ;

            return(null);
        }
        public async Task Remove(int id, RemovalType removalType)
        {
            var repository = DataContextManager.CreateRepository <ICommonRepository <TEntity> >();

            var entity = await repository.GetById(id);

            if (entity == null)
            {
                throw new ObjectNotFoundException();
            }

            var carRepository = DataContextManager.CreateRepository <ICarRepository>();

            var car = await carRepository.GetCarByEntityType(entity.Id, removalType);

            if (car != null)
            {
                throw new RemovingException();
            }

            await repository.Remove(entity.Id);
        }
Exemplo n.º 4
0
        private JsonObject Removed()
        {
            JsonArray cards = new JsonArray();
            JsonArray notes = new JsonArray();
            JsonArray decks = new JsonArray();
            var       list  = collection.Database.QueryColumn <graves>("SELECT oid, type FROM graves WHERE usn"
                                                                       + (collection.IsServer ? (" >= " + minUsn) : (" = -1")));

            foreach (var g in list)
            {
                RemovalType type = (RemovalType)g.Type;
                switch (type)
                {
                case RemovalType.CARD:
                    cards.Add(JsonValue.CreateNumberValue(g.Oid));
                    break;

                case RemovalType.NOTE:
                    notes.Add(JsonValue.CreateNumberValue(g.Oid));
                    break;

                case RemovalType.DECK:
                    decks.Add(JsonValue.CreateNumberValue(g.Oid));
                    break;
                }
            }
            if (!collection.IsServer)
            {
                collection.Database.Execute("UPDATE graves SET usn=" + maxUsn + " WHERE usn=-1");
            }
            JsonObject o = new JsonObject();

            o.Add("cards", cards);
            o.Add("notes", notes);
            o.Add("decks", decks);
            return(o);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Removes a buff by various means.
        /// </summary>
        /// <param name="type">Type of removal.</param>
        /// <param name="buff">Buff to remove.</param>
        public void RemoveBuff(RemovalType type, Buff buff)
        {
            switch (type)
            {
            case RemovalType.TIMED_OUT:
                buff.OnTimeOut(Stats);
                break;

            case RemovalType.DISPEL:
                buff.OnDispell(Stats);
                break;

            default:
                Util.Assert(false, "Unknown removal type: " + type);
                break;
            }

            // Remove if possible
            if (buff.IsDispellable || type == RemovalType.TIMED_OUT)
            {
                set.Remove(buff);
                AddSplat(new SplatDetails(Color.red, string.Format("-"), buff.Sprite));
            }
        }
Exemplo n.º 6
0
 // Call CheckIfExposed(true) on any surrounding block;
 void RemoveBlock(RemovalType removalType)
 {
 }