|
@@ -0,0 +1,296 @@
|
|
|
|
+<?php
|
|
|
|
+
|
|
|
|
+namespace loyalsoft;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Description of PetProc
|
|
|
|
+ *
|
|
|
|
+ * @author Administrator
|
|
|
|
+ */
|
|
|
|
+class PetProc {
|
|
|
|
+
|
|
|
|
+ public static function InitArea() {
|
|
|
|
+ $isUnlock = FightProc::isFunUnlock(Enum_FunType::Pet);
|
|
|
|
+ if (!$isUnlock) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ $dic = GameConfig::pet_area();
|
|
|
|
+ if ($dic != null && count(StlUtil::dictToArray(ctx()->store->exploreArea, 1)) == 0) {
|
|
|
|
+ foreach ($dic as $areaId => $arr) {
|
|
|
|
+ $ins_exploreArea = new Ins_ExploreArea();
|
|
|
|
+ $ins_exploreArea->areaId = $areaId;
|
|
|
|
+ ctx()->store()->exploreArea->$areaId = $ins_exploreArea;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 6433 区域等级升级
|
|
|
|
+ * @return Resp
|
|
|
|
+ */
|
|
|
|
+ public static function Pet_AreaLevelUpgrade() {
|
|
|
|
+ list($areaId) = req()->paras;
|
|
|
|
+
|
|
|
|
+ if (!StlUtil::dictHasProperty(ctx()->store->exploreArea, $areaId)) {
|
|
|
|
+ $ins_ExploreArea = new Ins_ExploreArea();
|
|
|
|
+ $ins_ExploreArea->areaId = $areaId;
|
|
|
|
+ ctx()->store->exploreArea->$areaId = $ins_ExploreArea;
|
|
|
|
+ }
|
|
|
|
+ $vo = new Ins_ExploreArea(ctx()->store->exploreArea->$areaId);
|
|
|
|
+ $vo->level += 1;
|
|
|
|
+
|
|
|
|
+ my_Assert(ctx()->baseInfo->gold >= $vo->mo()->unlockArea_gold, ErrCode::notenough_gold_msg);
|
|
|
|
+ my_Assert(ctx()->baseInfo->level >= $vo->mo()->unlockArea_userLv, ErrCode::user_levelnotenough_msg);
|
|
|
|
+
|
|
|
|
+ ctx()->base()->Consume_Gold($vo->mo()->unlockArea_gold);
|
|
|
|
+ ctx()->store->exploreArea->$areaId = $vo;
|
|
|
|
+ UserProc::updateUserInfo();
|
|
|
|
+
|
|
|
|
+ return Resp::ok(array(
|
|
|
|
+ 'gold' => ctx()->baseInfo->gold,
|
|
|
|
+ 'store' => ctx()->store,
|
|
|
|
+ ));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ * @param Ins_ExploreArea $ins_ExploreArea
|
|
|
|
+ */
|
|
|
|
+ public static function GetAreaOutPutInfo(&$ins_ExploreArea, $outPut_type) {
|
|
|
|
+ $num = $ins_ExploreArea->mo()->output_num; //等级带来的
|
|
|
|
+ $ts = $ins_ExploreArea->mo()->output_time; //等级带来的
|
|
|
|
+
|
|
|
|
+ if (count($ins_ExploreArea->explorePetList) > 0) {
|
|
|
|
+ $list = $ins_ExploreArea->explorePetList;
|
|
|
|
+ foreach ($list as $petUid) {
|
|
|
|
+ $ins_pet = new Ins_Pet(ctx()->store->$petUid);
|
|
|
|
+ $typeId = $ins_pet->mo()->type;
|
|
|
|
+ $qual = $ins_pet->qual;
|
|
|
|
+
|
|
|
|
+ $pet_exploreoutputMo = GameConfig::pet_exploreoutput_getItem($typeId, $qual);
|
|
|
|
+ if ($pet_exploreoutputMo->exploreOutput != null) {
|
|
|
|
+ $sList = explode(';', $pet_exploreoutputMo->exploreOutput);
|
|
|
|
+ foreach ($sList as $str) {
|
|
|
|
+ $s = explode(',', $str);
|
|
|
|
+ if ((int) $s[0] == $ins_ExploreArea->areaId) {
|
|
|
|
+ $num += (int) $s[1];
|
|
|
|
+ $ts += (int) $s[2];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return ($outPut_type == 1) ? $num : $ts;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 6434 更换派遣宠物
|
|
|
|
+ * @return Resp
|
|
|
|
+ */
|
|
|
|
+ public static function ReplaceDispatchPet_old() {
|
|
|
|
+ list($areaId, $petUid, $exploreType) = req()->paras;
|
|
|
|
+
|
|
|
|
+ $vo = new Ins_ExploreArea(ctx()->store->exploreArea->$areaId);
|
|
|
|
+
|
|
|
|
+ if (StlUtil::arrayContains($vo->explorePetList, $petUid)) {
|
|
|
|
+ StlUtil::arrayRemove($vo->explorePetList, $petUid);
|
|
|
|
+ } else {
|
|
|
|
+ my_Assert(count($vo->explorePetList) < $vo->mo()->dispatchPetNum, ErrCode::user_store_dispatchPetNumLimit);
|
|
|
|
+ $petDic = ctx()->store->pet;
|
|
|
|
+ my_Assert(StlUtil::dictHasProperty($petDic, $petUid), ErrCode::user_store_NotExistPet);
|
|
|
|
+
|
|
|
|
+ $ins_pet = new Ins_Pet($petDic->$petUid);
|
|
|
|
+ $mo = GameConfig::pet_exploreoutput_getItem($ins_pet->mo()->type, $ins_pet->qual);
|
|
|
|
+ my_Assert(null != $mo, ErrCode::err_const_no);
|
|
|
|
+
|
|
|
|
+ $sList = explode(';', $mo->exploreOutput);
|
|
|
|
+ $tag = false;
|
|
|
|
+ foreach ($sList as $key => $value) {
|
|
|
|
+ $str = explode(',', $value);
|
|
|
|
+ if ($str[0] == $areaId) {
|
|
|
|
+ $tag = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ my_Assert($tag, ErrCode::user_store_dispatchPetErr);
|
|
|
|
+ $vo->explorePetList[] = $petUid;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ my_Assert($exploreType == 1 && now() - $vo->startTs < 10 * 60, ErrCode::user_store_CannotReplaced_tsLimit);
|
|
|
|
+
|
|
|
|
+ //开始探索
|
|
|
|
+ if (count($vo->explorePetList) == 0) {
|
|
|
|
+ $vo->startTs = 0;
|
|
|
|
+ $vo->endTs = 0;
|
|
|
|
+ $vo->output_num = 0;
|
|
|
|
+ $vo->output_ts = 0;
|
|
|
|
+ } else {
|
|
|
|
+ if ($vo->startTs == 0) {
|
|
|
|
+ $vo->startTs = now();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $ts = self::GetAreaOutPutInfo($vo, 2);
|
|
|
|
+ $num = self::GetAreaOutPutInfo($vo, 1);
|
|
|
|
+ $vo->endTs = $vo->startTs + $ts;
|
|
|
|
+ $vo->output_num = $num;
|
|
|
|
+ $vo->output_ts = $vo->endTs - $vo->startTs;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ctx()->store->exploreArea->$areaId = $vo;
|
|
|
|
+
|
|
|
|
+ UserProc::updateUserInfo();
|
|
|
|
+ return Resp::ok(array(
|
|
|
|
+ 'store' => ctx()->store,
|
|
|
|
+ ));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 6434 更换派遣宠物 废弃
|
|
|
|
+ * @return Resp
|
|
|
|
+ */
|
|
|
|
+ public static function ReplaceDispatchPet() {
|
|
|
|
+ list($areaId, $petUid) = req()->paras;
|
|
|
|
+
|
|
|
|
+ $vo = new Ins_ExploreArea(ctx()->store->exploreArea->$areaId);
|
|
|
|
+
|
|
|
|
+ if (StlUtil::arrayContains($vo->explorePetList, $petUid)) {
|
|
|
|
+ StlUtil::arrayRemove($vo->explorePetList, $petUid);
|
|
|
|
+ } else {
|
|
|
|
+ my_Assert(count($vo->explorePetList) < $vo->mo()->dispatchPetNum, ErrCode::user_store_dispatchPetNumLimit);
|
|
|
|
+ $petDic = ctx()->store->pet;
|
|
|
|
+ my_Assert(StlUtil::dictHasProperty($petDic, $petUid), ErrCode::user_store_NotExistPet);
|
|
|
|
+
|
|
|
|
+ $ins_pet = new Ins_Pet($petDic->$petUid);
|
|
|
|
+ $mo = GameConfig::pet_exploreoutput_getItem($ins_pet->mo()->type, $ins_pet->qual);
|
|
|
|
+ my_Assert(null != $mo, ErrCode::err_const_no);
|
|
|
|
+
|
|
|
|
+ $sList = explode(';', $mo->exploreOutput);
|
|
|
|
+ $tag = false;
|
|
|
|
+ foreach ($sList as $key => $value) {
|
|
|
|
+ $str = explode(',', $value);
|
|
|
|
+ if ($str[0] == $areaId) {
|
|
|
|
+ $tag = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ my_Assert($tag, ErrCode::user_store_dispatchPetErr);
|
|
|
|
+ $vo->explorePetList[] = $petUid;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ my_Assert($exploreType == 1 && now() - $vo->startTs < 10 * 60, ErrCode::user_store_CannotReplaced_tsLimit);
|
|
|
|
+
|
|
|
|
+ ctx()->store->exploreArea->$areaId = $vo;
|
|
|
|
+
|
|
|
|
+ UserProc::updateUserInfo();
|
|
|
|
+ return Resp::ok(array(
|
|
|
|
+ 'store' => ctx()->store,
|
|
|
|
+ ));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 派遣宠物
|
|
|
|
+ * @return Resp
|
|
|
|
+ */
|
|
|
|
+ public static function DispatchPet() {
|
|
|
|
+ list($areaId, $petUidList) = req()->paras;
|
|
|
|
+
|
|
|
|
+ $ins_ExploreArea = new Ins_ExploreArea(ctx()->store->exploreArea->$areaId);
|
|
|
|
+ $ins_ExploreArea->explorePetList = $petUidList;
|
|
|
|
+
|
|
|
|
+ if ($ins_ExploreArea->startTs > 0 && $ins_ExploreArea->endTs > 0) {//说明是更换
|
|
|
|
+ //my_Assert(count($ins_ExploreArea->explorePetList) > 0, ErrCode::user_store_addDispatchPet);
|
|
|
|
+ my_Assert(now() - $ins_ExploreArea->startTs < 10 * 60, ErrCode::user_store_CannotReplaced_tsLimit);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (count($petUidList) == 0) {
|
|
|
|
+ $ins_ExploreArea->startTs = 0;
|
|
|
|
+ $ins_ExploreArea->endTs = 0;
|
|
|
|
+ $ins_ExploreArea->output_num = 0;
|
|
|
|
+ $ins_ExploreArea->output_ts = 0;
|
|
|
|
+ } else {
|
|
|
|
+ if ($ins_ExploreArea->startTs == 0) {
|
|
|
|
+ $ins_ExploreArea->startTs = now();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $ts = self::GetAreaOutPutInfo($ins_ExploreArea, 2);
|
|
|
|
+ $num = self::GetAreaOutPutInfo($ins_ExploreArea, 1);
|
|
|
|
+ $ins_ExploreArea->endTs = $ins_ExploreArea->startTs + $ts;
|
|
|
|
+ $ins_ExploreArea->output_num = $num;
|
|
|
|
+ $ins_ExploreArea->output_ts = $ins_ExploreArea->endTs - $ins_ExploreArea->startTs;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ctx()->store->exploreArea->$areaId = $ins_ExploreArea;
|
|
|
|
+
|
|
|
|
+ UserProc::updateUserInfo();
|
|
|
|
+ return Resp::ok(array(
|
|
|
|
+ 'store' => ctx()->store,
|
|
|
|
+ ));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 6435 删除全部派遣宠物
|
|
|
|
+ */
|
|
|
|
+ public static function RemoveDispatchPet() {
|
|
|
|
+ list($areaId) = req()->paras;
|
|
|
|
+
|
|
|
|
+ $vo = new Ins_ExploreArea(ctx()->store->exploreArea->$areaId);
|
|
|
|
+ $vo->explorePetList = array();
|
|
|
|
+ $vo->startTs = 0;
|
|
|
|
+ $vo->endTs = 0;
|
|
|
|
+ $vo->output_num = 0;
|
|
|
|
+ $vo->output_ts = 0;
|
|
|
|
+
|
|
|
|
+ ctx()->store->exploreArea->$areaId = $vo;
|
|
|
|
+
|
|
|
|
+ UserProc::updateUserInfo();
|
|
|
|
+ return Resp::ok(array(
|
|
|
|
+ 'store' => ctx()->store,
|
|
|
|
+ ));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 6436 领取探索奖励
|
|
|
|
+ */
|
|
|
|
+ public static function Pet_ReceiveReward() {
|
|
|
|
+ list($areaId) = req()->paras;
|
|
|
|
+
|
|
|
|
+ $vo = new Ins_ExploreArea(ctx()->store->exploreArea->$areaId);
|
|
|
|
+
|
|
|
|
+ my_Assert($vo->startTs > 0 && now() - $vo->startTs > 10 * 60, ErrCode::user_store_CannotReceiveReward);
|
|
|
|
+
|
|
|
|
+ $tt = now() - $vo->startTs;
|
|
|
|
+ if (now() >= $vo->endTs) {
|
|
|
|
+ $tt = $vo->endTs - $vo->startTs;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $ts_n = $vo->output_ts / $vo->output_num;
|
|
|
|
+ $num = intval($tt *= $ts_n);
|
|
|
|
+ $goodsStr = $vo->mo()->reward_fixed . ',' . $num;
|
|
|
|
+ StoreProc::AddMultiItemInStore($goodsStr);
|
|
|
|
+
|
|
|
|
+ $reward = explode(',', $vo->mo()->reward_extra);
|
|
|
|
+ $randNum = rand(1, $reward[2]);
|
|
|
|
+ if ($randNum <= $reward[2]) {
|
|
|
|
+ StoreProc::AddMultiItemInStore($reward[0] . ',' . $reward[1]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //$vo->explorePetList = array();
|
|
|
|
+ $vo->startTs = 0;
|
|
|
|
+ $vo->endTs = 0;
|
|
|
|
+ $vo->output_num = 0;
|
|
|
|
+ $vo->output_ts = 0;
|
|
|
|
+
|
|
|
|
+ ctx()->store->exploreArea->$areaId = $vo;
|
|
|
|
+
|
|
|
|
+ UserProc::updateUserInfo();
|
|
|
|
+ return Resp::ok(array(
|
|
|
|
+ 'gold' => ctx()->baseInfo->gold,
|
|
|
|
+ 'cash' => ctx()->baseInfo->cash,
|
|
|
|
+ 'reward' => StoreProc::$reward,
|
|
|
|
+ 'reward_Gem' => StoreProc::$reward_Gem,
|
|
|
|
+ 'reward_equip' => StoreProc::$reward_equip,
|
|
|
|
+ 'store' => ctx()->store,
|
|
|
|
+ ));
|
|
|
|
+ }
|
|
|
|
+}
|