Role.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <?php
  2. /**
  3. * Role.php UTF-8
  4. * 角色信息
  5. *
  6. * @date : 2018/1/19 15:44
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\controller\request;
  13. class Role {
  14. private $event = 0; /* 角色上传事件类型 5 */
  15. private $server_id = ''; /* 游戏服务器id, */
  16. private $server_name = ''; /* 游戏服务器名称 */
  17. private $role_id = ''; /* 玩家角色id */
  18. private $role_name = ''; /* 玩家角色名称 */
  19. private $role_level = 0; /* 玩家角色等级 */
  20. private $role_vip = 0; /* 玩家vip等级 */
  21. private $combat_num = 0; /* 玩家角色战力 */
  22. private $onlineTime = 0; /* 本次在线时长(单位:秒) */
  23. private $scene = ''; /* 登出场景 */
  24. private $axis = ''; /* 登出时所在场景坐标, 应该是 (x,y,z)的形式 */
  25. private $last_operation = ''; /* 登出前角色最后一次操作或者完成的玩法 */
  26. private $experience = ''; /* 经验 */
  27. private $party_name = ''; /* 工会、帮派名称 */
  28. private $role_balance = ''; /* 用户游戏币余额 */
  29. private $attach = ''; /* 扩展信息 */
  30. private $rolelevel_ctime = ''; /* 角色创建时间 */
  31. private $rolelevel_mtime = ''; /* 角色升级时间 */
  32. private $last_login_time = 0; /* 最近登陆时间 */
  33. public function __construct($data = []) {
  34. if (!empty($data)) {
  35. $this->setData($data);
  36. }
  37. }
  38. /**
  39. * 设置数据
  40. *
  41. * @param array $data
  42. */
  43. public function setData($data = []) {
  44. if (empty($data)) {
  45. return;
  46. }
  47. $this->setEvent(get_val($data, 'event', 0));
  48. $this->setServerId(get_val($data, 'server_id'));
  49. $this->setServerName(get_val($data, 'server_name'));
  50. $this->setRoleId(get_val($data, 'role_id'));
  51. $this->setRoleName(get_val($data, 'role_name'));
  52. $this->setRoleLevel(get_val($data, 'role_level', 0));
  53. $this->setRoleVip(get_val($data, 'role_vip', 0));
  54. $this->setCombatNum(get_val($data, 'combat_num', 0));
  55. $this->setLastLoginTime(get_val($data, 'list_login_time', 0));
  56. $this->setOnlineTime(get_val($data, 'onlineTime', 0));
  57. $this->setScene(get_val($data, 'scene'));
  58. $this->setAxis(get_val($data, 'axis'));
  59. $this->setLastOperation(get_val($data, 'last_operation'));
  60. $this->setExperience(get_val($data, 'last_operation', 0));
  61. $this->setPartyName(get_val($data, 'party_name', 0));
  62. $this->setRoleBalance(get_val($data, 'role_balance', 0));
  63. $this->setAttach(get_val($data, 'attach', 0));
  64. $this->setRolelevelCtime(get_val($data, 'rolelevel_ctime', 0));
  65. $this->setRolelevelMtime(get_val($data, 'rolelevel_mtime', 0));
  66. }
  67. /**
  68. * @return int
  69. */
  70. public function getEvent() {
  71. return $this->event;
  72. }
  73. /**
  74. * @param int $event
  75. */
  76. public function setEvent($event) {
  77. if (is_numeric($event)) {
  78. $this->event = $event;
  79. } else {
  80. switch ($event) {
  81. case 'online':
  82. /* 角色登录 */
  83. $this->event = 1;
  84. break;
  85. case 'create':
  86. /* 创建角色 */
  87. $this->event = 2;
  88. break;
  89. case 'levelup':
  90. /* 提升等级 */
  91. $this->event = 3;
  92. break;
  93. case 'offline':
  94. /* 角色退出 */
  95. $this->event = 4;
  96. break;
  97. case 'delete':
  98. /* 其他 */
  99. $this->event = 6;
  100. break;
  101. default:
  102. /* 其他 */
  103. $this->event = 5;
  104. }
  105. }
  106. }
  107. /**
  108. * @return string
  109. */
  110. public function getServerId() {
  111. return $this->server_id;
  112. }
  113. /**
  114. * @param string $server_id
  115. */
  116. public function setServerId($server_id) {
  117. $this->server_id = $server_id;
  118. }
  119. /**
  120. * @return string
  121. */
  122. public function getServerName() {
  123. return $this->server_name;
  124. }
  125. /**
  126. * @param string $server_name
  127. */
  128. public function setServerName($server_name) {
  129. $this->server_name = $server_name;
  130. }
  131. /**
  132. * @return string
  133. */
  134. public function getRoleId() {
  135. return $this->role_id;
  136. }
  137. /**
  138. * @param string $role_id
  139. */
  140. public function setRoleId($role_id) {
  141. $this->role_id = $role_id;
  142. }
  143. /**
  144. * @return string
  145. */
  146. public function getRoleName() {
  147. return $this->role_name;
  148. }
  149. /**
  150. * @param string $role_name
  151. */
  152. public function setRoleName($role_name) {
  153. $this->role_name = $role_name;
  154. }
  155. /**
  156. * @return int
  157. */
  158. public function getRoleLevel() {
  159. return $this->role_level;
  160. }
  161. /**
  162. * @param int $role_level
  163. */
  164. public function setRoleLevel($role_level) {
  165. $this->role_level = $role_level;
  166. }
  167. /**
  168. * @return int
  169. */
  170. public function getRoleVip() {
  171. return $this->role_vip;
  172. }
  173. /**
  174. * @param int $role_vip
  175. */
  176. public function setRoleVip($role_vip) {
  177. $this->role_vip = $role_vip;
  178. }
  179. /**
  180. * @return int
  181. */
  182. public function getCombatNum() {
  183. return $this->combat_num;
  184. }
  185. /**
  186. * @param int $combat_num
  187. */
  188. public function setCombatNum($combat_num) {
  189. $this->combat_num = $combat_num;
  190. }
  191. /**
  192. * @return int
  193. */
  194. public function getLastLoginTime() {
  195. return $this->last_login_time;
  196. }
  197. /**
  198. * @param int $last_login_time
  199. */
  200. public function setLastLoginTime($last_login_time) {
  201. $this->last_login_time = $last_login_time;
  202. }
  203. /**
  204. * @return int
  205. */
  206. public function getOnlineTime() {
  207. return $this->onlineTime;
  208. }
  209. /**
  210. * @param int $onlineTime
  211. */
  212. public function setOnlineTime($onlineTime) {
  213. $this->onlineTime = $onlineTime;
  214. }
  215. /**
  216. * @return string
  217. */
  218. public function getScene() {
  219. return $this->scene;
  220. }
  221. /**
  222. * @param string $scene
  223. */
  224. public function setScene($scene) {
  225. $this->scene = $scene;
  226. }
  227. /**
  228. * @return string
  229. */
  230. public function getAxis() {
  231. return $this->axis;
  232. }
  233. /**
  234. * @param string $axis
  235. */
  236. public function setAxis($axis) {
  237. $this->axis = $axis;
  238. }
  239. /**
  240. * @return string
  241. */
  242. public function getLastOperation() {
  243. return $this->last_operation;
  244. }
  245. /**
  246. * @param string $last_operation
  247. */
  248. public function setLastOperation($last_operation) {
  249. $this->last_operation = $last_operation;
  250. }
  251. /**
  252. * @return string
  253. */
  254. public function getExperience() {
  255. return $this->experience;
  256. }
  257. /**
  258. * @param string $experience
  259. */
  260. public function setExperience($experience) {
  261. $this->experience = $experience;
  262. }
  263. /**
  264. * @return string
  265. */
  266. public function getPartyName() {
  267. return $this->party_name;
  268. }
  269. /**
  270. * @param string $party_name
  271. */
  272. public function setPartyName($party_name) {
  273. $this->party_name = $party_name;
  274. }
  275. /**
  276. * @return string
  277. */
  278. public function getRoleBalance() {
  279. return $this->role_balance;
  280. }
  281. /**
  282. * @param string $role_balance
  283. */
  284. public function setRoleBalance($role_balance) {
  285. $this->role_balance = $role_balance;
  286. }
  287. /**
  288. * @return string
  289. */
  290. public function getAttach() {
  291. return $this->attach;
  292. }
  293. /**
  294. * @param string $attach
  295. */
  296. public function setAttach($attach) {
  297. $this->attach = $attach;
  298. }
  299. /**
  300. * @return string
  301. */
  302. public function getRolelevelCtime() {
  303. return $this->rolelevel_ctime;
  304. }
  305. /**
  306. * @param string $rolelevel_ctime
  307. */
  308. public function setRolelevelCtime($rolelevel_ctime) {
  309. $this->rolelevel_ctime = $rolelevel_ctime;
  310. }
  311. /**
  312. * @return string
  313. */
  314. public function getRolelevelMtime() {
  315. return $this->rolelevel_mtime;
  316. }
  317. /**
  318. * @param string $rolelevel_mtime
  319. */
  320. public function setRolelevelMtime($rolelevel_mtime) {
  321. $this->rolelevel_mtime = $rolelevel_mtime;
  322. }
  323. public function toArray() {
  324. $_data['server_id'] = $this->getServerId();
  325. $_data['server_name'] = $this->getServerName();
  326. $_data['role_id'] = $this->getRoleId();
  327. $_data['role_name'] = $this->getRoleName();
  328. $_data['role_level'] = $this->getRoleLevel();
  329. $_data['role_vip'] = $this->getRoleVip();
  330. $_data['online_time'] = $this->getOnlineTime();
  331. $_data['scene'] = $this->getScene();
  332. $_data['axis'] = $this->getAxis();
  333. $_data['last_operation'] = $this->getLastOperation();
  334. $_data['type'] = $this->getEvent();
  335. $_data['last_operation'] = $this->getExperience();
  336. $_data['party_name'] = $this->getPartyName();
  337. $_data['role_balance'] = $this->getRoleBalance();
  338. $_data['attach'] = $this->getAttach();
  339. $_data['rolelevel_ctime'] = $this->getRolelevelCtime();
  340. $_data['rolelevel_mtime'] = $this->getRolelevelMtime();
  341. return $_data;
  342. }
  343. }