118 lines
3.7 KiB
JavaScript
118 lines
3.7 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '7ca91e6zJtIYJZHgumgkE6/', 'guildmarketplace_controller');
|
|
// Scripts/mod/guild/marketplace/guildmarketplace_controller.js
|
|
|
|
"use strict";
|
|
|
|
// ////////////////////////////////////////////////////////////////////
|
|
// @author: lwc@syg.com(必填, 创建模块的人员)
|
|
// @editor: xxx@syg.com(必填, 后续维护以及修改的人员)
|
|
// @description:
|
|
// 公会宝库 后端 国辉 策划 松岳
|
|
// <br/>Create: 2019-09-04
|
|
// ////////////////////////////////////////////////////////////////////
|
|
var BridgeController = require("bridge.controller");
|
|
var RoleController = require("role_controller");
|
|
var GuildmarketplaceEvent = require("guildmarketplace_event");
|
|
var GuildmarketplaceController = cc.Class({
|
|
"extends": BridgeController,
|
|
ctor: function ctor() {},
|
|
// 初始化配置数据
|
|
initConfig: function initConfig() {
|
|
var GuildmarketplaceModel = require("guildmarketplace_model");
|
|
this.model = new GuildmarketplaceModel();
|
|
this.model.initConfig();
|
|
},
|
|
// 返回当前的model
|
|
getModel: function getModel() {
|
|
return this.model;
|
|
},
|
|
registerProtocals: function registerProtocals() {
|
|
this.RegisterProtocal(26900, this.handle26900.bind(this)); //宝库信息
|
|
this.RegisterProtocal(26901, this.handle26901.bind(this)); //出售商品
|
|
this.RegisterProtocal(26902, this.handle26902.bind(this)); //购买商品
|
|
this.RegisterProtocal(26903, this.handle26903.bind(this)); //公告信息
|
|
this.RegisterProtocal(26904, this.handle26904.bind(this)); //增加
|
|
this.RegisterProtocal(26905, this.handle26905.bind(this)); //变化
|
|
this.RegisterProtocal(26906, this.handle26906.bind(this)); //删除
|
|
},
|
|
|
|
reqBaseFromServer: function reqBaseFromServer(_cb) {
|
|
var _this = this;
|
|
var cfgs = ["guild_marketplace_data"];
|
|
this.loadConfigs(cfgs, function (_ret, _data) {
|
|
_this.requestGuildMarketData(_cb);
|
|
});
|
|
},
|
|
requestGuildMarketData: function requestGuildMarketData(_cb) {
|
|
this.sender26900(_cb);
|
|
},
|
|
sender26900: function sender26900(_cb) {
|
|
//宝库信息
|
|
var protocal = {};
|
|
this.SendProtocal(26900, protocal, _cb);
|
|
},
|
|
handle26900: function handle26900(data) {
|
|
//宝库信息
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
this.model.initMarketItems(data);
|
|
},
|
|
handle26904: function handle26904(data) {
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
this.model.updateMarketItems(data, true);
|
|
},
|
|
handle26905: function handle26905(data) {
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
this.model.updateMarketItems(data, false);
|
|
},
|
|
handle26906: function handle26906(data) {
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
this.model.delMarketItems(data);
|
|
},
|
|
sender26901: function sender26901(id, quantity, storage) {
|
|
var protocal = {};
|
|
protocal.id = id;
|
|
protocal.quantity = quantity;
|
|
protocal.storage = storage;
|
|
this.SendProtocal(26901, protocal);
|
|
},
|
|
handle26901: function handle26901(data) {
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
},
|
|
sender26902: function sender26902(id, quantity, _cb) {
|
|
//购买商品
|
|
var protocal = {};
|
|
protocal.id = id;
|
|
protocal.quantity = quantity;
|
|
this.SendProtocal(26902, protocal, _cb);
|
|
},
|
|
handle26902: function handle26902(data) {
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
},
|
|
sender26903: function sender26903() {
|
|
//公告信息
|
|
var protocal = {};
|
|
this.SendProtocal(26903, protocal);
|
|
},
|
|
handle26903: function handle26903(data) {
|
|
if (!this.isGoodData(data)) {
|
|
return;
|
|
}
|
|
gcore.GlobalEvent.fire(GuildmarketplaceEvent.GUILD_MARKET_PLACE_MESSAGE_EVENT, data);
|
|
}
|
|
});
|
|
module.exports = GuildmarketplaceController;
|
|
|
|
cc._RF.pop(); |