difenduandada
2024-12-31 34abe6963b344c882358274957f4b992456fee40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      商城的model
// <br/>Create: 2018-12-18 17:12:27
// --------------------------------------------------------------------
// var HeroController = require("hero_controller");
var RoleController = require("role_controller");
var BackpackController = require("backpack_controller")
var MallModel = cc.Class({
    extends: BaseClass,
    ctor: function () {
        var MailController = require("mall_controller");
        this.ctrl = MailController.getInstance();
    },
 
    properties: {
    },
 
    initConfig: function () {
        this.buy_list = {};
        this.shop_list = {};
    },
 
    setBuyList: function (data) {
        this.buy_list = data;
    },
 
    getBuyList: function () {
        return this.buy_list
    },
 
    getScoreBuyList: function (shop_type) {
        if (this.shop_list[shop_type] && Utils.next(this.shop_list[shop_type]) != null) {
            return this.shop_list[shop_type]
        }
        return null
    },
 
    //检查当前神格商店中是否存在上阵的的伙伴碎片
    checkHeroChips: function (item_id) {
        var is_has = false;
        var pos_list = [];
        // var pos_list = HeroController.getInstance().getModel().getMyPosList();
        if (pos_list != null && Utils.next(pos_list || {}) != null) {
            for (var k in pos_list) {
                var v = pos_list[k];
                var partner_data = PartnerController.getInstance().getModel().getPartnerById(v.id);
                if (partner_data && partner_data.chips_id == item_id) {
                    is_has = true;
                }
            }
            return is_has
        }
        return false
    },
 
    //根据商店类型以及支付类型和单价来判断能够买多少个
    checkMoenyByType: function (pay_type, price) {
        var role_vo = RoleController.getInstance().getRoleVo();
        var is_can_buy_num = 0;
        if (role_vo != null) {
            var config = Utils.deepCopy(Config.item_data.data_assets_label2id)
            if (typeof (pay_type) == "number") {
                if (pay_type == config.hero_soul) { //神格
                    var hero_soul = role_vo.hero_soul;
                    is_can_buy_num = Math.floor(hero_soul / price);
                }
                else if (pay_type == config.silver_coin) {
                    var silver_coin = role_vo.silver_coin;
                    is_can_buy_num = Math.floor(silver_coin / price);
                }
                else if (pay_type == config.red_gold_or_gold) {
                    var sum_gold = role_vo.red_gold + role_vo.gold;
                    is_can_buy_num = Math.floor(sum_gold / price);
                }
                else if (pay_type == config.arena_guesscent) {
                    var arena_guesscent = role_vo.arena_guesscent;
                    is_can_buy_num = Math.floor(arena_guesscent / price);
                }
                else if (pay_type == config.star_point) {
                    var star_point = role_vo.star_point;
                    is_can_buy_num = Math.floor(star_point / price);
                }
                else if (pay_type == config.gold) {
                    var sum_gold = role_vo.gold;
                    is_can_buy_num = Math.floor(sum_gold / price);
                }
                else if (pay_type == config.coin) {
                    var coin = role_vo.coin;
                    is_can_buy_num = Math.floor(coin / price);
                }
                else{
                    let count = BackpackController.getInstance().getModel().getItemNumByBid(pay_type)
                    is_can_buy_num = Math.floor(count / price)
                }
            } else {
                if (pay_type == "gold") {
                    var gold = role_vo.gold;
                    is_can_buy_num = Math.floor(gold / price);
                }
                else if (pay_type == "red_gold_or_gold") {
                    var sum_gold = role_vo.red_gold + role_vo.gold;
                    is_can_buy_num = Math.floor(sum_gold / price);
                }
                else if (pay_type == "arena_cent") {
                    var arena_cent = role_vo.arena_cent;
                    is_can_buy_num = Math.floor(arena_cent / price);
                }
                else if (pay_type == "friend_point") {
                    var friend_point = role_vo.friend_point
                    is_can_buy_num = Math.floor(friend_point / price)
                }
                else if (pay_type == "guild") {
                    var guild = role_vo.guild
                    is_can_buy_num = Math.floor(guild / price)
                }
                else if (pay_type == "boss_point") {
                    var boss_point = role_vo.boss_point
                    is_can_buy_num = Math.floor(boss_point / price)
                }
                else if (pay_type == "arena_guesscent") {
                    var arena_guesscent = role_vo.arena_guesscent
                    is_can_buy_num = Math.floor(arena_guesscent / price)
                }
                else if (pay_type == "star_point") {
                    var star_point = role_vo.star_point
                    is_can_buy_num = Math.floor(star_point / price)
                }
                else if (pay_type == "sky_coin") {
                    var sky_coin = role_vo.sky_coin
                    is_can_buy_num = Math.floor(sky_coin / price)
                }
                else if (pay_type == "recruithigh_hero") {
                    var recruithigh_hero = role_vo.recruithigh_hero
                    is_can_buy_num = Math.floor(recruithigh_hero / price)
                }
                else if (pay_type == "expedition_medal") {
                    var expedition_medal = role_vo.expedition_medal
                    is_can_buy_num = Math.floor(expedition_medal / price)
                }
                else if (pay_type == "coin") {
                    var coin = role_vo.coin
                    is_can_buy_num = Math.floor(coin / price)
                }
                else if (pay_type == "silver_coin") {
                    var silver_coin = role_vo.silver_coin
                    is_can_buy_num = Math.floor(silver_coin / price)
                }
            }
        }
        return is_can_buy_num
    },
 
    checkActionMoenyByType:function(pay_type,price){
        var role_vo = RoleController.getInstance().getRoleVo();
        var is_can_buy_num = 0;
        if (role_vo){
            var count = role_vo.getActionAssetsNumByBid(pay_type);
            is_can_buy_num = Math.floor(count/price);
        }
        return is_can_buy_num;
    }
});
 
module.exports = MallModel;