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YACd,4BAA4B;YAC5B,oDAAoD;YACpD,IAAI;QACR,CAAC;KACJ,CAAA;IAzIU,8BAAI,GAAG,2BAA2B,CAAC;IAFzB,yBAAyB;QAD7C,qCAAY,CAAC,uCAAoB,CAAC;OACd,yBAAyB,CA2I7C;IAAD,gCAAC;KAAA;kBA3IoB,yBAAyB","file":"","sourceRoot":"/","sourcesContent":["import { RegPresenter } from \"../PresenterCCViewFactory\";\r\nimport { ExchangeCodeViewType, ExchangeCodeView, ExchangeCodeViewProps } from \"../view/type/ExChangeCodeView\";\r\nimport { Presenter } from \"../../../common/classbase/PresenterBase\";\r\nimport { HttpRequests } from \"../../network/HttpRequests\";\r\nimport { GameModelManager } from \"../../model/GameModelManager\";\r\nimport { GameConstData } from \"../../../common/gameplay/gamedata/GameConstData\";\r\nimport { UIManager } from \"../../../common/gameplay/managers/UIManager\";\r\nimport { GameTextData } from \"../../../common/gameplay/gamedata/GameTextData\";\r\nimport GameDotMgr from \"../../GameDotMgr\";\r\nimport { SDK } from \"simba-sdk\";\r\nimport UnlockSpecialPlotEventManager from \"../../model/UnlockSpecialPlotEventManager\";\r\nimport CDKeyEventManager from \"../../model/CDKeyEventManager\";\r\nimport { exchangeCode } from \"simba-sdk-exchangecode\";\r\nimport { ExchangeErrorCode } from \"simba-sdk-exchangecode/dist/ExchangeCodeClassBase\";\r\nimport { GameConfig } from \"../../../GameConfig\";\r\n\r\ninterface ExchangeCodeParam {\r\n titletxt: string;\r\n contenttxt: string;\r\n}\r\n@RegPresenter(ExchangeCodeViewType)\r\nexport default class ExchangeCodeViewPresenter extends Presenter<ExchangeCodeParam, ExchangeCodeView>\r\n{\r\n static uuid = \"ExchangeCodeViewPresenter\";\r\n\r\n private _viewProps: ExchangeCodeViewProps;\r\n\r\n constructor() {\r\n super();\r\n this._viewProps = {\r\n onActionClick: this.onActionClickCallback\r\n };\r\n }\r\n\r\n onOpen(param: ExchangeCodeParam) {\r\n super.onOpen(param);\r\n this._view.setProps(this._viewProps);\r\n this.view.setContentTxt(param.titletxt, param.contenttxt);\r\n this.view.showBanner(false);\r\n }\r\n\r\n onClose() {\r\n super.onClose();\r\n this.view.setContentTxt(\"\", \"\");\r\n }\r\n\r\n onActionClickCallback = async (ret: boolean, cdkey: string) => {\r\n if (!cdkey || \"\" === cdkey.trim()) {\r\n return;\r\n }\r\n GameDotMgr.getInstance().dotClickUI(\"exchange_code\");\r\n let sdkExchangeCode = true;\r\n let toastStr = \"\";\r\n if (sdkExchangeCode) {\r\n let ret = await exchangeCode(cdkey);\r\n if (GameConfig.debug) console.log(\"SDKExchangeCode ret: \", ret);\r\n switch (ret.errorCode) {\r\n case ExchangeErrorCode.Invalid:\r\n {\r\n toastStr = \"兑换码无效\";\r\n if (GameConfig.debug) console.log(\"SDKExchangeCode Invalid, toastStr: \", toastStr);\r\n UIManager.showToast(toastStr);\r\n }\r\n break;\r\n case ExchangeErrorCode.OK:\r\n {\r\n if (ret.props && 0 !== ret.props.length) {\r\n let player = GameModelManager.getPlayerData();\r\n for (let i = 0; i < ret.props.length; i++) {\r\n let p = ret.props[i];\r\n // player.addProps(parseInt(p.id + ''), parseInt(p.num + ''));\r\n let id = Number.parseInt(p.id + '');\r\n let count = Number.parseInt(p.num + '');\r\n if (id >= GameConstData.GAME_ITEM_AND_SPECIAL_PLOT_ID && id < 1000) {\r\n let itemId = Math.floor(id / GameConstData.GAME_ITEM_AND_SPECIAL_PLOT_ID);\r\n let specialPlotId = id - GameConstData.GAME_ITEM_AND_SPECIAL_PLOT_ID * itemId;\r\n UnlockSpecialPlotEventManager.getInstance().cdKeyUnlockSpecialPlot(specialPlotId, itemId);\r\n } else if (id === GameConstData.UNLOCK_PLOT_WITHOUT_AD) {\r\n CDKeyEventManager.getInstance().cdKeyRemovePlotAD();\r\n } else if (id >= GameConstData.CHANGE_ROLE_LIKE && id < 3000) {\r\n let roleId = id - GameConstData.CHANGE_ROLE_LIKE;\r\n CDKeyEventManager.getInstance().changeRoleLike(roleId, count);\r\n }\r\n }\r\n GameModelManager.UpdatePlayerData.emit();\r\n }\r\n }\r\n break;\r\n case ExchangeErrorCode.TimeOut:\r\n {\r\n toastStr = \"兑换码已过期!\";\r\n if (GameConfig.debug) console.log(\"SDKExchangeCode TimeOut, toastStr: \", toastStr);\r\n UIManager.showToast(toastStr);\r\n }\r\n break;\r\n case ExchangeErrorCode.Used:\r\n {\r\n toastStr = \"兑换码已经兑换过了\";\r\n if (GameConfig.debug) console.log(\"SDKExchangeCode Used, toastStr: \", toastStr);\r\n UIManager.showToast(toastStr);\r\n }\r\n break;\r\n case ExchangeErrorCode.ScoreWeak:\r\n {\r\n toastStr = \"积分不足\";\r\n if (GameConfig.debug) console.log(\"SDKExchangeCode Used, toastStr: \", toastStr);\r\n UIManager.showToast(toastStr);\r\n }\r\n break;\r\n }\r\n } else {\r\n if (ret) {\r\n let ret = await HttpRequests.exchangeCDKEY(cdkey) as any;\r\n console.log(\"current ret is\" + JSON.stringify(ret));\r\n if (ret.code === \"0\") {\r\n for (let i = 0; i < ret.obj.props.length; i++) {\r\n let data = ret.obj.props[i];\r\n let id = Number.parseInt(data.prop_id);\r\n let count = Number.parseInt(data.count);\r\n if (id >= GameConstData.GAME_ITEM_AND_SPECIAL_PLOT_ID && id < 1000) {\r\n let itemId = Math.floor(id / GameConstData.GAME_ITEM_AND_SPECIAL_PLOT_ID);\r\n let specialPlotId = id - GameConstData.GAME_ITEM_AND_SPECIAL_PLOT_ID * itemId;\r\n UnlockSpecialPlotEventManager.getInstance().cdKeyUnlockSpecialPlot(specialPlotId, itemId);\r\n } else if (id === GameConstData.UNLOCK_PLOT_WITHOUT_AD) {\r\n CDKeyEventManager.getInstance().cdKeyRemovePlotAD();\r\n //兑换码兑换成功打点\r\n if (SDK.getLoginInfo()!.playerId) {\r\n GameDotMgr.getInstance().dotExchangeCodeSuccess(SDK.getLoginInfo()!.playerId, GameConstData.UNLOCK_PLOT_WITHOUT_AD.toString());\r\n }\r\n } else if (id >= GameConstData.CHANGE_ROLE_LIKE && id < 3000) {\r\n let roleId = id - GameConstData.CHANGE_ROLE_LIKE;\r\n CDKeyEventManager.getInstance().changeRoleLike(roleId, count);\r\n }\r\n }\r\n GameModelManager.UpdatePlayerData.emit();\r\n } else if (ret.code === \"104001\") {//错误的验证码\r\n let content = GameModelManager.getLanguageTxt(GameTextData.TEXT_CDKEYINVALID_VALUE);\r\n UIManager.showToast(content);\r\n } else if (ret.code === \"104002\") {//已经领过了\r\n let content = GameModelManager.getLanguageTxt(GameTextData.TEXT_CDKEYHADEXCHANGED_VALUE);\r\n UIManager.showToast(content);\r\n } else {//其他\r\n let content = GameModelManager.getLanguageTxt(GameTextData.TEXT_CDKEYINVALID_VALUE);\r\n UIManager.showToast(content);\r\n }\r\n }\r\n }\r\n }\r\n\r\n addSkin(itemId: number) {\r\n // let item = ConfigManager.getConfig(itemConfig, itemId);\r\n // let splitArr: string[] = item.icon.split(\"_\");\r\n // let roleId = parseInt(splitArr[0]);\r\n // let skinId = parseInt(splitArr[1]);\r\n // let role = GameModelManager.getRoleData(roleId);\r\n // if (role) {\r\n // role.addSkin(skinId);\r\n // GameModelManager.addSkinItemToRecord(itemId);\r\n // }\r\n }\r\n}"]}