|
@@ -75,10 +75,165 @@ class StoreProc {
|
|
|
return StoreProc::GemRemoveYanLing();
|
|
|
case CmdCode::cmd_store_unlockStore:
|
|
|
return StoreProc::unlockStore();
|
|
|
+ case CmdCode::map_buyWeapon: # [7507] 购买武器map_getShopWeapon
|
|
|
+ return self::buyWeapon();
|
|
|
+ case CmdCode::map_getShopWeapon: # [7507] 购买武器
|
|
|
+ return self::getShopWeapon();
|
|
|
default:
|
|
|
Err(ErrCode::cmd_err);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public static function getShopWeapon() {
|
|
|
+ $npcid = req()->paras[0]; # 提取参数
|
|
|
+
|
|
|
+ self::DailyRefreshWeapon($npcid);
|
|
|
+
|
|
|
+ UserProc::updateUserInfo();
|
|
|
+ return Resp::ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function buyWeapon() {
|
|
|
+ $npcid = req()->paras[0]; # 提取参数
|
|
|
+ $weaponId = req()->paras[1]; # 提取参数
|
|
|
+
|
|
|
+ $store = req()->userInfo->game->store();
|
|
|
+ $type = 0;
|
|
|
+
|
|
|
+ $tag = true;
|
|
|
+ if(StlUtil::dictHasProperty($store->weaponReward, $npcid)){
|
|
|
+ $dic = $store->weaponReward->$npcid;
|
|
|
+ foreach ($dic as $k => $list) {
|
|
|
+ if(in_array($weaponId, $list)){
|
|
|
+ $tag = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $tag = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ my_Assert($tag == true, ErrCode::store_weaponCantBuy);
|
|
|
+
|
|
|
+ $list = GameConfig::shop_weapon_getItemArray($npcid);
|
|
|
+
|
|
|
+
|
|
|
+ req()->userInfo->game->newMap = $newMap;
|
|
|
+
|
|
|
+ UserProc::updateUserInfo();
|
|
|
+ return Resp::ok($newMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 每日刷新武器
|
|
|
+ */
|
|
|
+ public static function DailyRefreshWeapon($npcid = null) {
|
|
|
+ if($npcid != null ){//&& !StlUtil::dictHasProperty(req()->userInfo->game->store()->weaponPool, $npcid)
|
|
|
+ $retArr = array();
|
|
|
+ $ret = new \stdClass();
|
|
|
+ $list = GameConfig::shop_weapon_getItemArray($npcid);
|
|
|
+
|
|
|
+ $ret2 = new \stdClass();
|
|
|
+ foreach ($list as $value) {
|
|
|
+ $arr = $value->weaponlist;
|
|
|
+ foreach ($arr as $item) {
|
|
|
+ $itemList = explode(';',$item);
|
|
|
+ foreach ($itemList as $val) {
|
|
|
+ $valList = explode(',',$val);
|
|
|
+ $id = $valList[0];
|
|
|
+ $per = $valList[1];
|
|
|
+ $ret->$id = $per;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $ret2 = $ret;
|
|
|
+ $type = $value->id;
|
|
|
+ if(StlUtil::dictHasProperty(req()->userInfo->game->store()->weaponReward, $npcid)){
|
|
|
+ $weaponList = req()->userInfo->game->store()->weaponReward->$npcid->$type;
|
|
|
+ foreach ($weaponList as $wid) {
|
|
|
+ if(StlUtil::dictHasProperty($ret, $wid)){
|
|
|
+ StlUtil::dictRemove($ret, $id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ $temp = $ret;
|
|
|
+ if(count($ret)< $value->num){
|
|
|
+ $temp = $ret2;
|
|
|
+ req()->userInfo->game->store()->weaponReward->$npcid->$type = array();
|
|
|
+ }
|
|
|
+ $pArr = self::randweapon($temp, $value->num);
|
|
|
+ //数组合并
|
|
|
+ $retArr = array_merge($retArr, $pArr);
|
|
|
+ req()->userInfo->game->store()->weaponPool->$npcid->$type = $retArr;
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ $dic = req()->userInfo->game->store()->weaponPool;
|
|
|
+ foreach ($dic as $npcid => $val) {
|
|
|
+ $ret = array();
|
|
|
+ $retArr= array();
|
|
|
+ $list = GameConfig::shop_weapon_getItemArray($npcid);
|
|
|
+ foreach ($list as $value) {
|
|
|
+ $arr = $value->weaponlist;
|
|
|
+ foreach ($arr as $item) {
|
|
|
+ $itemList = explode(';',$item);
|
|
|
+ foreach ($itemList as $val) {
|
|
|
+ $valList = explode(',',$val);
|
|
|
+ $id = $valList[0];
|
|
|
+ $per = $valList[1];
|
|
|
+ $ret->$id = $per;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ req()->userInfo->game->store()->weaponPool->$npcid = array();
|
|
|
+ $pArr = self::randweapon($ret, $value->num);
|
|
|
+
|
|
|
+ $retArr = array_merge($retArr, $pArr);
|
|
|
+ }
|
|
|
+
|
|
|
+ $type = $value->id;
|
|
|
+ req()->userInfo->game->store()->weaponPool->$npcid->$type = $retArr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ static function randweapon($temp,$limit) {
|
|
|
+ $retArr = array();
|
|
|
+ $num = 0;
|
|
|
+ while (true) {
|
|
|
+ $total = 0;
|
|
|
+ foreach ($temp as $k => $v) {
|
|
|
+ $total += $v;
|
|
|
+ }
|
|
|
+
|
|
|
+ $n = rand(1,$total);
|
|
|
+ $start = 0;
|
|
|
+ foreach ($temp as $id => $per) {
|
|
|
+ $start += $per;
|
|
|
+ if($n<=$start){
|
|
|
+ if(in_array($id, $retArr)){
|
|
|
+ StlUtil::dictRemove($temp, $id);
|
|
|
+ } else {
|
|
|
+ $retArr[] = $id;
|
|
|
+ $num += 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($num >= $limit){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $retArr;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 扩容
|