Files
fc/dev/project/library/imports/30/30d65589-22cc-4a98-b30c-0a3ced8fa53f.js
2026-05-24 10:21:26 +08:00

380 lines
14 KiB
JavaScript

"use strict";
cc._RF.push(module, '30d65WJIsxKmLMMCjztj6U/', 'cmp.wing.procurement.wnd');
// Scripts/mod/partner/wings/cmp/cmp.wing.procurement.wnd.js
"use strict";
/******************************************************************
*
* 僚机科研
*
******************************************************************/
var BridgeWindow = require("bridge.window");
var HeroController = require("hero_controller");
var BackpackController = require("backpack_controller");
var ElfinEvent = require("elfin_event");
var ElfinController = require("elfin_controller");
var TipsController = require("tips_controller");
var FID = require("bridge.function.ids");
cc.Class({
"extends": BridgeWindow,
properties: {
nodProcess: {
"default": null,
type: cc.Node,
displayName: "抽奖进度"
},
nodShowWings: {
"default": null,
type: cc.Node,
displayName: "展示節點"
},
nodOps: {
"default": null,
type: cc.Node,
displayName: "操作"
},
nodWishPool: {
"default": null,
type: cc.Node,
displayName: "许愿池"
},
nodRule: {
"default": null,
type: cc.Node,
displayName: "说明"
},
nodReward: {
"default": [],
type: cc.Node,
displayName: "奖励组"
}
},
onLoad: function onLoad() {
this.bindGEvent(ElfinEvent.Update_Elfin_Summon_Data_Event, this.freshSumon.bind(this));
this.screen_width = cc.winSize.width;
},
// 重载:参数打开
onOpenConfigs: function onOpenConfigs(_params) {
var _this = this;
this.unscheduleAllCallbacks();
this.schedule(function () {
for (var i = 0; i < _this.nodShowWings.children.length; i++) {
var nod = _this.nodShowWings.children[i];
nod.x -= 1 * 0.9;
if (nod.x <= -(_this.nodShowWings.children[0].width + (_this.screen_width < 1920 ? 1920 : _this.screen_width))) {
nod.x = (_this.screen_width < 1920 ? 1920 : _this.screen_width) - _this.nodShowWings.children[0].width + 370;
nx.tween.fadeIn(nod, "", 0.001);
}
}
}, 0, cc.macro.REPEAT_FOREVER);
// this.summon = {};
this.freshSumon();
},
// 重载:关闭前
onPreClosed: function onPreClosed() {},
// 刷新所有的方案列表
freshSumon: function freshSumon(_summon) {
// console.log( "许愿池相关" + JSON.stringify( _summon ) );
var EC = ElfinController.getInstance();
var model = EC.getModel();
var summon = {};
if (model) {
summon = model.getElfinSummonData();
}
this.summon = summon || _summon;
var max = 120;
// console.log( "许愿池相关当前" + JSON.stringify( this.summon ) );
/********
* {"camp_id":0,"free_time":1683475200,"times":84,"do_awards":[{"award_id":1}],"lucky_ids":[{"lucky_sprites_bid":113003}],"day_count":20}
* [26550]:{"camp_id":0,"free_time":1682784000,"times":121,"do_awards":[{"award_id":1}],"lucky_ids":[],"day_count":120}
* [26550]:{"camp_id":0,"free_time":1682611200,"times":22,"do_awards":[],"lucky_ids":[{"lucky_sprites_bid":113004}],"day_count":0}
* {"camp_id":0,"free_time":1682697600,"times":1,"do_awards":[],"lucky_ids":[{"lucky_sprites_bid":113003}],"day_count":0}
*/
for (var i = 0; i < this.nodReward.length; i++) {
var item = this.nodReward[i];
nx.gui.setActive(item, "get", false);
}
if (this.summon) {
nx.gui.setString(this.nodProcess, "point/txt", this.summon.times);
nx.gui.find(this.nodProcess, "prog/progress").getComponent(cc.ProgressBar).progress = this.summon.times / max;
var cmp = this.nodWishPool.getComponent("cmp.item.base");
if (cmp) {
if (!nx.dt.arrEmpty(this.summon.lucky_ids)) {
cmp.setData(this.summon.lucky_ids[0].lucky_sprites_bid);
var ifg = gdata("item_data", "data_unit9", this.summon.lucky_ids[0].lucky_sprites_bid);
nx.bridge.setIcon(this.nodRule, "descs/wish/icon", ifg.imageid);
nx.bridge.setIcon(this.nodWishPool, "icon", ifg.imageid);
nx.gui.setActive(this.nodWishPool, "add", false);
} else {
cmp.setData(0);
nx.gui.setSpriteFrame(this.nodRule, "descs/wish/icon", "");
nx.gui.setSpriteFrame(this.nodWishPool, "icon", "");
nx.gui.setActive(this.nodWishPool, "add", true);
}
}
// nx.gui.setString( )
this.freshOp();
}
},
freshOp: function freshOp() {
nx.gui.setActive(this.nodRule, "", false);
// 读取配置信息
var slcfg = game.configs.holiday_sprite_lottery_data;
var mfg = slcfg.data_const.common_s;
var mat = mfg.val;
var allCfg = slcfg.data_summon[110];
var count = BackpackController.getInstance().getModel().getItemNumByBid(mat);
var afg = slcfg.data_award[0];
var time = this.summon.times;
var all_rewards = [0, 0, 0];
var awards = this.summon.do_awards;
for (var i = 0; i < all_rewards.length; i++) {
var a = awards[i];
if (a) {
all_rewards[a.award_id - 1] = a.award_id;
}
}
if (nx.dt.arrEmpty(awards)) {
awards.sort(Utils.tableLowerSorter(["award_id"]));
}
// console.log( "当前的award" + JSON.stringify( awards ) );
// 领取奖励的操作
for (var _i = 0; _i < this.nodReward.length; _i++) {
var item = this.nodReward[_i];
nx.bridge.setIcon(item, "icon", afg[_i + 1].reward[0][0]);
if (time >= afg[_i + 1].times) {
if (all_rewards[_i] == 0) {
nx.gui.setActive(item, "get", true);
nx.gui.btnFadeColorAndAlphaChildren(item, "bg", false);
nx.gui.btnFadeColorAndAlphaChildren(item, "icon", false);
} else {
nx.gui.setActive(item, "get", false);
nx.gui.btnFadeColorAndAlphaChildren(item, "bg", true);
nx.gui.btnFadeColorAndAlphaChildren(item, "icon", true);
}
} else {
nx.gui.btnFadeColorAndAlphaChildren(item, "bg", false);
nx.gui.btnFadeColorAndAlphaChildren(item, "icon", false);
}
}
// 单抽次数上限
var max = slcfg.data_const.sprite_lottery_daily_limit.val;
var desc = slcfg.data_const.sprite_lottery_daily_limit.desc;
nx.gui.setString(this.nodOps, "mat/txt", nx.dt.shortCount(count));
nx.bridge.setIconS(this.nodOps, "mat/icon", mat);
var icon = count > 0 ? mat : allCfg.loss_gold_once[0][0];
var ticon = count >= allCfg.loss_item_ten[0][1] ? mat : allCfg.loss_gold_once[0][0];
var once = count > 0 ? allCfg.loss_item_once[0][1] : allCfg.loss_gold_once[0][1];
var ten = count >= allCfg.loss_item_ten[0][1] ? allCfg.loss_item_ten[0][1] : allCfg.loss_gold_ten[0][1];
var Nowtimes = this.summon.day_count;
// nx.gui.setString( this.nodOps, "tips/desc", desc + ":" );
nx.gui.setString(this.nodOps, "tips/num", Nowtimes);
nx.gui.setString(this.nodOps, "tips/max", "/" + max);
// 材料不同显示不同
nx.bridge.setIconS(this.nodOps, "free/mat/icon", icon);
nx.bridge.setIconS(this.nodOps, "ten/mat/icon", ticon);
nx.gui.setString(this.nodOps, "free/mat/txt", once);
nx.gui.setString(this.nodOps, "ten/mat/txt", ten);
nx.gui.setActive(this.nodOps, "free/tips/tip", this.summon.free_time > 0);
if (this.summon.free_time > 0) {
nx.gui.setCdTxt(this.nodOps, "free/tips/tip", this.summon.free_time - Math.floor(cc.sys.now() / 1000));
}
if (slcfg.data_action[0]) {
var rule = slcfg.data_action[0].desc;
nx.gui.find(this.nodRule, "descs/rule/txt").getComponent(cc.RichText).string = rule;
}
var rateDescs = slcfg.data_probability[110];
// console.log( "当前的数据" + JSON.stringify( rateDescs ) );
var chd = nx.gui.find(this.nodRule, "descs/rate/rateDesc").children;
for (var _i2 = 0; _i2 < chd.length; _i2++) {
var node = chd[_i2];
var _desc = rateDescs[_i2 + 1];
nx.gui.setString(node, "txt", _desc.name);
nx.gui.setString(node, "rate", _desc.probability + "%");
}
},
// 设置要领取的奖励信息
setAward: function setAward(_index) {
// 抽奖次数奖励配置
var afg = game.configs.holiday_sprite_lottery_data.data_award[0];
var safg = afg[_index];
var mfg = game.configs.holiday_sprite_lottery_data.data_const.common_s;
var mat = mfg.val;
var TC = TipsController.getInstance();
if (_index == 4) {
if (mat) {
TC.showItemTips(mat);
}
} else {
var rewards = safg.reward;
if (rewards) {
TC.showItemTips(rewards[0][0]);
}
}
},
// 领取
getAward: function getAward(_index) {
// 抽奖次数奖励配置
var afg = game.configs.holiday_sprite_lottery_data.data_award[0];
var safg = afg[_index];
var mfg = game.configs.holiday_sprite_lottery_data.data_const.common_s;
var TC = TipsController.getInstance();
if (!TC) {
return;
}
if (!nx.dt.arrEmpty(this.summon.do_awards)) {
var now_award_id = this.summon.do_awards[_index - 1];
if (now_award_id && now_award_id == _index) {
nx.tbox(nx.text.getKey("Cannot claim the reward"));
return;
}
}
var EC = ElfinController.getInstance();
var rewards = safg.reward;
if (this.summon.times >= safg.times) {
if (rewards) {
if (EC) {
EC.send26552(_index);
}
}
} else {
nx.tbox(nx.text.getKey("Cannot get the reward"));
}
},
// 返回主场景
onBackToMain: function onBackToMain() {
var HR = HeroController.getInstance();
var BC = BackpackController.getInstance();
if (BC) {
BC.openMainWindow(false);
}
ElfinController.getInstance().openElfinWishWindow(false);
HR.openHeroMainInfoWindow(false);
HR.openHeroBagWindow(true);
},
// 点击抽奖
onTouchLottery: function onTouchLottery(_index) {
// let type = this.free_time == 0 ? 1 :
// 抽1次 与抽 10 次同一条信息 free 1 diamond 2 mat 4
// 读取配置信息
var slcfg = game.configs.holiday_sprite_lottery_data;
var mfg = slcfg.data_const.common_s;
var mat = mfg.val;
var allCfg = slcfg.data_summon[110];
var count = BackpackController.getInstance().getModel().getItemNumByBid(mat);
var have = BackpackController.getInstance().getModel().getItemNumByBid(allCfg.loss_gold_once[0][0]);
// 单日次数上限
var max = slcfg.data_const.sprite_lottery_daily_limit.val;
console.log("free" + JSON.stringify(this.summon));
// let gain_once_num = ;
var time = this.summon.times;
var EC = ElfinController.getInstance();
var dayCount = this.summon.day_count;
if (EC) {
if (_index == 0) {
if (this.summon.free_time == 0) {
EC.send26551(1, 1, false);
}
if (this.summon.free_time != 0) {
// 有材料使用相应的材料
if (count > 0) {
EC.send26551(1, 4, false);
} else {
if (dayCount == max) {
nx.tbox(nx.text.getKey("lab_elfin_summon_tips_11"));
return;
}
var timeNow = dayCount + 1;
if (timeNow > max) {
nx.tbox(nx.text.getKey("lab_elfin_summon_tips_11"));
return;
}
var mat0 = allCfg.loss_gold_once[0][0];
var mat1 = allCfg.gain_once[0][0];
var txt = nx.text.format("lab_elfin_summon_tips_9t", allCfg.loss_gold_once[0][1], allCfg.gain_once[0][1], 1);
EC.openElfUseTipsWindow(true, txt, [mat0, mat1], [allCfg.loss_gold_once[0][1], allCfg.gain_once[0][1]], function (_deal) {
EC.send26551(1, 3, false);
EC.openElfUseTipsWindow(false);
});
}
}
} else {
if (count >= 10) {
EC.send26551(10, 4, false);
} else {
if (dayCount == max) {
nx.tbox(nx.text.getKey("lab_elfin_summon_tips_11"));
return;
}
time = this.summon.dayCount + 10;
if (time > max) {
nx.tbox(nx.text.getKey("lab_elfin_summon_tips_11"));
return;
}
var _mat = allCfg.loss_gold_ten[0][0];
var _mat2 = allCfg.gain_ten[0][0];
var _txt = nx.text.format("lab_elfin_summon_tips_9t", allCfg.loss_gold_ten[0][1], allCfg.gain_ten[0][1], 10);
EC.openElfUseTipsWindow(true, _txt, [_mat, _mat2], [allCfg.loss_gold_ten[0][1], allCfg.gain_ten[0][1]], function (_deal) {
EC.send26551(10, 3, false);
EC.openElfUseTipsWindow(false);
});
}
}
}
},
// 许愿
onTouchWish: function onTouchWish() {
var EC = ElfinController.getInstance();
if (EC) {
var cmp = this.nodWishPool.getComponent("cmp.item.base");
var nowSelect = this.summon.lucky_ids;
// if( cmp ){
// if( cmp.mdata ){
// nowSelect = cmp.mdata;
// }
// }
var wfg = game.configs.holiday_sprite_lottery_data.data_const.lucky_sprite_ids;
var wishList = wfg.val;
var args = {
wishLst: wishList,
count: 1,
selects: nowSelect
};
EC.openElfinWishTip(true, args);
}
},
// 点击帮助
onTouchHelp: function onTouchHelp() {
var TC = TipsController.getInstance();
if (TC) {
var txt = game.configs.holiday_sprite_lottery_data.data_const.reward_desc;
TC.showTextPanel("tip", txt.desc);
}
},
// 点击帮助
onTouchRule: function onTouchRule() {
nx.gui.setActive(this.nodRule, "", !nx.gui.find(this.nodRule).active);
},
close: function close() {
if (nx.bridge.plot && nx.bridge.plot.isDoing()) {
nx.bridge.jumper.jump2Window(FID.Wing);
}
this._super();
}
/*******
* [26553]:{"group_id":110,"times":1,"rewards":[{"base_id":112004,"num":1}],"sprite_bids":[{"sprite_bid":112004,"quality":3,"jie":1}]}
*/
});
cc._RF.pop();