hy-farm/home/web/game/js/main/02-startup-proxies.js
2026-05-07 20:10:54 +08:00

923 lines
31 KiB
JavaScript

var SceneNotify = class SceneNotify {
constructor() {}
static OPEN_LOGIN = "SceneNotify_OPEN_LOGIN";
static CLOSE_LOGIN = "SceneNotify_CLOSE_LOGIN";
static CLOSE_LOADING = "SceneNotify_CLOSE_LOADING";
static OPEN_CREATEROLE = "SceneNotify_OPEN_CREATEROLE";
static CLOSE_CREATEROLE = "SceneNotify_CLOSE_CREATEROLE";
static OPEN_OTHER_GAME = "SceneNotify_OPEN_OTHER_GAME";
static OPEN_MINE_GAME = "SceneNotify_OPEN_MINE_GAME";
static BACK_MINE_GAME = "SceneNotify_BACK_MINE_GAME";
static CLOSE_GAME = "SceneNotify_CLOSE_GAME";
static GAME_NEXT_QUESTION = "GAME_NEXT_QUESTION";
static CLOSE_TOUCH_GROUP = "CLOSE_TOUCH_GROUP";
static OPEN_SAY = "OPEN_SAY";
static CLOSE_SAY = "CLOSE_SAY";
};
__reflect(SceneNotify.prototype, "SceneNotify");
var LoadingUI = class LoadingUI extends egret.Sprite {
constructor() {
super();
}
setProgress(t, e) {}
};
__reflect(LoadingUI.prototype, "LoadingUI");
var game;
!(function (game) {
const ControllerPrepCommand = class ControllerPrepCommand extends puremvc.SimpleCommand {
constructor() {
super();
}
execute(e) {
this.facade.registerCommand(ClientNotify.GO_OTHER_FARM, game.GoOtherFarmCommand);
}
};
((game.ControllerPrepCommand = ControllerPrepCommand),
__reflect(ControllerPrepCommand.prototype, "game.ControllerPrepCommand", [
"puremvc.ICommand",
"puremvc.INotifier"
]));
})(game || (game = {}));
var game;
!(function (game) {
const GoOtherFarmCommand = class GoOtherFarmCommand extends puremvc.SimpleCommand {
constructor() {
super();
}
execute(t) {
const e = this,
i = t.getBody().uid,
n = GameConfig.SERVER_PATH + "interaction/get-other-user-info";
Global.netProxy.sendRequest(
n,
{
be_user_id: i
},
function (t) {
return 0 !== t.status
? void TipsUtils.showErrorCodeTips(t.status)
: (Global.otherPlayerProxy.setPlayerData(t.data),
Global.otherPlayerProxy.setPlayerLandData(t.data),
void e.facade.sendNotification(SceneNotify.OPEN_OTHER_GAME));
}
);
}
static NAME = "GoOtherFarmCommand";
};
((game.GoOtherFarmCommand = GoOtherFarmCommand),
__reflect(GoOtherFarmCommand.prototype, "game.GoOtherFarmCommand", ["puremvc.ICommand", "puremvc.INotifier"]));
})(game || (game = {}));
var game;
!(function (game) {
const ModelPrepCommand = class ModelPrepCommand extends puremvc.SimpleCommand {
constructor() {
super();
}
execute(e) {
const i = [
game.NetProxy,
game.PlayerProxy,
game.OtherPlayerProxy,
game.WeixinProxy,
game.AudioProxy,
game.GameProxy
],
n = this;
_.forEach(i, function (t, e) {
const a = new i[e]();
(n.facade.registerProxy(a), a && a.init && a.init());
});
}
};
((game.ModelPrepCommand = ModelPrepCommand),
__reflect(ModelPrepCommand.prototype, "game.ModelPrepCommand", ["puremvc.ICommand", "puremvc.INotifier"]));
})(game || (game = {}));
var game;
!(function (game) {
const StartupCommand = class StartupCommand extends puremvc.MacroCommand {
constructor() {
super();
}
initializeMacroCommand() {
(this.addSubCommand(game.ControllerPrepCommand),
this.addSubCommand(game.ModelPrepCommand),
this.addSubCommand(game.ViewPrepCommand));
}
};
((game.StartupCommand = StartupCommand), __reflect(StartupCommand.prototype, "game.StartupCommand"));
})(game || (game = {}));
var game;
!(function (game) {
const ViewPrepCommand = class ViewPrepCommand extends puremvc.SimpleCommand {
constructor() {
super();
}
execute(e) {
(this.facade.registerMediator(new game.AlertMediator()),
this.facade.registerMediator(new game.LogoMediator()),
this.facade.registerMediator(new game.RegisterMediator()));
}
};
((game.ViewPrepCommand = ViewPrepCommand),
__reflect(ViewPrepCommand.prototype, "game.ViewPrepCommand", ["puremvc.ICommand", "puremvc.INotifier"]));
})(game || (game = {}));
var game;
!(function (game) {
const AudioProxy = class AudioProxy extends puremvc.Proxy {
constructor() {
super(AudioProxy.NAME);
this.soundOpen = !0;
}
init() {
Global.audioProxy = this;
const t = egret.localStorage.getItem("farm1.sound");
this.isOpen = t && "0" === t ? !1 : !0;
}
setSoundOpen(t) {
this.soundOpen = t;
}
closeBgMusic() {
this.isOpen && this.channel && (this.channel.stop(), (this.backgroundSound = null));
}
setVolice(t) {
this.moveChannel && (this.moveChannel.volume = t);
}
startBgMusic() {
this.isOpen &&
(this.backgroundSound ||
((this.backgroundSound = RES.getRes("background_mp3")),
this.channel && (this.channel.stop(), (this.channel = null)),
(this.channel = this.backgroundSound.play(0, -1))));
}
openSound(t) {
if (((this.isOpen = t), t)) {
if (this.channel) return;
((this.backgroundSound = RES.getRes("background_mp3")),
this.backgroundSound && ((this.channel = this.backgroundSound.play(0, -1)), (this.channel.volume = 1)));
} else (this.channel && this.channel.stop(), (this.channel = null));
}
playSound(t) {
if (this.soundOpen) {
const e = RES.getRes(t);
e && e.play(0, 1);
}
}
playSoundCount(t, e, i) {
if ((void 0 === i && (i = 1), this.isOpen)) {
const n = RES.getRes(t);
((this.moveChannel = n.play(0, e)), (this.moveChannel.volume = i));
}
}
static NAME = Proxy.AUDIO_PROXY;
};
((game.AudioProxy = AudioProxy),
__reflect(AudioProxy.prototype, "game.AudioProxy", ["puremvc.IProxy", "puremvc.INotifier"]));
})(game || (game = {}));
var game;
!(function (game) {
const GameProxy = class GameProxy extends ResourceProxyBase {
constructor() {
super(GameProxy.NAME);
this.allShopItemDatas = [];
}
init() {
Global.gameProxy = this;
}
getGameConfigJson(t) {
const e = this;
Global.netProxy.sendRequest(
GameConfig.SERVER_PATH + "comm/game-config",
{
msg: 123
},
function (i) {
0 === i.status
? ((e.gameConfig = i.data || {}), e.normalizeGameConfig(), e.initShopItemDatas(), t && t())
: Global.alertMediator.addAlert("获取游戏配置失败,请重新打开游戏!");
}
);
}
normalizeGameConfig() {
(this.ensureConfigTable(game.TabelName.player_level),
this.ensureConfigTable(game.TabelName.store_list),
this.ensureConfigTable(game.TabelName.item_list),
this.ensureConfigTable(game.TabelName.farm_level),
this.ensureConfigTable(game.TabelName.land_extend),
this.ensureConfigTable(game.TabelName.land_upgrade),
this.ensureConfigTable(game.TabelName.crop_list),
this.ensureConfigTable(game.TabelName.common),
this.ensureConfigTable(game.TabelName.txt_list),
this.ensureRequiredItemConfigs(),
this.ensurePlayerLevelConfigs(),
this.ensureFarmLevelConfigs(),
this.ensureLandExtendConfigs(),
this.ensureLandUpgradeConfigs());
}
ensureConfigTable(tableName) {
return this.gameConfig[tableName] || (this.gameConfig[tableName] = {});
}
fillMissingConfigFields(target, defaults) {
for (const fieldName in defaults)
(void 0 !== target[fieldName] && null !== target[fieldName] && "" !== target[fieldName]) ||
(target[fieldName] = defaults[fieldName]);
return target;
}
ensureRequiredItemConfigs() {
const itemList = this.ensureConfigTable(game.TabelName.item_list),
requiredItems = {
105001: {
id: 105001,
type1: 4,
type2: 1000,
name: "钻石",
graphical_id: 3001,
player_level: 1,
sell_gold: 0,
effect_id: 0,
desc: "本地推断的钻石配置"
},
105002: {
id: 105002,
type1: 4,
type2: 1001,
name: "金币",
graphical_id: 3002,
player_level: 1,
sell_gold: 0,
effect_id: 0,
desc: "本地推断的金币配置"
},
201000: {
id: 201000,
type1: 2,
type2: 14,
name: "石材",
graphical_id: 8001,
player_level: 1,
sell_gold: 0,
effect_id: 0,
desc: "本地推断的石材配置"
},
201001: {
id: 201001,
type1: 2,
type2: 15,
name: "钢材",
graphical_id: 8002,
player_level: 1,
sell_gold: 0,
effect_id: 0,
desc: "本地推断的钢材配置"
}
};
for (const itemId in requiredItems)
itemList[itemId]
? this.fillMissingConfigFields(itemList[itemId], requiredItems[itemId])
: (itemList[itemId] = requiredItems[itemId]);
}
ensurePlayerLevelConfigs() {
const playerLevels = this.ensureConfigTable(game.TabelName.player_level);
let lastExp = 0;
for (let level = 1; level <= 60; level++) {
const levelConfig = playerLevels[level] || (playerLevels[level] = {});
(this.fillMissingConfigFields(levelConfig, {
id: level,
exp: lastExp + level
}),
(levelConfig.id = int(levelConfig.id) || level),
(levelConfig.exp = int(levelConfig.exp) || lastExp + level),
(lastExp = levelConfig.exp));
}
}
ensureFarmLevelConfigs() {
const farmLevels = this.ensureConfigTable(game.TabelName.farm_level);
let previousConfig = null;
for (let level = 1; level <= 12; level++) {
const farmConfig = farmLevels[level] || (farmLevels[level] = {});
this.fillMissingConfigFields(farmConfig, {
id: level,
player_level: previousConfig ? int(previousConfig.player_level) + 5 : level,
output: previousConfig ? int(previousConfig.output) + 1 : 1,
add_exp: previousConfig ? int(previousConfig.add_exp) + 5 : level,
item_id: previousConfig ? previousConfig.item_id : Const.GOLD_ID + ":0"
});
((farmConfig.id = int(farmConfig.id) || level),
(farmConfig.player_level = int(farmConfig.player_level)),
(farmConfig.output = int(farmConfig.output)),
(farmConfig.add_exp = int(farmConfig.add_exp)),
(farmConfig.item_id = game.CostUtils.normalizeCostString(
farmConfig.item_id,
previousConfig ? previousConfig.item_id : Const.GOLD_ID + ":0"
)),
(previousConfig = farmConfig));
}
}
ensureLandExtendConfigs() {
const landExtendConfigs = this.ensureConfigTable(game.TabelName.land_extend);
let previousConfig = null;
for (let landCount = 1; landCount <= 12; landCount++) {
const extendConfig = landExtendConfigs[landCount] || (landExtendConfigs[landCount] = {});
this.fillMissingConfigFields(extendConfig, {
id: landCount,
player_level: previousConfig ? int(previousConfig.player_level) : 1,
gold: previousConfig ? int(previousConfig.gold) + 10000 : 0
});
((extendConfig.id = int(extendConfig.id) || landCount),
(extendConfig.player_level = int(extendConfig.player_level)),
(extendConfig.gold = int(extendConfig.gold)),
(previousConfig = extendConfig));
}
}
ensureLandUpgradeConfigs() {
const landUpgradeConfigs = this.ensureConfigTable(game.TabelName.land_upgrade);
let configValues = _.values(landUpgradeConfigs),
maxId = 0,
fallbackConfig = configValues[0] || null;
configValues.forEach(function (landConfig) {
maxId = Math.max(maxId, int(landConfig.id));
});
for (let landLevel = 1; landLevel <= 3; landLevel++)
for (let landPosition = 1; landPosition <= 12; landPosition++) {
configValues = _.values(landUpgradeConfigs);
let landConfig = configValues.find(function (configItem) {
return int(configItem.level) == landLevel && int(configItem.position) == landPosition;
});
if (!landConfig) {
maxId++;
landConfig = landUpgradeConfigs[maxId] = {
id: maxId,
level: landLevel,
position: landPosition
};
}
this.fillMissingConfigFields(landConfig, {
id: int(landConfig.id) || maxId,
level: landLevel,
position: landPosition,
player_level: landLevel,
item_id: fallbackConfig ? fallbackConfig.item_id : Const.GOLD_ID + ":0",
output: 10 * landLevel,
add_exp: 10 * landLevel
});
((landConfig.id = int(landConfig.id)),
(landConfig.level = int(landConfig.level) || landLevel),
(landConfig.position = int(landConfig.position) || landPosition),
(landConfig.player_level = int(landConfig.player_level)),
(landConfig.output = int(landConfig.output)),
(landConfig.add_exp = int(landConfig.add_exp)),
(landConfig.item_id = game.CostUtils.normalizeCostString(
landConfig.item_id,
fallbackConfig ? fallbackConfig.item_id : Const.GOLD_ID + ":0"
)),
(fallbackConfig = landConfig));
}
}
getLvConfigByLv(e) {
return this.gameConfig[game.TabelName.player_level][e] || this.gameConfig[game.TabelName.player_level][1];
}
getMaxExpByLv(e) {
return (
e + 1 > 21 && (e = 21),
(this.gameConfig[game.TabelName.player_level][e] || this.gameConfig[game.TabelName.player_level][1]).exp
);
}
getAllShopConfig() {
return this.gameConfig[game.TabelName.store_list] || {};
}
initShopItemDatas() {
const e = this.getAllShopConfig();
for (const i in e)
if (i && "undefined" !== i) {
const n = e[i],
a = new game.ShopItemData(n);
this.allShopItemDatas.push(a);
}
}
getShopConfigByType(t) {
return _.groupBy(this.allShopItemDatas, "type")[t] || [];
}
getCommonConfigById(e) {
return this.gameConfig[game.TabelName.common][e] || {
min: 0,
max: 0
};
}
getPlantConfig(e) {
return new game.PlantConfig(
this.gameConfig[game.TabelName.crop_list][e] || {
id: e,
name: "未知作物" + e,
seedling_id: 1011,
grow_id: 1012,
ripe_id: 1013,
seedling_time: 0,
grow_time: 0,
ripe_time: 0,
item_id: 102001
}
);
}
getPlantConfigByPlantId(e) {
const i = _.groupBy(this.gameConfig[game.TabelName.crop_list], "item_id");
return i[e] ? i[e][0] : this.getPlantConfig(e);
}
getItemImageId(e) {
const i = this.getItemConfig(e);
return i && null != i.graphical_id ? i.graphical_id : 3002;
}
getItemConfig(e) {
const i = this.gameConfig[game.TabelName.item_list] || {};
let n = i[e];
return (
n ||
(n = {
id: e,
type1: 0,
type2: 0,
name: "未知物品" + e,
graphical_id: 3002,
player_level: 1,
sell_gold: 0,
effect_id: 0,
desc: "本地配置缺少该物品"
}),
n
);
}
getLandExtendConfig(e) {
return this.gameConfig[game.TabelName.land_extend][e] || this.gameConfig[game.TabelName.land_extend][1] || {};
}
getTextConfig(e) {
return this.gameConfig[game.TabelName.txt_list][e] || {};
}
getHouseUpgradeConfig(e) {
return this.gameConfig[game.TabelName.farm_level][e] || this.gameConfig[game.TabelName.farm_level][12] || {};
}
getTabelConfigByType(t) {
return this.gameConfig[t] || {};
}
getConfigArrFactory() {
const t = this.gameConfig.factory,
e = [];
for (const i in t) t[i].id <= 15 && e.push(t[i]);
return e;
}
getCurItemArrforFactoryLV(t = 0) {
for (var e = this.getConfigArrFactory(), i = [], n = 0; n < e.length; n++) e[n].level <= t && i.push(e[n]);
return i;
}
getFactoryConfigForID(t) {
return this.gameConfig.factory_upgrade[t];
}
gethechengConfig() {
return this.gameConfig.compose;
}
getCurhechengArrforLV(t) {
const e = this.gethechengConfig(),
i = [];
for (const n in e) e[n].level == t && i.push(e[n]);
return i;
}
getOnlineGiftConfig() {
return this.gameConfig.online_gift;
}
getOnlineGiftConfigForID(t) {
return this.gameConfig.online_gift[t];
}
getLevelGiftConfig() {
return this.gameConfig.player_level_gift || {};
}
getLevelGiftConfigforID(t) {
return this.getLevelGiftConfig()[t];
}
getVipConfig() {
return this.gameConfig.vip_list || {};
}
getVipConfigForID(t) {
return this.getVipConfig()[t] || null;
}
getzyConfig() {
return this.gameConfig.card || {};
}
getzyConfigForID(t) {
return this.getzyConfig()[t] || null;
}
getTaskConfig() {
return this.gameConfig.daily_list || {};
}
getTaskConfigForID(t) {
return this.getTaskConfig()[t] || null;
}
getSignConfig() {
return this.gameConfig.sign || {};
}
getSignConfigForID(t) {
return this.getSignConfig()[t] || null;
}
getBoxConfig() {
return this.gameConfig["case"] || {};
}
getBoxConfigForID(t) {
return this.getBoxConfig()[t] || null;
}
static NAME = "GameProxy";
};
((game.GameProxy = GameProxy), __reflect(GameProxy.prototype, "game.GameProxy"));
})(game || (game = {}));
var game;
!(function (game) {
const NetProxy = class NetProxy extends ResourceProxyBase {
constructor() {
super();
this.callbackList = new HashMap();
this.base64 = window.Base64;
this.lockReq = !1;
this.token = "";
}
init() {
Global.netProxy = this;
}
setToken(t) {
this.token = t;
}
startUnlockTimeout() {
(this.lockTimeOut && (egret.clearTimeout(this.lockTimeOut), (this.lockTimeOut = null)),
egret.setTimeout(
function () {
this.lockReq = !1;
},
this,
2e3
));
}
sendRequest(t, e, i) {
if (!this.lockReq) {
(this.token && e && (e.token = this.token), (this.lockReq = !0));
const n = new egret.URLLoader();
(this.callbackList.set(n.hashCode, i),
(n.dataFormat = egret.URLLoaderDataFormat.TEXT),
n.addEventListener(egret.Event.COMPLETE, this.onPostComplete, this));
const a = new egret.URLRequest(t);
a.method = e ? egret.URLRequestMethod.POST : egret.URLRequestMethod.GET;
const o = JSON.stringify(e);
((a.data = new egret.URLVariables("msg=" + encodeURIComponent(this.base64.encode(o)))),
this.startUnlockTimeout(),
n.load(a));
}
}
sendHttpRequest(t, e, i) {
const n = new egret.HttpRequest();
n.responseType = egret.HttpResponseType.TEXT;
}
onPostComplete(t) {
this.lockReq = !1;
const e = t.currentTarget;
(e.removeEventListener(egret.Event.COMPLETE, this.onPostComplete, this),
e.removeEventListener(egret.IOErrorEvent.IO_ERROR, this.onPostIOError, this));
const i = e.data.replace(/\s/g, ""),
n = JSON.parse(i);
(n && n.data && (n.data = JSON.parse(this.base64.decode(n.data))),
n.hasOwnProperty("server_time") && DateTimer.instance.updateServerTime(1e3 * n.server_time),
this.lockTimeOut && (egret.clearTimeout(this.lockTimeOut), (this.lockTimeOut = null)));
const a = this.callbackList.get(e.hashCode);
(a && (a(n), this.callbackList.remove(e.hashCode)),
n &&
7 === n.status &&
Global.alertMediator.addAlert(GameConfig.ServerCode[7], function () {
window.location.href = window.location.href;
}));
}
onPostIOError(t) {
egret.error("post error : " + t);
}
static NAME = "NetProxy";
};
((game.NetProxy = NetProxy), __reflect(NetProxy.prototype, "game.NetProxy"));
})(game || (game = {}));
var game;
!(function (game) {
const OtherPlayerProxy = class OtherPlayerProxy extends ResourceProxyBase {
constructor() {
super();
this.playerData = {};
this.landData = {};
}
init() {
Global.otherPlayerProxy = this;
}
clearPlayerData() {
((this.playerData = {}), (this.landData = {}));
}
setPlayerData(t) {
((this.playerData = t), (this.playerData.id = t.user_id));
}
getPlayerData() {
return this.playerData;
}
setPlayerDataProperty(t, e) {
this.playerData[t] = e;
}
getLandByIndex(t) {
return this.landData[t];
}
setPlayerLandData(e) {
this.landData = {};
for (let i = e.landList, n = 0; n < i.length; n++)
this.landData[i[n].position] = new game.LandData(i[n].position, i[n]);
}
updateLandData(e, i) {
let n = this.landData[e];
if (n) n.updateData(i);
else {
const a = new game.LandData(e, i);
((this.landData[e] = a), (n = a));
}
game.EventManager.instance.dispatch(SysNotify.OTHER_PLANT_REFRESH, n.landId);
}
};
((game.OtherPlayerProxy = OtherPlayerProxy), __reflect(OtherPlayerProxy.prototype, "game.OtherPlayerProxy"));
})(game || (game = {}));
var game;
!(function (game) {
const PlayerProxy = class PlayerProxy extends ResourceProxyBase {
constructor() {
super();
this.landData = {};
this.uuid = "";
this.wareHouseItemData = {};
}
init() {
Global.playerProxy = this;
}
setPlayerData(t) {
((this.playerData = t), (this.playerData.id = t.user_id));
}
setPlayerDataProperty(t, e) {
this.playerData[t] = e;
}
setPlayerLandData(e) {
this.landData = {};
for (let i = e.landList, n = 0; n < i.length; n++)
this.landData[i[n].position] = new game.LandData(i[n].position, i[n]);
}
changeLandDataToDie(t) {}
updateLandData(e, i) {
let n = this.landData[e];
if (n) n.updateData(i);
else {
const a = new game.LandData(e, i);
((this.landData[e] = a), (n = a));
}
(game.EventManager.instance.dispatch(SysNotify.LAND_REFRESH, n.landId),
game.EventManager.instance.dispatch(SysNotify.PLANT_REFRESH, n.landId),
n.get_exp && this.addExp(n.get_exp));
}
getLandCountByLv(t, e = !1) {
let i = 0;
for (const n in this.landData) {
const a = this.landData[n];
e ? a.landLv >= t && i++ : a.landLv == t && i++;
}
return i;
}
getLandUpDataByLvOrder(e, i) {
for (let n = _.values(Global.gameProxy.gameConfig[game.TabelName.land_upgrade]), a = 0; a < n.length; a++) {
var o = n[a];
if (o.level == e && o.position == i) return new game.LandUpgradeData(o);
}
return new game.LandUpgradeData(o);
}
addExp(e) {
this.playerData.exp += e;
const i = Global.gameProxy.getMaxExpByLv(this.playerData.level);
(this.playerData.exp >= i && ((this.playerData.exp -= i), this.playerData.level++),
game.EventManager.instance.dispatch(SysNotify.USER_EXP_CHANGE));
}
getPlayerStoreHouse(e) {
const i = GameConfig.SERVER_PATH + "store-house",
n = this;
Global.netProxy.sendRequest(
i,
{
msg: 123
},
function (i) {
if (0 === i.status) {
const a = {};
(i.data.forEach(function (e) {
a[e.item_id] = new game.ItemData(e.item_id, e.num);
}),
(n.wareHouseItemData = a),
e && e());
}
}
);
}
wareHouseHas(t) {
return !!this.wareHouseItemData[t];
}
updateWareHouseItem(e, i) {
if ((void 0 === i && (i = 0), i)) {
const n = this.wareHouseItemData[e.item_id];
n ? (n.number += i) : (this.wareHouseItemData[e.item_id] = new game.ItemData(e.item_id, i));
} else this.wareHouseItemData[e.item_id] = new game.ItemData(e.item_id, e.num);
}
sellWareHouseItem(t, e) {
const i = this.wareHouseItemData[t.id];
i && ((i.number -= e), i.number <= 0 && delete this.wareHouseItemData[t.id]);
}
sellWareHouseItem1(itemString) {
const t = this;
game.CostUtils.parseCostString(itemString).forEach(function (costItem) {
costItem.count > 0 && game.CostUtils.deductOwnedAmount(costItem.itemId, costItem.count);
});
game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE);
}
addItem1(itemString, showTips = !0) {
const t = this,
tips = [];
game.CostUtils.parseCostString(itemString).forEach(function (costItem) {
const itemId = costItem.itemId,
count = costItem.count;
if (count <= 0) return;
itemId == Const.DIAMOND_ID
? (t.playerData.gem = int(t.playerData.gem) + count)
: itemId == Const.GOLD_ID
? (t.playerData.gold = int(t.playerData.gold) + count)
: 201000 == itemId
? (t.playerData.stone = int(t.playerData.stone) + count)
: 201001 == itemId
? (t.playerData.steel = int(t.playerData.steel) + count)
: t.updateWareHouseItem({ item_id: itemId }, count);
const config = Global.gameProxy.getItemConfig(itemId);
config && tips.push("获得" + config.name + "X" + count);
});
if (showTips && tips.length > 0) {
let index = 0;
core.TimerManager.instance.addTick(
300,
tips.length,
function () {
TipsUtils.showTipsDownToUp(tips[index]);
index++;
index == tips.length && game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE);
},
this
);
} else game.EventManager.instance.dispatch(SysNotify.TOPLAYER_INFO_UPDATE);
}
getMySkins() {
const t = [];
for (const e in this.wareHouseItemData) {
const i = this.wareHouseItemData[e];
i.config.smallType == SmallType.SKIN && t.push(i);
}
return t;
}
getItemByType(t) {
const e = _.values(this.wareHouseItemData),
i = _.groupBy(e, function (t) {
return t.config && t.config.type;
});
return i[t] ? i[t] : [];
}
getItemBySmallType(t) {
const e = _.values(this.wareHouseItemData),
i = _.groupBy(e, function (t) {
return t.config && t.config.smallType;
});
return i[t] ? i[t] : [];
}
getHasItemByItemId(t) {
return this.wareHouseItemData[t];
}
};
((game.PlayerProxy = PlayerProxy), __reflect(PlayerProxy.prototype, "game.PlayerProxy"));
})(game || (game = {}));
var ThemeAdapter = class ThemeAdapter {
constructor() {}
getTheme(t, e, i, n) {
function a(t) {
e.call(n, t);
}
function o(e) {
e.resItem.url == t && (RES.removeEventListener(RES.ResourceEvent.ITEM_LOAD_ERROR, o, null), i.call(n));
}
(RES.addEventListener(RES.ResourceEvent.ITEM_LOAD_ERROR, o, null),
RES.getResByUrl(t, a, this, RES.ResourceItem.TYPE_TEXT));
}
};
__reflect(ThemeAdapter.prototype, "ThemeAdapter", ["eui.IThemeAdapter"]);
var game;
!(function (game) {
const WeixinProxy = class WeixinProxy extends ResourceProxyBase {
constructor() {
super(WeixinProxy.NAME);
this.shareServerIndex = 0;
this.shareServerURLArr = [GameConfig.SERVER_PATH + "share"];
this.shareData = {};
this.weixinConfig = !1;
}
init() {
Global.weixinProxy = this;
}
config(t = null) {
const e = (Global.playerProxy, Global.netProxy),
i = window.wx,
n = encodeURIComponent(window.location.href.split("#")[0]),
a = this.shareServerURLArr[this.shareServerIndex],
o = {
url: n
},
r = this;
e.sendRequest(a, o, function (t) {
(i.config({
debug: GameConfig.WEIXIN_DEBUG,
appId: t.appId,
timestamp: t.timestamp,
nonceStr: t.nonceStr,
signature: t.signature,
jsApiList: [
"checkJsApi",
"onMenuShareTimeline",
"onMenuShareAppMessage",
"onMenuShareQQ",
"onMenuShareWeibo",
"chooseImage",
"previewImage",
"uploadImage",
"downloadImage"
]
}),
i.ready(function () {
i.checkJsApi({
jsApiList: [
"checkJsApi",
"onMenuShareTimeline",
"onMenuShareAppMessage",
"onMenuShareQQ",
"onMenuShareWeibo",
"chooseImage",
"previewImage",
"uploadImage",
"downloadImage"
],
success: function (e) {
(Mta.getMathH5() && Mta.getMathH5().clickShare("wechat_moments"),
(r.shareURL = t.url),
r.share(),
(r.weixinConfig = !0));
}
});
}),
i.error(function (t) {
(r.shareServerIndex++,
r.shareServerIndex >= r.shareServerURLArr.length ? alert("wx.error: " + JSON.stringify(t)) : r.config());
}));
});
}
share(e = "", i = null) {
const n = Math.floor(_.random(1, 3)),
a = (this.shareData[n], "拼眼力赢红包!一带一路上的寻宝之旅"),
o = window.wx,
r = this.shareURL + encodeURIComponent(e),
s = {
title: a,
desc: "你的眼力有多好,到手的红包有多少",
link: r,
imgUrl:
"https://mmbiz.qlogo.cn/mmbiz_jpg/DSvNbEibEqELrSQE9cRFBUxjcRQicktRGWpEbPmTK7SNATKYomoQt70ZcNVUScpUnT9r0E4dAjwkGdtlQFpia99cw/0?wx_fmt=jpeg"
},
l = {};
for (var h in s) l[h] = s[h];
l.success = function () {
(game.AppFacade.getInstance().sendNotification(SceneNotify.CLOSE_TOUCH_GROUP),
Mta.getMathH5() && Mta.getMathH5().clickShare("wechat_moments"));
const e = GameConfig.SERVER_PATH + "yutong_share";
Global.netProxy.sendRequest(e, {}, function (t) {
1 === t.status ? alert(t.msg) : alert(t.msg);
});
};
const c = {};
for (var h in s) c[h] = s[h];
((c.success = function () {
(game.AppFacade.getInstance().sendNotification(SceneNotify.CLOSE_TOUCH_GROUP),
Mta.getMathH5() && Mta.getMathH5().clickShare("wechat_moments"));
const e = GameConfig.SERVER_PATH + "yutong_share";
Global.netProxy.sendRequest(e, {}, function (t) {
1 === t.status ? alert(t.msg) : alert(t.msg);
});
}),
o.onMenuShareTimeline(l),
o.onMenuShareAppMessage(c),
o.onMenuShareQQ(s),
o.onMenuShareWeibo(s));
}
changeShareText(t) {
this.share(this.shareURL, t);
}
static NAME = "WeixinProxy";
};
((game.WeixinProxy = WeixinProxy), __reflect(WeixinProxy.prototype, "game.WeixinProxy"));
})(game || (game = {}));