public ShopEffectGroup(ShopEffectGroupDto dto) { Id = dto.Id; Name = dto.Name; Effects = dto.ShopEffects.Select(e => new ShopEffect(e)).ToList(); MainEffect = dto.Effect; }
private static void FillShop() { if (!Config.Instance.NoobMode) { return; } using (var db = GameDatabase.Open()) { if (!db.Find <ShopVersionDto>().Any()) { var version = new ShopVersionDto { Version = DateTimeOffset.UtcNow.ToString("yyyyMMddHHmmss") }; db.Insert(version); } if (db.Find <ShopEffectGroupDto>().Any() || db.Find <ShopEffectDto>().Any() || db.Find <ShopPriceGroupDto>().Any() || db.Find <ShopPriceDto>().Any() || db.Find <ShopItemDto>().Any() || db.Find <ShopItemInfoDto>().Any()) { return; } Log.Information("NoobMode: Filling the shop with items"); using (var transaction = db.BeginTransaction()) { var effects = new Dictionary <string, Tuple <uint[], uint> > // effectids, groupid/effect { { "None", Tuple.Create(Array.Empty <uint>(), (uint)0) }, { "Shooting Weapon Defense (Head) +5%", Tuple.Create(new uint[] { 1100313003, 1100315003, 1100317003 }, (uint)1100315002) }, { "SP+6", Tuple.Create(new uint[] { 1101301006 }, (uint)1101301006) }, { "Attack+1%", Tuple.Create(new uint[] { 1102303001 }, (uint)1102303001) }, { "Attack+5%", Tuple.Create(new uint[] { 1102303003 }, (uint)1102303003) }, { "Attack+10%", Tuple.Create(new uint[] { 1299600006 }, (uint)1299600006) }, { "Defense+5%", Tuple.Create(new uint[] { 1103302004 }, (uint)1103302004) }, { "HP+4", Tuple.Create(new uint[] { 1105300004 }, (uint)1105300004) }, { "HP+30", Tuple.Create(new uint[] { 1999300011 }, (uint)1999300011) }, { "HP+15", Tuple.Create(new uint[] { 1999300009 }, (uint)1999300009) }, { "SP+40", Tuple.Create(new uint[] { 1300301012 }, (uint)1300301012) }, { "HP+20 & SP+20", Tuple.Create(new uint[] { 1999300010, 1999301011 }, (uint)30001) }, { "HP+25 & SP+25", Tuple.Create(new uint[] { 1999300012, 1999301013 }, (uint)30003) } }; #region Effects foreach (var pair in effects.ToArray()) { var effectGroup = new ShopEffectGroupDto { Name = pair.Key, Effect = pair.Value.Item2 }; db.Insert(effectGroup, statement => statement.AttachToTransaction(transaction)); effects[pair.Key] = Tuple.Create(pair.Value.Item1, (uint)effectGroup.Id); foreach (var effect in pair.Value.Item1) { db.Insert(new ShopEffectDto { EffectGroupId = effectGroup.Id, Effect = effect }, statement => statement.AttachToTransaction(transaction)); } } #endregion #region Price var priceGroup = new ShopPriceGroupDto { Name = "PEN", PriceType = (byte)ItemPriceType.PEN }; var priceGroup2 = new ShopPriceGroupDto { Name = "Item", PriceType = (byte)ItemPriceType.Premium }; db.Insert(priceGroup); db.Insert(priceGroup2); var price_none_perm = new ShopPriceDto { PriceGroupId = priceGroup.Id, PeriodType = (byte)ItemPeriodType.None, IsRefundable = true, Durability = 2400, IsEnabled = true, Price = 1 }; var price_unit_one = new ShopPriceDto { PriceGroupId = priceGroup2.Id, Durability = 1, PeriodType = (byte)ItemPeriodType.Units, IsRefundable = true, Period = 1, IsEnabled = true, Price = 1000 }; var price_unit_two = new ShopPriceDto { PriceGroupId = priceGroup2.Id, Durability = 1, PeriodType = (byte)ItemPeriodType.Units, IsRefundable = true, Period = 2, IsEnabled = true, Price = 2000 }; var price_unit_five = new ShopPriceDto { PriceGroupId = priceGroup2.Id, Durability = 1, PeriodType = (byte)ItemPeriodType.Units, IsRefundable = true, Period = 5, IsEnabled = true, Price = 4500 }; var price_unit_ten = new ShopPriceDto { PriceGroupId = priceGroup2.Id, Durability = 1, PeriodType = (byte)ItemPeriodType.Units, IsRefundable = true, Period = 10, IsEnabled = true, Price = 8000 }; db.Insert(price_none_perm); db.Insert(price_unit_one); db.Insert(price_unit_two); db.Insert(price_unit_five); db.Insert(price_unit_ten); #endregion #region Items var items = GameServer.Instance.ResourceCache.GetItems().Values.ToArray(); Log.Information("{count} items cargados", items.Count()); for (var i = 0; i < items.Length; ++i) { var item = items[i]; var effectToUse = effects["None"]; byte mainTab = 0; byte subTab = 0; switch (item.ItemNumber.Category) { case ItemCategory.Card: case ItemCategory.Coupon: mainTab = 4; subTab = 6; break; case ItemCategory.EsperChip: mainTab = 4; subTab = 2; break; case ItemCategory.Boost: switch ((BoostCategory)item.ItemNumber.SubCategory) { case BoostCategory.Pen: mainTab = 4; subTab = 4; break; case BoostCategory.Exp: mainTab = 4; subTab = 5; break; case BoostCategory.Mp: mainTab = 4; subTab = 3; break; case BoostCategory.Unique: mainTab = 4; subTab = 5; break; } break; case ItemCategory.OneTimeUse: switch ((OneTimeUseCategory)item.ItemNumber.SubCategory) { case OneTimeUseCategory.Namechange: mainTab = 4; subTab = 0; break; case OneTimeUseCategory.Stat: mainTab = 4; subTab = 0; break; case OneTimeUseCategory.Capsule: //clothes+weps mainTab = 1; subTab = 0; break; case OneTimeUseCategory.FumbiCapsule: mainTab = 1; subTab = 4; break; case OneTimeUseCategory.Event: mainTab = 4; subTab = 0; break; default: continue; } break; case ItemCategory.Weapon: effectToUse = effects["Attack+1%"]; mainTab = 2; switch ((WeaponCategory)item.ItemNumber.SubCategory) { case WeaponCategory.Melee: subTab = 1; break; case WeaponCategory.RifleGun: subTab = 2; break; case WeaponCategory.HeavyGun: subTab = 4; break; case WeaponCategory.Sniper: subTab = 5; break; case WeaponCategory.Sentry: subTab = 6; break; case WeaponCategory.Bomb: subTab = 7; break; case WeaponCategory.Mind: subTab = 6; break; } break; case ItemCategory.Skill: mainTab = 2; subTab = 8; if (item.ItemNumber.SubCategory == 0 && item.ItemNumber.Number == 0) // half hp mastery { effectToUse = effects["HP+15"]; } if (item.ItemNumber.SubCategory == 0 && item.ItemNumber.Number == 1) // hp mastery { effectToUse = effects["HP+30"]; } if (item.ItemNumber.SubCategory == 0 && item.ItemNumber.Number == 2) // sp mastery { effectToUse = effects["SP+40"]; } if (item.ItemNumber.SubCategory == 0 && item.ItemNumber.Number == 3) // dual mastery { effectToUse = effects["HP+20 & SP+20"]; } if (item.ItemNumber.SubCategory == 0 && item.ItemNumber.Number == 5 ) // dual mastery - returner { effectToUse = effects["HP+20 & SP+20"]; } if (item.ItemNumber.SubCategory == 0 && item.ItemNumber.Number == 7 ) // unique dual mastery - balanced! { effectToUse = effects["HP+25 & SP+25"]; } break; case ItemCategory.Costume: mainTab = 3; subTab = (byte)(item.ItemNumber.SubCategory + 2); switch ((CostumeSlot)item.ItemNumber.SubCategory) { case CostumeSlot.Hair: effectToUse = effects["Shooting Weapon Defense (Head) +5%"]; break; case CostumeSlot.Face: effectToUse = effects["SP+6"]; break; case CostumeSlot.Shirt: effectToUse = effects["Attack+5%"]; break; case CostumeSlot.Pants: effectToUse = effects["Defense+5%"]; break; case CostumeSlot.Gloves: effectToUse = effects["HP+4"]; break; case CostumeSlot.Shoes: effectToUse = effects["HP+4"]; break; case CostumeSlot.Accessory: effectToUse = effects["SP+6"]; break; case CostumeSlot.Pet: effectToUse = effects["SP+6"]; break; } break; default: effectToUse = effects["None"]; mainTab = 4; subTab = 6; break; } var shopItem = new ShopItemDto { Id = item.ItemNumber, RequiredGender = (byte)item.Gender, RequiredLicense = (byte)item.License, IsDestroyable = true, MainTab = mainTab, SubTab = subTab, Colors = (byte)item.Colors }; db.Insert(shopItem, statement => statement.AttachToTransaction(transaction)); var shopItemInfo = new ShopItemInfoDto { ShopItemId = shopItem.Id, PriceGroupId = priceGroup.Id, EffectGroupId = (int)effectToUse.Item2, IsEnabled = true }; var shopItemInfo_onetimeuse = new ShopItemInfoDto { ShopItemId = shopItem.Id, PriceGroupId = priceGroup2.Id, EffectGroupId = (int)effectToUse.Item2, IsEnabled = true }; if (item.ItemNumber.Category == ItemCategory.Costume || item.ItemNumber.Category == ItemCategory.Weapon || item.ItemNumber.Category == ItemCategory.Skill || item.ItemNumber.Category == ItemCategory.EsperChip) { db.Insert(shopItemInfo, statement => statement.AttachToTransaction(transaction)); } else { db.Insert(shopItemInfo_onetimeuse, statement => statement.AttachToTransaction(transaction)); } Log.Information($"[{i}/{items.Length}] {item.ItemNumber}: {item.Name} | Colors: {item.Colors}"); } #endregion try { transaction.Commit(); } catch { transaction.Rollback(); throw; } } } }
private static void FillShop() { if (!Config.Instance.NoobMode) { return; } using (var db = GameDatabase.Open()) { if (!db.Find <ShopVersionDto>().Any()) { var version = new ShopVersionDto { Version = DateTimeOffset.UtcNow.ToString("yyyyMMddHHmmss") }; db.Insert(version); } if (db.Find <ShopEffectGroupDto>().Any() || db.Find <ShopEffectDto>().Any() || db.Find <ShopPriceGroupDto>().Any() || db.Find <ShopPriceDto>().Any() || db.Find <ShopItemDto>().Any() || db.Find <ShopItemInfoDto>().Any()) { return; } Log.Information("NoobMode: Filling the shop with items"); using (var transaction = db.BeginTransaction()) { var effects = new Dictionary <string, Tuple <uint[], int> > { { "None", Tuple.Create(Array.Empty <uint>(), 0) }, { "HP+30", Tuple.Create(new uint[] { 1030 }, 0) }, { "HP+15", Tuple.Create(new uint[] { 1015 }, 0) }, { "SP+40", Tuple.Create(new uint[] { 2040 }, 0) }, { "HP+20 & SP+20", Tuple.Create(new uint[] { 4001 }, 0) }, { "SP+3", Tuple.Create(new uint[] { 2003 }, 0) }, { "Defense+7", Tuple.Create(new uint[] { 19907 }, 0) }, { "HP+3", Tuple.Create(new uint[] { 1003 }, 0) } }; #region Effects foreach (var pair in effects.ToArray()) { var effectGroup = new ShopEffectGroupDto { Name = pair.Key }; db.Insert(effectGroup, statement => statement.AttachToTransaction(transaction)); effects[pair.Key] = Tuple.Create(pair.Value.Item1, effectGroup.Id); foreach (var effect in pair.Value.Item1) { db.Insert(new ShopEffectDto { EffectGroupId = effectGroup.Id, Effect = effect }, statement => statement.AttachToTransaction(transaction)); } } #endregion #region Price var priceGroup = new ShopPriceGroupDto { Name = "PEN", PriceType = (byte)ItemPriceType.PEN }; db.Insert(priceGroup, statement => statement.AttachToTransaction(transaction)); var price = new ShopPriceDto { PriceGroupId = priceGroup.Id, PeriodType = (byte)ItemPeriodType.None, IsRefundable = false, Durability = 1000000, IsEnabled = true, Price = 1 }; db.Insert(price, statement => statement.AttachToTransaction(transaction)); #endregion #region Items var items = GameServer.Instance.ResourceCache.GetItems().Values.ToArray(); for (var i = 0; i < items.Length; ++i) { var item = items[i]; var effectToUse = effects["None"]; switch (item.ItemNumber.Category) { case ItemCategory.Weapon: break; case ItemCategory.Skill: if (item.ItemNumber.SubCategory == 0 && item.ItemNumber.Number == 0) // half hp mastery { effectToUse = effects["HP+15"]; } if (item.ItemNumber.SubCategory == 0 && item.ItemNumber.Number == 1) // hp mastery { effectToUse = effects["HP+30"]; } if (item.ItemNumber.SubCategory == 0 && item.ItemNumber.Number == 2) // sp mastery { effectToUse = effects["SP+40"]; } if (item.ItemNumber.SubCategory == 0 && item.ItemNumber.Number == 3) // dual mastery { effectToUse = effects["HP+20 & SP+20"]; } break; case ItemCategory.Costume: if (item.ItemNumber.SubCategory == (int)CostumeSlot.Hair) { effectToUse = effects["Defense+7"]; } if (item.ItemNumber.SubCategory == (int)CostumeSlot.Face) { effectToUse = effects["SP+3"]; } if (item.ItemNumber.SubCategory == (int)CostumeSlot.Pants) { effectToUse = effects["Defense+7"]; } if (item.ItemNumber.SubCategory == (int)CostumeSlot.Gloves) { effectToUse = effects["HP+3"]; } if (item.ItemNumber.SubCategory == (int)CostumeSlot.Shoes) { effectToUse = effects["HP+3"]; } if (item.ItemNumber.SubCategory == (int)CostumeSlot.Accessory) { effectToUse = effects["SP+3"]; } break; default: continue; } var shopItem = new ShopItemDto { Id = item.ItemNumber, RequiredGender = (byte)item.Gender, RequiredLicense = (byte)item.License, IsDestroyable = true }; db.Insert(shopItem, statement => statement.AttachToTransaction(transaction)); var shopItemInfo = new ShopItemInfoDto { ShopItemId = shopItem.Id, PriceGroupId = priceGroup.Id, EffectGroupId = effectToUse.Item2, IsEnabled = true }; db.Insert(shopItemInfo, statement => statement.AttachToTransaction(transaction)); Log.Information($"[{i}/{items.Length}] {item.ItemNumber}: {item.Name}"); } #endregion try { transaction.Commit(); } catch { transaction.Rollback(); throw; } } } }
private static void FillShop() { if (!Config.Instance.NoobMode) { return; } using (var db = GameDatabase.Open()) { if (!db.Find <ShopVersionDto>().Any()) { var version = new ShopVersionDto { Version = DateTimeOffset.UtcNow.ToString("yyyyMMddHHmmss") }; db.Insert(version); } if (db.Find <ShopEffectGroupDto>().Any() || db.Find <ShopEffectDto>().Any() || db.Find <ShopPriceGroupDto>().Any() || db.Find <ShopPriceDto>().Any() || db.Find <ShopItemDto>().Any() || db.Find <ShopItemInfoDto>().Any()) { return; } Log.Information("NoobMode: Filling the shop with items"); using (var transaction = db.BeginTransaction()) { var effects = new Dictionary <string, Tuple <uint[], int> > { { "None", Tuple.Create(Array.Empty <uint>(), 0) }, { "Shooting Weapon Defense (Head) +5%", Tuple.Create(new uint[] { 1100313003, 1100315003, 1100317003 }, 0) }, { "SP+6", Tuple.Create(new uint[] { 1101301006 }, 0) }, { "Attack+1%", Tuple.Create(new uint[] { 1102303001 }, 0) }, { "Attack+5%", Tuple.Create(new uint[] { 1102303003 }, 0) }, { "Defense+5%", Tuple.Create(new uint[] { 1103302004 }, 0) }, { "HP+4", Tuple.Create(new uint[] { 1105300004 }, 0) }, { "HP+30", Tuple.Create(new uint[] { 1999300011 }, 0) }, { "HP+15", Tuple.Create(new uint[] { 1999300009 }, 0) }, { "SP+40", Tuple.Create(new uint[] { 1300301012 }, 0) }, { "HP+20 & SP+20", Tuple.Create(new uint[] { 1999300010, 1999301011 }, 0) } }; #region Effects foreach (var pair in effects.ToArray()) { var effectGroup = new ShopEffectGroupDto { Name = pair.Key }; db.Insert(effectGroup, statement => statement.AttachToTransaction(transaction)); effects[pair.Key] = Tuple.Create(pair.Value.Item1, effectGroup.Id); foreach (var effect in pair.Value.Item1) { db.Insert(new ShopEffectDto { EffectGroupId = effectGroup.Id, Effect = effect }, statement => statement.AttachToTransaction(transaction)); } } #endregion #region Price var priceGroup = new ShopPriceGroupDto { Name = "PEN", PriceType = (byte)ItemPriceType.PEN }; db.Insert(priceGroup, statement => statement.AttachToTransaction(transaction)); var price = new ShopPriceDto { PriceGroupId = priceGroup.Id, PeriodType = (byte)ItemPeriodType.None, IsRefundable = false, Durability = 1000000, IsEnabled = true, Price = 1 }; db.Insert(price, statement => statement.AttachToTransaction(transaction)); #endregion #region Items var items = GameServer.Instance.ResourceCache.GetItems().Values.ToArray(); for (var i = 0; i < items.Length; ++i) { var item = items[i]; var effectToUse = effects["None"]; byte mainTab = 4; byte subTab = 1; switch (item.ItemNumber.Category) { case ItemCategory.Weapon: effectToUse = effects["Attack+1%"]; mainTab = 2; switch ((WeaponCategory)item.ItemNumber.SubCategory) { case WeaponCategory.Melee: subTab = 1; break; case WeaponCategory.RifleGun: subTab = 2; break; case WeaponCategory.HeavyGun: subTab = 4; break; case WeaponCategory.Sniper: subTab = 5; break; case WeaponCategory.Sentry: subTab = 6; break; case WeaponCategory.Bomb: subTab = 7; break; case WeaponCategory.Mind: subTab = 6; break; } break; case ItemCategory.Skill: mainTab = 2; subTab = 8; if (item.ItemNumber.SubCategory == 0 && item.ItemNumber.Number == 0) // half hp mastery { effectToUse = effects["HP+15"]; } if (item.ItemNumber.SubCategory == 0 && item.ItemNumber.Number == 1) // hp mastery { effectToUse = effects["HP+30"]; } if (item.ItemNumber.SubCategory == 0 && item.ItemNumber.Number == 2) // sp mastery { effectToUse = effects["SP+40"]; } if (item.ItemNumber.SubCategory == 0 && item.ItemNumber.Number == 3) // dual mastery { effectToUse = effects["HP+20 & SP+20"]; } break; case ItemCategory.Costume: mainTab = 3; subTab = (byte)(item.ItemNumber.SubCategory + 2); switch ((CostumeSlot)item.ItemNumber.SubCategory) { case CostumeSlot.Hair: effectToUse = effects["Shooting Weapon Defense (Head) +5%"]; break; case CostumeSlot.Face: effectToUse = effects["SP+6"]; break; case CostumeSlot.Shirt: effectToUse = effects["Attack+5%"]; break; case CostumeSlot.Pants: effectToUse = effects["Defense+5%"]; break; case CostumeSlot.Gloves: effectToUse = effects["HP+4"]; break; case CostumeSlot.Shoes: effectToUse = effects["HP+4"]; break; case CostumeSlot.Accessory: effectToUse = effects["SP+6"]; break; case CostumeSlot.Pet: effectToUse = effects["SP+6"]; break; } break; default: continue; } var shopItem = new ShopItemDto { Id = item.ItemNumber, RequiredGender = (byte)item.Gender, RequiredLicense = (byte)item.License, IsDestroyable = true, MainTab = mainTab, SubTab = subTab }; db.Insert(shopItem, statement => statement.AttachToTransaction(transaction)); var shopItemInfo = new ShopItemInfoDto { ShopItemId = shopItem.Id, PriceGroupId = priceGroup.Id, EffectGroupId = effectToUse.Item2, IsEnabled = true }; db.Insert(shopItemInfo, statement => statement.AttachToTransaction(transaction)); Log.Information($"[{i}/{items.Length}] {item.ItemNumber}: {item.Name}"); } #endregion try { transaction.Commit(); } catch { transaction.Rollback(); throw; } } } }