mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-13 07:24:52 +01:00
initial equip leveling impl
This commit is contained in:
@@ -35,6 +35,8 @@ namespace EpinelPS.StaticInfo
|
||||
public Dictionary<int, ClearedTutorialData> tutorialTable;
|
||||
public Dictionary<int, ItemEquipRecord> itemEquipTable;
|
||||
public Dictionary<int, ItemMaterialRecord> itemMaterialTable;
|
||||
public Dictionary<int, ItemEquipExpRecord> itemEquipExpTable;
|
||||
public Dictionary<int, ItemEquipGradeExpRecord> ItemEquipGradeExpTable;
|
||||
private Dictionary<string, JArray> FieldMapData = new Dictionary<string, JArray>(); // Fixed initialization
|
||||
private Dictionary<int, CharacterLevelData> LevelData = new Dictionary<int, CharacterLevelData>(); // Fixed initialization
|
||||
private Dictionary<int, TacticAcademyLessonRecord> TacticAcademyLessons = new Dictionary<int, TacticAcademyLessonRecord>(); // Fixed initialization
|
||||
@@ -96,6 +98,8 @@ namespace EpinelPS.StaticInfo
|
||||
tutorialTable = [];
|
||||
itemEquipTable = [];
|
||||
itemMaterialTable = [];
|
||||
itemEquipExpTable = [];
|
||||
ItemEquipGradeExpTable = [];
|
||||
characterStatTable = [];
|
||||
skillInfoTable = [];
|
||||
costTable = [];
|
||||
@@ -327,6 +331,18 @@ namespace EpinelPS.StaticInfo
|
||||
this.itemMaterialTable.Add(obj.id, obj);
|
||||
}
|
||||
|
||||
var itemEquipExpTable = await LoadZip<ItemEquipExpTable>("ItemEquipExpTable.json", progress);
|
||||
foreach (var obj in itemEquipExpTable.records)
|
||||
{
|
||||
this.itemEquipExpTable.Add(obj.id, obj);
|
||||
}
|
||||
|
||||
var ItemEquipGradeExpTable = await LoadZip<ItemEquipGradeExpTable>("ItemEquipGradeExpTable.json", progress);
|
||||
foreach (var obj in ItemEquipGradeExpTable.records)
|
||||
{
|
||||
this.ItemEquipGradeExpTable.Add(obj.id, obj);
|
||||
}
|
||||
|
||||
var characterLevelTable = await LoadZip("CharacterLevelTable.json", progress);
|
||||
|
||||
foreach (JToken item in characterLevelTable)
|
||||
|
||||
@@ -172,7 +172,32 @@
|
||||
public class ItemEquipRecord
|
||||
{
|
||||
public int id;
|
||||
public string item_sub_type = "";
|
||||
public string name_localkey;
|
||||
public string description_localkey;
|
||||
public string resource_id;
|
||||
public string item_type;
|
||||
public string item_sub_type;
|
||||
public string @class;
|
||||
public string item_rare;
|
||||
public int grade_core_id;
|
||||
public int grow_grade;
|
||||
public List<Stat> stat;
|
||||
public List<OptionSlot> option_slot;
|
||||
public int option_cost;
|
||||
public int option_change_cost;
|
||||
public int option_lock_cost;
|
||||
}
|
||||
|
||||
public class Stat
|
||||
{
|
||||
public string stat_type = "";
|
||||
public int stat_value;
|
||||
}
|
||||
|
||||
public class OptionSlot
|
||||
{
|
||||
public int option_slot;
|
||||
public int option_slot_success_ratio;
|
||||
}
|
||||
public class ItemEquipTable
|
||||
{
|
||||
@@ -571,4 +596,31 @@
|
||||
{
|
||||
public List<TowerRecord> records = [];
|
||||
}
|
||||
|
||||
public class ItemEquipExpRecord
|
||||
{
|
||||
public int id;
|
||||
public int level;
|
||||
public int exp;
|
||||
public string item_rare;
|
||||
public int grade_core_id;
|
||||
}
|
||||
|
||||
public class ItemEquipExpTable
|
||||
{
|
||||
public List<ItemEquipExpRecord> records = [];
|
||||
}
|
||||
|
||||
public class ItemEquipGradeExpRecord
|
||||
{
|
||||
public int id;
|
||||
public int exp;
|
||||
public string item_rare;
|
||||
public int grade_core_id;
|
||||
}
|
||||
|
||||
public class ItemEquipGradeExpTable
|
||||
{
|
||||
public List<ItemEquipGradeExpRecord> records = [];
|
||||
}
|
||||
}
|
||||
|
||||
74
EpinelPS/LobbyServer/Inventory/IncreaseEquipmentExp.cs
Normal file
74
EpinelPS/LobbyServer/Inventory/IncreaseEquipmentExp.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.StaticInfo;
|
||||
using EpinelPS.Utils;
|
||||
|
||||
namespace EpinelPS.LobbyServer.Inventory
|
||||
{
|
||||
[PacketPath("/inventory/increaseexpequipment")]
|
||||
public class IncreaseEquipmentExp : LobbyMsgHandler
|
||||
{
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
var req = await ReadData<ReqIncreaseExpEquip>();
|
||||
var user = GetUser();
|
||||
var response = new ResIncreaseExpEquip();
|
||||
var destItem = user.Items.FirstOrDefault(x => x.Isn == req.Isn);
|
||||
int goldCost = 0;
|
||||
|
||||
foreach (var srcItem in req.ItemList)
|
||||
{
|
||||
var item = user.Items.FirstOrDefault(x => x.Isn == srcItem.Isn);
|
||||
item.Count -= srcItem.Count;
|
||||
|
||||
goldCost += AddExp(srcItem, destItem);
|
||||
|
||||
response.Items.Add(NetUtils.ToNet(item));
|
||||
}
|
||||
|
||||
response.Currency = new NetUserCurrencyData
|
||||
{
|
||||
Type = (int)CurrencyType.Gold,
|
||||
Value = user.GetCurrencyVal(CurrencyType.Gold) - goldCost
|
||||
};
|
||||
|
||||
// we NEED to make sure the target item itself is in the delta list, or the UI won't update!
|
||||
response.Items.Add(NetUtils.ToNet(destItem));
|
||||
|
||||
JsonDb.Save();
|
||||
|
||||
await WriteDataAsync(response);
|
||||
}
|
||||
|
||||
int AddExp(NetItemData srcItem, ItemData destItem)
|
||||
{
|
||||
var srcEquipRecord = GameData.Instance.itemEquipTable.Values.FirstOrDefault(x => x.id == srcItem.Tid);
|
||||
var destEquipRecord = GameData.Instance.itemEquipTable.Values.FirstOrDefault(x => x.id == destItem.ItemType);
|
||||
var levelRecord = GameData.Instance.ItemEquipGradeExpTable.Values.FirstOrDefault(x => x.grade_core_id == srcEquipRecord.grade_core_id);
|
||||
int[] maxLevel = { 0, 0, 3, 3, 4, 4, 5, 5, 5, 5 };
|
||||
int[] expNextTable = GameData.Instance.itemEquipExpTable.Values
|
||||
.Where(x => x.item_rare == destEquipRecord.item_rare)
|
||||
.Select(x => x.exp)
|
||||
.OrderBy(x => x) // order from lowest to highest
|
||||
.ToArray();
|
||||
int exp = levelRecord.exp * srcItem.Count;
|
||||
|
||||
destItem.Exp += exp * srcItem.Count;
|
||||
|
||||
// TODO: double-check this. is this a thing?
|
||||
// destItem.Exp += GetUser().Items.FirstOrDefault(x => x.Isn == srcItem.Isn).Exp;
|
||||
|
||||
while (destItem.Exp >= expNextTable[destItem.Level + 1] && destItem.Level < maxLevel[destEquipRecord.grade_core_id - 1])
|
||||
{
|
||||
destItem.Exp -= expNextTable[destItem.Level - 1];
|
||||
destItem.Level++;
|
||||
}
|
||||
|
||||
if (destItem.Level >= maxLevel[destEquipRecord.grade_core_id - 1])
|
||||
{
|
||||
destItem.Exp = 0;
|
||||
}
|
||||
|
||||
return exp;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user