diff --git a/hwe/d_setting/templates/allButton.php.orig b/hwe/d_setting/templates/allButton.php.orig index e21f008b..f1bfd702 100644 --- a/hwe/d_setting/templates/allButton.php.orig +++ b/hwe/d_setting/templates/allButton.php.orig @@ -1,18 +1,16 @@ -
- - - - - - - - - - - - - - - - -
+">세력도 +">세력일람 +">장수일람 +">명장일람 +">연감 +">명예의전당 +">왕조일람 +">천통국 베팅 +">삼모게시판 +">팁/강좌 +">삼국 일보 +">개인 열전 +">국가 열전 +">패치 내역 +">전투 시뮬레이터 +"> \ No newline at end of file diff --git a/hwe/sammo/API/Betting/Bet.php b/hwe/sammo/API/Betting/Bet.php index 4fa82448..f93066d1 100644 --- a/hwe/sammo/API/Betting/Bet.php +++ b/hwe/sammo/API/Betting/Bet.php @@ -1,11 +1,11 @@ args); $v->rule('required', [ - 'betting_id', - 'betting_type', + 'bettingID', + 'bettingType', 'amount' ]) - ->rule('integer', 'betting_id') - ->rule('integerArray', 'betting_type') + ->rule('integer', 'bettingID') + ->rule('integerArray', 'bettingType') ->rule('integer', 'amount') ->rule('min', 'amount', 1); @@ -47,10 +47,10 @@ class BetNation extends \sammo\BaseAPI $db = DB::db(); /** @var int */ - $bettingID = $this->arg['betting_id']; - /** @var int[] */ - $bettingType = $this->arg['betting_type']; + $bettingID = $this->args['bettingID']; /** @var int[] */ + $bettingType = $this->args['bettingType']; + /** @var int */ $amount = $this->args['amount']; $gameStor = KVStorage::getStorage($db, 'game_env'); @@ -75,7 +75,7 @@ class BetNation extends \sammo\BaseAPI $yearMonth = Util::joinYearMonth($year, $month); - if($bettingInfo->closeYearMonth > $yearMonth){ + if($bettingInfo->closeYearMonth <= $yearMonth){ return '이미 마감된 베팅입니다'; } @@ -102,15 +102,24 @@ class BetNation extends \sammo\BaseAPI } $bettingTypeKey = Json::encode($bettingType); - $general = General::createGeneralObjFromDB($session->generalID, ['gold', 'aux'], 1); + + $inheritStor = KVStorage::getStorage($db, "inheritance_{$session->userID}"); + + $prevBetAmount = $db->queryFirstField('SELECT sum(amount) FROM ng_betting WHERE betting_id = %i AND user_id = %i', $bettingID, $session->userID) ?? 0; + + if($prevBetAmount + $amount > 1000){ + return (1000 - $prevBetAmount).' 포인트까지만 베팅 가능합니다.'; + } if($bettingInfo->reqInheritancePoint){ - if($general->getInheritancePoint('previous') < $amount){ + $remainPoint = ($inheritStor->getValue('previous') ?? [0,0])[0]; + if($remainPoint < $amount){ return '유산포인트가 충분하지 않습니다.'; } } else { - if($general->getVar('gold') < GameConst::$generalMinimumGold + $amount){ + $remainPoint = $db->queryFirstField('SELECT gold FROM general WHERE no = %i', $session->generalID)??0; + if($remainPoint < GameConst::$generalMinimumGold + $amount){ return '금이 부족합니다.'; } } @@ -126,17 +135,17 @@ class BetNation extends \sammo\BaseAPI ]); if($bettingInfo->reqInheritancePoint){ - $general->increaseInheritancePoint('previous', -$amount); + $inheritStor->setValue('previous', [$remainPoint - $amount, null]); } else{ - $general->increaseVar('gold', -$amount); + $db->update('general', [ + 'gold' => $db->sqleval('gold - %i', $amount) + ], 'no = %i', $session->generalID); } $db->insertUpdate('ng_betting', $bettingItem->toArray()); if(!$db->affected_rows){ - $general->flushUpdateValues(); return '베팅을 실패했습니다.'; } - $general->applyDB($db); return [ 'result'=>true diff --git a/hwe/sammo/API/Betting/GetBettingDetail.php b/hwe/sammo/API/Betting/GetBettingDetail.php index 1195fca1..78e87507 100644 --- a/hwe/sammo/API/Betting/GetBettingDetail.php +++ b/hwe/sammo/API/Betting/GetBettingDetail.php @@ -1,6 +1,6 @@ arg['betting_id']; + $bettingID = $this->args['betting_id']; $gameStor = KVStorage::getStorage($db, 'game_env'); $bettingStor = KVStorage::getStorage($db, 'betting'); @@ -63,7 +64,7 @@ class GetBettingDetail extends \sammo\BaseAPI 'SELECT betting_type, sum(amount) as sum_amount FROM ng_betting WHERE betting_id = %i GROUP BY betting_type', $bettingID ) as [$bettingType, $amount]) { - $bettingDetail[] = [$bettingType, $amount]; + $bettingDetail[] = [$bettingType, Util::toInt($amount)]; } [$year, $month] = $gameStor->getValuesAsArray(['year', 'month']); @@ -73,20 +74,19 @@ class GetBettingDetail extends \sammo\BaseAPI 'SELECT betting_type, sum(amount) as sum_amount FROM ng_betting WHERE betting_id = %i AND user_id = %i GROUP BY betting_type', $bettingID, $session->userID ) as [$bettingType, $amount]){ - $myBetting[] = [$bettingType, $amount]; + $myBetting[] = [$bettingType, Util::toInt($amount)]; } - $general = General::createGeneralObjFromDB($session->generalID, ['gold', 'aux'], 1); - if($bettingInfo->reqInheritancePoint){ - $remainPoint = $general->getInheritancePoint('previous'); + $inheritStor = KVStorage::getStorage($db, "inheritance_{$session->userID}"); + $remainPoint = ($inheritStor->getValue('previous') ?? [0,0])[0]; } else{ - $remainPoint = $general->getVar('gold'); + $remainPoint = $db->queryFirstField('SELECT gold FROM general WHERE no = %i', $session->generalID)??0; } return [ - 'result' => false, + 'result' => true, 'bettingInfo' => $rawBettingInfo, 'bettingDetail' => $bettingDetail, 'myBetting' => $myBetting, diff --git a/hwe/sammo/API/Betting/GetBettingList.php b/hwe/sammo/API/Betting/GetBettingList.php index 0a80ae7b..df89dc55 100644 --- a/hwe/sammo/API/Betting/GetBettingList.php +++ b/hwe/sammo/API/Betting/GetBettingList.php @@ -1,6 +1,6 @@ getAll() as $_key => $rawItem) { $item = new BettingInfo($rawItem); + unset($rawItem['candidates']); $bettingList[$item->id] = $rawItem; $bettingList[$item->id]['totalAmount'] = 0; } @@ -61,7 +62,7 @@ class GetBettingList extends \sammo\BaseAPI [$year, $month] = $gameStor->getValuesAsArray(['year', 'month']); return [ - 'result' => false, + 'result' => true, 'bettingList' => $bettingList, 'year' => $year, 'month' => $month, diff --git a/hwe/sammo/DTO/BettingInfo.php b/hwe/sammo/DTO/BettingInfo.php index 984a8955..13fae86e 100644 --- a/hwe/sammo/DTO/BettingInfo.php +++ b/hwe/sammo/DTO/BettingInfo.php @@ -2,10 +2,11 @@ namespace sammo\DTO; -use Sammo\DTO\SelectItem; +use sammo\DTO\SelectItem; use Spatie\DataTransferObject\Attributes\CastWith; use Spatie\DataTransferObject\Attributes\Strict; use Spatie\DataTransferObject\DataTransferObject; +use Spatie\DataTransferObject\Casters\ArrayCaster; //https://json2dto.atymic.dev/ diff --git a/hwe/sammo/DTO/BettingItem.php b/hwe/sammo/DTO/BettingItem.php index c37d8290..d88426aa 100644 --- a/hwe/sammo/DTO/BettingItem.php +++ b/hwe/sammo/DTO/BettingItem.php @@ -1,8 +1,9 @@ $rhs['power']); + }); + + foreach ($nations as $nationRaw) { $nationID = $nationRaw['nation']; $cityCnt = $citiesCnt[$nationID] ?? 0; $nationRaw['city_cnt'] = $cityCnt; diff --git a/hwe/sammo/ResetHelper.php b/hwe/sammo/ResetHelper.php index 5c188c0c..d2638a54 100644 --- a/hwe/sammo/ResetHelper.php +++ b/hwe/sammo/ResetHelper.php @@ -133,6 +133,8 @@ class ResetHelper{ $gameStor = KVStorage::getStorage($db, 'game_env'); $gameStor->resetValues(); $gameStor->next_season_idx = $seasonIdx; + $bettingStor = KVStorage::getStorage($db, 'betting'); + $bettingStor->resetValues(); $lastExecuteStor = KVStorage::getStorage($db, 'next_execute'); $lastExecuteStor->resetValues(); diff --git a/hwe/scss/nationBetting.scss b/hwe/scss/nationBetting.scss new file mode 100644 index 00000000..e69de29b diff --git a/hwe/sql/reset.sql b/hwe/sql/reset.sql index a18f0f28..90015539 100644 --- a/hwe/sql/reset.sql +++ b/hwe/sql/reset.sql @@ -62,4 +62,6 @@ CREATE TABLE `reserved_open` ( INDEX `date` (`date`) ) DEFAULT CHARSET=utf8mb4 -ENGINE=Aria; \ No newline at end of file +ENGINE=Aria; + +DROP TABLE IF EXISTS ng_betting; \ No newline at end of file diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index 85346286..c7753c4c 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -680,7 +680,7 @@ DEFAULT CHARSET=utf8mb4 ENGINE=Aria ; -CREATE TABLE IF NOT EXISTS `ng_betting` ( +CREATE TABLE `ng_betting` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `betting_id` INT(11) NOT NULL, `general_id` INT(11) NOT NULL, diff --git a/hwe/templates/allButton.php b/hwe/templates/allButton.php index f398492f..f1bfd702 100644 --- a/hwe/templates/allButton.php +++ b/hwe/templates/allButton.php @@ -5,7 +5,7 @@ ">연감 ">명예의전당 ">왕조일람 -">접속량정보 +">천통국 베팅 ">삼모게시판 ">팁/강좌 ">삼국 일보 diff --git a/hwe/ts/PageNationBetting.vue b/hwe/ts/PageNationBetting.vue new file mode 100644 index 00000000..29313dbb --- /dev/null +++ b/hwe/ts/PageNationBetting.vue @@ -0,0 +1,315 @@ + + + \ No newline at end of file diff --git a/hwe/ts/SammoAPI.ts b/hwe/ts/SammoAPI.ts index f9fe713a..548c3da2 100644 --- a/hwe/ts/SammoAPI.ts +++ b/hwe/ts/SammoAPI.ts @@ -13,6 +13,11 @@ async function done{{ toast.title }} - {{ toast.content }} {{ toast.visible }} + {{ toast.content }} @@ -64,7 +64,7 @@ export default defineComponent({ doneMap.clear(); toasts.value.length = 0; - emit("update:modelValue", toasts); + emit("update:modelValue", toasts.value); } watch(props.modelValue, (values) => { diff --git a/hwe/ts/v_nationBetting.ts b/hwe/ts/v_nationBetting.ts new file mode 100644 index 00000000..a6269476 --- /dev/null +++ b/hwe/ts/v_nationBetting.ts @@ -0,0 +1,12 @@ +import "@scss/nationBetting.scss"; + +import { createApp } from 'vue' +import PageNationBetting from '@/PageNationBetting.vue'; +import BootstrapVue3 from 'bootstrap-vue-3'; +import { auto500px } from './util/auto500px'; + + + + +auto500px(); +createApp(PageNationBetting).use(BootstrapVue3).mount('#app'); \ No newline at end of file diff --git a/hwe/v_nationBetting.php b/hwe/v_nationBetting.php index 02a13850..a24f9a25 100644 --- a/hwe/v_nationBetting.php +++ b/hwe/v_nationBetting.php @@ -20,7 +20,7 @@ $generalID = $session->generalID; - <?= UniqueConst::$serverName ?>: 내무부 + <?= UniqueConst::$serverName ?>: 국가 베팅장 [