|
@@ -75,9 +75,9 @@ class StoreProc {
|
|
|
return StoreProc::GemRemoveYanLing();
|
|
|
case CmdCode::cmd_store_unlockStore:
|
|
|
return StoreProc::unlockStore();
|
|
|
- case CmdCode::map_buyWeapon: # [7507] 购买武器map_getShopWeapon
|
|
|
+ case CmdCode::map_buyWeapon: #6429
|
|
|
return self::buyWeapon();
|
|
|
- case CmdCode::map_getShopWeapon: # [7507] 购买武器
|
|
|
+ case CmdCode::map_getShopWeapon: # 6430
|
|
|
return self::getShopWeapon();
|
|
|
default:
|
|
|
Err(ErrCode::cmd_err);
|
|
@@ -89,18 +89,24 @@ class StoreProc {
|
|
|
*/
|
|
|
public static function getShopWeapon() {
|
|
|
$npcid = req()->paras[0]; # 提取参数
|
|
|
-
|
|
|
+
|
|
|
self::DailyRefreshWeapon($npcid);
|
|
|
|
|
|
UserProc::updateUserInfo();
|
|
|
- return Resp::ok();
|
|
|
+
|
|
|
+ return Resp::ok(array(
|
|
|
+ "ret" => 'ok',));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @return type
|
|
|
+ */
|
|
|
public static function buyWeapon() {
|
|
|
$npcid = req()->paras[0]; # 提取参数
|
|
|
$weaponId = req()->paras[1]; # 提取参数
|
|
|
|
|
|
- $store = req()->userInfo->game->store();
|
|
|
+ $store = req()->userInfo->game->store(true);
|
|
|
$type = 0;
|
|
|
|
|
|
$tag = true;
|
|
@@ -115,96 +121,102 @@ class StoreProc {
|
|
|
} else {
|
|
|
$tag = false;
|
|
|
}
|
|
|
-
|
|
|
- my_Assert($tag == true, ErrCode::store_weaponCantBuy);
|
|
|
-
|
|
|
+
|
|
|
+ my_Assert($tag == false, ErrCode::store_weaponCantBuy);
|
|
|
+
|
|
|
$list = GameConfig::shop_weapon_getItemArray($npcid);
|
|
|
+ $cost = 0;
|
|
|
+ foreach ($list as $item) {
|
|
|
+ $weaponList = explode(';',$item->weaponlist);
|
|
|
+ foreach ($weaponList as $value) {
|
|
|
+ $pList = explode(',',$value);
|
|
|
+ if(in_array($weaponId, $pList)){
|
|
|
+ $type = $item->id;
|
|
|
+ $cost = $item->cost;
|
|
|
+ break 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ req()->userInfo->game->base(true)->Consume_Gold($cost);
|
|
|
|
|
|
+ $store->weaponReward->$npcid->$type[] = $weaponId;
|
|
|
|
|
|
- req()->userInfo->game->newMap = $newMap;
|
|
|
+// req()->userInfo->game->store = $store;
|
|
|
|
|
|
UserProc::updateUserInfo();
|
|
|
- return Resp::ok($newMap);
|
|
|
+ return Resp::ok();
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 每日刷新武器
|
|
|
*/
|
|
|
- public static function DailyRefreshWeapon($npcid = null) {
|
|
|
- if($npcid != null ){//&& !StlUtil::dictHasProperty(req()->userInfo->game->store()->weaponPool, $npcid)
|
|
|
- $retArr = array();
|
|
|
+ public static function DailyRefreshWeapon($npcid = null) {
|
|
|
+ //没有数据初始化,有数据不在管
|
|
|
+ if($npcid != null && !StlUtil::dictHasProperty(req()->userInfo->game->store()->weaponPool, $npcid)){
|
|
|
$ret = new \stdClass();
|
|
|
$list = GameConfig::shop_weapon_getItemArray($npcid);
|
|
|
-
|
|
|
- $ret2 = new \stdClass();
|
|
|
+
|
|
|
foreach ($list as $value) {
|
|
|
- $arr = $value->weaponlist;
|
|
|
+ $arr = explode(';',$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;
|
|
|
- }
|
|
|
+ $itemList = explode(',',$item);
|
|
|
+ $id = $itemList[0];
|
|
|
+ $per = $itemList[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();
|
|
|
+ $type = $value->id;
|
|
|
+ $pArr = self::randweapon($ret, $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();
|
|
|
+ foreach ($dic as $npcid => $val) {
|
|
|
$list = GameConfig::shop_weapon_getItemArray($npcid);
|
|
|
- foreach ($list as $value) {
|
|
|
- $arr = $value->weaponlist;
|
|
|
+ foreach ($list as $value) {
|
|
|
+ $ret = new \stdClass();
|
|
|
+ $arr = explode(';',$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;
|
|
|
- }
|
|
|
+ $itemList = explode(',',$item);
|
|
|
+ $id = $itemList[0];
|
|
|
+ $per = $itemList[1];
|
|
|
+ $ret->$id = $per;
|
|
|
}
|
|
|
|
|
|
- req()->userInfo->game->store()->weaponPool->$npcid = array();
|
|
|
- $pArr = self::randweapon($ret, $value->num);
|
|
|
+ $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, $wid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $temp = $ret;
|
|
|
+ if(count((array)$ret)< $value->num){//一旦所有的武器或是不够刷新数量了,重置当前档位
|
|
|
+ $temp = $ret2;
|
|
|
+ req()->userInfo->game->store()->weaponReward->$npcid->$type = array();
|
|
|
+ }
|
|
|
+ $retArr= array();
|
|
|
+
|
|
|
+ $pArr = self::randweapon($temp, $value->num);
|
|
|
|
|
|
$retArr = array_merge($retArr, $pArr);
|
|
|
- }
|
|
|
-
|
|
|
- $type = $value->id;
|
|
|
- req()->userInfo->game->store()->weaponPool->$npcid->$type = $retArr;
|
|
|
+ req()->userInfo->game->store()->weaponPool->$npcid->$type = $retArr;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static function randweapon($temp,$limit) {
|
|
|
- $retArr = array();
|
|
|
+ $resultArr = array();
|
|
|
$num = 0;
|
|
|
while (true) {
|
|
|
$total = 0;
|
|
@@ -217,10 +229,11 @@ class StoreProc {
|
|
|
foreach ($temp as $id => $per) {
|
|
|
$start += $per;
|
|
|
if($n<=$start){
|
|
|
- if(in_array($id, $retArr)){
|
|
|
+ if(in_array($id, $resultArr)){
|
|
|
StlUtil::dictRemove($temp, $id);
|
|
|
+ break;
|
|
|
} else {
|
|
|
- $retArr[] = $id;
|
|
|
+ $resultArr[] = $id;
|
|
|
$num += 1;
|
|
|
break;
|
|
|
}
|
|
@@ -232,7 +245,7 @@ class StoreProc {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return $retArr;
|
|
|
+ return $resultArr;
|
|
|
}
|
|
|
|
|
|
/**
|