Exemple #1
0
        public async Task <ActionResult> Edit(LootModel lootModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(lootModel));
                }
                var email = User?.Claims.First(c => c.Type == Email).Value;

                HttpResponseMessage response = await _httpClient.GetAsync(_url + "/account/" + email);

                if (!response.IsSuccessStatusCode)
                {
                    return(View("Error", new ErrorViewModel()));
                }
                PlayerModel player = await response.Content.ReadAsAsync <PlayerModel>();


                response = await _httpClient.PostAsJsonAsync(_url + "/Loot/" + player.PlayerId, lootModel);

                if (!response.IsSuccessStatusCode)
                {
                    return(View("Error", new ErrorViewModel()));
                }
                var x = await response.Content.ReadAsAsync <IEnumerable <ActionResult> >();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
 public static Loot Map(LootModel loot) => new Loot
 {
     LootId      = loot.LootId,
     Name        = loot.Name,
     Price       = loot.Price,
     Description = loot.Description,
 };
Exemple #3
0
        public async Task <ActionResult> Delete(int id, LootModel lootModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(lootModel));
                }
                var email = User?.Claims.First(c => c.Type == Email).Value;

                HttpResponseMessage response = await _httpClient.DeleteAsync(_url + "/DeleteLoot/" + id);

                if (!response.IsSuccessStatusCode)
                {
                    return(View("Error", new ErrorViewModel()));
                }
                var x = await response.Content.ReadAsAsync <IEnumerable <ActionResult> >();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
        public async Task <ActionResult> StoreIndex(StoreModel Store, LootModel item, PlayerModel Player)
        {
            var email = User?.Claims.First(c => c.Type == Email).Value ?? "fortest";

            HttpResponseMessage response = await _httpClient.GetAsync(_url + "/player/account/" + email);

            if (!response.IsSuccessStatusCode)
            {
                return(View("Error", new ErrorViewModel()));
            }
            PlayerModel player = await response.Content.ReadAsAsync <PlayerModel>();

            int bonus = Store.Flavors.Where(f => f.FlavorId == item.Flavor.FlavorId).Select(f => f.Bonus).FirstOrDefault();

            player.Gold += item.Price * bonus * item.Quantity;

            response = await _httpClient.PutAsJsonAsync(_url + "/player/" + player.PlayerId, player);

            if (!response.IsSuccessStatusCode)
            {
                return(View("Error", new ErrorViewModel()));
            }
            var x = await response.Content.ReadAsAsync <IEnumerable <ActionResult> >();

            response = await _httpClient.DeleteAsync(_url + "/player/DeleteLoot/" + item.PlayerLootId);

            if (!response.IsSuccessStatusCode)
            {
                return(View("Error", new ErrorViewModel()));
            }
            var y = await response.Content.ReadAsAsync <IEnumerable <ActionResult> >();

            return(RedirectToAction(nameof(StoreIndex), new { StoreId = Store.StoreId.ToString() }));
        }
        public void LootModel()
        {
            var model  = new LootModel();
            var model2 = Mapper.Map(model);
            var model3 = Mapper.Map(model2);

            Assert.IsAssignableFrom(model.GetType(), model3);
        }
Exemple #6
0
 public LootModel GetLoot(int id)
 {
     if (!_lootMap.TryGetValue(id, out var item))
     {
         var serializable = _content.GetLoot(id);
         item = new LootModel(serializable, this);
         _lootMap.Add(id, item);
     }
     return(item);
 }
