Info_UserGameHero.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. StatisticsProc::TargetStatistics(Enum_TargetStatistics::HuanLingShiId_UserNum, $heroModelId);
  57. StatisticsProc::TargetStatistics(Enum_TargetStatistics::HuanLingShiLevel_UserNum, $heroModelId,"1");
  58. // // 初始化言灵
  59. // $yanlingMo = GameConfig::item_yanling_getItem($yanlingId);
  60. // my_Assert(null != $yanlingMo, ErrCode::err_const_no);
  61. // $yl_uid = StoreProc::PutYanLingInStore($yanlingMo->typeId, req());
  62. // ctx()->store->yanling->$yl_uid->herouid = $uid;
  63. // $position = $yanlingMo->position;
  64. // $hero->yanling->$position = array("itemuid" => $yl_uid); # 装备位置
  65. $this->collectHeros->$uid = $hero;
  66. $this->displayHeroUID = $uid;
  67. $this->firendSupportHeroUID = $uid;
  68. }
  69. }
  70. /**
  71. *
  72. * @param type $heroMoId
  73. */
  74. public function GetHeroByMoID($heroMoId) {
  75. my_Assert(null != $this->collectHeros, ErrCode::err_innerfault);
  76. foreach ($this->collectHeros as $hid => $hero) {
  77. isEditor() and $hero = new Ins_UserHero();
  78. if ($hero->typeId == $heroMoId) {
  79. return $hero;
  80. }
  81. }
  82. return null;
  83. }
  84. }