fix: 修复七日活动道具同步
This commit is contained in:
parent
e1ab800383
commit
3d5dafe71c
|
|
@ -81,7 +81,7 @@ export default class SevenDayGiftApi {
|
||||||
}, callback);
|
}, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static saveDebugProps(propData: object, callback: (response: SevenDayResponse<any>) => void) {
|
public static saveProps(propData: object, callback: (response: SevenDayResponse<any>) => void) {
|
||||||
this.post("userProp", {
|
this.post("userProp", {
|
||||||
uid: this.getUid(),
|
uid: this.getUid(),
|
||||||
action: "save",
|
action: "save",
|
||||||
|
|
@ -90,6 +90,10 @@ export default class SevenDayGiftApi {
|
||||||
}, callback);
|
}, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static saveDebugProps(propData: object, callback: (response: SevenDayResponse<any>) => void) {
|
||||||
|
this.saveProps(propData, callback);
|
||||||
|
}
|
||||||
|
|
||||||
public static saveDebugPower(userPowerTime: number, callback: (response: SevenDayResponse<any>) => void) {
|
public static saveDebugPower(userPowerTime: number, callback: (response: SevenDayResponse<any>) => void) {
|
||||||
this.post("userPower", {
|
this.post("userPower", {
|
||||||
uid: this.getUid(),
|
uid: this.getUid(),
|
||||||
|
|
|
||||||
|
|
@ -35,34 +35,53 @@ export default class SevenDayGiftReward {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.grantCommonRewards(coin, hammer, freeze, magic, infiniteHealth);
|
this.grantCommonRewards(coin, hammer, freeze, magic, infiniteHealth, (commonSuccess: boolean, commonMessage?: string) => {
|
||||||
this.saveCats(cats, 0, (success: boolean, message?: string) => {
|
if (!commonSuccess) {
|
||||||
if (!success) {
|
callback(false, commonMessage);
|
||||||
callback(false, message);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.markProcessed(result.claimId);
|
this.saveCats(cats, 0, (success: boolean, message?: string) => {
|
||||||
callback(true);
|
if (!success) {
|
||||||
|
callback(false, message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.markProcessed(result.claimId);
|
||||||
|
callback(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static grantCommonRewards(coin: number, hammer: number, freeze: number, magic: number, infiniteHealth: number) {
|
private static grantCommonRewards(
|
||||||
|
coin: number,
|
||||||
|
hammer: number,
|
||||||
|
freeze: number,
|
||||||
|
magic: number,
|
||||||
|
infiniteHealth: number,
|
||||||
|
callback: (success: boolean, message?: string) => void,
|
||||||
|
) {
|
||||||
if (coin > 0) {
|
if (coin > 0) {
|
||||||
cc.fx.GameTool.changeCoin(coin);
|
cc.fx.GameTool.changeCoin(coin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let propData = null;
|
||||||
if (hammer > 0 || freeze > 0 || magic > 0) {
|
if (hammer > 0 || freeze > 0 || magic > 0) {
|
||||||
const info = cc.fx.GameConfig.GM_INFO;
|
const info = cc.fx.GameConfig.GM_INFO;
|
||||||
info.hammerAmount = (Number(info.hammerAmount) || 0) + hammer;
|
info.hammerAmount = (Number(info.hammerAmount) || 0) + hammer;
|
||||||
info.freezeAmount = (Number(info.freezeAmount) || 0) + freeze;
|
info.freezeAmount = (Number(info.freezeAmount) || 0) + freeze;
|
||||||
info.magicAmount = (Number(info.magicAmount) || 0) + magic;
|
info.magicAmount = (Number(info.magicAmount) || 0) + magic;
|
||||||
|
propData = {
|
||||||
|
freeze: info.freezeAmount,
|
||||||
|
hammer: info.hammerAmount,
|
||||||
|
magic_wand: info.magicAmount,
|
||||||
|
};
|
||||||
cc.fx.StorageMessage.setStorage("prop", {
|
cc.fx.StorageMessage.setStorage("prop", {
|
||||||
hammerAmount: info.hammerAmount,
|
hammerAmount: info.hammerAmount,
|
||||||
freezeAmount: info.freezeAmount,
|
freezeAmount: info.freezeAmount,
|
||||||
magicAmount: info.magicAmount,
|
magicAmount: info.magicAmount,
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
});
|
});
|
||||||
cc.fx.GameTool.setUserProp(0, 0, () => { });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (infiniteHealth > 0) {
|
if (infiniteHealth > 0) {
|
||||||
cc.fx.GameTool.setUserPowerTime(infiniteHealth, "seven_day_gift");
|
cc.fx.GameTool.setUserPowerTime(infiniteHealth, "seven_day_gift");
|
||||||
}
|
}
|
||||||
|
|
@ -72,6 +91,19 @@ export default class SevenDayGiftReward {
|
||||||
if (home && home.updateCoin) {
|
if (home && home.updateCoin) {
|
||||||
home.updateCoin();
|
home.updateCoin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!propData) {
|
||||||
|
callback(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SevenDayGiftApi.saveProps(propData, response => {
|
||||||
|
if (!response || response.code !== 1) {
|
||||||
|
callback(false, response && response.msg ? response.msg : "道具同步失败");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callback(true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static saveCats(cats: number[], index: number, callback: (success: boolean, message?: string) => void) {
|
private static saveCats(cats: number[], index: number, callback: (success: boolean, message?: string) => void) {
|
||||||
|
|
|
||||||
|
|
@ -182,9 +182,9 @@ cc.fx.StorageMessage.getStorage("uid")
|
||||||
| 后端类型 | 前端处理 |
|
| 后端类型 | 前端处理 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `coin` | `cc.fx.GameTool.changeCoin()` |
|
| `coin` | `cc.fx.GameTool.changeCoin()` |
|
||||||
| `hammer` | 增加 `GM_INFO.hammerAmount`,保存 `prop`,调用 `setUserProp` |
|
| `hammer` | 增加 `GM_INFO.hammerAmount`,保存 `prop`,通过 `SevenDayGiftApi.saveProps()` 同步 `/userProp` |
|
||||||
| `freeze` | 增加 `GM_INFO.freezeAmount`,保存 `prop`,调用 `setUserProp` |
|
| `freeze` | 增加 `GM_INFO.freezeAmount`,保存 `prop`,通过 `SevenDayGiftApi.saveProps()` 同步 `/userProp` |
|
||||||
| `magic_wand` | 增加 `GM_INFO.magicAmount`,保存 `prop`,调用 `setUserProp` |
|
| `magic_wand` | 增加 `GM_INFO.magicAmount`,保存 `prop`,通过 `SevenDayGiftApi.saveProps()` 同步 `/userProp` |
|
||||||
| `infinite_health` | 调用 `setUserPowerTime(seconds, "seven_day_gift")` |
|
| `infinite_health` | 调用 `setUserPowerTime(seconds, "seven_day_gift")` |
|
||||||
| `cat_skin` | 使用 `itemId` 调用 `setCatArr?action=save` |
|
| `cat_skin` | 使用 `itemId` 调用 `setCatArr?action=save` |
|
||||||
|
|
||||||
|
|
@ -272,7 +272,7 @@ hammer
|
||||||
- `/userProp?action=read`。
|
- `/userProp?action=read`。
|
||||||
- `/userPower?action=read`。
|
- `/userPower?action=read`。
|
||||||
|
|
||||||
领取时产生的 `signInClaim` 和 `setCatArr` 请求也会自动进入记录。面板最多保存 120 条记录,按最新记录在上方展示,内容区域支持垂直滚动。
|
领取时产生的 `signInClaim`、`userProp` 和 `setCatArr` 请求也会自动进入记录。普通道具必须等待 `userProp` 返回 `code=1` 后,才能将本次 `claimId` 标记为前端处理完成。面板最多保存 120 条记录,按最新记录在上方展示,内容区域支持垂直滚动。
|
||||||
|
|
||||||
### 3.8 Prefab 和图片资源
|
### 3.8 Prefab 和图片资源
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user