mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-12 15:04:36 +01:00
Implement tower rewards
This commit is contained in:
@@ -59,6 +59,7 @@ namespace EpinelPS.StaticInfo
|
||||
public Dictionary<int, SkillInfoRecord> skillInfoTable = [];
|
||||
public Dictionary<int, CostRecord> costTable = [];
|
||||
public Dictionary<string, MidasProductRecord> mediasProductTable = [];
|
||||
public Dictionary<int, TowerRecord> towerTable = [];
|
||||
|
||||
|
||||
|
||||
@@ -492,6 +493,12 @@ namespace EpinelPS.StaticInfo
|
||||
{
|
||||
this.mediasProductTable.Add(obj.midas_product_id_proximabeta, obj);
|
||||
}
|
||||
|
||||
var towerTable = await LoadZip<TowerTable>("TowerTable.json", progress);
|
||||
foreach (var obj in towerTable.records)
|
||||
{
|
||||
this.towerTable.Add(obj.id, obj);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task LoadJukeboxListData(ProgressBar bar)
|
||||
|
||||
@@ -559,4 +559,16 @@
|
||||
Mileage = 7,
|
||||
Trade = 8
|
||||
}
|
||||
public class TowerRecord
|
||||
{
|
||||
public int id;
|
||||
public int floor;
|
||||
public string type = "";
|
||||
public int standard_battle_power;
|
||||
public int reward_id;
|
||||
}
|
||||
public class TowerTable
|
||||
{
|
||||
public List<TowerRecord> records = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using EpinelPS.Database;
|
||||
using EpinelPS.Utils;
|
||||
using EpinelPS.StaticInfo;
|
||||
using EpinelPS.LobbyServer.Stage;
|
||||
|
||||
namespace EpinelPS.LobbyServer.Tower
|
||||
{
|
||||
@@ -25,20 +27,26 @@ namespace EpinelPS.LobbyServer.Tower
|
||||
{
|
||||
var response = new ResClearTower();
|
||||
|
||||
if (!GameData.Instance.towerTable.TryGetValue(TowerId, out TowerRecord record)) throw new Exception("unable to find tower with id " + TowerId);
|
||||
|
||||
// Parse TowerId to get TowerType and FloorNumber
|
||||
int TowerType = (TowerId / 10000) - 1; // For some weird reason the Type here doesn't match up with NetTowerData, thus the -1
|
||||
int FloorNumber = TowerId % 10000;
|
||||
|
||||
// Update user's TowerProgress
|
||||
if (!user.TowerProgress.ContainsKey(TowerType))
|
||||
if (!user.TowerProgress.TryGetValue(TowerType, out int value))
|
||||
{
|
||||
user.TowerProgress[TowerType] = FloorNumber;
|
||||
user.TowerProgress[TowerType] = record.floor;
|
||||
}
|
||||
else if (user.TowerProgress[TowerType] < FloorNumber)
|
||||
else if (value < FloorNumber)
|
||||
{
|
||||
user.TowerProgress[TowerType] = FloorNumber;
|
||||
user.TowerProgress[TowerType] = record.floor;
|
||||
}
|
||||
|
||||
var reward = GameData.Instance.GetRewardTableEntry(record.reward_id) ?? throw new Exception("failed to get reward");
|
||||
response.Reward = ClearStage.RegisterRewardsForUser(user, reward);
|
||||
|
||||
|
||||
JsonDb.Save();
|
||||
|
||||
return response;
|
||||
|
||||
Reference in New Issue
Block a user