mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-13 23:44:45 +01:00
begin gacha system, ch2 fix
This commit is contained in:
@@ -13,7 +13,7 @@ namespace nksrv.LobbyServer.Msgs.Character
|
|||||||
var response = new ResGetCharacterData();
|
var response = new ResGetCharacterData();
|
||||||
foreach (var item in user.Characters)
|
foreach (var item in user.Characters)
|
||||||
{
|
{
|
||||||
response.Character.Add(new NetUserCharacterData() { Default = new() { Csn = item.Csn, Skill1Lv = item.Skill1Lvl, Skill2Lv = item.Skill2Lvl, CostumeId = item.CostumeId, Lv = item.Level, Grade = item.Grade, Tid = item.Tid } });
|
response.Character.Add(new NetUserCharacterData() { Default = new() { Csn = item.Csn, Skill1Lv = item.Skill1Lvl, Skill2Lv = item.Skill2Lvl, CostumeId = item.CostumeId, Lv = item.Level, Grade = item.Grade, Tid = item.Tid, UltiSkillLv = item.UltimateLevel } });
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteData(response);
|
WriteData(response);
|
||||||
|
|||||||
26
nksrv/LobbyServer/Msgs/Gacha/CheckGachaDailyEvent.cs
Normal file
26
nksrv/LobbyServer/Msgs/Gacha/CheckGachaDailyEvent.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using nksrv.Utils;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace nksrv.LobbyServer.Msgs.Gacha
|
||||||
|
{
|
||||||
|
[PacketPath("/gacha/event/check")]
|
||||||
|
public class CheckGachaDailyEvent : LobbyMsgHandler
|
||||||
|
{
|
||||||
|
protected override async Task HandleAsync()
|
||||||
|
{
|
||||||
|
var req = ReadData<ReqCheckDailyFreeGacha>();
|
||||||
|
|
||||||
|
var response = new ResCheckDailyFreeGacha();
|
||||||
|
|
||||||
|
// TODO implement
|
||||||
|
response.FreeCount = 1000;
|
||||||
|
response.EventData = new NetEventData() { Id = 1 };
|
||||||
|
|
||||||
|
WriteData(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
32
nksrv/LobbyServer/Msgs/Gacha/ExecGacha.cs
Normal file
32
nksrv/LobbyServer/Msgs/Gacha/ExecGacha.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using nksrv.Utils;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace nksrv.LobbyServer.Msgs.Gacha
|
||||||
|
{
|
||||||
|
[PacketPath("/gacha/execute")]
|
||||||
|
public class ExecGacha : LobbyMsgHandler
|
||||||
|
{
|
||||||
|
protected override async Task HandleAsync()
|
||||||
|
{
|
||||||
|
var req = await ReadData<ReqExecuteGacha>();
|
||||||
|
|
||||||
|
var response = new ResExecuteGacha();
|
||||||
|
|
||||||
|
// TODO implement
|
||||||
|
response.Reward = new NetRewardData();
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
response.Gacha.Add(new NetGachaEntityData() { Corporation = 0, PieceCount = 1, CurrencyValue = 5, Sn = 130201, Tid = 2500601, Type = 1 });
|
||||||
|
// response.Characters.Add(new NetUserCharacterDefaultData() { Lv = 1, Skill1Lv = 1, Grade = 0, Csn = 1, Tid = 130201 });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WriteData(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,9 @@ namespace nksrv.LobbyServer.Msgs.Stage
|
|||||||
|
|
||||||
if (req.BattleResult == 1)
|
if (req.BattleResult == 1)
|
||||||
{
|
{
|
||||||
|
var clearedStage = StaticDataParser.Instance.GetStageData(req.StageId);
|
||||||
|
if (clearedStage == null) throw new Exception("cleared stage cannot be null");
|
||||||
|
|
||||||
user.LastStageCleared = req.StageId;
|
user.LastStageCleared = req.StageId;
|
||||||
|
|
||||||
if (user.FieldInfo.Count == 0)
|
if (user.FieldInfo.Count == 0)
|
||||||
@@ -34,7 +37,7 @@ namespace nksrv.LobbyServer.Msgs.Stage
|
|||||||
DoQuestSpecificUserOperations(user, req.StageId);
|
DoQuestSpecificUserOperations(user, req.StageId);
|
||||||
|
|
||||||
// TODO: figure out how stageid corresponds to chapter
|
// TODO: figure out how stageid corresponds to chapter
|
||||||
user.FieldInfo[GetChapterForStageId(req.StageId)].CompletedStages.Add(new NetFieldStageData() { StageId = req.StageId });
|
user.FieldInfo[clearedStage.chapter_id - 1].CompletedStages.Add(new NetFieldStageData() { StageId = req.StageId });
|
||||||
JsonDb.Save();
|
JsonDb.Save();
|
||||||
|
|
||||||
|
|
||||||
@@ -112,21 +115,5 @@ namespace nksrv.LobbyServer.Msgs.Stage
|
|||||||
user.TeamData.Slots.Add(new NetWholeTeamSlot { Slot = 5, Csn = 47263459, Tid = 301201, Lvl = 1 });
|
user.TeamData.Slots.Add(new NetWholeTeamSlot { Slot = 5, Csn = 47263459, Tid = 301201, Lvl = 1 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static int GetChapterForStageId(int stageId)
|
|
||||||
{
|
|
||||||
if (6000001 <= stageId && stageId <= 6000003)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if (6001001 <= stageId && stageId <= 6001004)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Logger.Error("Unknown stage id: " + stageId);
|
|
||||||
return 100;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace nksrv.LobbyServer.Msgs.User
|
|||||||
}
|
}
|
||||||
foreach (var item in user.Characters)
|
foreach (var item in user.Characters)
|
||||||
{
|
{
|
||||||
response.Character.Add(new NetUserCharacterData() { Default = new() { Csn = item.Csn, Skill1Lv = item.Skill1Lvl, Skill2Lv = item.Skill2Lvl, CostumeId = item.CostumeId, Lv = item.Level, Grade = item.Grade, Tid = item.Tid } });
|
response.Character.Add(new NetUserCharacterData() { Default = new() { Csn = item.Csn, Skill1Lv = item.Skill1Lvl, Skill2Lv = item.Skill2Lvl, CostumeId = item.CostumeId, Lv = item.Level, Grade = item.Grade, Tid = item.Tid, UltiSkillLv = item.UltimateLevel } });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.Characters.Count > 0)
|
if (user.Characters.Count > 0)
|
||||||
|
|||||||
@@ -1630,4 +1630,37 @@ message ResGetSimRoom {
|
|||||||
//repeated NetSimRoomClearInfo clearInfos = 4;
|
//repeated NetSimRoomClearInfo clearInfos = 4;
|
||||||
//repeated NetSimRoomEvent events = 5;
|
//repeated NetSimRoomEvent events = 5;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
message ReqCheckDailyFreeGacha {
|
||||||
|
int32 gachaId = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ResCheckDailyFreeGacha {
|
||||||
|
NetEventData eventData = 1;
|
||||||
|
int32 freeCount = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ReqExecuteGacha {
|
||||||
|
int32 tid = 2;
|
||||||
|
int32 currencyType = 3;
|
||||||
|
int32 count = 4;
|
||||||
|
bool isDiscount = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message NetGachaEntityData {
|
||||||
|
int32 tid = 1;
|
||||||
|
int32 sn = 2;
|
||||||
|
int32 type = 3;
|
||||||
|
int32 corporation = 4;
|
||||||
|
int32 pieceCount = 5;
|
||||||
|
int32 currencyValue = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ResExecuteGacha {
|
||||||
|
repeated NetGachaEntityData gacha = 2;
|
||||||
|
repeated NetUserCurrencyData currencies = 3;
|
||||||
|
repeated NetUserCharacterDefaultData characters = 6;
|
||||||
|
repeated NetUserItemData items = 5;
|
||||||
|
NetRewardData reward = 9;
|
||||||
}
|
}
|
||||||
@@ -16,4 +16,11 @@ namespace nksrv.StaticInfo
|
|||||||
public int reward_id = 0;
|
public int reward_id = 0;
|
||||||
public int target_chapter_id;
|
public int target_chapter_id;
|
||||||
}
|
}
|
||||||
|
public class CampaignStageRecord
|
||||||
|
{
|
||||||
|
public int id;
|
||||||
|
public int chapter_id;
|
||||||
|
public string stage_category = "";
|
||||||
|
public int reward_id = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ namespace nksrv.StaticInfo
|
|||||||
private MemoryStream ZipStream;
|
private MemoryStream ZipStream;
|
||||||
private JArray questDataRecords;
|
private JArray questDataRecords;
|
||||||
private JArray stageDataRecords;
|
private JArray stageDataRecords;
|
||||||
|
private JArray rewardDataRecords;
|
||||||
|
|
||||||
public StaticDataParser(string filePath)
|
public StaticDataParser(string filePath)
|
||||||
{
|
{
|
||||||
@@ -200,23 +201,32 @@ namespace nksrv.StaticInfo
|
|||||||
{
|
{
|
||||||
var mainQuestData = MainZip.GetEntry("MainQuestTable.json");
|
var mainQuestData = MainZip.GetEntry("MainQuestTable.json");
|
||||||
var campaignStageData = MainZip.GetEntry("CampaignStageTable.json");
|
var campaignStageData = MainZip.GetEntry("CampaignStageTable.json");
|
||||||
|
var rewardDataEntry = MainZip.GetEntry("RewardTable.json");
|
||||||
|
|
||||||
|
|
||||||
if (mainQuestData == null) throw new Exception("MainQuestTable.json does not exist in static data");
|
if (mainQuestData == null) throw new Exception("MainQuestTable.json does not exist in static data");
|
||||||
if (campaignStageData == null) throw new Exception("CampaignStageTable.json does not exist in static data");
|
if (campaignStageData == null) throw new Exception("CampaignStageTable.json does not exist in static data");
|
||||||
|
if (rewardDataEntry == null) throw new Exception("RewardTable.json does not exist in static data");
|
||||||
|
|
||||||
using StreamReader mainQuestReader = new StreamReader(MainZip.GetInputStream(mainQuestData));
|
using StreamReader mainQuestReader = new StreamReader(MainZip.GetInputStream(mainQuestData));
|
||||||
var mainQuestDataString = await mainQuestReader.ReadToEndAsync();
|
var mainQuestDataString = await mainQuestReader.ReadToEndAsync();
|
||||||
|
|
||||||
using StreamReader campaignStageDataReader = new StreamReader(MainZip.GetInputStream(mainQuestData));
|
using StreamReader campaignStageDataReader = new StreamReader(MainZip.GetInputStream(campaignStageData));
|
||||||
var campaignStageDataString = await campaignStageDataReader.ReadToEndAsync();
|
var campaignStageDataString = await campaignStageDataReader.ReadToEndAsync();
|
||||||
|
|
||||||
|
using StreamReader rewardDataReader = new StreamReader(MainZip.GetInputStream(rewardDataEntry));
|
||||||
|
var rewardJsonString = await rewardDataReader.ReadToEndAsync();
|
||||||
|
|
||||||
var questdata = JObject.Parse(mainQuestDataString);
|
var questdata = JObject.Parse(mainQuestDataString);
|
||||||
var stagedata = JObject.Parse(campaignStageDataString);
|
var stagedata = JObject.Parse(campaignStageDataString);
|
||||||
|
var rewardData = JObject.Parse(rewardJsonString);
|
||||||
|
|
||||||
questDataRecords = (JArray?)questdata["records"];
|
questDataRecords = (JArray?)questdata["records"];
|
||||||
stageDataRecords = (JArray?)stagedata["records"];
|
stageDataRecords = (JArray?)stagedata["records"];
|
||||||
|
rewardDataRecords = (JArray?)rewardData["records"];
|
||||||
if (questDataRecords == null) throw new Exception("MainQuestTable.json does not contain records array");
|
if (questDataRecords == null) throw new Exception("MainQuestTable.json does not contain records array");
|
||||||
if (stageDataRecords == null) throw new Exception("CampaignStageTable.json does not contain records array");
|
if (stageDataRecords == null) throw new Exception("CampaignStageTable.json does not contain records array");
|
||||||
|
if (rewardDataRecords == null) throw new Exception("CampaignChapterTable.json does not contain records array");
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainQuestCompletionData? GetMainQuestForStageClearCondition(int stage)
|
public MainQuestCompletionData? GetMainQuestForStageClearCondition(int stage)
|
||||||
@@ -253,6 +263,24 @@ namespace nksrv.StaticInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public CampaignStageRecord? GetStageData(int stage)
|
||||||
|
{
|
||||||
|
foreach (JObject item in stageDataRecords)
|
||||||
|
{
|
||||||
|
var id = item["id"];
|
||||||
|
if (id == null) throw new Exception("expected id field in campaign data");
|
||||||
|
|
||||||
|
int value = id.ToObject<int>();
|
||||||
|
if (value == stage)
|
||||||
|
{
|
||||||
|
CampaignStageRecord? data = JsonConvert.DeserializeObject<CampaignStageRecord>(item.ToString());
|
||||||
|
if (data == null) throw new Exception("failed to deserialize stage data");
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user