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
"use strict";
cc._RF.push(module, 'ea7eb0d9mFNdY0UoO3iYk7X', 'role_vo');
// Scripts/mod/role/role_vo.js
 
"use strict";
 
/*-----------------------------------------------------+
 * 角色数据模块
 * @author whjing2012@163.com
 +-----------------------------------------------------*/
var RoleEvent = require("role_event");
 
var RoleVo = cc.Class({
  "extends": gcore.BaseEvent,
  ctor: function ctor() {
    this.rid = 0;
    this.srv_id = "";
    this.name = "";
    this.lev = 0;
    this.exp = 0;
    this.exp_max = 0;
    this.sex = 0;
    this.gold = 0;
    this.coin = 0;
    this.vip_lev = 0;
    this.vip_exp = 0;
    this.is_vip = 0; //是否激活vip;
 
    this.face_id = 0; // 头像
 
    this.avatar_base_id = 0; // 头像框
 
    this.face_list = []; // 头像列表 
 
    this.title_id = 0; // 使用称号ID
 
    this.title_list = []; // 已获得称号列表
 
    this.reg_time = 0; //注册时间
 
    this.gid = 0; //公会id
 
    this.gsrv_id = ""; //公会服务器id
 
    this.position = 0; //公会职位
 
    this.gname = ""; //所属帮派的名字
 
    this.guild_lev = 0; //公会等级
 
    this.guild_quit_time = 0; //上次退帮时间
 
    this.friend_point = 0; //友情点
 
    this.power = 0; //战力
 
    this.max_power = 0; //最高战力
 
    this.open_day = 0; // 开服天数
 
    this.energy = 0; //远航情报
 
    this.energy_max = 0; //远航情报上限
 
    this.dic_action_assets = {}; // --活动资产信息 self.dic_action_assets[资产id] = 数量
 
    this.recruithigh_hero = 0; // -- 先知殿积分
 
    this.vip_card_exp = 0;
  },
  // 更新角色数据
  initAttributeData: function initAttributeData(data) {
    for (var k in data) {
      this.setRoleAttribute(k, data[k]);
    }
  },
  // 设置单个属性信息
  setRoleAttribute: function setRoleAttribute(key, value) {
    if (key == "srv_id") {
      var str = "srv_id" + gcore.SysEnv.get("user_name");
      gcore.SysEnv.set(str, value); // console.log("key===",key,value,str);
      // console.log("存储的服务器", gcore.SysEnv.get(str))
    }
 
    if (this[key] != value) {
      this[key] = value;
      this.dispatchUpdateAttrByKey(key, value);
 
      if (key == "lev" && (PLATFORM_TYPR == "SH_RH" || PLATFORM_TYPR == "SH_SDK")) {
        SDK.roleUpLevel(value);
      }
    }
  },
  // 派发单个属性变化事件
  dispatchUpdateAttrByKey: function dispatchUpdateAttrByKey(key, value) {
    this.fire(EventId.UPDATE_ROLE_ATTRIBUTE, key, value);
  },
  // 角色基础数据变化 
  dispatchUpdateBaseAttr: function dispatchUpdateBaseAttr() {
    this.fire(EventId.ROLE_EVENT_BASE_ATTR);
  },
  //判断是否有加入宗派
  isHasGuild: function isHasGuild() {
    return this.gid != 0;
  },
  // --[[角色活动资产信息]]
  // --@is_update 是否数据更新
  initActionAssetsData: function initActionAssetsData(holiday_assets, is_update) {
    holiday_assets = holiday_assets || [];
 
    for (var i = 0; i < holiday_assets.length; ++i) {
      var v = holiday_assets[i];
      this.dic_action_assets[v.id] = v.val;
 
      if (is_update) {
        this.fire(RoleEvent.UPDATE_ROLE_ACTION_ASSETS, v.id, v.val);
      }
    }
  },
  // --获取活动资产数量
  getActionAssetsNumByBid: function getActionAssetsNumByBid(bid) {
    var self = this;
 
    if (self.dic_action_assets && self.dic_action_assets[bid]) {
      return self.dic_action_assets[bid];
    } else {
      return 0;
    }
  },
  setPower: function setPower(value) {
    var old_value = this.power;
    this.power = value || 0;
 
    if (this.is_show_power == true) {
      if (old_value < value) {
        GlobalMessageMgr.getInstance().showPowerMove(value - old_value, null, old_value);
      }
    }
 
    if (this.power != old_value) {
      this.fire(EventId.UPDATE_ROLE_ATTRIBUTE, "power", this.power);
    }
 
    this.showPower(false);
  },
  showPower: function showPower(bool) {
    this.is_show_power = bool;
  },
  //设置最高战力
  setMaxPower: function setMaxPower(value) {
    var old_value = this.max_power;
    this.max_power = value || 0;
 
    if (this.max_power != old_value) {
      this.fire(EventId.UPDATE_ROLE_ATTRIBUTE, "max_power", this.max_power);
    }
  }
});
 
cc._RF.pop();