Info_UserGameHero.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 Info_UserGameHero 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. /**
  69. *
  70. * @param type $heroMoId
  71. */
  72. public function GetHeroByMoID($heroMoId) {
  73. my_Assert(null != $this->collectHeros, ErrCode::err_innerfault);
  74. foreach ($this->collectHeros as $hid => $hero) {
  75. isEditor() and $hero = new Ins_UserHero();
  76. if ($hero->typeId == $heroMoId) {
  77. return $hero;
  78. }
  79. }
  80. return null;
  81. }
  82. }