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