mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-12 23:14:34 +01:00
implement ObtainEpReward
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user