feat(WIP): 베팅 개시 타입 변경
-candidate를 미리 추가. -이를 통해 betting을 중립적으로 운용 가능
This commit is contained in:
@@ -8,7 +8,7 @@ use sammo\DB;
|
||||
use Sammo\DTO\BettingItem;
|
||||
use sammo\Validator;
|
||||
use sammo\Json;
|
||||
use sammo\DTO\NationBettingInfo;
|
||||
use sammo\DTO\BettingInfo;
|
||||
use sammo\GameConst;
|
||||
use sammo\General;
|
||||
use sammo\KVStorage;
|
||||
@@ -54,14 +54,14 @@ class BetNation extends \sammo\BaseAPI
|
||||
$amount = $this->args['amount'];
|
||||
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$nationBettingStor = KVStorage::getStorage($db, 'nation_betting');
|
||||
$rawBettingInfo = $nationBettingStor->getValue("id_{$bettingID}");
|
||||
$bettingStor = KVStorage::getStorage($db, 'betting');
|
||||
$rawBettingInfo = $bettingStor->getValue("id_{$bettingID}");
|
||||
if($rawBettingInfo === null){
|
||||
return '해당 베팅이 없습니다';
|
||||
}
|
||||
|
||||
try{
|
||||
$bettingInfo = new NationBettingInfo($rawBettingInfo);
|
||||
$bettingInfo = new BettingInfo($rawBettingInfo);
|
||||
}
|
||||
catch(\Error $e){
|
||||
return $e->getMessage();
|
||||
@@ -88,16 +88,20 @@ class BetNation extends \sammo\BaseAPI
|
||||
}
|
||||
|
||||
|
||||
sort($bettingType);//NOTE: key로 바로 사용하므로 중요함
|
||||
$bettingTypeKey = Json::encode($bettingType);
|
||||
$nations = getAllNationStaticInfo();
|
||||
|
||||
foreach($bettingType as $bettingNationID){
|
||||
if(!key_exists($bettingNationID, $nations)){
|
||||
return '존재하지 않는 국가를 선택했습니다.';
|
||||
}
|
||||
$bettingType = array_unique($bettingType, SORT_NUMERIC);//NOTE: key로 바로 사용하므로 중요함
|
||||
if(count($bettingType) != $bettingInfo->selectCnt){
|
||||
return '중복된 값이 있습니다.';
|
||||
}
|
||||
|
||||
if($bettingType[0] < 0){
|
||||
return '올바르지 않은 값이 있습니다.(0 미만)';
|
||||
}
|
||||
|
||||
if(Util::array_last($bettingType) >= count($bettingInfo->candidates)){
|
||||
return '올바르지 않은 값이 있습니다.(초과)';
|
||||
}
|
||||
|
||||
$bettingTypeKey = Json::encode($bettingType);
|
||||
$general = General::createGeneralObjFromDB($session->generalID, ['gold', 'aux'], 1);
|
||||
|
||||
if($bettingInfo->reqInheritancePoint){
|
||||
+4
-4
@@ -5,7 +5,7 @@ namespace sammo\API\NationBetting;
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\DTO\NationBettingInfo;
|
||||
use sammo\DTO\BettingInfo;
|
||||
use sammo\General;
|
||||
use sammo\KVStorage;
|
||||
use sammo\Validator;
|
||||
@@ -42,14 +42,14 @@ class GetBettingDetail extends \sammo\BaseAPI
|
||||
$bettingID = $this->arg['betting_id'];
|
||||
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$nationBettingStor = KVStorage::getStorage($db, 'nation_betting');
|
||||
$rawBettingInfo = $nationBettingStor->getValue("id_{$bettingID}");
|
||||
$bettingStor = KVStorage::getStorage($db, 'betting');
|
||||
$rawBettingInfo = $bettingStor->getValue("id_{$bettingID}");
|
||||
if($rawBettingInfo === null){
|
||||
return '해당 베팅이 없습니다';
|
||||
}
|
||||
|
||||
try{
|
||||
$bettingInfo = new NationBettingInfo($rawBettingInfo);
|
||||
$bettingInfo = new BettingInfo($rawBettingInfo);
|
||||
}
|
||||
catch(\Error $e){
|
||||
return $e->getMessage();
|
||||
+5
-5
@@ -5,7 +5,7 @@ namespace sammo\API\NationBetting;
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\DTO\NationBettingInfo;
|
||||
use sammo\DTO\BettingInfo;
|
||||
use sammo\KVStorage;
|
||||
|
||||
use function sammo\checkLimit;
|
||||
@@ -27,10 +27,10 @@ class GetBettingList extends \sammo\BaseAPI
|
||||
{
|
||||
$db = DB::db();
|
||||
|
||||
increaseRefresh("국가베팅장", 1);
|
||||
increaseRefresh("베팅장", 1);
|
||||
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$nationBettingStor = KVStorage::getStorage($db, 'nation_betting');
|
||||
$bettingStor = KVStorage::getStorage($db, 'betting');
|
||||
$userID = $session->userID;
|
||||
|
||||
$me = $db->queryFirstRow('SELECT no,nation,officer_level,con,turntime,belong,penalty,permission FROM general WHERE owner=%i', $userID);
|
||||
@@ -40,8 +40,8 @@ class GetBettingList extends \sammo\BaseAPI
|
||||
}
|
||||
|
||||
$bettingList = [];
|
||||
foreach ($nationBettingStor->getAll() as $_key => $rawItem) {
|
||||
$item = new NationBettingInfo($rawItem);
|
||||
foreach ($bettingStor->getAll() as $_key => $rawItem) {
|
||||
$item = new BettingInfo($rawItem);
|
||||
$bettingList[$item->id] = $rawItem;
|
||||
$bettingList[$item->id]['totalAmount'] = 0;
|
||||
}
|
||||
Reference in New Issue
Block a user