implementation for the Favorite Item ,Character Counse and Harmony Cube systems (#51)

* feat: Implement Favorite Item and Harmony Cube systems

This commit introduces the core implementation for the Favorite Item and Harmony Cube systems.

Features:

- Added data structures and loading for Favorite Items, Harmony Cubes, and Attractive Levels.

- Implemented lobby handlers for all related actions:

    - Favorite Items: equip, increase exp, quests, rewards, etc.

    - Harmony Cubes: get, clear, increase exp, level up, management, etc.

    - Character Counsel: check, present, quick counsel.

- Updated user data models to store related progression.

- Switched JSON deserialization for db.json to Newtonsoft.Json to handle protobuf models correctly.

* fix  InfraCoreExp

* fix UserFavoriteItems and present count

---------

Co-authored-by: Mikhail Tyukin <mishakeys20@gmail.com>
This commit is contained in:
fxz2018
2025-09-10 07:05:12 +08:00
committed by GitHub
parent ee15420257
commit 2e4310edf1
40 changed files with 2356 additions and 111 deletions

View File

@@ -1,4 +1,4 @@
using EpinelPS.Data;
using EpinelPS.Data;
using EpinelPS.Database;
using EpinelPS.Utils;
@@ -13,7 +13,7 @@ namespace EpinelPS.LobbyServer.LobbyUser
User user = GetUser();
TimeSpan battleTime = DateTime.UtcNow - user.BattleTime;
long battleTimeMs = (long)(battleTime.TotalNanoseconds / 100);
long battleTimeMs = (long)(battleTime.TotalNanoseconds / 100);
// NOTE: Keep this in sync with GetUser code
@@ -67,18 +67,47 @@ namespace EpinelPS.LobbyServer.LobbyUser
response.TypeTeams.Add(teamInfo.Value);
}
// TODO: Save outpost data
response.Outposts.Add(new NetUserOutpostData() { SlotId = 1, BuildingId = 22401, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Outposts.Add(new NetUserOutpostData() { SlotId = 4, BuildingId = 22701, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Outposts.Add(new NetUserOutpostData() { SlotId = 5, BuildingId = 22801, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Outposts.Add(new NetUserOutpostData() { SlotId = 6, BuildingId = 22901, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Outposts.Add(new NetUserOutpostData() { SlotId = 7, BuildingId = 23001, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Outposts.Add(new NetUserOutpostData() { SlotId = 3, BuildingId = 23101, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Outposts.Add(new NetUserOutpostData() { SlotId = 2, BuildingId = 23201, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Outposts.Add(new NetUserOutpostData() { SlotId = 9, BuildingId = 23301, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Outposts.Add(new NetUserOutpostData() { SlotId = 8, BuildingId = 23401, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Outposts.Add(new NetUserOutpostData() { SlotId = 10, BuildingId = 23501, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
response.Outposts.Add(new NetUserOutpostData() { SlotId = 38, BuildingId = 33601, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 });
if (user.OutpostBuildings != null && user.OutpostBuildings.Count > 0)
{
bool needsSave = false;
foreach (NetUserOutpostData building in user.OutpostBuildings)
{
if (!building.IsDone && DateTime.UtcNow.Ticks >= building.CompleteAt)
{
building.IsDone = true;
needsSave = true;
}
}
if (needsSave)
{
JsonDb.Save();
}
response.Outposts.AddRange(user.OutpostBuildings);
}
else
{
List<NetUserOutpostData> defaultBuildings = new List<NetUserOutpostData>
{
new() { SlotId = 1, BuildingId = 22401, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 },
new() { SlotId = 4, BuildingId = 22701, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 },
new() { SlotId = 5, BuildingId = 22801, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 },
new() { SlotId = 6, BuildingId = 22901, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 },
new() { SlotId = 7, BuildingId = 23001, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 },
new() { SlotId = 3, BuildingId = 23101, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 },
new() { SlotId = 2, BuildingId = 23201, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 },
new() { SlotId = 9, BuildingId = 23301, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 },
new() { SlotId = 8, BuildingId = 23401, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 },
new() { SlotId = 10, BuildingId = 23501, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 },
new() { SlotId = 38, BuildingId = 33601, IsDone = true, StartAt = 638549982076760660, CompleteAt = 638549982076760660 }
};
response.Outposts.AddRange(defaultBuildings);
user.OutpostBuildings = defaultBuildings;
JsonDb.Save();
}
response.LastClearedNormalMainStageId = user.LastNormalStageCleared;
response.TimeRewardBuffs.AddRange(NetUtils.GetOutpostTimeReward(user));
@@ -90,4 +119,4 @@ namespace EpinelPS.LobbyServer.LobbyUser
await WriteDataAsync(response);
}
}
}
}