Info_Store.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. namespace loyalsoft;
  3. /**
  4. * Description of StoreModel
  5. * 玩家背包/仓库数据模型
  6. * @author gwang
  7. */
  8. class Info_Store extends Object_ext {
  9. /**
  10. * 其他道具
  11. * @var array
  12. */
  13. public $items;
  14. /**
  15. * 任务卡道具(存在叠加)
  16. * @var array
  17. */
  18. public $taskcards;
  19. /**
  20. * 装备, 能强化升级, 独立于其它道具
  21. * @var type
  22. */
  23. public $equipment;
  24. /**
  25. * @var 言灵,能强化升级, 独立于其它道具
  26. */
  27. public $yanling;
  28. /**
  29. * 宝箱
  30. * @var array
  31. */
  32. public $boxes;
  33. /**
  34. * 英雄碎片,叠加
  35. * @var object
  36. * @deprecated since version 0
  37. */
  38. public $segement;
  39. /**
  40. * 触发限时随机礼包的记录
  41. * @var type
  42. */
  43. public $triggerLimitTsGift = array();
  44. /**
  45. * 商店武器每日刷新出的武器id----不同地区npc不同
  46. * @var type
  47. */
  48. public $weaponPool = null;
  49. /**
  50. * 万一所有的武器都随机完了那,只能在重置武器池重新刷新,这个就是保存购买记录的
  51. * @var type
  52. */
  53. public $weaponReward = null;
  54. /*
  55. * 储物间
  56. */
  57. public $storage = null;
  58. /*
  59. * 战斗中使用的血瓶等消耗品
  60. */
  61. public $battleItem = null;
  62. /*
  63. * 每日任务--交付任务是否领取奖励
  64. */
  65. public $dailyTask_HandOver = 0;
  66. /**
  67. * 玩家注册时初始化
  68. */
  69. public function initialize() {
  70. $this->boxes = GameConfig::primordial_data()->User_Store_boxes;
  71. $this->taskcards = ObjectInit();
  72. StoreProc::PutTaskCardInStore(601100022); # 进杰: 直接设定第一张任务卡, --gwang 2022年2月25日11:16:18
  73. $this->items = JsonUtil::decode(GameConfig::primordial_data()->User_Store_items); # 初始含有一张黄金通知书
  74. $this->equipment = JsonUtil::decode(GameConfig::primordial_data()->User_Store_equipment); # 装备初始化数据
  75. $this->yanling = JsonUtil::decode(GameConfig::primordial_data()->User_Store_yanling); # 言灵初始化数据
  76. $this->segement = JsonUtil::decode(GameConfig::primordial_data()->User_Store_segment); # 碎片
  77. $this->weaponPool = ObjectInit();
  78. $this->weaponReward = ObjectInit();
  79. $key = 1;
  80. $key2 = 2;
  81. $this->storage = ObjectInit();
  82. $this->storage->$key = new Ins_storage();
  83. $this->storage->$key2 = new Ins_storage();
  84. $this->battleItem = ObjectInit();
  85. }
  86. /**
  87. * 返回指定物品的数量
  88. */
  89. function GetItemCount($typeId) {
  90. if (property_exists($this->items, $typeId)) {
  91. return $this->items->$typeId;
  92. }
  93. return 0;
  94. }
  95. function RemoveItemFromStore($typeId, $num) {
  96. my_Assert(CommUtil::isPropertyExists($this->items, $typeId), ErrCode::store_itemno_err); # 没有这个道具
  97. my_Assert($this->items->$typeId >= $num, ErrCode::store_itemnotenough); # 数量不足
  98. $this->items->$typeId -= $num;
  99. if ($this->items->$typeId == 0) {
  100. unset($this->items->$typeId);
  101. }
  102. NormalEventProc::OnBag_Remove_Item($typeId, $num); # 插入事件
  103. return ErrCode::ok;
  104. }
  105. /**
  106. * 扣除玩家碎片
  107. * @param int $segmentId 碎片ID
  108. * @param int $amt 数量
  109. * @return boolean true 成功, false 失败
  110. */
  111. function Consume_HeroSegment($segmentId, $amt) {
  112. if ($amt > 0) {
  113. if (CommUtil::isPropertyExists($this->items, $segmentId)) {
  114. if ($this->items->$segmentId - $amt >= 0) {
  115. $this->items->$segmentId -= $amt;
  116. return true;
  117. }
  118. }
  119. }
  120. return false;
  121. }
  122. }