|
@@ -77,10 +77,192 @@ class StoreProc {
|
|
|
return StoreProc::Pet_DownGradingLevel();
|
|
|
case CmdCode::store_pet_downGradingQual: # 6428 宠物降品
|
|
|
return StoreProc::Pet_DownGradingQual();
|
|
|
+ case CmdCode::store_pet_breedEgg: # 6429 孵化宠物
|
|
|
+ return StoreProc::Pet_BreedEgg();
|
|
|
+ case CmdCode::store_pet_fastBreedEgg: # 6430 加速孵化宠物
|
|
|
+ return StoreProc::Pet_FastBreedEgg();
|
|
|
+ case CmdCode::store_pet_receiveBreedPet: # 6431 正常孵化完成点击领取
|
|
|
+ return StoreProc::Pet_ReceiveBreedPet();
|
|
|
+ case CmdCode::store_pet_unlockBreedLocation: # 6432 解锁孵化位置
|
|
|
+ return StoreProc::Pet_UnlockBreedLocation();
|
|
|
default:
|
|
|
Err(ErrCode::cmd_err);
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 6432 解锁孵化位置
|
|
|
+ * @return Resp
|
|
|
+ */
|
|
|
+ public static function Pet_UnlockBreedLocation() {
|
|
|
+ list($slotId) = req()->paras;
|
|
|
+
|
|
|
+ $list = explode(';',GameConfig::glc2()->Pet_BreedLocationUnlockInfo);
|
|
|
+ foreach ($list as $value) {
|
|
|
+ $s = explode(',', $value);
|
|
|
+ if($s[0] == $slotId){
|
|
|
+ my_Assert(ctx()->baseInfo->cash >= $s[1], ErrCode::notenough_cash_msg);
|
|
|
+ ctx()->base()->Consume_Cash($s[1]);
|
|
|
+ $breed = new Ins_BreedEggSlot(ctx()->store->breedEggLocation->$slotId);
|
|
|
+ $breed->unlock = 1;
|
|
|
+ ctx()->store()->breedEggLocation->$slotId = $breed;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ UserProc::updateUserInfo();
|
|
|
+ return Resp::ok(array(
|
|
|
+ 'cash' => ctx()->baseInfo->cash,
|
|
|
+ 'store' => ctx()->store,
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 6431 正常孵化完成点击领取
|
|
|
+ * @return Resp
|
|
|
+ */
|
|
|
+ public static function Pet_ReceiveBreedPet() {
|
|
|
+ list($slotId) = req()->paras;
|
|
|
+
|
|
|
+ $ins_breed = new Ins_BreedEggSlot(ctx()->store()->breedEggLocation->$slotId);
|
|
|
+ my_Assert($ins_breed->eggId != 0, ErrCode::user_store_NoExistBreedEgg);
|
|
|
+ my_Assert($ins_breed->unlock == 1, ErrCode::user_store_SlotNotUnlocked);
|
|
|
+ my_Assert(now() >= $ins_breed->endTs, ErrCode::user_store_NoCompleteBreed);
|
|
|
+
|
|
|
+ StoreProc::AddMultiItemInStore($ins_breed->mo()->reward);
|
|
|
+
|
|
|
+ //随机一个灵宠
|
|
|
+ $str = explode(';', $ins_breed->mo()->per);
|
|
|
+ $newPet = self::RandObtainPet($str);
|
|
|
+
|
|
|
+ $uid = 0;
|
|
|
+ if($newPet != null){
|
|
|
+ $uid = $newPet->uid;
|
|
|
+ ctx()->store()->pet->$uid = $newPet;
|
|
|
+ }
|
|
|
+
|
|
|
+ UserProc::updateUserInfo();
|
|
|
+ return Resp::ok(array(
|
|
|
+ 'cash' => ctx()->baseInfo->cash,
|
|
|
+ 'store' => ctx()->store,
|
|
|
+ 'newPetUid'=>$uid,
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 6430 加速孵化宠物
|
|
|
+ * @return Resp
|
|
|
+ */
|
|
|
+ public static function Pet_FastBreedEgg() {
|
|
|
+ list($slotId) = req()->paras;
|
|
|
+ $ins_breed = new Ins_BreedEggSlot(ctx()->store()->breedEggLocation->$slotId);
|
|
|
+ my_Assert($ins_breed->eggId != 0, ErrCode::user_store_NoExistBreedEgg);
|
|
|
+ my_Assert($ins_breed->unlock == 1, ErrCode::user_store_SlotNotUnlocked);
|
|
|
+ my_Assert(now() < $ins_breed->endTs, ErrCode::user_store_CompleteBreed);
|
|
|
+
|
|
|
+ $num = $ins_breed->mo()->breedTs/60/10;
|
|
|
+ $cash_one = $ins_breed->mo()->fastBreed_cost/$num;
|
|
|
+
|
|
|
+ $ts = $ins_breed->endTs - now();
|
|
|
+ $costNum = ceil($ts/60/10);
|
|
|
+
|
|
|
+ my_Assert(ctx()->baseInfo->cash >= $costNum*$cash_one, ErrCode::notenough_cash_msg);
|
|
|
+ ctx()->base()->Consume_Cash($costNum*$cash_one);
|
|
|
+
|
|
|
+ StoreProc::AddMultiItemInStore($ins_breed->mo()->reward);
|
|
|
+
|
|
|
+ //随机一个灵宠
|
|
|
+ $str = explode(';', $ins_breed->mo()->per);
|
|
|
+ $newPet = self::RandObtainPet($str);
|
|
|
+
|
|
|
+ $uid = 0;
|
|
|
+ if($newPet != null){
|
|
|
+ $uid = $newPet->uid;
|
|
|
+ ctx()->store()->pet->$uid = $newPet;
|
|
|
+ }
|
|
|
+
|
|
|
+ UserProc::updateUserInfo();
|
|
|
+ return Resp::ok(array(
|
|
|
+ 'cash' => ctx()->baseInfo->cash,
|
|
|
+ 'store' => ctx()->store,
|
|
|
+ 'newPetUid'=>$uid,
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化一个宠物
|
|
|
+ * @param type $rarity
|
|
|
+ * @param type $qual
|
|
|
+ * @param type $petType
|
|
|
+ */
|
|
|
+ public static function RandObtainPet($str) {
|
|
|
+ //随机一个灵宠
|
|
|
+ $randNum = rand(1,10000);
|
|
|
+ $start = 0;
|
|
|
+ $end = 0;
|
|
|
+
|
|
|
+ $rarity = 0;
|
|
|
+ $qual = 0;
|
|
|
+ $petType = 0;
|
|
|
+ foreach ($str as $key => $value) {
|
|
|
+ $s = explode(',', $value);
|
|
|
+ $end += $s[3]*100;
|
|
|
+ if($randNum > $start && $randNum <= $end){
|
|
|
+ $rarity = $s[0];
|
|
|
+ $qual = $s[1];
|
|
|
+ $petType = $s[2];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $start = $end;
|
|
|
+ }
|
|
|
+
|
|
|
+ $dic = GameConfig::pet();
|
|
|
+ $petArr = array();
|
|
|
+ foreach ($dic as $typeId => $mo) {
|
|
|
+ if($mo->petType == $petType && $mo->qual == $qual && $mo->rarity == $rarity){
|
|
|
+ $petArr[] = $typeId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $typeId = 0;
|
|
|
+ if(count($petArr) > 0){
|
|
|
+ $num = rand(0,count($petArr)-1);
|
|
|
+ $typeId = $petArr[$num];
|
|
|
+ }
|
|
|
+ if($typeId != 0){
|
|
|
+ return self::initPet($typeId);
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 6429 孵化宠物
|
|
|
+ * @return Resp
|
|
|
+ */
|
|
|
+ public static function Pet_BreedEgg() {
|
|
|
+ list($slotId,$eggId) = req()->paras;
|
|
|
+
|
|
|
+ my_Assert(StlUtil::dictHasProperty(ctx()->store->items, $eggId), ErrCode::user_store_NoItem);
|
|
|
+ $mo = GameConfig::item_getItem($eggId);
|
|
|
+ my_Assert($mo != null, ErrCode::err_const_no);
|
|
|
+ my_Assert($mo->itemType == 103, ErrCode::user_store_NoItem);
|
|
|
+
|
|
|
+ $ins_breed = new Ins_BreedEggSlot(ctx()->store()->breedEggLocation->$slotId);
|
|
|
+ my_Assert($ins_breed->eggId == 0 && $ins_breed->unlock == 1, ErrCode::user_store_NoBreedSlot);
|
|
|
+ ctx()->store()->removeItem($eggId, 1);
|
|
|
+
|
|
|
+ //$ins_breed = ctx()->store()->breedEggLocation->$slot;
|
|
|
+
|
|
|
+ $ins_breed->eggId = $eggId;
|
|
|
+ $ts = $ins_breed->mo()->breedTs;
|
|
|
+ $ins_breed->endTs = now()+$ts;
|
|
|
+ ctx()->store()->breedEggLocation->$slotId = $ins_breed;
|
|
|
+
|
|
|
+ UserProc::updateUserInfo();
|
|
|
+ return Resp::ok(array(
|
|
|
+ //'gold' => ctx()->baseInfo->gold,
|
|
|
+ 'store' => ctx()->store,
|
|
|
+ ));
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 6428 宠物降品
|
|
@@ -1638,6 +1820,17 @@ class StoreProc {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public static function initPet($typeId, $uid = 0) {
|
|
|
+ if ($uid == 0) {
|
|
|
+ $uid = ctx()->store->petUid+1;
|
|
|
+ }
|
|
|
+ $ins_Pet = new Ins_Pet();
|
|
|
+ $ins_Pet->uid = $uid;
|
|
|
+ $ins_Pet->typeId = $typeId;
|
|
|
+ $ins_Pet->qual = GameConfig::pet_getItem($typeId)->qual;
|
|
|
+ return $ins_Pet;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 装备回存
|