Files
fc/dev/project/library/imports/3f/3f4e7c90-8df0-48a0-ab15-b9774be2c0ca.js
T
2026-05-24 10:21:26 +08:00

334 lines
13 KiB
JavaScript

"use strict";
cc._RF.push(module, '3f4e7yQjfBIoKsVuXdL4sDK', 'cmp.battledrama.quick');
// Scripts/mod/battle_drama/cmp/cmp.battledrama.quick.js
"use strict";
var BridgeWindow = require("bridge.window");
var FxSVC = require("nx.fx.sv.expand");
var PathTool = require("pathtool");
var BattleDramaController = require("battle_drama_controller");
var RoleController = require("role_controller");
var DramaEvent = require("battle_drama_event");
var TPC = require("tips_controller");
var ActMod = require("act.month.mod");
var PartnerBodyShow = require("cmp.partner.body.show");
var NxSpine = require("nx.fx.spine");
cc.Class({
"extends": BridgeWindow,
properties: {
SVClist: {
"default": null,
type: FxSVC
},
desc: {
"default": null,
type: cc.RichText
},
source_label: {
"default": null,
type: cc.Label
},
notice_label: {
"default": null,
type: cc.RichText
},
btn_buy_rt: {
"default": null,
type: cc.RichText
},
source_icon: {
"default": null,
type: cc.Node
},
smod: {
"default": null,
type: cc.Prefab
},
mod_tar: {
"default": null,
type: cc.Node
},
nodRole: {
"default": null,
type: NxSpine
}
},
// LIFE-CYCLE CALLBACKS:
onLoad: function onLoad() {
this.controller = BattleDramaController.getInstance();
this.drama_model = this.controller.getModel();
this.role_vo = RoleController.getInstance().getRoleVo();
this.quick_battle_status = 0;
this.privilege_status = RoleController.getInstance().getModel().checkPrivilegeStatus(1); // 是否有特权
//快速战斗数据更新
this.bindGEvent(DramaEvent.BattleDrama_Quick_Battle_Data, this.updateData.bind(this));
},
start: function start() {
var _this = this;
this.btn_buy_rt.string = cc.js.formatStr("<u>%s</u>", nx.text.getKey("newfirstcharge_window_tip2"));
//秘书组id
var _id = nx.bridge.vget("clerkShowId");
var arr = _id.split("_");
var id = cc.js.formatStr("%s_%s", arr[0], arr[1]);
var cfg = gdata("partner_data", "data_partner_star", id);
var rcfg = gdata("partner_data", "data_partner_base", id);
var path = cc.path.join("resDB/models/" + cfg.res_id + "/show");
this.nodRole.load(path, function (_e) {
if (!_e) {
_this.nodRole.action("drama1", true);
} else {
_this.nodRole.stop();
}
});
// this.nodRole.setPartner( cfg );
// if(!this.splayer){
// this.splayer = cc.instantiate(this.smod);
// this.splayer.parent = this.mod_tar;
// this.splayer.position = cc.v2(0,0);
// }
// let cmp = this.splayer.getComponent("cmp.partner.smod");
// if(cmp &&( arr.length>1)){
// cmp.setData(cfg,true,false);
// }
},
touchVIp: function touchVIp() {
nx.bridge.createPanel("WndPayment", {
page: "shop"
});
this.controller.openDramBattleQuickView(false);
},
onOpenConfigs: function onOpenConfigs() {
this.updateData();
this.updateShowItems();
this.cardhoner = ActMod.getInstance().vget("monthCard1");
this.cardsmall = ActMod.getInstance().vget("monthCard2"); // 説明 添加關於月卡祝福的説明
this.updateShowDesc();
},
onPreClosed: function onPreClosed() {
this.SVClist.rebuild([]);
},
// 次数和按钮显示
updateData: function updateData() {
var quickdata = this.drama_model.getQuickData();
if (nx.dt.objEmpty(quickdata)) {
return false;
}
this.quick_battle_status = 0; // 当前特权次数状态
this.quick_battle_cost = 0; // 当前特权消耗
var res = PathTool.queryIconPath(3);
nx.gui.setSpriteFrame(this.source_icon, "", res);
// 优先处理按钮显示
// this.source_label.node.x = -85;
if (quickdata.fast_combat_free_num > 0) {
// 免费就不做任何处理了.直接判断了
this.source_label.string = nx.text.getKey("lab_battle_fastfight");
this.source_icon.active = false;
this.notice_label.string = "<color=#373857>" + nx.text.getKey("btn_battle_fast_fight_free") + "</color>";
} else {
var combat_num = quickdata.fast_combat_max - quickdata.fast_combat_num; // 剩余普通次数
var privilege_num = game.configs.privilege_data.data_fast_combat_cost_length - quickdata.fast_combat_p_num; // 剩余特权数量
if (privilege_num > 0 && this.privilege_status) {
this.notice_label.string = cc.js.formatStr("%s<color=#373857>%s+%s</color>%s", nx.text.getKey("lab_battle_fast_fight_left"), combat_num, privilege_num, "");
} else {
this.notice_label.string = cc.js.formatStr("%s<color=#373857>%s</color>%s", nx.text.getKey("lab_battle_fast_fight_left"), combat_num, "");
}
// 先判断普通次数,在判断是否是有特权,判断特权消耗
var next_config = game.configs.dungeon_data.data_drama_quick_cost[quickdata.fast_combat_num + 1];
var cost = 0;
if (next_config) {
cost = next_config.cost;
this.quick_battle_status = 2;
} else {
if (this.privilege_status) {
// 开了特权的
var privilege_config = game.configs.privilege_data.data_fast_combat_cost[quickdata.fast_combat_p_num + 1];
if (privilege_config) {
cost = privilege_config.cost; // 下一次特权消耗
this.quick_battle_status = 2;
}
this.notice_label.string = cc.js.formatStr("%s<color=#249003>%s+%s</color>%s", nx.text.getKey("lab_battle_fast_fight_left"), combat_num, privilege_num, "");
}
}
this.quick_battle_cost = cost;
if (cost == 0) {
this.quick_battle_status = 3; // 没有次数了
this.source_icon.active = false;
if (this.privilege_status) {
this.source_label.string = nx.text.getKey("lab_battle_fastfight");
} else {
this.source_label.string = nx.text.getKey("lab_battle_fast_fight_up_free");
}
} else {
this.source_icon.active = true;
if (!this.source_icon_status) {
this.source_icon_status = true;
}
this.source_label.string = cost + " " + nx.text.getKey("lab_battle_fastfight");
}
}
},
// 描述文字库
updateShowDesc: function updateShowDesc() {
var tips_str = nx.text.getKey("lab_battle_fast_fight_vip_cantip");
var str_card1 = "";
var str_card = "";
var desc = "";
if (this.cardhoner && this.cardsmall) {
if (this.cardhoner.is_reward == 1 || this.cardhoner.is_reward == 2) {
str_card = nx.text.format("msg_battle_fast_fight_month", 3) + nx.text.getKey("lab_battle_fast_fight_vip_is");
if (this.cardsmall.is_reward == 1 || this.cardsmall.is_reward == 2) {
str_card1 = nx.text.format("msg_battle_fast_fight_month1", 1) + nx.text.getKey("lab_battle_fast_fight_vip_is");
} else {
str_card1 = nx.text.format("msg_battle_fast_fight_month1", 1) + nx.text.getKey("lab_battle_fast_fight_vip_no");
}
} else {
// str_card = nx.text.format( "msg_battle_fast_fight_month", 3 ) + nx.text.getKey("lab_battle_fast_fight_vip_no") ;
if (this.cardsmall.is_reward == 1 || this.cardsmall.is_reward == 2) {
str_card1 = nx.text.format("msg_battle_fast_fight_month1", 1) + nx.text.getKey("lab_battle_fast_fight_vip_is");
str_card = nx.text.format("msg_battle_fast_fight_month", 3) + nx.text.getKey("lab_battle_fast_fight_vip_no");
} else {
str_card1 = nx.text.format("msg_battle_fast_fight_month1", 1) + nx.text.getKey("lab_battle_fast_fight_vip_no");
str_card = nx.text.format("msg_battle_fast_fight_month", 3) + nx.text.getKey("lab_battle_fast_fight_vip_no");
}
}
} else {
str_card = nx.text.format("msg_battle_fast_fight_month", 3) + nx.text.getKey("lab_battle_fast_fight_vip_no");
str_card1 = nx.text.format("msg_battle_fast_fight_month1", 1) + nx.text.getKey("lab_battle_fast_fight_vip_no");
}
// let activem = this.cardsmall.is_reward == 2
// let active = this.cardsmall.is_reward == 2 ?
if (this.privilege_status == true) {
tips_str = tips_str + nx.text.getKey("lab_battle_fast_fight_vip_is") + "\n" + str_card1 + "\n" + str_card;
this.btn_buy_rt.node.active = false;
} else {
tips_str = tips_str + nx.text.getKey("lab_battle_fast_fight_vip_no") + "\n" + str_card1 + "\n" + str_card;
this.btn_buy_rt.node.active = true;
}
this.desc.string = tips_str;
},
// 增加物品展示
updateShowItems: function updateShowItems() {
var data = this.drama_model.getDramaData();
if (nx.dt.objEmpty(data)) {
return false;
}
var drama_config = game.configs.dungeon_data.data_drama_dungeon_info[data.max_dun_id];
if (nx.dt.objEmpty(drama_config)) {
return false;
}
var item_list = [];
for (var index = 0; index < drama_config.quick_show_items.length; index++) {
var element = drama_config.quick_show_items[index];
item_list.push({
bid: element[0],
num: element[1]
});
}
this.SVClist.rebuild(item_list);
},
send13004: function send13004() {
var _this2 = this;
if (!this.role_vo) return;
var cur_energy = this.role_vo.energy;
var max_energy = this.role_vo.energy_max;
var qingbao_val = 0;
var vip_add_per = 0;
var hook_max_time = this.drama_model.hook_max_time || 120;
var drama_data = this.drama_model.getDramaData() || {};
var config = gdata("dungeon_data", "data_drama_dungeon_info", [drama_data.dun_id]);
if (config && config.per_hook_items) {
for (var i in config.per_hook_items) {
var v = config.per_hook_items[i];
if (v[0] == game.configs.item_data.data_assets_label2id.energy) {
qingbao_val = v[1] * hook_max_time * (1 + vip_add_per);
}
}
}
if (cur_energy + qingbao_val > max_energy) {
var call_back = function call_back(_key, _box) {
_box.close();
if (_key == "confirm") {
_this2.controller.send13004();
}
};
var str = cc.js.formatStr(nx.text.getKey("msg_battle_fast_fight_warring"), cur_energy, max_energy);
nx.mbox(str, ['cancel', 'confirm'], call_back);
} else {
this.controller.send13004();
}
},
touchSourceBtn: function touchSourceBtn() {
var _this3 = this;
if (this.quick_battle_status == 0 || this.quick_battle_status == 1) {
// 可以直接使用
this.send13004();
} else if (this.quick_battle_status == 2 && this.quick_battle_cost != 0) {
// 需要花费钻石
if (this.drama_model.getFirstFresh() && !this.privilege_status) {
this.controller.send13039();
var str = nx.text.getKey("msg_battle_fast_fight_goto_buy");
var _fun = function _fun(_key, _box) {
_box.close();
if (_key == "confirm") {
nx.bridge.createPanel("WndPayment", {
page: "shop"
});
_this3.controller.openDramBattleQuickView(false);
} else if (_key == "cancel") {
var str = cc.js.formatStr(nx.text.getKey("msg_battle_fast_fight_cost"), game.configs.item_data.data_assets_label2id.gold, _this3.quick_battle_cost);
var res = PathTool.queryIconPath(3);
nx.gui.setSpriteFrame(_this3.source_icon, "", res);
var fun2 = function fun2(_key, _box) {
_box.close();
if (_key == "confirm") {
_this3.send13004();
}
};
nx.mbox(str, ['cancel', 'confirm'], fun2);
}
};
nx.mbox(str, ['cancel', 'confirm'], _fun);
return;
}
var str = cc.js.formatStr(nx.text.getKey("msg_battle_fast_fight_cost"), game.configs.item_data.data_assets_label2id.gold, this.quick_battle_cost);
var res = PathTool.queryIconPath(3);
nx.gui.setSpriteFrame(this.source_icon, "", res);
var fun = function fun(_key, _box) {
_box.close();
if (_key == "confirm") {
_this3.send13004();
}
};
nx.mbox(str, ['cancel', 'confirm'], fun);
} else if (this.quick_battle_status == 3) {
// 没有次数了,需要判断特权
if (this.privilege_status) {
this.send13004();
} else {
var str = nx.text.getKey("msg_battle_fast_fight_goto_buy");
var _fun2 = function _fun2(_key, _box) {
_box.close();
if (_key == "confirm") {
nx.bridge.createPanel("WndPayment", {
page: "shop"
});
_this3.controller.openDramBattleQuickView(false);
}
};
nx.mbox(str, ['cancel', 'confirm'], _fun2);
}
} else {
this.send13004();
}
},
touchExplain: function touchExplain() {
var desc = game.configs.dungeon_data.data_drama_const.game_rule.desc;
TPC.getInstance().showTextPanel("", desc);
} // update (dt) {},
});
cc._RF.pop();