feat(upserver): 保存M2客户端KV迁移至本人统计写检查点
保存独立KV用户服务、固定会话存档与原业务接线,以及C3d资料缓存和C3e本人统计写。 保留原PF/AGG路线、业务公式和时序;榜单读取、好友资料、公告、匹配及首场景闸仍待完成。 验证:ServiceHost两条件各33组646断言;Unity CLI Loop编译0错误269警告。 包含相关方案、评审裁决、测试及状态文档。未操作服务器、正式账号或打包。
This commit is contained in:
@@ -0,0 +1,183 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using LitJson;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GameCore
|
||||
{
|
||||
public class TotalRechargeData
|
||||
{
|
||||
public int eventID;
|
||||
public int progress;
|
||||
public int vip;
|
||||
public int oldProgress;
|
||||
}
|
||||
public class TotalRechargeManager
|
||||
{
|
||||
readonly game.PlayerDataStorage.IPlayerSaveStore saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
|
||||
|
||||
public const string TotalRechargeDataKey = "EventTotalRecharge";
|
||||
public TotalRechargeData GetEventData()
|
||||
{
|
||||
var totalRechargeData = new TotalRechargeData();
|
||||
|
||||
string data = saveStore.Read(TotalRechargeDataKey).ValueOrThrow();
|
||||
if (data != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
totalRechargeData = Newtonsoft.Json.JsonConvert.DeserializeObject<TotalRechargeData>(data) ?? throw new Newtonsoft.Json.JsonSerializationException("Null TotalRechargeData save.");
|
||||
if (totalRechargeData.vip > 10)
|
||||
{
|
||||
totalRechargeData.vip = 10;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
FishingEvent tr = GContext.container.Resolve<FishingEventData>().GetEventByTypeAndSubType(12, 1);
|
||||
|
||||
if (tr != null && totalRechargeData.eventID != tr.ID)
|
||||
{
|
||||
totalRechargeData = new TotalRechargeData();
|
||||
totalRechargeData.eventID = tr.ID;
|
||||
totalRechargeData.vip = GContext.container.Resolve<PlayerData>().PriceLv;
|
||||
if (totalRechargeData.vip > 10)
|
||||
{
|
||||
totalRechargeData.vip = 10;
|
||||
}
|
||||
SaveTotalRechargeData(totalRechargeData);
|
||||
}
|
||||
return totalRechargeData;
|
||||
}
|
||||
|
||||
public void GetTotalReward(RewardType rewardType, string textValue)
|
||||
{
|
||||
var totalRechargeData = GetEventData();
|
||||
List<int> rewardIDs = new List<int>();
|
||||
var tables = GContext.container.Resolve<Tables>();
|
||||
var eventTotalRecharge = GetEventTotalRecharge(totalRechargeData);
|
||||
var taskIds = eventTotalRecharge.TaskList;
|
||||
var vip = totalRechargeData.vip;
|
||||
int oldProgress = totalRechargeData.oldProgress;
|
||||
int newProgress = totalRechargeData.progress;
|
||||
int taskCount = taskIds.Count;
|
||||
for (int i = 0; i < taskCount; i++)
|
||||
{
|
||||
int taskId = taskIds[i];
|
||||
CommonTask commonTask = tables.TbCommonTask.GetOrDefault(taskId);
|
||||
if (commonTask == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int iapid = commonTask.TaskParam[vip];
|
||||
var iap = tables.TbIAPItemList.GetOrDefault(iapid);
|
||||
if (oldProgress < iap.VIPPoint && newProgress >= iap.VIPPoint)
|
||||
{
|
||||
int rewardID = commonTask.TaskReward[vip];
|
||||
rewardIDs.Add(rewardID);
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("event_totalrecharge"))
|
||||
{
|
||||
e.AddContent("task_id", taskId)
|
||||
.AddContent("reward_id", rewardID);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (rewardIDs.Count > 0)
|
||||
{
|
||||
PlayerItemData playerItemData = GContext.container.Resolve<PlayerItemData>();
|
||||
var itemData = playerItemData.GetItemByDropListLureInflation(null, rewardIDs);
|
||||
var showData = new ShowData(itemData, rewardType);
|
||||
showData.textValue = textValue;
|
||||
GContext.Publish(showData);
|
||||
playerItemData.AddItem(itemData, null);
|
||||
}
|
||||
totalRechargeData.oldProgress = totalRechargeData.progress;
|
||||
SaveTotalRechargeData(totalRechargeData);
|
||||
}
|
||||
|
||||
public void AddProgress(int progress)
|
||||
{
|
||||
TotalRechargeData totalRechargeData = GetEventData();
|
||||
if (CheckTotalRechargeOpen(totalRechargeData))
|
||||
{
|
||||
totalRechargeData.progress += progress;
|
||||
SaveTotalRechargeData(totalRechargeData);
|
||||
}
|
||||
}
|
||||
public bool CheckTotalRechargeOpen()
|
||||
{
|
||||
TotalRechargeData totalRechargeData = GetEventData();
|
||||
return CheckTotalRechargeOpen(totalRechargeData);
|
||||
}
|
||||
EventTotalRecharge GetEventTotalRecharge(TotalRechargeData totalRechargeData)
|
||||
{
|
||||
if (totalRechargeData == null || totalRechargeData.eventID == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var _tables = GContext.container.Resolve<Tables>();
|
||||
FishingEvent fishingEvent = _tables.TbFishingEvent.GetOrDefault(totalRechargeData.eventID);
|
||||
if (fishingEvent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _tables.TbEventTotalRecharge[fishingEvent.RedirectID];
|
||||
}
|
||||
public bool CheckTotalRechargeOpen(TotalRechargeData totalRechargeData)
|
||||
{
|
||||
if (totalRechargeData == null || totalRechargeData.eventID == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var _tables = GContext.container.Resolve<Tables>();
|
||||
FishingEvent fishingEvent = _tables.TbFishingEvent.GetOrDefault(totalRechargeData.eventID);
|
||||
if (fishingEvent == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
LimitedTime limitedTime = fishingEvent.TimeDefinition as LimitedTime;
|
||||
var startTime = DateTime.Parse(limitedTime.StartTime);
|
||||
var endTime = DateTime.Parse(limitedTime.EndTime);
|
||||
var curTime = ZZTimeHelper.UtcNow();
|
||||
if (curTime < startTime || curTime > endTime)
|
||||
{
|
||||
if (totalRechargeData.oldProgress != totalRechargeData.progress)
|
||||
{
|
||||
RewardType rewardType = RewardType.FishBoxFlyRestore;
|
||||
string textValue = LocalizationMgr.GetText("UI_FishingRewardPanel_101042");
|
||||
GetTotalReward(rewardType, textValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var eventTotalRecharge = GetEventTotalRecharge(totalRechargeData);
|
||||
var taskIds = eventTotalRecharge.TaskList;
|
||||
var vip = totalRechargeData.vip;
|
||||
int oldProgress = totalRechargeData.oldProgress;
|
||||
int taskCount = taskIds.Count;
|
||||
int taskId = taskIds[^1];
|
||||
CommonTask commonTask = _tables.TbCommonTask.GetOrDefault(taskId);
|
||||
if (commonTask == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int iapid = commonTask.TaskParam[vip];
|
||||
var iap = _tables.TbIAPItemList.GetOrDefault(iapid);
|
||||
|
||||
return totalRechargeData.oldProgress < iap.VIPPoint;
|
||||
}
|
||||
|
||||
void SaveTotalRechargeData(TotalRechargeData totalRechargeData)
|
||||
{
|
||||
saveStore.Write(TotalRechargeDataKey, JsonMapper.ToJson(totalRechargeData)).RequireAccepted();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user