1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087 |
- <?php
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- namespace loyalsoft;
- /**
- * Description of StoreProc
- *
- * @author c'y'zhao
- */
- class StoreProc {
- /**
- * 逻辑分发
- * 所有的Proc中必须有这样一个方法
- * @param Req $req
- */
- public static function procMain($req) {
- switch ($req->cmd) {
- case CmdCode::cmd_store_put: # 6401 放入仓库
- return StoreProc::AddItemInStore();
- case CmdCode::cmd_store_gemSet: # 6402 装备宝石
- return StoreProc::GemSet();
- case CmdCode::cmd_store_gemRemove: # 6403 卸下装备宝石
- return StoreProc::GemRemove();
- case CmdCode::cmd_store_equipUpgrade: # 6404 装备升级
- return StoreProc::EquipUpgrade();
- case CmdCode::cmd_store_equipUpgrade_MaxLv: # 6405 一键升级(装备)
- return StoreProc::EquipUpgrade_MaxLv();
- case CmdCode::store_gemCompose: # 6406 宝石合成
- return StoreProc::GemCompose();
- case CmdCode::store_switchEquipPag: # 6408 切换装备分页
- return StoreProc::SwitchEquipPag();
- case CmdCode::store_gemLockState: # 6409 宝石开锁解锁
- return StoreProc::GemLockState();
- case CmdCode::store_equip_removeEquipUpgradeTip: # 6410 移除装备可以升级绿点提示 -------废弃
- return StoreProc::RemoveEquipUpgradeTip();
- case CmdCode::store_equip_removeNewGemTip: # 6411 移除是新宝石绿点提示
- return StoreProc::RemoveNewGemTip();
- case CmdCode::store_allEquipUpgrade: # 6412 所有装备的一键升级-----------废弃
- return StoreProc::AllEquipUpgrade();
- case CmdCode::store_gemXiLian: # 6413 洗练
- return StoreProc::GemXiLian();
- case CmdCode::store_equiped: # 6413 装备
- return StoreProc::Equiped();
- case CmdCode::store_remove_equip: # 6413 卸下装备
- return StoreProc::RemoveEquip();
- case CmdCode::store_equip_gemSlotBuy: # 6416 购买装备宝石槽
- return StoreProc::Gem_BuySlot();
- default:
- Err(ErrCode::cmd_err);
- }
- }
- /**
- * 6416 购买装备宝石槽
- * @return type
- */
- public static function Gem_BuySlot() {
- list($uid) = req()->paras;
- $equipDic = ctx()->store->equip;
- my_Assert(StlUtil::dictHasProperty($equipDic, $uid), ErrCode::user_store_NotExistEquip);
- $ins_equip = new Ins_Equip($equipDic->$uid);
- $mo = GameConfig::gem_slotposition_getItem($ins_equip->mo()->qual);
- my_Assert(null != $mo, ErrCode::err_const_no);
- $initNum = $mo->initNum_slot;
- $buyNum = $mo->buyNum_slot;
- $unlockIndex = 0;
- if ($buyNum > 0) {
- for ($i = $initNum + 1; $i <= $initNum + $buyNum; $i++) {
- if (!StlUtil::dictHasProperty($ins_equip->gemSetSlot, $i)) {
- $ins_equip->gemSetSlot->$i = 0;
- break;
- }
- $unlockIndex += 1;
- }
- }
- $costArr = explode(';', $mo->cost);
- $cash = explode(',', $costArr[$unlockIndex]);
- my_Assert(ctx()->base(true)->cash >= $cash[1], ErrCode::notenough_cash_msg);
- ctx()->base(true)->Consume_Cash($unlockIndex);
- ctx()->store(true)->equip->$uid = $ins_equip;
- UserProc::updateUserInfo();
- return Resp::ok(array(
- 'cash' => ctx()->baseInfo->cash,
- 'store' => ctx()->store,
- ));
- }
- /**
- * 6413 装备
- * @return type
- */
- public static function Equiped() {
- list($uid) = req()->paras;
- $equipDic = ctx()->store->equip;
- my_Assert(StlUtil::dictHasProperty($equipDic, $uid), ErrCode::user_store_NotExistEquip);
- $ins_equip = new Ins_Equip($equipDic->$uid);
- $posId = $ins_equip->mo()->position;
- ctx()->store(true)->equipLocation->$posId = $uid;
- UserProc::updateUserInfo();
- return Resp::ok(array());
- }
- /**
- * 6413 卸下装备
- * @return type
- */
- public static function RemoveEquip() {
- list($uid) = req()->paras;
- $equipDic = ctx()->store->equip;
- my_Assert(StlUtil::dictHasProperty($equipDic, $uid), ErrCode::user_store_NotExistEquip);
- $ins_equip = new Ins_Equip($equipDic->$uid);
- $posId = $ins_equip->mo()->position;
- StlUtil::dictRemove(ctx()->store(true)->equipLocation, $posId);
- UserProc::updateUserInfo();
- return Resp::ok(array());
- }
- /**
- * 洗练
- * @return Resp
- */
- public static function GemXiLian() {
- list($uid) = req()->paras;
- //把 qual pos u一样的宝石开锁关锁
- $gemStore = ctx()->store->gemStore;
- my_Assert(StlUtil::dictHasProperty($gemStore, $uid), ErrCode::user_store_NotExistGem);
- $gem = new Ins_Gem($gemStore->$uid);
- my_Assert($gem->mo()->qual >= 5, ErrCode::user_store_XilianStoneNoEnough);
- $arr = explode(';', glc()->XILianGemlNeedXILianStone);
- $needStone = 0;
- $xilianStoneId = 0;
- foreach ($arr as $val) {
- $str = explode(':', $val);
- if ($str[0] == $gem->mo()->qual) {
- $s = explode(',', $str[1]);
- $needStone = $s[1];
- $xilianStoneId = $s[0];
- break;
- }
- }
- my_Assert(StlUtil::dictHasProperty(ctx()->store->items, $xilianStoneId) && ctx()->store->items->$xilianStoneId >= $needStone, ErrCode::user_store_XilianStoneNoEnough);
- $dic = GameConfig::predicate();
- $pList = array();
- foreach ($dic as $id => $pMo) {
- if ($pMo->positions != null && $pMo->qual != null) {
- $list = explode(',', $pMo->positions);
- if ($pMo->id != $gem->predicateId && $pMo->qual == $gem->mo()->qual && in_array($gem->mo()->position, $list) && $pMo->attachTarget == "gem") {
- $pList[] = $pMo->id;
- }
- }
- }
- my_Assert(count($pList) > 0, ErrCode::user_store_NoFindPredicate);
- $rand = random_int(0, count($pList) - 1);
- $pId = $pList[$rand];
- ctx()->store->gemStore->$uid->predicateId = $pId;
- ctx()->store->removeItem($xilianStoneId, $needStone);
- $xilianStoneNum = 0;
- if (StlUtil::dictHasProperty(ctx()->store->items, $xilianStoneId)) {
- $xilianStoneNum = ctx()->store->items->$xilianStoneId;
- }
- UserProc::updateUserInfo();
- return Resp::ok(array(
- 'xilianStoneId' => $xilianStoneId,
- 'xilianStone' => $xilianStoneNum,
- 'predicateId' => $pId,
- ));
- }
- /**
- * 宝石开锁解锁
- * @return Resp
- */
- public static function GemLockState() {
- list($uid) = req()->paras;
- $user = ctx();
- //把 qual pos u一样的宝石开锁关锁
- $gemStore = $user->store->gemStore;
- $gem = $gemStore->$uid;
- $tag = 0;
- if ($gem->isUnlock == 0) {
- $gem->isUnlock = 1;
- $tag = 1;
- } else {
- $gem->isUnlock = 0;
- $tag = 0;
- }
- $gemStore->$uid = $gem;
- foreach ($gemStore as $k => $ins_gem) {
- if ($ins_gem->typeId == $gem->typeId && $ins_gem->predicateId == $gem->predicateId) {
- $gemStore->$k->isUnlock = $tag;
- }
- }
- $user->store->gemStore = $gemStore;
- ctx($user);
- UserProc::updateUserInfo();
- return Resp::ok(array(
- 'gold' => 0,
- 'store' => $user->store,
- ));
- }
- /**
- * 切换装备分页
- * @return Resp
- */
- public static function SwitchEquipPag() {
- list($index) = req()->paras;
- $user = ctx();
- $user->store->equipPag = $index;
- ctx($user);
- UserProc::updateUserInfo();
- return Resp::ok(array());
- }
- /**
- * 所有装备的一键升级
- * 规则:等级不同从等级小到大,等级一样按照部位顺序
- *
- * @return Resp
- */
- public static function AllEquipUpgrade() {
- list() = req()->paras;
- $user = ctx();
- // $equipDic = $user->store->equipPosition;
- //
- // $equip_levelDic = GameConfig::equip_levelupgrade();
- // $maxLv = count(StlUtil::dictToArray($equip_levelDic));
- // $arr = array();
- // if ($equipDic != null) {
- // foreach ($equipDic as $k => &$equip) {
- // $equip = new Ins_EquipPosition($equip);
- //
- // if ($equip->level >= $maxLv) {
- // continue;
- // }
- //
- // $lvMo = GameConfig::equip_levelupgrade_getItem($equip->level);
- // $needGold = $lvMo->needGold;
- // $needItemNum = $lvMo->needItemNum;
- // $neeItemId = $equip->mo()->costTuzhiId;
- //
- // if ($user->baseInfo->gold >= $needGold && StlUtil::dictHasProperty($user->store->items, $neeItemId) && $user->store->items->$neeItemId >= $needItemNum) {
- // $arr[] = $equip;
- // }
- // }
- // }
- // $upLevelArr = array();
- // if (count($arr) > 0) {
- // //进行排序
- // $len = count($arr);
- // for ($i = 0; $i < $len - 1; $i++) {
- // for ($j = 0; $j < $len - $i - 1; $j++) {
- // if ($arr[$j]->level > $arr[$j + 1]->level) {//从小到大
- // $temp = $arr[$j];
- // $arr[$j] = $arr[$j + 1];
- // $arr[$j + 1] = $temp;
- // } elseif ($arr[$j]->level == $arr[$j + 1]->level) {
- // $j_equip = new Ins_EquipPosition($arr[$j]);
- // $jj_equip = new Ins_EquipPosition($arr[$j + 1]);
- // if ($j_equip->mo()->position > $jj_equip->mo()->position) {
- // $temp = $arr[$j];
- // $arr[$j] = $arr[$j + 1];
- // $arr[$j + 1] = $temp;
- // }
- // }
- // }
- // }
- //升级,扣除金币和图纸
- // while (true) {
- // $tag = 9999;
- // foreach ($arr as $index => &$equip) {
- // $ins_equip = new Ins_EquipPosition($equip);
- // $lvMo = GameConfig::equip_levelupgrade_getItem($ins_equip->level);
- // $needGold = $lvMo->needGold;
- // $needItemNum = $lvMo->needItemNum;
- // $neeItemId = $ins_equip->mo()->costTuzhiId;
- // if ($user->baseInfo->gold >= $needGold && StlUtil::dictHasProperty($user->store->items, $neeItemId) && $user->store->items->$neeItemId >= $needItemNum) {
- // $id = $ins_equip->typeId;
- // if (!in_array($id, $upLevelArr)) {
- // $upLevelArr[] = $id;
- // }
- //
- // $ins_equip->level += 1;
- // $equipDic->$id->level += 1;
- // $user->baseInfo->Consume_Gold($needGold);
- // $user->store->removeItem($neeItemId, $needItemNum);
- // if ($ins_equip->level >= 99) {
- // $tag = $index;
- // break;
- // }
- // } else {
- // $tag = $index;
- // break;
- // }
- // }
- // if ($tag != 9999) {
- // if (array_key_exists($tag, $arr)) {
- // StlUtil::arrayRemoveAt($arr, $tag);
- // }
- // }
- //
- // if (count($arr) <= 0) {
- // break;
- // }
- // }
- // }
- // TaskProc::OnAnyEquipUpLevel_X();
- // TaskProc::OnAllEquipUpLevel_X();
- // TaskProc::OnEquipLevelUpNum();
- // ctx($user);
- //
- // FightProc::Ranking_FightPower();
- UserProc::updateUserInfo();
- return Resp::ok(array(
- 'upLevelArr' => $upLevelArr,
- 'gold' => $user->baseInfo->gold,
- 'store' => $user->store,
- 'task' => $user->task,
- ));
- }
- /**
- * 6411 移除是新宝石绿点提示
- * @return Resp
- */
- public static function RemoveNewGemTip() {
- list($uid) = req()->paras; //宝石uid
- my_Assert(StlUtil::dictHasProperty(ctx()->store->gemStore, $uid), ErrCode::user_store_NoItem);
- ctx()->store(true)->gemStore->$uid->isNew = 0;
-
- UserProc::updateUserInfo();
- return Resp::ok(array());
- }
- /**
- * 移除装备可以升级绿点提示 -------废弃
- * @return Resp
- */
- public static function RemoveEquipUpgradeTip() {
- // list($posId) = req()->paras; //装备部位
- // $user = ctx();
- //
- // my_Assert(StlUtil::dictHasProperty($user->store->equipPosition, $posId), ErrCode::user_store_NoEquip);
- //
- // $user->store->equipPosition->$posId->tip = 0;
- //
- // ctx($user);
- // UserProc::updateUserInfo();
- // return Resp::ok(array(
- // 'gold' => 0,
- // 'store' => $user->store,));
- }
- /**
- * 6406 合成
- * @return type
- */
- public static function GemCompose() {
- list($gemIds) = req()->paras;
- $user = ctx();
- //做校验
- $composeArr = array();
- //$gemIds = substr($gemIds, 0, -1);
- $list = explode(';', $gemIds);
- krsort($list);
- foreach ($list as $str) {
- $str = substr($str, 0, -1);
- $gemUidList = explode(',', $str);
- $firstGemUId = $gemUidList[0];
- $qual = 0;
- $posId = 0;
- if (StlUtil::dictHasProperty($user->store->gemStore, $firstGemUId)) {
- $ins_gem = $user->store->gemStore->$firstGemUId;
- $mo = GameConfig::gem_getItem($ins_gem->typeId);
- $qual = $mo->qual;
- $posId = $mo->position;
- }
- $isCompose = true;
- //在做一次校验
- foreach ($gemUidList as $uid) {
- if (StlUtil::dictHasProperty($user->store->gemStore, $uid)) {
- $ins_gem = $user->store->gemStore->$uid;
- $mo = GameConfig::gem_getItem($ins_gem->typeId);
- if ($mo->qual != $qual || $mo->position != $posId) {
- $isCompose = false;
- break;
- }
- }
- }
- my_Assert($isCompose == true, ErrCode::user_store_GemCanotCompose);
- //查找要合成的宝石配置信息
- $gemConf = self::GemComposeSynthesis($qual, $posId);
- my_Assert($gemConf != null, ErrCode::err_const_no);
- $synthesisList = explode('_', $gemConf->synthesis);
- $composePosition = $synthesisList[0];
- $composeQual = $synthesisList[1];
- $composeNum = $synthesisList[2];
- foreach ($composeArr as $val) {
- $mo = GameConfig::gem_getItem($val->typeId);
- if ($mo->qual == $composeQual && $mo->position == $composePosition) {
- $gemUidList[] = $val->uid;
- }
- }
- if (count($gemUidList) >= $composeNum) {
- if ($gemConf != null) {
- $maxGemNum = intval(count($gemUidList) / $composeNum);
- $index = 0;
- $res = 0;
- foreach ($gemUidList as $uid) {
- my_Assert(self::GemIsCanCompose($uid) == false && $user->store->gemStore->$uid->isUnlock == 0, ErrCode::user_store_GemCanotCompose);
- $index += 1;
- self::RemoveGemInStore($uid);
- //$composeArr 有的话删除
- for ($i = 0; $i < count($composeArr); $i++) {
- if ($composeArr[$i]->uid == $uid) {
- StlUtil::arrayRemoveAt($composeArr, $i);
- break;
- }
- }
- if ($index % $composeNum == 0) {
- $res += 1;
- $composeGem = self::initGem($gemConf->typeId);
- self::PutGemInStore($composeGem);
- $composeArr[] = $composeGem; //临时放这
- }
- if ($res >= $maxGemNum) {
- break;
- }
- }
- }
- }
- }
- $resultArr = array();
- foreach ($composeArr as $value) {
- SystemProc::GetGem_GreaterOrangeQual_GemCompose(req()->zoneid, ctx()->baseInfo->name, $value->typeId); //广播
- ctx()->store->gemComposeNum += 1;
- $resultArr[] = $value->uid;
- }
- TaskProc::OnComposeNumGem();
- TaskProc::OnComposeNumGem_state();
- ctx($user);
- UserProc::updateUserInfo();
- return Resp::ok(array(
- 'composeGemIds' => $resultArr,
- 'store' => $user->store,
- 'task' => $user->task,
- ));
- }
- /**
- * 该宝石是否可以参与合成,其他页镶嵌的,已经被锁的都不能参与
- * @param type $uid
- * @return bool
- */
- private static function GemIsCanCompose($uid) {
- $Ins_gemItem = new Ins_Gem(ctx()->store->gemStore->$uid);
- $equipGemDic = ctx()->store->gemEquip;
- $equipPag = ctx()->store->equipPag;
- $isExist = false;
- foreach ($equipGemDic as $pag => $dic) {
- if ($equipPag == $pag) {
- continue;
- }
- if (StlUtil::dictHasProperty($dic, $Ins_gemItem->mo()->position)) {
- $posId = $Ins_gemItem->mo()->position;
- $tDic = $dic->$posId;
- foreach ($tDic as $index => $ins_gem) {
- if ($ins_gem->uid == $Ins_gemItem->uid) {
- $isExist = true;
- break;
- }
- }
- }
- if ($isExist) {
- break;
- }
- }
- return $isExist;
- }
- private static function GemComposeSynthesis($qual, $posId) {
- $gem = GameConfig::gem();
- foreach ($gem as $key => $value) {
- if ($value->synthesis != null) {
- $synthesisList = explode('_', $value->synthesis);
- $composePosition = $synthesisList[0];
- $composeQual = $synthesisList[1];
- $composeNum = $synthesisList[2];
- if ($composeQual != 0 && $composePosition != 0 && $composeQual == $qual && $posId == $composePosition && $value->isfixed_predicateId == 0) {
- return $value;
- }
- }
- }
- return null;
- }
- /**
- * 装备宝石
- * @return type
- */
- public static function GemSet() {
- list($equipUid, $uid, $type, $replaceUId) = req()->paras; //宝石uid 手动的时候记得校验u $replaceUId宝石槽坑位id
-
- my_Assert(StlUtil::dictHasProperty(ctx()->store->gemStore, $uid), ErrCode::user_store_NoItem);
- my_Assert(StlUtil::dictHasProperty(ctx()->store->equip, $equipUid), ErrCode::user_store_NoEquip);
- $ins_equip = new Ins_Equip(ctx()->store->equip->$equipUid);
- $ins_gem = new Ins_Gem(ctx()->store->gemStore->$uid);
- my_Assert($ins_equip->mo()->position == $ins_gem->mo()->qual, ErrCode::user_store_PositionNotFit);
- $gemSetSlotDic = $ins_equip->gemSetSlot;
- $tag_index = 0;
- $tag_gem = null;
- foreach ($gemSetSlotDic as $slotId => $gemUid) {
- $gem = new Ins_Gem(ctx()->store->gemStore->$gemUid);
- if ($gem->predicateMo()->uniqueKey == $ins_gem->predicateMo()->uniqueKey) {
- $tag_index = $slotId;
- $tag_gem = $gem;
- break;
- }
- }
- $mo = GameConfig::gem_slotposition_getItem($ins_equip->mo()->qual);
- my_Assert(null != $mo, ErrCode::err_const_no);
- switch ($type) {
- case 1://镶嵌
- my_Assert($tag_gem == null, ErrCode::user_store_GemCanotSet);
- for ($i = 1; $i <= $mo->initNum_slot+$mo->buyNum_slot; $i++) {
- if (!StlUtil::dictHasProperty($gemSetSlotDic, $i)) {
- $gemSetSlotDic->$i = $ins_gem;
- break;
- }
- }
- break;
- case 2://替换
- //满不满都高替低品阶
- my_Assert(StlUtil::dictHasProperty($gemSetSlotDic, $replaceUId), ErrCode::user_store_NoExistGemReplace);
- $gUid = $gemSetSlotDic->$replaceUId;
- $replace_ins_Gem = new Ins_Gem(ctx()->store->gemStore->$gUid); //这个$replaceUId是坑位的index id
- my_Assert($replace_ins_Gem->mo()->qual < $ins_gem->mo()->qual, ErrCode::user_store_NoExistGemReplace);
- $gemSetSlotDic->$replaceUId = $ins_gem;
- break;
- case 3://手动
- my_Assert(count((array) $gemSetSlotDic) >= $mo->initNum_slot+$mo->buyNum_slot, ErrCode::user_store_GemCanotSet);
- $gUid = $gemSetSlotDic->$replaceUId;
- my_Assert(StlUtil::dictHasProperty($gemSetSlotDic, $replaceUId), ErrCode::user_store_NoExistGemReplace);
- $replace_ins_Gem = new Ins_Gem(ctx()->store->gemStore->$gUid);
- //$id = $replace_ins_Gem->uid;
- if ($tag_gem != null) {//如果有u那
- my_Assert($replace_ins_Gem->uid == $tag_gem->uid, ErrCode::user_store_SameGemCanotEquip); //点的不是u一样的,则提示同一件装备无法镶嵌多个技能相同的宝石 【错误】
- //有U一样的,则点击正好是这个直接替换
- //$user->store->gemStore->$id = $replace_ins_Gem;
- $gemSetSlotDic->$tag_index = $ins_gem;
- } else {
- $go_index = 0;
- foreach ($gemSetSlotDic as $slotId => $gUid) {
- if ($gUid == $replaceUId) {
- $go_index = $slotId;
- break;
- }
- }
- my_Assert($go_index > 0, ErrCode::user_store_NoExistGemReplace);
- $gemSetSlotDic->$go_index = $ins_gem;
- }
- break;
- case 4://不能
- //1.小品阶替大品阶 或是 相等的,在不满的时候不允许 2. //满的 相等不允许替
- my_Assert($uid == 0, ErrCode::user_store_SameGemCanotEquip); //点的不是u一样的,则提示同一件装备无法镶嵌多个技能相同的宝石 【错误】
- break;
- default:
- break;
- }
- $ins_equip->gemSetSlot = $gemSetSlotDic;
- ctx()->store(true)->equip->$equipUid = $ins_equip;
-
- TaskProc::OnSetSpecialQualGem();
- FightProc::Ranking_FightPower();
- UserProc::updateUserInfo();
- return Resp::ok(array(
- 'gold' => 0,
- 'store' => ctx()->store,
- 'task' => ctx()->task,
- ));
- }
- /**
- * 卸下装备
- * @return type
- */
- public static function GemRemove() {
- list($uid) = req()->paras; //装备宝石id
-
- $equips = ctx()->store->equip;
- foreach ($equips as $eUid => $ins_equip) {
- $dic = $ins_equip->gemSetSlot;
- foreach ($dic as $slotId => $gemUid) {
- if($uid == $gemUid){
- ctx()->store->equip->$eUid->gemSetSlot->$slotId = 0;
- }
- break 2;
- }
- }
-
- FightProc::Ranking_FightPower();
- UserProc::updateUserInfo();
- return Resp::ok(array(
- 'gold' => 0,
- 'store' => ctx()->store,));
- }
- /**
- * 6404 升级装备
- * @return type
- */
- public static function EquipUpgrade() {
- list($uid) = req()->paras; //装备uid
- my_Assert(StlUtil::dictHasProperty(ctx()->store->equip, $uid), ErrCode::user_store_NoEquip);
- $ins_equip = new Ins_Equip(ctx()->store->equip->$uid);
- my_Assert($ins_equip->level < $ins_equip->Equip_MaxLevel(), ErrCode::user_store_equipLevelLimit);
- $mo = GameConfig::equip_levelupgrade_getItem($ins_equip->mo()->rarity, $ins_equip->mo()->qual, $ins_equip->mo()->position, $ins_equip->level);
- my_Assert(null != $mo, ErrCode::err_const_no);
- my_Assert(ctx()->baseInfo->gold >= $mo->needGold, ErrCode::notenough_gold_msg);
- $costTuzhiId = GameConfig::equip_position_getItem($ins_equip->mo()->position)->costTuzhiId;
- $tuzhiNum = 0;
- if (StlUtil::dictHasProperty(ctx()->store->items, $costTuzhiId)) {
- $tuzhiNum = ctx()->store->items->$costTuzhiId;
- }
- my_Assert($tuzhiNum >= $mo->needItemNum, ErrCode::notenough_item);
- ctx()->store(true)->removeItem($costTuzhiId, $mo->needItemNum);
- ctx()->base(true)->Consume_Gold($mo->needGold);
- TaskProc::OnAnyEquipUpLevel_X();
- TaskProc::OnAllEquipUpLevel_X();
- TaskProc::OnEquipLevelUpNum();
- FightProc::Ranking_FightPower();
- UserProc::updateUserInfo();
- return Resp::ok(array(
- 'gold' => $user->baseInfo->gold,
- 'store' => $user->store,
- 'task' => $user->task,
- ));
- }
- /**
- * 6405 单个装备部位一键升级
- * @return type
- */
- public static function EquipUpgrade_MaxLv() {
- list($uid) = req()->paras;
- my_Assert(StlUtil::dictHasProperty(ctx()->store->equip, $uid), ErrCode::user_store_NoEquip);
- $ins_equip = new Ins_Equip(ctx()->store->equip->$uid);
- $maxLevel = $ins_equip->Equip_MaxLevel();
- my_Assert($ins_equip->level < $ins_equip->Equip_MaxLevel(), ErrCode::user_store_equipLevelLimit);
- $tuzhiId = GameConfig::equip_position_getItem($ins_equip->mo()->position)->costTuzhiId;
- $itemNum_store = 0;
- if (StlUtil::dictHasProperty(ctx()->store->items, $tuzhiId)) {
- $itemNum_store = ctx()->store->items->$tuzhiId;
- }
- $up_Gold = 0;
- $up_needItem = 0;
- $up_lv = 0;
- $noUp_gold = false;
- $noUp_item = false;
- for ($i = $ins_equip->level; $i <= $maxLevel; $i++) {
- $up_Gold += GameConfig::equip_levelupgrade_getItem($ins_equip->mo()->rarity, $ins_equip->mo()->qual, $ins_equip->mo()->position, $i)->needGold;
- $up_needItem += GameConfig::equip_levelupgrade_getItem($ins_equip->mo()->rarity, $ins_equip->mo()->qual, $ins_equip->mo()->position, $i)->needItemNum;
- if (ctx()->baseInfo->gold >= $up_Gold) {
- $noUp_gold = true;
- }
- if ($itemNum_store >= $up_needItem) {
- $noUp_item = true;
- }
- if (ctx()->baseInfo->gold >= $up_Gold && $itemNum_store >= $up_needItem) {
- //$need_gold = $up_Gold;
- //$need_item = $up_needItem;
- $up_lv = $i;
- continue;
- }
- break;
- }
- if ($up_lv == 0) {
- my_Assert($noUp_gold, ErrCode::notenough_gold_msg);
- my_Assert($noUp_item, ErrCode::notenough_item);
- }
- ctx()->base(true)->Consume_Gold($up_Gold);
- ctx()->store(true)->removeItem($tuzhiId, $up_needItem);
- if ($up_lv > 0) {
- ctx()->store->equip->$uid->level = $up_lv;
- }
- TaskProc::OnAnyEquipUpLevel_X();
- TaskProc::OnAllEquipUpLevel_X();
- TaskProc::OnEquipLevelUpNum();
- FightProc::Ranking_FightPower();
- UserProc::updateUserInfo();
- return Resp::ok(array(
- 'gold' => ctx()->baseInfo->gold,
- 'store' => ctx()->store,
- 'task' => ctx()->task,
- ));
- }
- public static function AddItemInStore() {
- list($rwdStr) = req()->paras; //mask = 1:表示战斗中掉落
- $user = ctx();
- $err = self::AddMultiItemInStore($rwdStr);
- my_Assert(ErrCode::ok == $err, $err);
- UserProc::updateUserInfo();
- return Resp::ok(array(
- //'gold' => $user->baseInfo->gold,
- //'tili' => $user->baseInfo->tili,
- //'cash' => $user->baseInfo->cash,
- 'store' => $user->store));
- }
- static $reward = array();
- static $reward_Gem = array();
- //static $reward_hero = array();
- /**
- * 具体奖励存入背包
- * @param type $goodsStr
- * @param type $src
- */
- public static function AddMultiItemInStore($goodsStr, $src = 0) {
- if ($goodsStr == null) {
- return;
- }
- $ary = explode(";", $goodsStr);
- foreach ($ary as $value) {
- $val = explode(",", $value);
- my_Assert(count($val) > 1, "解析奖励字符串出错");
- list($itemId, $num) = $val; # ID, 数量
- $itemMo = GameConfig::item_getItem($itemId);
- if ($itemMo->itemType != 701 && $itemMo->itemType != 201 && $itemMo->itemType != 502 && $src != 1) {
- self::$reward[] = $value;
- }
- switch ($itemMo->itemType) {
- case 1:
- ctx()->baseInfo->Add_Gold($num);
- //self::checkEquipUpgradeTip();//废弃
- break;
- case 2:
- ctx()->baseInfo->Add_Cash($num);
- break;
- case 3:
- ctx()->baseInfo->Add_tili($num);
- break;
- case 4:
- ctx()->baseInfo->Add_Exp($num);
- break;
- case 100://图纸
- case 103://钥匙
- case 401://启灵石
- case 301://洗练石
- case 501://人物碎片
- case 601://人身果
- case 801://寻宝券
- self::PutItemsInStore($itemId, $num);
- // if ($itemMo->itemType == 100) {//图纸
- // self::checkEquipUpgradeTip();//废弃
- // }
- break;
- case 502://角色卡
- HeroProc::RoleCardUnlockHero($itemId, $num);
- break;
- case 201://宝石
- for ($i = 0; $i < $num; $i++) {
- $gem = self::initGem($itemId);
- if ($src != 1) {
- self::$reward_Gem[] = $gem->uid;
- }
- self::PutGemInStore($gem);
- if ($src == Enum_StoreSourceType::ShopBox) {
- SystemProc::GetGem_GreaterOrangeQual_ShopBox(req()->zoneid, ctx()->baseInfo->name, $gem->typeId);
- }
- }
- break;
- case 701://道具宝箱
- for ($i = 0; $i < $num; $i++) {
- self::DistributeItemsBox($itemId);
- }
- break;
- default:
- break;
- }
- }
- }
- public static function PutItemsInStore($itemId, $num) {
- $items = ctx()->store->items;
- if (StlUtil::dictHasProperty($items, $itemId)) {
- $items->$itemId += $num;
- } else {
- $items->$itemId = $num;
- }
- ctx()->store->items = $items;
- }
- /**
- * 拆分宝箱盒子
- * @param type $reward
- */
- public static function DistributeItemsBox($itemId) {
- $itemBoxMo = GameConfig::item_2023_box_getItem($itemId);
- my_Assert($itemBoxMo != null, ErrCode::err_const_no);
- if ($itemBoxMo->type == 1) {
- $strList = explode(';', $itemBoxMo->contents);
- $numList = explode('-', $strList[0]);
- $randNum = rand($numList[0], $numList[1]);
- $ctxList = explode(',', $strList[1]);
- $per = 0;
- foreach ($ctxList as $value) {
- $ctx = explode(':', $value);
- $per += $ctx[1];
- }
- $reward = "";
- for ($i = 0; $i < $randNum; $i++) {
- $ctxPer = rand(1, $per);
- $start = 0;
- $end = 0;
- $id = 0;
- foreach ($ctxList as $value) {
- $ctx = explode(':', $value);
- $end += $ctx[1];
- if ($ctxPer > $start && $ctxPer <= $end) {
- $id = $ctx[0];
- break;
- }
- $start = $end;
- }
- if ($id != 0) {
- $str = $id . ',1';
- if ($reward == "") {
- $reward = $str;
- } else {
- $reward = $reward . ';' . $str;
- }
- }
- }
- self::AddMultiItemInStore($reward);
- } else {
- self::AddMultiItemInStore($itemBoxMo->contents);
- }
- }
- // public static function PutEquipInStore($equipId, $num) {
- // if ($equipId == 0) {
- // return;
- // }
- // $n = count((array) ctx()->store->equip) + 1;
- //
- // for ($index = 0; $index < $num; $index++) {
- // $Equip = new Ins_Equip();
- // $Equip->uid = $n;
- // $Equip->typeId = $equipId;
- // $Equip->qual = GameConfig::equip_getItem($equipId)->qual;
- // ctx()->store->equip->$n = $Equip;
- // $n += 1;
- // }
- // }
- /**
- * 得到金币或是图纸的时候校验下,是否满足装备升级条件,满足则tip字段设置为1 废弃
- */
- // public static function checkEquipUpgradeTip() {
- // $equipDic = ctx()->store->equipPosition;
- // if ($equipDic != null) {
- // foreach ($equipDic as $k => &$equip) {
- // $equip = new Ins_EquipPosition($equip);
- // $lvMo = GameConfig::equip_levelupgrade_getItem($equip->level);
- // $needGold = $lvMo->needGold;
- // $needItemNum = $lvMo->needItemNum;
- // $neeItemId = $equip->mo()->costTuzhiId;
- //
- // if (ctx()->baseInfo->gold >= $needGold && StlUtil::dictHasProperty(ctx()->store->items, $neeItemId) && ctx()->store->items->$neeItemId >= $needItemNum) {
- // $equipDic->$k->tip = 1; //绿点是每次得到金币或是图纸了,只要满足升级条件都变绿
- // }
- // }
- // }
- // ctx()->store->equipPosition = $equipDic;
- // }
- /**
- * 新宝石入库
- */
- public static function PutGemIdInStore($id, $num = 1) {
- for ($i = 0; $i < $num; $i++) {
- $gem = self::initGem($id);
- $length = $gem->uid;
- ctx()->store->gemStore->$length = $gem;
- }
- }
- public static function PutGemInStore($gem, $num = 1) {
- for ($i = 0; $i < $num; $i++) {
- $length = $gem->uid;
- ctx()->store->gemStore->$length = $gem;
- }
- }
- public static function initGem($id) {
- $length = ctx()->store->gemLength;
- $length += 1;
- $gem = new Ins_Gem();
- $gem->uid = $length;
- $gem->typeId = $id;
- $gem->predicateId = self::RandomGemPredicateId($id);
- $tag = self::CheckNewGemTip($gem);
- $gem->isNew = $tag;
- ctx()->store->gemLength = $length;
- return $gem;
- }
- /**
- * 从仓库移除宝石
- */
- public static function RemoveGemInStore($uid) {
- if (StlUtil::dictHasProperty(ctx()->store->gemStore, $uid)) {
- StlUtil::dictRemove(ctx()->store->gemStore, $uid);
- }
- return 0;
- }
- /**
- * 新宝石随机词条 临时等刚哥
- */
- public static function RandomGemPredicateId($id) {
- $mo = GameConfig::gem_getItem($id);
- my_Assert(null != $mo, "找不到宝石{$id}的配置数据");
- if ($mo->isfixed_predicateId == 1) {
- return $mo->predicateId;
- }
- $posId = $mo->position;
- $qual = $mo->qual;
- $arr = array();
- $predicateMo = GameConfig::predicate();
- foreach ($predicateMo as $key => $value) {
- if ($value->positions != null) {
- $list = explode(',', $value->positions);
- if ($value->qual == $qual && in_array($posId, $list) && $value->attachTarget == "gem") {
- $arr[] = $value->id;
- }
- }
- }
- if (count($arr) <= 0) {
- return 40;
- }
- my_Assert(count($arr) > 0, "宝石没有对应词条信息");
- $n = mt_rand(0, count($arr) - 1);
- return $arr[$n];
- //return 40;
- }
- /**
- * 新宝石提示
- */
- public static function CheckNewGemTip($gem) {
- $gemStore = ctx()->store->gemStore;
- $tag = false;
- foreach ($gemStore as $k => $ins_gem) {
- if ($ins_gem->typeId == $gem->typeId && $ins_gem->predicateId == $gem->predicateId) {
- $tag = true;
- break;
- }
- }
- return $tag == true ? 0 : 1;
- }
- //临时代码
- // public static function InitGemInfo() {
- // if(count((array)ctx()->store->gemStore) > 0){
- // return;
- // }
- //
- // $index = 0;
- // $gem = GameConfig::gem();
- //
- // for ($i = 1; $i <=21; $i++) {
- // foreach ($gem as $key => $value) {
- // if($value->id == $i){
- // self::PutGemInStore($value->typeId);
- // }
- //
- // }
- // }
- //
- //
- //
- //
- // }
- }
|