Info_Store.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. */
  42. public function initialize() {
  43. $this->boxes = GameConfig::primordial_data()->User_Store_boxes;
  44. $this->taskcards = ObjectInit();
  45. $this->items = JsonUtil::decode(GameConfig::primordial_data()->User_Store_items); # 初始含有一张黄金通知书
  46. $this->equipment = JsonUtil::decode(GameConfig::primordial_data()->User_Store_equipment); # 装备初始化数据
  47. $this->yanling = JsonUtil::decode(GameConfig::primordial_data()->User_Store_yanling); # 言灵初始化数据
  48. $this->segement = JsonUtil::decode(GameConfig::primordial_data()->User_Store_segment); # 碎片
  49. }
  50. /**
  51. * 返回指定物品的数量
  52. */
  53. function GetItemCount($typeId) {
  54. if (property_exists($this->items, $typeId)) {
  55. return $this->items->$typeId;
  56. }
  57. return 0;
  58. }
  59. /**
  60. * 扣除玩家碎片
  61. * @param int $segmentId 碎片ID
  62. * @param int $amt 数量
  63. * @return boolean true 成功, false 失败
  64. */
  65. function Consume_HeroSegment($segmentId, $amt) {
  66. if ($amt > 0) {
  67. if (CommUtil::isPropertyExists($this->items, $segmentId)) {
  68. if ($this->items->$segmentId - $amt >= 0) {
  69. $this->items->$segmentId -= $amt;
  70. return true;
  71. }
  72. }
  73. }
  74. return false;
  75. }
  76. }