Files
fc/dev/project/library/imports/44/44767801-3557-437f-b377-655c19f28a62.js
T
2026-05-24 10:21:26 +08:00

259 lines
8.8 KiB
JavaScript

"use strict";
cc._RF.push(module, '44767gBNVdDf7N3ZVwZ8opi', 'cmp.holy.pray.wnd');
// Scripts/mod/pray/cmp/cmp.holy.pray.wnd.js
"use strict";
var BridgeWindow = require("bridge.window");
var BackPackController = require("backpack_controller");
var PrayMod = require("pray.mod");
var TipsController = require("tips_controller");
cc.Class({
"extends": BridgeWindow,
properties: {
luckyHolys: {
"default": [],
type: cc.Node
},
nodRewards: {
"default": null,
type: cc.Node
},
// :{ default: [], type: cc.Node },
rewards: {
"default": [],
type: cc.Node
},
nodScore: {
"default": null,
type: cc.Node
},
nameLen: 0
},
onEnable: function onEnable() {
// 视图监听
this.vbind([["HolyPray", this.dealPray.bind(this)]]);
},
// 隐藏
onDisable: function onDisable() {
// 视图监听解除
this.vunbind();
// 事件监听释放
},
// 重载:参数打开
onOpenConfigs: function onOpenConfigs(_params) {
var pray = PrayMod.getInstance();
var score = pray.getScore();
nx.gui.setString(this.nodScore, "txt", nx.text.format("ScoreMax", score));
this.score = score;
},
// 重载:关闭前
onPreClosed: function onPreClosed() {},
// 重载:参数打开
dealPray: function dealPray(_data) {
var _this = this;
this.prayInfos = _data;
this.prayInfos.forEach(function (_pray) {
if (_pray.is_open == 1) {
_this.nowPrayInfos = _pray;
}
});
this.nowPrayInfos.lucky_holy_eqm.sort(Utils.tableUpperSorter("pos"));
//刷新 许愿战斗义肢神装相关
this.freshLuckyHoly();
//刷新 许愿战斗义肢/神装 奖励相关
this.freshLuckyHolyRewards();
},
freshLuckyHoly: function freshLuckyHoly() {
// 刷新 祈禱相關
this.showRewards = [];
var cfgs = game.configs.holy_eqm_lottery_data.data_wish_show;
var wishes = this.nowPrayInfos.lucky_holy_eqm;
if (nx.dt.arrEmpty(wishes)) {
this.luckyHolys.forEach(function (_nod) {
nx.gui.setActive(_nod, "holy", false);
nx.gui.setActive(_nod, "name", false);
nx.gui.setActive(_nod, "empty", true);
});
} else {
for (var i = 0; i < wishes.length; i++) {
var wish = wishes[i];
nx.gui.setActive(this.luckyHolys[wish.pos], "holy", wish.lucky_holy_eqm != 0);
nx.gui.setActive(this.luckyHolys[wish.pos], "empty", wish.lucky_holy_eqm == 0);
nx.gui.setActive(this.luckyHolys[wish.pos], "name", wish.lucky_holy_eqm != 0);
var cfg = cfgs[wish.lucky_holy_eqm];
if (cfg) {
var set = parseInt(cfg.group_id / 100);
var path = cc.path.join("coms/images/eqm_set" + set);
nx.gui.setSpriteFrame(this.luckyHolys[wish.pos], "holy/ico_set", path);
nx.bridge.setIcon(this.luckyHolys[wish.pos], "holy/icon", cfg.icon);
nx.gui.setString(this.luckyHolys[wish.pos], "name/txt", nx.dt.strCut(cfg.name, this.nameLen));
}
}
}
nx.gui.setString(this, "panel/sid", this.nowPrayInfos.lev);
nx.gui.setString(this, "panel/desc/time", nx.text.format("lab_heaven_tips_8", this.nowPrayInfos.baodi_count));
},
freshLuckyHolyRewards: function freshLuckyHolyRewards() {
var _this2 = this;
var BC = BackPackController.getInstance();
var limit = game.configs.holy_eqm_lottery_data.data_group[this.nowPrayInfos.group_id];
var one = nx.gui.find(this.nodRewards, "op/once");
var ten = nx.gui.find(this.nodRewards, "op/ten");
var prog = nx.gui.getComponent(this.nodRewards, "awards/prog", cc.ProgressBar);
var count = Object.keys(game.configs.holy_eqm_lottery_data.data_award[this.nowPrayInfos.group_id]).length;
var total = game.configs.holy_eqm_lottery_data.data_award[this.nowPrayInfos.group_id][count];
if (prog) {
prog.progress = parseFloat(this.nowPrayInfos.all_award_count / total.times);
}
nx.gui.setStringRich(this, "panel/times", nx.text.format("lab_heaven_tips", this.nowPrayInfos.day_count, limit.day_limit_count));
this.mat = limit.loss_item_once[0][0];
// let nodRewards = nx.gui.find( this.nodRewards, )
// 設置寶箱可領取
nx.gui.setString(this.nodRewards, "awards/count/txt", this.nowPrayInfos.all_award_count);
var rewards = game.configs.holy_eqm_lottery_data.data_award[this.nowPrayInfos.group_id];
for (var i in rewards) {
var award = rewards[i];
var nod = this.rewards[i - 1];
if (nod) {
nx.gui.setString(nod, "txt", award.times);
var lay = nx.gui.getComponent(nod, "show", "cmp.item.layout");
if (lay) {
lay.rebuild(award.reward);
}
var data = {
"award_id": i
};
nx.gui.setActive(nod, "get", award.times <= this.nowPrayInfos.all_award_count);
}
}
this.nowPrayInfos.do_awards.forEach(function (_ard) {
var nod = _this2.rewards[_ard.award_id - 1];
nx.gui.setActive(nod, "get", false);
});
var cost = 0;
var canBuyTen = false;
var have = BC.getModel().getItemNumByBid(this.mat);
nx.gui.setActive(one, "cost/info/icon", false);
if (this.nowPrayInfos.free_times == 1) {
cost = nx.text.getKey("btn_battle_fast_fight_free");
} else {
if (have >= limit.loss_item_once[0][1]) {
cost = limit.loss_item_once[0][1];
nx.bridge.setIconS(one, "cost/info/icon", this.mat);
} else {
nx.bridge.setIconS(one, "cost/info/icon", 3);
cost = limit.loss_gold_once;
}
nx.gui.setActive(one, "cost/info/icon", true);
// nx.bridge.setIconS( one, "cost/icon", this.mat );
}
if (have >= limit.loss_item_ten[0][1]) {
canBuyTen = true;
}
nx.gui.setString(one, "cost/info/txt", cost);
nx.bridge.setIconS(ten, "cost/icon", canBuyTen ? this.mat : 3);
nx.gui.setString(ten, "cost/txt", canBuyTen ? limit.loss_item_ten[0][1] : limit.loss_gold_ten);
},
// 添加許願戰鬥義肢
onTouchAddWish: function onTouchAddWish(_idx) {
nx.bridge.createPanel("WndHolyPrayWish", {
group_id: this.nowPrayInfos.group_id,
select: this.nowPrayInfos.lucky_holy_eqm,
focus: parseInt(_idx)
});
},
onTouchShow: function onTouchShow(_idx) {
for (var i = 0; i < this.rewards.length; i++) {
var _nod2 = this.rewards[i];
if (i != _idx) {
nx.gui.setActive(_nod2, "show", false);
}
}
var nod = nx.gui.find(this.rewards[_idx], "show");
nx.gui.setActive(nod, "", !nod.active);
},
onTouchGet: function onTouchGet(_idx) {
var pray = PrayMod.getInstance();
pray.sender25231(this.nowPrayInfos.group_id, _idx);
},
onTouchPray: function onTouchPray(_times) {
var BC = BackPackController.getInstance();
var pray = PrayMod.getInstance();
var have = BC.getModel().getItemNumByBid(this.mat);
var haveDiam = BC.getModel().getItemNumByBid(3);
var canBuyOne = false;
var canBuyTen = false;
var type = 0;
var cfg = game.configs.holy_eqm_lottery_data.data_group[this.nowPrayInfos.group_id];
if (have > 0) {
if (have >= cfg.loss_item_once[0][1] && have < cfg.loss_item_ten[0][1]) {
canBuyOne = true;
canBuyTen = false;
type = 4;
} else if (have >= cfg.loss_item_ten[0][1]) {
canBuyTen = true;
canBuyOne = true;
type = 4;
}
} else {
if (haveDiam >= cfg.loss_gold_once && haveDiam < cfg.loss_gold_ten) {
canBuyOne = true;
canBuyTen = false;
type = 3;
} else if (haveDiam >= cfg.loss_gold_ten) {
canBuyTen = true;
canBuyOne = true;
type = 3;
}
}
// console.log( haveDiam + "sss" + type + "是否可以祈禱單次" + canBuyOne + "是否可以祈禱ss" + canBuyTen + have );
if (_times <= cfg.loss_item_once[0][1]) {
if (this.nowPrayInfos.free_times == 1) {
pray.sender25217(this.nowPrayInfos.group_id, _times, 1);
return;
} else {
if (!canBuyOne) {
nx.tbox("SummonItemNotEnough");
return;
}
}
} else {
if (!canBuyTen) {
nx.tbox("SummonItemNotEnough");
return;
}
}
pray.sender25217(this.nowPrayInfos.group_id, _times, type);
},
onTouchUplev: function onTouchUplev() {
nx.bridge.createPanel("WndHolyStatueUplev", this.nowPrayInfos);
},
onTouchRate: function onTouchRate() {
nx.bridge.createPanel("WndHolyPrayRate", this.nowPrayInfos);
},
onTouchEqmAutoSell: function onTouchEqmAutoSell() {
nx.bridge.createPanel("WndHolyEqmAutoSell", this.nowPrayInfos);
},
onTouchShop: function onTouchShop() {
nx.bridge.createPanel("WndHolyPrayShop", {
score: this.score
});
},
// 规则说明
onTouchTip: function onTouchTip() {
var desc = game.configs.holy_eqm_lottery_data.data_const.salvage_rule;
var TC = TipsController.getInstance();
if (TC) {
TC.showTextPanel(desc.title, desc.desc);
}
}
});
cc._RF.pop();