chore(m2): 保存功能验收及后续清理前检查点
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using asap.core;
|
||||
using asap.core;
|
||||
using Assets.Scripts.UI.OfferSweep;
|
||||
using cfg;
|
||||
using CodeStage.AntiCheat.ObscuredTypes;
|
||||
@@ -36,41 +36,9 @@ namespace GameCore
|
||||
Dictionary<string, string> NewPlayerDataDic = new Dictionary<string, string>();
|
||||
public IReadOnlyDictionary<string, string> PlayerDataDic => NewPlayerDataDic;
|
||||
|
||||
internal static game.PlayerDataStorage.PlayerKVPlayerState DecodeForKVLoad(IReadOnlyDictionary<string,string> raw,
|
||||
IReadOnlyDictionary<string,string> modern,game.PlayerDataStorage.PlayerKVSchemaSnapshot snapshot,
|
||||
game.PlayerDataStorage.PlayerKVSchemaDiagnostics errors) => game.PlayerDataStorage.PlayerKVSaveSchema.DecodePlayer(raw,modern,snapshot,errors);
|
||||
internal void ResetForKVLoad()
|
||||
{
|
||||
NewPlayerDataDic=new Dictionary<string,string>(StringComparer.Ordinal); vipScoreDic=new Dictionary<int,int>();
|
||||
newRodList=new List<int>();
|
||||
lv=vip=vipAllScore=0; vipLastScore=PriceLv=0; priceLevel=null;
|
||||
energy=pearl=diamond=equipRodID=magnification=seasonId=rewardNewMap=0;
|
||||
gold=0; goldRM=0; energyRM=0; _currentMapId=_lastMapId=0;
|
||||
_fishingFrequency=_allFishingFrequency=0; _lastEnergyRecoveryTime=DateTime.MinValue;
|
||||
IsOpenAppraise=false; InfiniteBuildingData=null;
|
||||
}
|
||||
internal void ReplaceFromKVDecoded(game.PlayerDataStorage.PlayerKVPlayerState state)
|
||||
{
|
||||
if(state==null || state.Core==null) throw new ArgumentNullException(nameof(state));
|
||||
var modern=state.Modern.ToDictionary(p=>p.Key,p=>p.Value,StringComparer.Ordinal);
|
||||
var scores=state.VipScores.ToDictionary(p=>p.Key,p=>p.Value);
|
||||
var rods=new List<int>(state.NewRods);
|
||||
var core=state.Core;
|
||||
lv=core.Integer(0); gold=core.Unsigned(1); vipAllScore=core.Integer(2); energy=core.Integer(3);
|
||||
pearl=core.Integer(4); magnification=core.Integer(5); equipRodID=core.Integer(6); _lastEnergyRecoveryTime=core.EnergyTime;
|
||||
rewardNewMap=core.Integer(8); energyRM=core.Integer(9); goldRM=core.Unsigned(10); diamond=core.Integer(11);
|
||||
_currentMapId=core.Integer(12); _lastMapId=core.Integer(13); _fishingFrequency=core.Integer(14); _allFishingFrequency=core.Integer(15);
|
||||
NewPlayerDataDic=modern; vipScoreDic=scores; newRodList=rods;
|
||||
seasonId=state.Season; IsOpenAppraise=state.Appraise; InfiniteBuildingData=state.Building;
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
internal game.PlayerDataStorage.PlayerKVPlayerState SnapshotForKVValidation() =>
|
||||
new game.PlayerDataStorage.PlayerKVPlayerState(new game.PlayerDataStorage.PlayerKVCoreState(new object[] {
|
||||
(int)lv,(ulong)gold,(int)vipAllScore,(int)energy,(int)pearl,(int)magnification,(int)equipRodID,_lastEnergyRecoveryTime,
|
||||
(int)rewardNewMap,energyRM,goldRM,(int)diamond,(int)_currentMapId,(int)_lastMapId,_fishingFrequency,_allFishingFrequency,0,0,0
|
||||
}),NewPlayerDataDic,vipScoreDic,newRodList,seasonId,IsOpenAppraise,InfiniteBuildingData);
|
||||
internal bool IsDerivedEmptyForKVValidation => (int)vip==0 && vipLastScore==0 && PriceLv==0 && priceLevel==null;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
public ObscuredInt lv { get; set; }
|
||||
public ObscuredInt vip { get; private set; }
|
||||
public ObscuredInt vipAllScore { get; private set; }
|
||||
@@ -1140,57 +1108,6 @@ namespace GameCore
|
||||
public void SavePlayerData(bool remote = true)
|
||||
{
|
||||
GContext.Publish<PlayerData>(this);
|
||||
SerializeAndSavePlayerData(remote);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR && !SERVICE_HOST
|
||||
internal async System.Threading.Tasks.Task ConsumeEnergyForKVLoopAsync(int cost,
|
||||
game.PlayerDataStorage.PlayerKVGameplayLoop.FishingAction action)
|
||||
{
|
||||
if(cost<=0 || Energy<cost) throw game.PlayerDataStorage.PlayerKVGameplayLoop.Stop("Invalid fishing energy cost or insufficient energy.");
|
||||
int before=Energy;
|
||||
var batch=game.PlayerDataStorage.PlayerKVGameplayLoop.BeginFishingWrites(action);
|
||||
game.PlayerDataStorage.PlayerKVEditResult primary;
|
||||
try
|
||||
{
|
||||
using(batch)
|
||||
{
|
||||
ReduceEnergy(cost,false);
|
||||
GContext.Publish(new ConditionTypeEvent(ConditionType.ConsumeEnergy,cost));
|
||||
primary=SerializeAndSavePlayerData(true);
|
||||
}
|
||||
game.PlayerDataStorage.PlayerKVGameplayLoop.Audit("fishing-energy-applied",new{before,cost,after=(int)Energy,writes=batch.Records.Count,localOnly=batch.Records.Count(r=>!r.Remote)});
|
||||
await game.PlayerDataStorage.PlayerKVGameplayLoop.ConfirmFishingAsync(action,batch,primary);
|
||||
}
|
||||
catch(System.Exception e) { game.PlayerDataStorage.PlayerKVGameplayLoop.Fault(e.Message); throw; }
|
||||
}
|
||||
internal async System.Threading.Tasks.Task SetEquipRodIDForKVLoopAsync(int id)
|
||||
{
|
||||
var batch=game.PlayerDataStorage.PlayerKVGameplayLoop.BeginEquip();
|
||||
game.PlayerDataStorage.PlayerKVEditResult primary;
|
||||
try
|
||||
{
|
||||
using(batch)
|
||||
{
|
||||
equipRodID=id;
|
||||
GContext.container.Resolve<PlayerFishData>().SetRedPoint();
|
||||
GContext.Publish<PlayerData>(this);
|
||||
primary=SerializeAndSavePlayerData(true);
|
||||
}
|
||||
await game.PlayerDataStorage.PlayerKVGameplayLoop.ConfirmEquipAsync(batch,primary);
|
||||
}
|
||||
catch(System.Exception e) { game.PlayerDataStorage.PlayerKVGameplayLoop.Fault(e.Message); throw; }
|
||||
}
|
||||
#endif
|
||||
#if UNITY_EDITOR && !SERVICE_HOST
|
||||
internal game.PlayerDataStorage.PlayerKVEditResult SaveFishingRewardForKVLoop()
|
||||
{
|
||||
game.PlayerDataStorage.PlayerKVGameplayLoop.CheckRewardMainSave();
|
||||
return SerializeAndSavePlayerData(true);
|
||||
}
|
||||
#endif
|
||||
private game.PlayerDataStorage.PlayerKVEditResult SerializeAndSavePlayerData(bool remote)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(lv).Append(",");
|
||||
sb.Append(gold).Append(",");
|
||||
@@ -1231,11 +1148,7 @@ namespace GameCore
|
||||
|
||||
NewPlayerDataDic["ct"] = GContext.container.Resolve<FishingEventData>().CTSerialize();
|
||||
NewPlayerDataDic["rt"] = GContext.container.Resolve<FishingEventData>().RTSerialize(); ;
|
||||
#if UNITY_EDITOR && !SERVICE_HOST
|
||||
if(game.PlayerDataStorage.PlayerKVGameplayLoop.Enabled) return game.PlayerDataStorage.PlayerKVGameplayLoop.Write("NewPlayerDataDic",Newtonsoft.Json.JsonConvert.SerializeObject(NewPlayerDataDic),remote);
|
||||
#endif
|
||||
playerSaveStore.Write("NewPlayerDataDic", Newtonsoft.Json.JsonConvert.SerializeObject(NewPlayerDataDic), remote).RequireAccepted();
|
||||
return null;
|
||||
}
|
||||
public void Init()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user