"use strict"; cc._RF.push(module, '26e62MynctBIbCnAmbcWc60', 'guildmarketplace_model'); // Scripts/mod/guild/marketplace/guildmarketplace_model.js "use strict"; // //////////////////////////////////////////////////////////////////// // @author: lwc@syg.com(必填, 创建模块的人员) // @editor: xxx@syg.com(必填, 后续维护以及修改的人员) // @description: // 公会宝库 后端 国辉 策划 松岳 //
Create: 2019-09-04 // //////////////////////////////////////////////////////////////////// var BridgeClass = require("bridge.class"); var GuildmarketplaceConst = require("guildmarketplace_const"); var GuildmarketplaceEvent = require("guildmarketplace_event"); var GuildmarketplaceModel = cc.Class({ "extends": BridgeClass, ctor: function ctor() {}, properties: {}, initConfig: function initConfig() { this.item_lists = []; //縂序列 }, getMarketItems: function getMarketItems() { return this.item_lists; }, initMarketItems: function initMarketItems(data) { //攤位id分類 // for(let i in data){ // if(!this.item_lists[data[i].id]){ // this.item_lists[data[i].id] = []; // this.item_lists[data[i].id].push(data[i]); // }else{ // this.item_lists[data[i].id].push(data[i]); // } // } this.item_lists = data.item_list; this.daybuy_list = data.day_buy; gcore.GlobalEvent.fire(GuildmarketplaceEvent.GUILD_MARKET_PLACE_ITEM_EVENT, this.item_lists); }, updateMarketItems: function updateMarketItems(data, is_add) { var list = data.item_list; if (is_add) { //增加 for (var i in list) { this.item_lists.push(list[i]); } } else { //更新 for (var v in this.item_lists) { var item = this.item_lists[v]; for (var a in list) { if (item.id == list[a].id) { this.item_lists[v].num = list[a].num; this.item_lists[v].end_time = list[a].end_time; } } } for (var d in this.daybuy_list) { var day_data = this.daybuy_list[d]; for (var buy in data.day_buy) { if (day_data[0] == data.day_buy[buy][0]) { this.daybuy_list[d][1] = data.day_buy[buy][1]; } } } } gcore.GlobalEvent.fire(GuildmarketplaceEvent.GUILD_MARKET_PLACE_ITEM_EVENT, this.item_lists); }, delMarketItems: function delMarketItems(data) { var list = data.id_list; for (var i in this.item_lists) { var d = this.item_lists[i]; for (var j in list) { if (d.id == list[j].id) { this.item_lists[i].is_del = true; } } } var newlist = []; for (var del in this.item_lists) { if (!this.item_lists[del].is_del) { newlist.push(this.item_lists[del]); } } this.item_lists = newlist; gcore.GlobalEvent.fire(GuildmarketplaceEvent.GUILD_MARKET_PLACE_ITEM_EVENT, this.item_lists); }, //限購相關 getBuyByBid: function getBuyByBid(bid) { //已購買的數量 for (var i in this.daybuy_list) { var day_data = this.daybuy_list[i]; if (day_data[0] == bid) { return day_data[1]; } } return 0; }, //售卖放入相关 isAllowSell: function isAllowSell(bid) { var data = this.getMarketCfg(bid); if (data) { if (data.is_sell == 1) { //允许售卖 return true; } else { return false; } } return false; }, getStorageType: function getStorageType(sub_type) { if (sub_type == 2 || sub_type == 3) { return 1; } else if (sub_type == 1 || sub_type == 4) { return 3; } }, getMarketCfg: function getMarketCfg(bid) { var filed = game.configs.guild_marketplace_data.data_item_info_fields; var gdata = game.configs.guild_marketplace_data.data_item_info[bid]; if (gdata) { var data = {}; for (var i in filed) { data[filed[i]] = gdata[i]; } return data; } else { return null; } } }); cc._RF.pop();