feat: 每日任务兼容
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"ver": "1.1.3",
|
||||
"uuid": "3b6374be-048b-4d24-a94f-61768ddd4b4e",
|
||||
"importer": "folder",
|
||||
"isBundle": false,
|
||||
"bundleName": "",
|
||||
"priority": 1,
|
||||
"compressionType": {},
|
||||
"optimizeHotUpdate": {},
|
||||
"inlineSpriteFrames": {},
|
||||
"isRemoteBundle": {},
|
||||
"subMetas": {}
|
||||
}
|
||||
@@ -1464,7 +1464,7 @@ export default class Utils {
|
||||
uid: cc.fx.GameConfig.GM_INFO.uid,
|
||||
action: 'read',
|
||||
}
|
||||
Utils.POST("dayTaskInfo", setData, res => {
|
||||
Utils.POST("dayTaskInfoV2", setData, res => {
|
||||
console.log("获取每日任务信息:", res);
|
||||
if (res.code === 1) {
|
||||
// //console.log("服务器:领取获得monthGetReward成功'✅ ", res);
|
||||
@@ -1491,7 +1491,7 @@ export default class Utils {
|
||||
action: 'save',
|
||||
task: JSON.stringify(task),
|
||||
}
|
||||
Utils.POST("dayTaskInfo", setData, res => {
|
||||
Utils.POST("dayTaskInfoV2", setData, res => {
|
||||
if (res.code === 1) {
|
||||
// 由 DailyTaskSync 合并回包,保留请求期间新产生的进度。
|
||||
// //console.log("服务器:领取获得monthGetReward成功'✅ ", res);
|
||||
@@ -1518,7 +1518,7 @@ export default class Utils {
|
||||
scope: scope,
|
||||
...(scope === "weekly" ? { rewardId: data } : { taskId: data }),
|
||||
}
|
||||
Utils.POST("getTaskReward", setData, res => {
|
||||
Utils.POST("getTaskRewardV2", setData, res => {
|
||||
if (res.code === 1) {
|
||||
// 领取状态和并发进度由 DailyTaskSync 统一更新。
|
||||
// //console.log("服务器:领取获得monthGetReward成功'✅ ", res);
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"ver": "1.1.3",
|
||||
"uuid": "172b11bd-4fe6-4402-995a-8438183fb97c",
|
||||
"importer": "folder",
|
||||
"isBundle": false,
|
||||
"bundleName": "",
|
||||
"priority": 1,
|
||||
"compressionType": {},
|
||||
"optimizeHotUpdate": {},
|
||||
"inlineSpriteFrames": {},
|
||||
"isRemoteBundle": {},
|
||||
"subMetas": {}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"ver": "1.1.3",
|
||||
"uuid": "558d0186-975f-436c-a511-8da29f94706a",
|
||||
"importer": "folder",
|
||||
"isBundle": false,
|
||||
"bundleName": "",
|
||||
"priority": 1,
|
||||
"compressionType": {},
|
||||
"optimizeHotUpdate": {},
|
||||
"inlineSpriteFrames": {},
|
||||
"isRemoteBundle": {},
|
||||
"subMetas": {}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"ver": "1.1.3",
|
||||
"uuid": "c01f982c-e835-44dd-b0cf-548cd8576641",
|
||||
"importer": "folder",
|
||||
"isBundle": false,
|
||||
"bundleName": "",
|
||||
"priority": 1,
|
||||
"compressionType": {},
|
||||
"optimizeHotUpdate": {},
|
||||
"inlineSpriteFrames": {},
|
||||
"isRemoteBundle": {},
|
||||
"subMetas": {}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"ver": "1.1.3",
|
||||
"uuid": "af596299-d697-4fab-9ec1-7e007923d861",
|
||||
"importer": "folder",
|
||||
"isBundle": false,
|
||||
"bundleName": "",
|
||||
"priority": 1,
|
||||
"compressionType": {},
|
||||
"optimizeHotUpdate": {},
|
||||
"inlineSpriteFrames": {},
|
||||
"isRemoteBundle": {},
|
||||
"subMetas": {}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"ver": "1.1.3",
|
||||
"uuid": "024d8834-fe15-47d6-950d-dc4eb4a3d9fa",
|
||||
"importer": "folder",
|
||||
"isBundle": false,
|
||||
"bundleName": "",
|
||||
"priority": 1,
|
||||
"compressionType": {},
|
||||
"optimizeHotUpdate": {},
|
||||
"inlineSpriteFrames": {},
|
||||
"isRemoteBundle": {},
|
||||
"subMetas": {}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"ver": "1.1.3",
|
||||
"uuid": "e7085468-b57f-461d-b207-9f212945c7f0",
|
||||
"importer": "folder",
|
||||
"isBundle": false,
|
||||
"bundleName": "",
|
||||
"priority": 1,
|
||||
"compressionType": {},
|
||||
"optimizeHotUpdate": {},
|
||||
"inlineSpriteFrames": {},
|
||||
"isRemoteBundle": {},
|
||||
"subMetas": {}
|
||||
}
|
||||
@@ -14,10 +14,25 @@ for (const scope of ['daily','weekly']) test(`${scope} reward requests send only
|
||||
vm.runInNewContext(code,context);
|
||||
context.Utils.POST=(endpoint,fields)=>{request={endpoint,fields};};
|
||||
context.Utils.getDailyQuestReward(scope==='weekly'?'weekly_35':'pass_1',()=>{},scope);
|
||||
assert.equal(request.endpoint,'getTaskReward');
|
||||
assert.equal(request.endpoint,'getTaskRewardV2');
|
||||
const own=scope==='weekly'?'rewardId':'taskId', other=scope==='weekly'?'taskId':'rewardId';
|
||||
assert.equal(Object.hasOwn(request.fields,other),false);
|
||||
assert.equal(request.fields[own],scope==='weekly'?'weekly_35':'pass_1');
|
||||
const form=Object.keys(request.fields).map(key=>key+'='+encodeURIComponent(request.fields[key])).join('&');
|
||||
assert.equal(form.includes('undefined'),false);
|
||||
});
|
||||
|
||||
test('task reads and progress saves use the V2 route while preserving the request payload',()=>{
|
||||
const start = source.indexOf(' static getDailyQuestInfo(');
|
||||
const code = stripTypeScriptTypes('class Utils {\n'+source.slice(start,end)+'\n}\nglobalThis.Utils=Utils;');
|
||||
const requests=[];
|
||||
const task={version:2,dailyTasks:[],weeklyRewards:[]};
|
||||
const context={wx:{},console:{log(){}},cc:{fx:{StorageMessage:{getStorage:()=> 'test-user'},GameConfig:{GM_INFO:{tasks:task}}}}};
|
||||
vm.runInNewContext(code,context);
|
||||
context.Utils.POST=(endpoint,fields)=>requests.push({endpoint,fields});
|
||||
context.Utils.getDailyQuestInfo(()=>{});
|
||||
context.Utils.setDailyQuestInfo(()=>{},task);
|
||||
assert.deepEqual(requests.map(request=>request.endpoint),['dayTaskInfoV2','dayTaskInfoV2']);
|
||||
assert.deepEqual(requests.map(request=>request.fields.action),['read','save']);
|
||||
assert.deepEqual(JSON.parse(requests[1].fields.task),task);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user