Role.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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 huolib\queue\request;
  13. class Role extends Request {
  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 $combat_num = 0; /* 玩家角色战力 */
  21. private $last_login_time = 0; /* 最后登陆时间 */
  22. public function __construct($data = []) {
  23. if (!empty($data)) {
  24. $this->setData($data);
  25. }
  26. }
  27. /**
  28. * 设置数据
  29. *
  30. * @param array $data
  31. */
  32. public function setData($data = []) {
  33. if (empty($data)) {
  34. return;
  35. }
  36. $this->setEvent(get_val($data, 'event', 0));
  37. $this->setServerId(get_val($data, 'server_id'));
  38. $this->setServerName(get_val($data, 'server_name'));
  39. $this->setRoleId(get_val($data, 'role_id'));
  40. $this->setRoleName(get_val($data, 'role_name'));
  41. $this->setRoleLevel(get_val($data, 'role_level', 0));
  42. $this->setCombatNum(get_val($data, 'combat_num', 0));
  43. $this->setLastLoginTime(get_val($data, 'last_login_time', 0));
  44. }
  45. /**
  46. * 变量转数组
  47. *
  48. * @return mixed
  49. */
  50. public function toArray() {
  51. $_data['server_id'] = $this->getServerId();
  52. $_data['server_name'] = $this->getServerName();
  53. $_data['role_id'] = $this->getRoleId();
  54. $_data['role_name'] = $this->getRoleName();
  55. $_data['role_level'] = $this->getRoleLevel();
  56. $_data['type'] = $this->getEvent();
  57. $_data['combat_num'] = $this->getCombatNum();
  58. $_data['last_login_time'] = $this->getLastLoginTime();
  59. return $_data;
  60. }
  61. /**
  62. * check参数合法性
  63. */
  64. public function check() {
  65. // TODO: wuyonghong 2018/5/30 校验角色参数合法性
  66. return true;
  67. }
  68. /**
  69. * @return int
  70. */
  71. public function getEvent() {
  72. return $this->event;
  73. }
  74. /**
  75. * @param int $event
  76. */
  77. public function setEvent($event) {
  78. $this->event = $event;
  79. }
  80. /**
  81. * @return string
  82. */
  83. public function getServerId() {
  84. return $this->server_id;
  85. }
  86. /**
  87. * @param string $server_id
  88. */
  89. public function setServerId($server_id) {
  90. $this->server_id = $server_id;
  91. }
  92. /**
  93. * @return string
  94. */
  95. public function getServerName() {
  96. return $this->server_name;
  97. }
  98. /**
  99. * @param string $server_name
  100. */
  101. public function setServerName($server_name) {
  102. $this->server_name = $server_name;
  103. }
  104. /**
  105. * @return string
  106. */
  107. public function getRoleId() {
  108. return $this->role_id;
  109. }
  110. /**
  111. * @param string $role_id
  112. */
  113. public function setRoleId($role_id) {
  114. $this->role_id = $role_id;
  115. }
  116. /**
  117. * @return string
  118. */
  119. public function getRoleName() {
  120. return $this->role_name;
  121. }
  122. /**
  123. * @param string $role_name
  124. */
  125. public function setRoleName($role_name) {
  126. $this->role_name = $role_name;
  127. }
  128. /**
  129. * @return int
  130. */
  131. public function getRoleLevel() {
  132. return $this->role_level;
  133. }
  134. /**
  135. * @param int $role_level
  136. */
  137. public function setRoleLevel($role_level) {
  138. $this->role_level = $role_level;
  139. }
  140. /**
  141. * @return int
  142. */
  143. public function getCombatNum() {
  144. return $this->combat_num;
  145. }
  146. /**
  147. * @param int $combat_num
  148. */
  149. public function setCombatNum($combat_num) {
  150. $this->combat_num = $combat_num;
  151. }
  152. /**
  153. * @return int
  154. */
  155. public function getLastLoginTime() {
  156. return $this->last_login_time;
  157. }
  158. /**
  159. * @param int $last_login_time
  160. */
  161. public function setLastLoginTime($last_login_time) {
  162. $this->last_login_time = $last_login_time;
  163. }
  164. }