UserGameHeroModel.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * Description of UserGameHeroModel
  5. * @version
  6. * 1.0.0 Created at 2017-2-14. by --gwang
  7. * @author gwang (mail@wanggangzero.cn)
  8. * @copyright ? 2017-2-14, SJZ LoyalSoft Corporation & gwang. All rights reserved.
  9. */
  10. /**
  11. * 玩家收集的英雄的卡牌集合
  12. */
  13. class UserGameHeroModel extends Object_ext {
  14. /**
  15. * 当前展示的英雄的UID
  16. * @var type string
  17. */
  18. public $displayHeroUID;
  19. /**
  20. * 好友支援的英雄的UID
  21. * @var type string
  22. */
  23. public $firendSupportHeroUID;
  24. /**
  25. * 当前收集卡牌的数量上限(可扩容)
  26. * @var type int
  27. */
  28. public $maxCollectCount;
  29. /**
  30. * 英雄集合
  31. * @var {}
  32. */
  33. public $collectHeros;
  34. /**
  35. * 记录一下曾经的最大UID
  36. * @var type int
  37. */
  38. public $recordMaxUID;
  39. /**
  40. *
  41. * @param CRedisUtil $mem
  42. */
  43. public function InitializeHero() {
  44. $this->displayHeroUID = null;
  45. $this->firendSupportHeroUID = null;
  46. $this->maxCollectCount = glc()->Game_CollectHero_BasicMaxCount;
  47. $this->recordMaxUID = 0;
  48. $this->collectHeros = ObjectInit(); # 初始化英雄集合
  49. $hids = GameConfig::primordial_data()->User_Heros; # 设置初始英雄
  50. my_Assert(null != $hids, ErrCode::err_const_no);
  51. foreach ($hids as $heroModelId_yanlingid) {
  52. list( $heroModelId, $yanlingId) = explode('_', $heroModelId_yanlingid);
  53. $uid = HeroProc::CreateNewGameHeroUID($this->collectHeros, $this->recordMaxUID);
  54. $this->recordMaxUID = $uid;
  55. $hero = HeroProc::getGameHeroModelInstance($heroModelId, $uid);
  56. // 初始化言灵
  57. $yanlingMo = GameConfig::item_yanling_getItem($yanlingId);
  58. my_Assert(null != $yanlingMo, ErrCode::err_const_no);
  59. $yl_uid = StoreProc::PutYanLingInStore($yanlingMo->typeId, req());
  60. req()->userInfo->game->store->yanling->$yl_uid->herouid = $uid;
  61. $position = $yanlingMo->position;
  62. $hero->yanling->$position = array("itemuid" => $yl_uid); # 装备位置
  63. $this->collectHeros->$uid = $hero;
  64. $this->displayHeroUID = $uid;
  65. $this->firendSupportHeroUID = $uid;
  66. }
  67. }
  68. }