UserHeroModel.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * 玩家的英雄的实体数据
  5. */
  6. class UserHeroModel extends Object_ext {
  7. /**
  8. * 唯一的英雄ID
  9. * @var string
  10. */
  11. public $uid;
  12. /**
  13. * 英雄的模板ID
  14. * @var string
  15. */
  16. public $typeId;
  17. /**
  18. * 英雄的当前等级
  19. * @var int
  20. */
  21. public $level;
  22. /**
  23. * 英雄当前等阶
  24. * @var string
  25. */
  26. public $grade;
  27. /**
  28. * 英雄的收集的当前等级满级的累计经验值
  29. * @var int
  30. */
  31. public $maxXp;
  32. /**
  33. * 英雄的当前总经验值
  34. * @var int
  35. */
  36. public $xp;
  37. /**
  38. * 当前等阶 默认是0.
  39. * 0= 绿 1=蓝 2= 红 3= 紫 4= 橙 5
  40. * @var int
  41. * @deprecated since version 0
  42. */
  43. public $strengthLevel;
  44. /**
  45. * 当前星级 默认是0星
  46. * @var int
  47. * @deprecated since version 0
  48. */
  49. public $curStar;
  50. /**
  51. * 当前神血的 血脉等级 默认是0
  52. * @var int
  53. * @deprecated since version 0
  54. */
  55. public $curBloodId;
  56. /**
  57. * 当前卡牌的锁定状态
  58. * true = 锁定
  59. * @var bool
  60. * @deprecated since version 0
  61. */
  62. public $isLocked;
  63. /**
  64. * 技能数据
  65. * @var object
  66. * @deprecated since version 0
  67. */
  68. public $skills;
  69. /**
  70. * 子技能列表(已解锁子技能id)
  71. * @var dic<int,[]int>
  72. */
  73. public $subSkills;
  74. /**
  75. * 装备
  76. * @var object
  77. */
  78. public $equip;
  79. /**
  80. * 言灵
  81. * @var {}
  82. */
  83. public $yanling;
  84. /**
  85. * 当前主线的好感度进度
  86. * @var object
  87. * @deprecated since version 0
  88. */
  89. public $curMainFavor;
  90. /**
  91. * 所有的已经拥有的好感度进度
  92. * @var array
  93. * @deprecated since version 0
  94. */
  95. public $favors;
  96. /**
  97. *
  98. * 构造函数
  99. */
  100. public function __construct($arg = null) {
  101. if (null != $arg) {
  102. parent::__construct($arg);
  103. } else {
  104. $this->level = 1;
  105. $this->xp = 0;
  106. $this->maxXp = 0;
  107. $this->strengthLevel = 0;
  108. $this->curBloodId = 0;
  109. $this->curStar = 0;
  110. $this->isLocked = false;
  111. $this->curMainFavor = 'E';
  112. $this->favors = ArrayInit();
  113. $this->favors[] = 'E';
  114. $this->grade = "D";
  115. //-----------初始化技能的默认数据
  116. $temp = ObjectInit();
  117. $temp->normalSkill = JsonUtil::decode('{"level":1}');
  118. $temp->manuSkill1 = JsonUtil::decode('{"level":1}');
  119. $temp->manuSkill2 = JsonUtil::decode('{"level":1}');
  120. $temp->manuSkill3 = JsonUtil::decode('{"level":1}');
  121. $temp->passiveSkill = JsonUtil::decode('{"level":1}');
  122. $temp->captainSkill = JsonUtil::decode('{"level":1}');
  123. $this->skills = $temp;
  124. $this->subSkills = ObjectInit();
  125. //----初始化装备的默认数据
  126. $this->equip = ObjectInit();
  127. $tempEq = ObjectInit();
  128. $tempEq->weapon = JsonUtil::decode('{"itemuid":0}');
  129. $tempEq->armor = JsonUtil::decode('{"itemuid":0}');
  130. $tempEq->ring = JsonUtil::decode('{"itemuid":0}');
  131. $this->equip = $tempEq;
  132. // ------初始化言灵的默认数据
  133. $this->yanling = JsonUtil::decode('{"1":{"itemuid":0},"2":{"itemuid":0},"3":{"itemuid":0}}');
  134. }
  135. }
  136. /**
  137. * 判断技能是否可升级
  138. * @param type $mainSkillId
  139. * @param type $subSkillId Description
  140. * @return type
  141. */
  142. public function IsSkillUpdateAble($mainSkillId, $subSkillId) {
  143. $sarr = array("D" => 1, "C" => 2, "B" => 3, "A" => 4, "S" => 5);
  144. $isOk = false;
  145. if (CommUtil::isPropertyExists($this->subSkills, $mainSkillId)) {
  146. if (CommUtil::isPropertyExists($this->subSkills->$mainSkillId, $subSkillId)) {
  147. $sm = GameConfig::subSkill_getItem($subSkillId);
  148. switch ($sm->upgradeConditionType) {
  149. case 1: // 角色等级
  150. $isOk = $this->level >= int($sm->upgradeParameter);
  151. break;
  152. case 2: // 角色品阶
  153. $cur = (array_key_exists($this->grade, $sarr) ? $sarr[$this->grade] : 0);
  154. $require = (array_key_exists($sm->upgradeParameter, $sarr) ? $sarr[$sm->upgradeParameter] : 0);
  155. $isOk = $cur >= $require;
  156. break;
  157. default:
  158. break;
  159. }
  160. }
  161. }
  162. return $isOk;
  163. }
  164. /**
  165. * 判断技能是否可解锁
  166. * @param type $mainSkillId
  167. * @param type $subSkillId Description
  168. * @return type
  169. */
  170. public function IsSkillUnlockAble($mainSkillId, $subSkillId) {
  171. $sarr = array("D" => 1, "C" => 2, "B" => 3, "A" => 4, "S" => 5);
  172. $isOk = false;
  173. if (CommUtil::isPropertyExists($this->subSkills, $mainSkillId)) {
  174. if (CommUtil::isPropertyExists($this->subSkills->$mainSkillId, $subSkillId)) {
  175. $sm = GameConfig::subSkill_getItem($subSkillId);
  176. switch ($sm->unlockConditionType) {
  177. case 1: // 角色等级
  178. $isOk = $this->level >= int($sm->unlockParameter);
  179. break;
  180. case 2: // 角色品阶
  181. $cur = (array_key_exists($this->grade, $sarr) ? $sarr[$this->grade] : 0);
  182. $require = (array_key_exists($sm->unlockParameter, $sarr) ? $sarr[$sm->unlockParameter] : 0);
  183. $isOk = $cur >= $require;
  184. break;
  185. default:
  186. break;
  187. }
  188. }
  189. }
  190. return $isOk;
  191. }
  192. /**
  193. * 是否可继续升级(指挥官等级限制 + 全局限制)
  194. * @return bool
  195. */
  196. public function HeroCanLevelUp() {
  197. $maxLevel = glc()->Hero_Upgrade_BasicMaxLevel; # 全局设置限制了当前英雄的最高等级
  198. $playerLimit = GameConfig::playerlevel_getItem(req()->userInfo->game->level)->hero_max_level;
  199. return $this->level < min($maxLevel, $playerLimit);
  200. }
  201. }