123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <?php
- namespace loyalsoft;
- /**
- * Description of StoreModel
- * 玩家背包/仓库数据模型
- * @author gwang
- */
- class Info_Store extends Object_ext {
- /**
- * 其他道具
- * @var array
- */
- public $items;
- /**
- * 任务卡道具(存在叠加)
- * @var array
- */
- public $taskcards;
- /**
- * 装备, 能强化升级, 独立于其它道具
- * @var type
- */
- public $equipment;
- /**
- * @var 言灵,能强化升级, 独立于其它道具
- */
- public $yanling;
- /**
- * 宝箱
- * @var array
- */
- public $boxes;
- /**
- * 英雄碎片,叠加
- * @var object
- * @deprecated since version 0
- */
- public $segement;
- /**
- * 触发限时随机礼包的记录
- * @var type
- */
- public $triggerLimitTsGift = array();
- /**
- * 商店武器每日刷新出的武器id----不同地区npc不同
- * @var type
- */
- public $weaponPool = null;
-
- /**
- * 万一所有的武器都随机完了那,只能在重置武器池重新刷新,这个就是保存购买记录的
- * @var type
- */
- public $weaponReward = null;
- /*
- * 储物间
- */
- public $storage = null;
-
- /*
- * 战斗中使用的血瓶等消耗品
- */
- public $battleItem = null;
- /*
- * 每日任务--交付任务是否领取奖励
- */
- public $dailyTask_HandOver = 0;
- /**
- * 玩家注册时初始化
- */
- public function initialize() {
- $this->boxes = GameConfig::primordial_data()->User_Store_boxes;
- $this->taskcards = ObjectInit();
- StoreProc::PutTaskCardInStore(601100022); # 进杰: 直接设定第一张任务卡, --gwang 2022年2月25日11:16:18
- $this->items = JsonUtil::decode(GameConfig::primordial_data()->User_Store_items); # 初始含有一张黄金通知书
- $this->equipment = JsonUtil::decode(GameConfig::primordial_data()->User_Store_equipment); # 装备初始化数据
- $this->yanling = JsonUtil::decode(GameConfig::primordial_data()->User_Store_yanling); # 言灵初始化数据
- $this->segement = JsonUtil::decode(GameConfig::primordial_data()->User_Store_segment); # 碎片
-
- $this->weaponPool = ObjectInit();
- $this->weaponReward = ObjectInit();
-
- $key = 1;
- $key2 = 2;
- $this->storage = ObjectInit();
- $this->storage->$key = new Ins_storage();
- $this->storage->$key2 = new Ins_storage();
-
- $this->battleItem = ObjectInit();
- }
- /**
- * 返回指定物品的数量
- */
- function GetItemCount($typeId) {
- if (property_exists($this->items, $typeId)) {
- return $this->items->$typeId;
- }
- return 0;
- }
- function RemoveItemFromStore($typeId, $num) {
- my_Assert(CommUtil::isPropertyExists($this->items, $typeId), ErrCode::store_itemno_err); # 没有这个道具
- my_Assert($this->items->$typeId >= $num, ErrCode::store_itemnotenough); # 数量不足
- $this->items->$typeId -= $num;
- if ($this->items->$typeId == 0) {
- unset($this->items->$typeId);
- }
- NormalEventProc::OnBag_Remove_Item($typeId, $num); # 插入事件
- return ErrCode::ok;
- }
- /**
- * 扣除玩家碎片
- * @param int $segmentId 碎片ID
- * @param int $amt 数量
- * @return boolean true 成功, false 失败
- */
- function Consume_HeroSegment($segmentId, $amt) {
- if ($amt > 0) {
- if (CommUtil::isPropertyExists($this->items, $segmentId)) {
- if ($this->items->$segmentId - $amt >= 0) {
- $this->items->$segmentId -= $amt;
- return true;
- }
- }
- }
- return false;
- }
- }
|