implement ObtainEpReward

This commit is contained in:
Mikhail
2025-05-01 16:21:26 -04:00
parent cb27bd926a
commit 24b4d11862
3 changed files with 60 additions and 2 deletions

View File

@@ -67,6 +67,8 @@ namespace EpinelPS.StaticInfo
public readonly Dictionary<int, TowerRecord> towerTable = [];
public readonly Dictionary<int, TriggerRecord> TriggerTable = [];
public readonly Dictionary<int, InfracoreRecord> InfracoreTable = [];
public readonly Dictionary<int, AttractiveCounselCharacterRecord> AttractiveCounselCharacterTable = [];
public readonly Dictionary<int, AttractiveLevelRewardRecord> AttractiveLevelReward = [];
public byte[] Sha256Hash;
@@ -514,6 +516,18 @@ namespace EpinelPS.StaticInfo
{
this.InfracoreTable.Add(obj.id, obj);
}
var attrData = await LoadZip<AttractiveCounselCharacterTable>("AttractiveCounselCharacterTable.json", progress);
foreach (var obj in attrData.records)
{
this.AttractiveCounselCharacterTable.Add(obj.name_code, obj);
}
var attrLData = await LoadZip<AttractiveLevelRewardTable>("AttractiveLevelRewardTable.json", progress);
foreach (var obj in attrLData.records)
{
this.AttractiveLevelReward.Add(obj.id, obj);
}
}
public MainQuestCompletionRecord? GetMainQuestForStageClearCondition(int stage)

View File

@@ -690,4 +690,27 @@
{
public List<InfracoreRecord> records = [];
}
public class AttractiveCounselCharacterRecord
{
public int id;
public int name_code;
public int collect_reward_id;
}
public class AttractiveCounselCharacterTable
{
public List<AttractiveCounselCharacterRecord> records = [];
}
public class AttractiveLevelRewardRecord
{
public int id;
public int name_code;
public int reward_id;
public int attractive_level;
public int costume;
}
public class AttractiveLevelRewardTable
{
public List<AttractiveLevelRewardRecord> records = [];
}
}

View File

@@ -1,4 +1,6 @@
using EpinelPS.Utils;
using EpinelPS.StaticInfo;
using EpinelPS.Database;
namespace EpinelPS.LobbyServer.Character
{
@@ -9,8 +11,27 @@ namespace EpinelPS.LobbyServer.Character
{
var req = await ReadData<ReqObtainAttractiveReward>();
var response = new ResObtainAttractiveReward();
// TODO
var user = GetUser();
// look up ID from name code and level
var levelUpRecord = GameData.Instance.AttractiveLevelReward.Where(x => x.Value.attractive_level == req.Level && x.Value.name_code == req.NameCode).FirstOrDefault();
foreach (var item in user.BondInfo)
{
if (item.NameCode == req.NameCode)
{
if (!item.ObtainedRewardLevels.Contains(levelUpRecord.Value.id))
{
item.ObtainedRewardLevels.Add(levelUpRecord.Value.id);
var reward = GameData.Instance.GetRewardTableEntry(levelUpRecord.Value.reward_id) ?? throw new Exception("failed to get reward");
response.Reward = RewardUtils.RegisterRewardsForUser(user, reward);
JsonDb.Save();
}
break;
}
}
await WriteDataAsync(response);
}