Exemple #7
0
    private void Awake()
    {
        if (instance != null)
        {
            Debug.LogWarning("More than one instance of Lootsystem !");
        }

        instance     = this;
        waitingItems = new List <List <Item> >();
    }
        public async Task <ActionResult> NewLoot(int id, LootModel lootModel)
        {
            var loot = await PlayerRepo.AddPlayerLoot(lootModel, id);

            if (loot == false)
            {
                return(NotFound());
            }
            _logger.Info($"Updated {lootModel.Name} for player {id}");
            return(NoContent());
        }
 public ActionResult Edit(int id, LootModel smodel)
 {
     try
     {
         LootDBHandle ldb = new LootDBHandle();
         ldb.UpdateRecord(smodel);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemple #10
0
    private LootSlot[] _slots; // inventory slots pełnią funkcije widoku


    void Start()
    {
        _lootModel = LootModel.instance;
        _lootModel.onLootItemChangedCallback += UpdateUI;
        _lootModel.onLootItemChangedCallback += ActiveUI;

        _inventoryController = InventoryController.instance;
        _slots = _lootModel.itemsParent.GetComponentsInChildren <LootSlot>();

        _questLogController = QuestLogController.instance;
        _notification       = Notification.instance;

        _lootModel.lootUI.SetActive(false);
    }
 public async Task <ActionResult> PutLoots(int id, [FromBody] LootModel lootModel)
 {
     if (id == lootModel.LootId && !(await lootRepo.GetLootById(id) is null))
     {
         if (await lootRepo.EditLoot(lootModel))
         {
             _logger.Info($"Edited Loot {id}");
             return(NoContent());
         }
         else
         {
             return(BadRequest());
         }
     }
        public async Task <IActionResult> PostLoots([FromBody] LootModel lootModel)
        {
            int id;

            try
            {
                id = await lootRepo.AddLoot(lootModel);

                _logger.Info($"Adding new Loot at {id}");
                return(CreatedAtRoute("GetLoots", new { Id = id }, GetLoots(id))); // 201 Created
            }
            catch (ArgumentException ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public async Task <ActionResult> Edit(LootModel item)
        {
            try
            {
                HttpResponseMessage response = await _httpClient.PutAsJsonAsync(_url + "/loot/" + item.LootId, item);

                if (!response.IsSuccessStatusCode)
                {
                    return(View("Error", new ErrorViewModel()));
                }
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Exemple #14
0
            public LootModel GetLoot(ItemId <LootModel> id, bool notNull = false)
            {
                if (_database._lootMap.TryGetValue(id.Value, out var item))
                {
                    return(item);
                }
                var serializable = _content.GetLoot(id.Value);

                if (serializable != null && !serializable.Disabled)
                {
                    return(LootModel.Create(serializable, this));
                }

                var value = LootModel.DefaultValue;

                if (notNull && value == null)
                {
                    throw new DatabaseException("Data not found " + id);
                }
                return(value);
            }
        public ActionResult Create(LootModel smodel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    LootDBHandle ldb = new LootDBHandle();
                    if (ldb.AddRecord(smodel))
                    {
                        ViewBag.Message = "Loot Record Added Successfully";
                        ModelState.Clear();
                    }
                }

                return(View());
            }
            catch
            {
                return(View());
            }
        }
        public async Task <ActionResult> EditLoot(LootModel lootModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(lootModel));
                }
                HttpResponseMessage response = await _httpClient.PutAsJsonAsync(_url + "/Location/Loot/", lootModel);

                if (!response.IsSuccessStatusCode)
                {
                    return(View("Error", new ErrorViewModel()));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Exemple #17
0
        public void GreedyThief()
        {
            var thief = new GreedyThief();

            var LootOne = new LootModel(3, 50, new List <Loot>()
            {
                new Loot(60, 20),
                new Loot(100, 50),
                new Loot(120, 30)
            });

            var GreedyLootOne = thief.GetLoot(LootOne);

            var LootSecond = new LootModel(1, 10, new List <Loot>()
            {
                new Loot(500, 30)
            });

            var GreedyLootSecond = thief.GetLoot(LootSecond);

            Assert.IsTrue(GreedyLootOne == 180 && GreedyLootSecond == (decimal)166.6667);
        }
Exemple #18
0
 public LootViewModel(IView view, LootModel model) :
     base(view, model)
 {
     Model = model;
     Model.SetViewModel(this);
 }
        public void Models()
        {
            AccountModel a = new AccountModel()
            {
                AccountId = 1, IsAdmin = true, Password = "******", PlayerId = 1, Username = ""
            };
            EquipmentModel b = new EquipmentModel()
            {
                Difficulty = 1, EquipmentId = 1, Modifier = 1, Name = "", PlayerEquipmentId = 1, Price = 1, Type = ""
            };
            FlavorModel c = new FlavorModel()
            {
                Bonus = 1, Name = "", Description = "", FlavorId = 1
            };
            FlavorLootModel d = new FlavorLootModel()
            {
                FlavorId = 1, FlavorLootId = 1, LootId = 1
            };
            LocationLootModel e = new LocationLootModel()
            {
                DropRate = 1, LocationId = 1, LocationLootId = 1, LootId = 1
            };
            LocationModel f = new LocationModel()
            {
                Description = "", Difficulty = 1, LocationId = 1, Loot = null, Name = ""
            };
            LootModel g = new LootModel()
            {
                Description = "", DropRate = 1, Flavor = new FlavorModel(), FlavorLootId = 1, LocationLootId = 1, LootId = 1, Name = "", PlayerLootId = 1, Price = 1, Quantity = 1
            };
            PlayerEquipmentModel pe = new PlayerEquipmentModel()
            {
                EquipmentId = 1, PlayerEquipmentId = 1, PlayerId = 1
            };
            PlayerLocationModel pl = new PlayerLocationModel()
            {
                LocationId = 1, PlayerId = 1, PlayerLocationId = 1
            };
            PlayerLootModel plm = new PlayerLootModel()
            {
                LootId = 1, PlayerId = 1, PlayerLootId = 1, Quantity = 1
            };
            PlayerModel pm = new PlayerModel()
            {
                Gold = 1, Name = "", PlayerId = 1
            };
            RecipeLootModel rl = new RecipeLootModel()
            {
                LootId = 1, RecipeLootId = 1, RecipeId = 1
            };
            RecipeModel r = new RecipeModel()
            {
                Description = "", Name = "", RecipeId = 1
            };
            StoreEquipmentModel se = new StoreEquipmentModel()
            {
                EquipmentId = 1, StoreEquipmentId = 1, StoreId = 1
            };
            StoreFlavorModel sf = new StoreFlavorModel()
            {
                Bonus = 1, FlavorId = 1, StoreFlavorId = 1, StoreId = 1
            };
            StoreModel s = new StoreModel()
            {
                Description = "", Difficulty = 1, Flavors = null, Name = "", StoreId = 1
            };



            ErrorViewModel    ev = new ErrorViewModel();
            LocationViewModel lv = new LocationViewModel();
            PlayerViewModel   pv = new PlayerViewModel();
            StoreViewModel    sv = new StoreViewModel()
            {
                CurrentVoucher = null, HighestVoucher = 1, InStock = null, Loot = null, NextVoucher = null, Player = null, PlayerEquipment = null, Store = null, StoreId = 1, storeModels = null, Vouchers = null
            };

            MyConfiguration my = new MyConfiguration();

            Assert.NotNull(my);
            Assert.NotNull(ev);
            Assert.NotNull(lv);
            Assert.NotNull(pv);
            Assert.NotNull(sv);
            Assert.NotNull(a);
            Assert.NotNull(s);
            Assert.NotNull(sf);
            Assert.NotNull(se);
            Assert.NotNull(r);
            Assert.NotNull(rl);
            Assert.NotNull(pm);
            Assert.NotNull(plm);
            Assert.NotNull(pl);
            Assert.NotNull(b);
            Assert.NotNull(c);
            Assert.NotNull(d);
            Assert.NotNull(e);
            Assert.NotNull(f);
            Assert.NotNull(g);
            Assert.NotNull(pe);
        }
Exemple #20
0
            public void Load()
            {
                foreach (var item in _content.AmmunitionObsoleteList)
                {
                    if (!item.Disabled && !_database._ammunitionObsoleteMap.ContainsKey(item.Id))
                    {
                        AmmunitionObsolete.Create(item, this);
                    }
                }
                foreach (var item in _content.ComponentList)
                {
                    if (!item.Disabled && !_database._componentMap.ContainsKey(item.Id))
                    {
                        Component.Create(item, this);
                    }
                }
                foreach (var item in _content.ComponentModList)
                {
                    if (!item.Disabled && !_database._componentModMap.ContainsKey(item.Id))
                    {
                        ComponentMod.Create(item, this);
                    }
                }
                foreach (var item in _content.ComponentStatsList)
                {
                    if (!item.Disabled && !_database._componentStatsMap.ContainsKey(item.Id))
                    {
                        ComponentStats.Create(item, this);
                    }
                }
                foreach (var item in _content.DeviceList)
                {
                    if (!item.Disabled && !_database._deviceMap.ContainsKey(item.Id))
                    {
                        Device.Create(item, this);
                    }
                }
                foreach (var item in _content.DroneBayList)
                {
                    if (!item.Disabled && !_database._droneBayMap.ContainsKey(item.Id))
                    {
                        DroneBay.Create(item, this);
                    }
                }
                foreach (var item in _content.FactionList)
                {
                    if (!item.Disabled && !_database._factionMap.ContainsKey(item.Id))
                    {
                        Faction.Create(item, this);
                    }
                }
                foreach (var item in _content.SatelliteList)
                {
                    if (!item.Disabled && !_database._satelliteMap.ContainsKey(item.Id))
                    {
                        Satellite.Create(item, this);
                    }
                }
                foreach (var item in _content.SatelliteBuildList)
                {
                    if (!item.Disabled && !_database._satelliteBuildMap.ContainsKey(item.Id))
                    {
                        SatelliteBuild.Create(item, this);
                    }
                }
                foreach (var item in _content.ShipList)
                {
                    if (!item.Disabled && !_database._shipMap.ContainsKey(item.Id))
                    {
                        Ship.Create(item, this);
                    }
                }
                foreach (var item in _content.ShipBuildList)
                {
                    if (!item.Disabled && !_database._shipBuildMap.ContainsKey(item.Id))
                    {
                        ShipBuild.Create(item, this);
                    }
                }
                foreach (var item in _content.SkillList)
                {
                    if (!item.Disabled && !_database._skillMap.ContainsKey(item.Id))
                    {
                        Skill.Create(item, this);
                    }
                }
                foreach (var item in _content.TechnologyList)
                {
                    if (!item.Disabled && !_database._technologyMap.ContainsKey(item.Id))
                    {
                        Technology.Create(item, this);
                    }
                }
                foreach (var item in _content.CharacterList)
                {
                    if (!item.Disabled && !_database._characterMap.ContainsKey(item.Id))
                    {
                        Character.Create(item, this);
                    }
                }
                foreach (var item in _content.FleetList)
                {
                    if (!item.Disabled && !_database._fleetMap.ContainsKey(item.Id))
                    {
                        Fleet.Create(item, this);
                    }
                }
                foreach (var item in _content.LootList)
                {
                    if (!item.Disabled && !_database._lootMap.ContainsKey(item.Id))
                    {
                        LootModel.Create(item, this);
                    }
                }
                foreach (var item in _content.QuestList)
                {
                    if (!item.Disabled && !_database._questMap.ContainsKey(item.Id))
                    {
                        QuestModel.Create(item, this);
                    }
                }
                foreach (var item in _content.QuestItemList)
                {
                    if (!item.Disabled && !_database._questItemMap.ContainsKey(item.Id))
                    {
                        QuestItem.Create(item, this);
                    }
                }
                foreach (var item in _content.AmmunitionList)
                {
                    if (!item.Disabled && !_database._ammunitionMap.ContainsKey(item.Id))
                    {
                        Ammunition.Create(item, this);
                    }
                }
                foreach (var item in _content.BulletPrefabList)
                {
                    if (!item.Disabled && !_database._bulletPrefabMap.ContainsKey(item.Id))
                    {
                        BulletPrefab.Create(item, this);
                    }
                }
                foreach (var item in _content.VisualEffectList)
                {
                    if (!item.Disabled && !_database._visualEffectMap.ContainsKey(item.Id))
                    {
                        VisualEffect.Create(item, this);
                    }
                }
                foreach (var item in _content.WeaponList)
                {
                    if (!item.Disabled && !_database._weaponMap.ContainsKey(item.Id))
                    {
                        Weapon.Create(item, this);
                    }
                }

                foreach (var item in _content.Images)
                {
                    if (!_database._images.ContainsKey(item.Key))
                    {
                        _database._images.Add(item.Key, item.Value);
                    }
                }

                foreach (var item in _content.AudioClips)
                {
                    if (!_database._audioClips.ContainsKey(item.Key))
                    {
                        _database._audioClips.Add(item.Key, item.Value);
                    }
                }

                foreach (var item in _content.Localizations)
                {
                    if (!_database._localizations.ContainsKey(item.Key))
                    {
                        _database._localizations.Add(item.Key, item.Value);
                    }
                }

                if (_database.DatabaseSettings == null)
                {
                    _database.DatabaseSettings = DatabaseSettings.Create(_content.DatabaseSettings ?? new Serializable.DatabaseSettingsSerializable {
                        ItemType = Enums.ItemType.DatabaseSettings
                    }, this);
                }
                if (_database.ExplorationSettings == null)
                {
                    _database.ExplorationSettings = ExplorationSettings.Create(_content.ExplorationSettings ?? new Serializable.ExplorationSettingsSerializable {
                        ItemType = Enums.ItemType.ExplorationSettings
                    }, this);
                }
                if (_database.GalaxySettings == null)
                {
                    _database.GalaxySettings = GalaxySettings.Create(_content.GalaxySettings ?? new Serializable.GalaxySettingsSerializable {
                        ItemType = Enums.ItemType.GalaxySettings
                    }, this);
                }
                if (_database.ShipSettings == null)
                {
                    _database.ShipSettings = ShipSettings.Create(_content.ShipSettings ?? new Serializable.ShipSettingsSerializable {
                        ItemType = Enums.ItemType.ShipSettings
                    }, this);
                }
            }
Exemple #21
0
 public void AddLoot(int id, LootModel item)
 {
     _database._lootMap.Add(id, item);
 }