From d18ae3dd11eb8c7ade5c44c109d8838608e99c86 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Wed, 8 Jun 2022 23:13:13 +0900 Subject: [PATCH] =?UTF-8?q?feat,wip:=20=EA=B8=B0=EC=A1=B4=20=EA=B1=B0?= =?UTF-8?q?=EB=9E=98=EC=9E=A5=20=EC=BD=94=EB=93=9C=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/_119_b.php | 4 +- hwe/b_auction.php | 306 --------------------- hwe/c_auction.php | 247 ----------------- hwe/func.php | 2 +- hwe/func_auction.php | 70 ++--- hwe/index.php | 2 +- hwe/sammo/Command/General/che_NPC능동.php | 3 - hwe/sammo/Command/General/che_모반시도.php | 3 - hwe/sammo/Command/General/che_방랑.php | 2 - hwe/sammo/Command/General/che_선양.php | 3 - hwe/sammo/Command/General/che_소집해제.php | 3 - hwe/sammo/Command/General/che_요양.php | 3 - hwe/sammo/Command/General/che_첩보.php | 2 - hwe/sammo/Command/General/che_하야.php | 3 - hwe/sammo/Command/General/che_해산.php | 2 - hwe/sammo/Command/General/che_화계.php | 3 - hwe/sammo/Command/General/휴식.php | 3 - hwe/sql/reset.sql | 3 - hwe/sql/schema.sql | 17 -- 19 files changed, 31 insertions(+), 650 deletions(-) delete mode 100644 hwe/b_auction.php delete mode 100644 hwe/c_auction.php diff --git a/hwe/_119_b.php b/hwe/_119_b.php index ddf70b11..84158b73 100644 --- a/hwe/_119_b.php +++ b/hwe/_119_b.php @@ -52,7 +52,7 @@ switch ($btn) { ], true); $db->update('ng_auction', [ 'close_date' => $db->sqleval('DATE_SUB(close_date, INTERVAL %i MINUTE)', $minute) - ], true); + ], 'finished = 0'); if ($locked) { unlock(); } @@ -80,7 +80,7 @@ switch ($btn) { ], true); $db->update('ng_auction', [ 'close_date' => $db->sqleval('DATE_ADD(close_date, INTERVAL %i MINUTE)', $minute) - ], true); + ], 'finished = 0'); if ($locked) { unlock(); } diff --git a/hwe/b_auction.php b/hwe/b_auction.php deleted file mode 100644 index 6fd02248..00000000 --- a/hwe/b_auction.php +++ /dev/null @@ -1,306 +0,0 @@ -setReadOnly(); -$userID = Session::getUserID(); - -$db = DB::db(); -$gameStor = KVStorage::getStorage($db, 'game_env'); - -increaseRefresh("거래장", 2); - -$me = $db->queryFirstRow('SELECT no,special,con,turntime from general where owner=%i', $userID); - -$con = checkLimit($me['con']); -if ($con >= 2) { - printLimitMsg($me['turntime']); - exit(); -} - -$tradeCount = $db->queryFirstField('SELECT count(no) FROM auction WHERE no1=%i', $me['no']); -$bidCount = $db->queryFirstField('SELECT count(no) FROM auction where no2=%i', $me['no']); - -$btCount = $tradeCount + $bidCount; - -if ($session->userGrade >= 5 || $btCount < 1) { - $btn = "submit"; -} else { - $btn = "hidden"; -} - -if ($msg == "") { - $msg = "-"; -} -if ($msg2 == "") { - $msg2 = "-"; -} -?> - - - - - <?= UniqueConst::$serverName ?>: 거래장 - - - - - - - - - - - - - - - - - -
거 래 장
- 거 래 장 -
- - - - - - - - - - - - - - - - - - - query('SELECT * from auction where type=0 order by expire') as $auction) { - $radio = ""; - $alert = ""; - $alert2 = ""; - if ($auction['no1'] == $me['no']) { - $radio = " disabled"; - } elseif ($auction['no2'] > 0 && $auction['amount'] * 2 <= $auction['value']) { - $radio = " disabled"; - $alert = ""; - $alert2 = ""; - } elseif ($auction['no2'] > 0 && $auction['topv'] <= $auction['value']) { - $radio = " disabled"; - $alert = ""; - $alert2 = ""; - } elseif ($chk == 0) { - $radio = " checked"; - $chk = 1; - } - $pv = round($auction['value'] * 100 / $auction['amount']) / 100 + 0.001; - $pv = substr((string)$pv, 0, 4); - - echo " - - - - - - - - - - - - - - "; - } - ?> - - - - - - - - - - - - - - - - -
- 팝 니 다 -
거래번호선택판매자물품수량시작판매가현재판매가즉시판매가단가구매 예정자거래종료
{$auction['no']}{$auction['name1']}{$auction['amount']}금 {$auction['cost']}{$alert}금 {$auction['value']}{$alert2}{$alert}금 {$auction['topv']}{$alert2}{$alert}{$pv}{$alert2}{$alert}{$auction['name2']}{$alert2}{$auction['expire']}
등록결과
입찰등록 -  지불할 금액: - name=btn value='구매시도' onclick='return confirm("정말 입찰하시겠습니까?");'> -
거래등록 -  종료: 턴 후 -  물품: 쌀 -  판매량: -  시작가: -  즉구가: - name=btn value='판매' onclick='return confirm("정말 판매하시겠습니까?");'> -
- ㆍHint) 거래자가 판매(물품 판매, 금 수령), 입찰자가 구매(물품 구입, 금 지불).
- ㆍHint) 단가가 1.00보다 높을수록 판매자 유리.
- ㆍHint) 단가가 1.00보다 낮을수록 입찰자 유리.
-
-
- - - - - - - - - - - - - - - - - - - query('SELECT * from auction where type=1 order by expire') as $auction) { - $radio = ""; - $alert = ""; - $alert2 = ""; - if ($auction['no1'] == $me['no']) { - $radio = " disabled"; - } elseif ($auction['no2'] > 0 && $auction['amount'] >= $auction['value'] * 2) { - $radio = " disabled"; - $alert = ""; - $alert2 = ""; - } elseif ($auction['no2'] > 0 && $auction['topv'] >= $auction['value']) { - $radio = " disabled"; - $alert = ""; - $alert2 = ""; - } elseif ($chk == 0) { - $radio = " checked"; - $chk = 1; - } - $pv = round($auction['value'] * 100 / $auction['amount']) / 100 + 0.001; - $pv = substr((string)$pv, 0, 4); - echo " - - - - - - - - - - - - - - "; - } - ?> - - - - - - - - - - - - - - - - -
- 삽 니 다 -
거래번호선택구매자물품수량시작구매가현재구매가즉시구매가단가판매 예정자거래종료
{$auction['no']}{$auction['name1']}{$auction['amount']}금 {$auction['cost']}{$alert}금 {$auction['value']}{$alert2}{$alert}금 {$auction['topv']}{$alert2}{$alert}{$pv}{$alert2}{$alert}{$auction['name2']}{$alert2}{$auction['expire']}
등록결과
입찰등록 -  수령할 금액: - name=btn value='판매시도' onclick='return confirm("정말 입찰하시겠습니까?");'> -
거래등록 -  종료: 턴 후 -  물품: 쌀 -  구입량: -  시작가: -  즉구가: - name=btn value='구매' onclick='return confirm("정말 구매하시겠습니까?");'> -
- ㆍHint) 거래자가 구매(물품 구매, 금 지불), 입찰자가 판매(물품 판매, 금 수령).
- ㆍHint) 단가가 1.00보다 낮을수록 구매자 유리.
- ㆍHint) 단가가 1.00보다 높을수록 입찰자 유리.
-
-
- - - - - - - - - - - - - - - - - - - -
- 최 근 기 록 -
- -
- 도 움 말 -
- - ㆍ판매거래는 거래자가 판매할 물품을 거래하면, 구입을 희망하는 사람이 현재가보다 높게 입찰하여 구입하는 방식입니다.
- ㆍHint) 쌀이 귀한 경우는 입찰자가 많아서 자연스레 단가가 오르게 됩니다. (해당 물품을 사려는 가격이 오름)
- ㆍHint) 쌀이 흔한 경우는 초기 가격을 낮게 책정해야 판매가 가능할 겁니다.
- ㆍ구매거래는 거래자가 구입할 물품을 거래하면, 판매를 희망하는 사람이 현재가보다 낮게 입찰하여 판매하는 방식입니다.
- ㆍHint) 쌀이 흔한 경우는 입찰자가 많아서 자연스레 단가가 내리게 됩니다. (해당 물품을 팔려는 가격이 내림)
- ㆍHint) 쌀이 귀한 경우는 초기 가격을 높게 책정해야 구입이 가능할 겁니다.
- ㆍ마감임박때 입찰하는 경우 입찰후 1턴 후로 종료시간이 연장됩니다.
- ㆍ즉시구매가로 입찰하는 경우 입찰후 1턴 후로 종료시간이 결정됩니다.
- ㆍ악용 방지를 위해 50% ~ 200%의 가격에서 거래시작이 가능합니다.
- ㆍ악용 방지를 위해 즉시판매가는 110% 이상, 즉시구매가는 90% 이하의 시세로 가능합니다.
- ㆍ악용 방지를 위해 즉시판매가는 시작판매가의 110% 이상, 즉시구매가는 시작구매가의 90% 이하로 가능합니다.
- ㆍ1인당 도합 1건의 거래와 입찰이 가능합니다.
- ㆍ기본금쌀 1000은 거래에 사용되지 못합니다.
- ㆍ유찰될 때는 거래 과실자에게 거래금의 1%가 벌금으로 부과됩니다.
- ㆍ10단위로 거래가 가능합니다. 1자리는 반올림 처리 됩니다.
- ㆍ★ 최고가 거래 ★ 혹은 ★ 최저가 거래 ★ 는 암거래 및 악용의 가능성이니 감시 부탁드립니다.
- ㆍ거래와 입찰은 취소가 불가능하니 주의하세요!
- ㆍHint) 단가는 금/쌀로 쌀1을 거래하기 위한 금의 양입니다.
- ㆍHint) 단가가 높으면(>1.00) 쌀이 비싸므로 판매가 이득입니다.
- ㆍHint) 단가가 낮으면(<1.00) 금이 비싸므로 구매가 이득입니다.
- ㆍ즐거운 거래! -
-
- - - \ No newline at end of file diff --git a/hwe/c_auction.php b/hwe/c_auction.php deleted file mode 100644 index c4f6c517..00000000 --- a/hwe/c_auction.php +++ /dev/null @@ -1,247 +0,0 @@ -rule('integer', [ - 'amount', - 'cost', - 'topv', - 'value', - 'term', - 'sel' -]); - -$btn = Util::getPost('btn'); -$amount = Util::getPost('amount', 'int'); -$cost = Util::getPost('cost', 'int'); -$topv = Util::getPost('topv', 'int'); -$value = Util::getPost('value', 'int'); -$term = Util::getPost('term', 'int'); -$sel = Util::getPost('sel', 'int'); - -$msg = ''; -$msg2 = ''; - - -//로그인 검사 -$session = Session::requireGameLogin()->setReadOnly(); -$userID = Session::getUserID(); - -$db = DB::db(); -$gameStor = KVStorage::getStorage($db, 'game_env'); - -increaseRefresh("입찰", 1); - -$turnterm = $gameStor->turnterm; - -$me = $db->queryFirstRow('SELECT no,name,gold,rice,special from general where owner=%i', $userID); - -$tradeCount = $db->queryFirstField('SELECT count(no) FROM auction WHERE no1=%i', $me['no']); -$bidCount = $db->queryFirstField('SELECT count(no) FROM auction WHERE no2=%i', $me['no']); - -$btCount = $tradeCount + $bidCount; - -$unit = $turnterm * 60; - -$amount = Util::round($amount, -1); -$cost = Util::round($cost, -1); -$topv = Util::round($topv, -1); -$value = Util::round($value, -1); -if ($term > 24) { - $term = 24; -} - -$valid = 1; -if ($session->userGrade >= 5 || $btCount < 1) { -} else { - $msg = "ㆍ더이상 등록할 수 없습니다."; - $msg2 = "ㆍ더이상 등록할 수 없습니다."; - $valid = 0; - $btn = "hidden"; -} - -if ($btn == "판매") { - if ($term < 0 || $term > 24) { - $msg = "ㆍ종료기한은 1 ~ 24 턴 이어야 합니다."; - $valid = 0; - } - if ($amount < 100 || $amount > 10000) { - $msg = "ㆍ거래량은 100 ~ 10000 이어야 합니다."; - $valid = 0; - } - if ($cost > $amount * 2 || $cost * 2 < $amount) { - $msg = "ㆍ시작판매가는 50% ~ 200% 이어야 합니다."; - $valid = 0; - } - if ($topv * 10 < $amount * 11 || $topv > $amount * 2) { - $msg = "ㆍ즉시판매가는 110% ~ 200% 이어야 합니다."; - $valid = 0; - } - if ($topv * 10 < $cost * 11) { - $msg = "ㆍ즉시판매가는 시작판매가의 110% 이상이어야 합니다."; - $valid = 0; - } - if ($amount > $me['rice'] - GameConst::$defaultRice) { - $msg = "ㆍ기본 군량 ".GameConst::$defaultRice."은 거래할 수 없습니다."; - $valid = 0; - } - if ($valid == 1) { - $msg = "ㆍ등록 성공."; - $date = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")) + $unit * $term); - $db->insert('auction', [ - 'type'=>0, - 'no1'=>$me['no'], - 'name1'=>$me['name'], - 'amount'=>$amount, - 'cost'=>$cost, - 'value'=>$cost, - 'topv'=>$topv, - 'expire'=>$date - ]); - } -} elseif ($btn == "구매시도") { - $auction = $db->queryFirstRow('SELECT no2,value,topv,expire,amount FROM auction WHERE no=%i LIMIT 1', $sel); - - if ($value == $auction['topv']) { - $valid = 2; - } - if (!$auction) { - $msg = "ㆍ종료된 거래입니다."; - $valid = 0; - } - if ($auction['no2'] > 0 && $value <= $auction['value']) { - $msg = "ㆍ현재판매가보다 높게 입찰해야 합니다."; - $valid = 0; - } - if ($value < $auction['value']) { - $msg = "ㆍ현재판매가보다 높게 입찰해야 합니다."; - $valid = 0; - } - if ($value > $auction['topv']) { - $msg = "ㆍ즉시판매가보다 높을 수 없습니다."; - $valid = 0; - } - if ($value > $me['gold'] - GameConst::$defaultGold) { - $msg = "ㆍ기본 자금 ".GameConst::$defaultGold."은 거래할 수 없습니다."; - $valid = 0; - } - if ($valid == 1) { - $msg = "ㆍ입찰 성공. 거래완료는 빨라도 현재로부터 1턴 뒤입니다."; - $date = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")) + $unit); - if ($auction['expire'] > $date) { - $date = $auction['expire']; - } - - $db->update('auction', [ - 'value'=>$value, - 'no2'=>$me['no'], - 'name2'=>$me['name'], - 'expire'=>$date, - ], 'no=%i', $sel); - } elseif ($valid == 2) { - $msg = "ㆍ즉시판매 성공. 거래완료는 빨라도 현재로부터 1턴 뒤입니다."; - $date = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")) + $unit); - - $db->update('auction', [ - 'value'=>$value, - 'no2'=>$me['no'], - 'name2'=>$me['name'], - 'expire'=>$date, - ], 'no=%i', $sel); - } -} elseif ($btn == "구매") { - if ($term < 0 || $term > 24) { - $msg2 = "ㆍ종료기한은 1 ~ 24 턴 이어야 합니다."; - $valid = 0; - } - if ($amount < 100 || $amount > 10000) { - $msg2 = "ㆍ거래량은 100 ~ 10000 이어야 합니다."; - $valid = 0; - } - if ($cost > $amount * 2 || $cost * 2 < $amount) { - $msg2 = "ㆍ시작구매가는 50% ~ 200% 이어야 합니다."; - $valid = 0; - } - if ($topv < $amount * 0.5 || $topv > $amount * 0.9) { - $msg2 = "ㆍ즉시구매가는 50% ~ 90% 이어야 합니다."; - $valid = 0; - } - if ($topv > $cost * 0.9) { - $msg2 = "ㆍ즉시구매가는 시작구매가의 90% 이하이어야 합니다."; - $valid = 0; - } - if ($cost > $me['gold'] - GameConst::$defaultGold) { - $msg2 = "ㆍ기본 자금 ".GameConst::$defaultGold."은 거래할 수 없습니다."; - $valid = 0; - } - if ($valid == 1) { - $msg2 = "ㆍ등록 성공."; - $date = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")) + $unit * $term); - - $db->insert('auction', [ - 'type'=>1, - 'no1'=>$me['no'], - 'name1'=>$me['name'], - 'amount'=>$amount, - 'cost'=>$cost, - 'value'=>$cost, - 'topv'=>$topv, - 'expire'=>$date - ]); - } -} elseif ($btn == "판매시도") { - $auction = $db->queryFirstRow('SELECT no2,value,topv,expire,amount FROM auction WHERE no=%i LIMIT 1', $sel); - - if ($value == $auction['topv']) { - $valid = 2; - } - if (!$auction) { - $msg2 = "ㆍ종료된 거래입니다."; - $valid = 0; - } - if ($auction['no2'] > 0 && $value >= $auction['value']) { - $msg2 = "ㆍ현재구매가보다 낮게 입찰해야 합니다."; - $valid = 0; - } - if ($value > $auction['value']) { - $msg2 = "ㆍ현재구매가보다 낮게 입찰해야 합니다."; - $valid = 0; - } - if ($value < $auction['topv']) { - $msg2 = "ㆍ즉시구매가보다 낮을 수 없습니다."; - $valid = 0; - } - if ($value > $me['rice'] - GameConst::$defaultRice) { - $msg2 = "ㆍ기본 군량 ".GameConst::$defaultRice."은 거래할 수 없습니다."; - $valid = 0; - } - if ($valid == 1) { - $msg2 = "ㆍ입찰 성공. 거래완료는 빨라도 현재로부터 1턴 뒤입니다."; - $date = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")) + $unit); - if ($auction['expire'] > $date) { - $date = $auction['expire']; - } - - $db->update('auction', [ - 'value'=>$value, - 'no2'=>$me['no'], - 'name2'=>$me['name'], - 'expire'=>$date, - ], 'no=%i', $sel); - } elseif ($valid == 2) { - $msg2 = "ㆍ즉시구매 성공. 거래완료는 빨라도 현재로부터 1턴 뒤입니다."; - $date = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s")) + $unit); - - $db->update('auction', [ - 'value'=>$value, - 'no2'=>$me['no'], - 'name2'=>$me['name'], - 'expire'=>$date, - ], 'no=%i', $sel); - } -} - -Submit("b_auction.php", $msg, $msg2); diff --git a/hwe/func.php b/hwe/func.php index a90a618c..c3a1bf60 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1207,7 +1207,7 @@ function checkDelay() ], 'turntime<=DATE_ADD(turntime, INTERVAL %i MINUTE)', $term); $db->update('ng_auction', [ 'close_date' => $db->sqleval('DATE_ADD(close_date, INTERVAL %i MINUTE)', $minute) - ], true); + ], 'finished = 0'); } } diff --git a/hwe/func_auction.php b/hwe/func_auction.php index bc5f07ae..e9f38529 100644 --- a/hwe/func_auction.php +++ b/hwe/func_auction.php @@ -7,39 +7,25 @@ use sammo\Enums\AuctionType; function registerAuction(RandUtil $rng) { $db = DB::db(); - $gameStor = KVStorage::getStorage($db, 'game_env'); - - $admin = $gameStor->getValues(['startyear', 'year', 'month', 'turnterm']); - - $unit = 60 * $admin['turnterm']; // 장수들 평금,평쌀 - $general = $db->queryFirstRow('SELECT avg(gold) as gold, avg(rice) as rice,max(gold) as maxgold from general where npc<2'); + [$avgGold, $avgRice] = $db->queryFirstList('SELECT avg(gold), avg(rice) from general where npc<2'); + $avgGold = Util::valueFit($avgGold, 1000, 20000); + $avgRice = Util::valueFit($avgRice, 1000, 20000); - if ($general['gold'] < 1000) { - $general['gold'] = 1000; - } - if ($general['gold'] > 20000) { - $general['gold'] = 20000; - } - if ($general['rice'] < 1000) { - $general['rice'] = 1000; - } - if ($general['rice'] > 20000) { - $general['rice'] = 20000; - } + $neutralAuctionCnt = Util::convertPairArrayToDict($db->queryAllLists( + 'SELECT `type`, count(*) FROM ng_auction WHERE `type` IN %s AND `host_general_id`=0 GROUP BY `type`', + [AuctionType::BuyRice->value, AuctionType::SellRice->value], + )); - $count = $db->queryFirstField('SELECT count(*) FROM auction WHERE type=0 AND no1=0'); - $count += 5; - - $dummyGeneral = AuctionBasicResource::genDummy(); + $neutralbuyRiceCnt = $neutralAuctionCnt[AuctionType::BuyRice->value]; // 판매건 등록 - if ($rng->nextBool(1 / $count)) { + if ($rng->nextBool(1 / ($neutralbuyRiceCnt + 5))) { //평균 쌀의 5% ~ 25% $mul = $rng->nextRangeInt(1, 5); - $amount = $general['rice'] / 20 * $mul; - $cost = $general['gold'] / 20 * 0.9 * $mul; + $amount = $avgRice / 20 * $mul; + $cost = $avgGold / 20 * 0.9 * $mul; $topv = $amount * 2; $cost = Util::valueFit($cost, $amount * 0.8, $amount * 1.2); @@ -48,18 +34,18 @@ function registerAuction(RandUtil $rng) $topv = Util::round($topv, -1); $term = $rng->nextRangeInt(3, 12); + $dummyGeneral = AuctionBasicResource::genDummy(); AuctionBuyRice::openResourceAuction($dummyGeneral, $amount, $term, $cost, $topv); } - $count = $db->queryFirstField('SELECT count(*) FROM auction WHERE type=1 AND no1=0'); - $count += 5; + $neutralSellRiceCnt = $neutralAuctionCnt[AuctionType::SellRice->value]; // 구매건 등록 - if ($rng->nextBool(1 / $count)) { + if ($rng->nextBool(1 / ($neutralSellRiceCnt + 5))) { //평균 쌀의 5% ~ 25% $mul = $rng->nextRangeInt(1, 5); - $amount = $general['rice'] / 20 * $mul; - $cost = $general['gold'] / 20 * 1.1 * $mul; - $topv = $amount * 0.5; + $amount = $avgGold / 20 * $mul; + $cost = $avgRice / 20 * 1.1 * $mul; + $topv = $amount * 2; $cost = Util::valueFit($cost, $amount * 0.8, $amount * 1.2); $amount = Util::round($amount, -1); @@ -67,6 +53,7 @@ function registerAuction(RandUtil $rng) $topv = Util::round($topv, -1); $term = $rng->nextRangeInt(3, 12); + $dummyGeneral = AuctionBasicResource::genDummy(); AuctionSellRice::openResourceAuction($dummyGeneral, $amount, $term, $cost, $topv); } } @@ -74,32 +61,29 @@ function registerAuction(RandUtil $rng) function processAuction() { $db = DB::db(); - $gameStor = KVStorage::getStorage($db, 'game_env'); $now = TimeUtil::now(); - [$year, $month] = $gameStor->getValuesAsArray(['year', 'month']); - - $admin = $gameStor->getValues(['year', 'month']); - $auctionList = $db->queryFirstColumn( - 'SELECT id, `type` FROM ng_auction WHERE `type` IN %ls AND `close_date` <= %s', - [AuctionType::BuyRice->value, AuctionType::SellRice->value], + 'SELECT id, `type` FROM ng_auction WHERE `close_date` <= %s AND finished = 0', $now ); - if(!$auctionList){ + if (!$auctionList) { return; } $dummyGeneral = AuctionBasicResource::genDummy(); - foreach($auctionList as [$auctionID, $rawAuctionType]) { + foreach ($auctionList as [$auctionID, $rawAuctionType]) { $auctionType = AuctionType::from($rawAuctionType); - if($auctionType === AuctionType::BuyRice){ + if ($auctionType === AuctionType::BuyRice) { $auction = new AuctionBuyRice($auctionID, $dummyGeneral); - } - else{ + } else if ($auctionType === AuctionType::SellRice) { $auction = new AuctionSellRice($auctionID, $dummyGeneral); + } else if ($auctionType === AuctionType::UniqueItem) { + $auction = new AuctionUniqueItem($auctionID, $dummyGeneral); + } else { + throw new \Exception('Unknown auction type'); } $auction->tryFinish(); } diff --git a/hwe/index.php b/hwe/index.php index a8fc6416..be5f5c2e 100644 --- a/hwe/index.php +++ b/hwe/index.php @@ -88,7 +88,7 @@ $color = "cyan"; $serverName = UniqueConst::$serverName; $serverCnt = $gameStor->server_cnt; -$auctionCount = $db->queryFirstField('SELECT count(`no`) FROM auction'); +$auctionCount = $db->queryFirstField('SELECT count(*) FROM ng_auction WHERE finished = 0'); $isTournamentActive = $gameStor->tournament > 0; $isTournamentApplicationOpen = $gameStor->tournament == 1; $isBettingActive = $gameStor->tournament == 6; diff --git a/hwe/sammo/Command/General/che_NPC능동.php b/hwe/sammo/Command/General/che_NPC능동.php index 70815485..7ee07fc3 100644 --- a/hwe/sammo/Command/General/che_NPC능동.php +++ b/hwe/sammo/Command/General/che_NPC능동.php @@ -13,8 +13,6 @@ use \sammo\{ use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; -use function sammo\tryRollbackInheritUniqueItem; - class che_NPC능동 extends Command\GeneralCommand{ static protected $actionName = 'NPC능동'; @@ -98,7 +96,6 @@ class che_NPC능동 extends Command\GeneralCommand{ $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); } - tryRollbackInheritUniqueItem($rng, $general); $general->applyDB($db); return true; diff --git a/hwe/sammo/Command/General/che_모반시도.php b/hwe/sammo/Command/General/che_모반시도.php index 0be42d50..c5e0d005 100644 --- a/hwe/sammo/Command/General/che_모반시도.php +++ b/hwe/sammo/Command/General/che_모반시도.php @@ -15,8 +15,6 @@ use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; use sammo\Enums\InheritanceKey; -use function sammo\tryRollbackInheritUniqueItem; - class che_모반시도 extends Command\GeneralCommand{ static protected $actionName = '모반시도'; @@ -99,7 +97,6 @@ class che_모반시도 extends Command\GeneralCommand{ $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->increaseInheritancePoint(InheritanceKey::active_action, 1); $general->checkStatChange(); - tryRollbackInheritUniqueItem($rng, $general); $general->applyDB($db); $lordGeneral->applyDB($db); diff --git a/hwe/sammo/Command/General/che_방랑.php b/hwe/sammo/Command/General/che_방랑.php index 74a559be..786f7464 100644 --- a/hwe/sammo/Command/General/che_방랑.php +++ b/hwe/sammo/Command/General/che_방랑.php @@ -17,7 +17,6 @@ use sammo\Enums\InheritanceKey; use function sammo\DeleteConflict; use function sammo\refreshNationStaticInfo; -use function sammo\tryRollbackInheritUniqueItem; class che_방랑 extends Command\GeneralCommand{ static protected $actionName = '방랑'; @@ -125,7 +124,6 @@ class che_방랑 extends Command\GeneralCommand{ refreshNationStaticInfo(); $general->increaseInheritancePoint(InheritanceKey::active_action, 1); $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); - tryRollbackInheritUniqueItem($rng, $general); $general->applyDB($db); return true; diff --git a/hwe/sammo/Command/General/che_선양.php b/hwe/sammo/Command/General/che_선양.php index 922dcc48..6fc4f3f3 100644 --- a/hwe/sammo/Command/General/che_선양.php +++ b/hwe/sammo/Command/General/che_선양.php @@ -21,8 +21,6 @@ use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; use sammo\Enums\InheritanceKey; -use function sammo\tryRollbackInheritUniqueItem; - class che_선양 extends Command\GeneralCommand { static protected $actionName = '선양'; @@ -139,7 +137,6 @@ class che_선양 extends Command\GeneralCommand $general->increaseInheritancePoint(InheritanceKey::active_action, 1); $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); - tryRollbackInheritUniqueItem($rng, $general); $general->applyDB($db); $destGeneral->applyDB($db); diff --git a/hwe/sammo/Command/General/che_소집해제.php b/hwe/sammo/Command/General/che_소집해제.php index 6d474a4b..f4a9b84f 100644 --- a/hwe/sammo/Command/General/che_소집해제.php +++ b/hwe/sammo/Command/General/che_소집해제.php @@ -13,8 +13,6 @@ use \sammo\{ use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; -use function sammo\tryRollbackInheritUniqueItem; - class che_소집해제 extends Command\GeneralCommand{ static protected $actionName = '소집해제'; @@ -82,7 +80,6 @@ class che_소집해제 extends Command\GeneralCommand{ $general->addDedication($ded); $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); - tryRollbackInheritUniqueItem($rng, $general); $general->applyDB($db); return true; diff --git a/hwe/sammo/Command/General/che_요양.php b/hwe/sammo/Command/General/che_요양.php index b316240e..8b06217f 100644 --- a/hwe/sammo/Command/General/che_요양.php +++ b/hwe/sammo/Command/General/che_요양.php @@ -13,8 +13,6 @@ use \sammo\{ use \sammo\Constraint\Constraint; use \sammo\Constraint\ConstraintHelper; -use function sammo\tryRollbackInheritUniqueItem; - class che_요양 extends Command\GeneralCommand{ static protected $actionName = '요양'; @@ -71,7 +69,6 @@ class che_요양 extends Command\GeneralCommand{ $general->addDedication($ded); $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); - tryRollbackInheritUniqueItem($rng, $general); $general->applyDB($db); return true; diff --git a/hwe/sammo/Command/General/che_첩보.php b/hwe/sammo/Command/General/che_첩보.php index 5102d1aa..1f3c72c2 100644 --- a/hwe/sammo/Command/General/che_첩보.php +++ b/hwe/sammo/Command/General/che_첩보.php @@ -12,7 +12,6 @@ use \sammo\Command; use \sammo\Json; use function \sammo\searchDistance; -use function sammo\tryRollbackInheritUniqueItem; use \sammo\Constraint\ConstraintHelper; use sammo\CityConst; @@ -214,7 +213,6 @@ class che_첩보 extends Command\GeneralCommand $general->increaseVar('leadership_exp', 1); $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); - tryRollbackInheritUniqueItem($rng, $general); $general->applyDB($db); return true; diff --git a/hwe/sammo/Command/General/che_하야.php b/hwe/sammo/Command/General/che_하야.php index 5cbcbd69..b00aea20 100644 --- a/hwe/sammo/Command/General/che_하야.php +++ b/hwe/sammo/Command/General/che_하야.php @@ -15,8 +15,6 @@ use \sammo\Constraint\ConstraintHelper; use sammo\CityConst; use sammo\Enums\InheritanceKey; -use function sammo\tryRollbackInheritUniqueItem; - class che_하야 extends Command\GeneralCommand{ static protected $actionName = '하야'; @@ -118,7 +116,6 @@ class che_하야 extends Command\GeneralCommand{ $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); - tryRollbackInheritUniqueItem($rng, $general); $general->applyDB($db); return true; diff --git a/hwe/sammo/Command/General/che_해산.php b/hwe/sammo/Command/General/che_해산.php index 48389b07..c3dd00f2 100644 --- a/hwe/sammo/Command/General/che_해산.php +++ b/hwe/sammo/Command/General/che_해산.php @@ -20,7 +20,6 @@ use sammo\Event\EventHandler; use function sammo\refreshNationStaticInfo; use function sammo\deleteNation; -use function sammo\tryRollbackInheritUniqueItem; class che_해산 extends Command\GeneralCommand{ static protected $actionName = '해산'; @@ -99,7 +98,6 @@ class che_해산 extends Command\GeneralCommand{ $oldGeneral->setVar('makelimit', 12); $oldGeneral->applyDB($db); } - tryRollbackInheritUniqueItem($rng, $general); $general->applyDB($db); // 이벤트 핸들러 동작 diff --git a/hwe/sammo/Command/General/che_화계.php b/hwe/sammo/Command/General/che_화계.php index 0b2cd114..ce06a2b2 100644 --- a/hwe/sammo/Command/General/che_화계.php +++ b/hwe/sammo/Command/General/che_화계.php @@ -12,7 +12,6 @@ use \sammo\LastTurn; use \sammo\Command; use function \sammo\searchDistance; -use function sammo\tryRollbackInheritUniqueItem; use \sammo\Constraint\ConstraintHelper; use sammo\CityConst; @@ -296,7 +295,6 @@ class che_화계 extends Command\GeneralCommand $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); - tryRollbackInheritUniqueItem($rng, $general); $general->applyDB($db); return false; } @@ -330,7 +328,6 @@ class che_화계 extends Command\GeneralCommand $general->increaseRankVar(RankColumn::firenum, 1); $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->checkStatChange(); - tryRollbackInheritUniqueItem($rng, $general); $general->applyDB($db); return true; diff --git a/hwe/sammo/Command/General/휴식.php b/hwe/sammo/Command/General/휴식.php index ecdb0b83..8dcba62c 100644 --- a/hwe/sammo/Command/General/휴식.php +++ b/hwe/sammo/Command/General/휴식.php @@ -7,8 +7,6 @@ use \sammo\JosaUtil; use \sammo\LastTurn; use \sammo\DB; -use function sammo\tryRollbackInheritUniqueItem; - class 휴식 extends Command\GeneralCommand{ static protected $actionName = '휴식'; @@ -41,7 +39,6 @@ class 휴식 extends Command\GeneralCommand{ $logger->pushGeneralActionLog("아무것도 실행하지 않았습니다. <1>$date"); $this->setResultTurn(new LastTurn()); - tryRollbackInheritUniqueItem($rng, $general); $general->applyDB(DB::db()); return true; } diff --git a/hwe/sql/reset.sql b/hwe/sql/reset.sql index 1bb8ec24..6bc7fb73 100644 --- a/hwe/sql/reset.sql +++ b/hwe/sql/reset.sql @@ -32,9 +32,6 @@ DROP TABLE IF EXISTS ng_diplomacy; # 토너먼트 테이블 삭제 DROP TABLE IF EXISTS tournament; -# 거래 테이블 삭제 -DROP TABLE IF EXISTS auction; - # 통계 테이블 삭제 DROP TABLE IF EXISTS statistic; diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index 5e7746b1..5d300bbb 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -441,23 +441,6 @@ CREATE TABLE `tournament` ( INDEX `grp` (`grp`, `grp_no`) ) COLLATE = 'utf8mb4_general_ci' ENGINE = Aria; ############################## -## 거래 테이블 -############################## -create table `auction` ( - `no` int(6) not null auto_increment, - `type` int(6) default 0, - `no1` int(6) default 0, - `name1` varchar(64) default '-', - `amount` int(6) default 0, - `cost` int(6) default 0, - `value` int(6) default 0, - `topv` int(6) default 0, - `no2` int(6) default 0, - `name2` varchar(64) default '-', - `expire` datetime, - PRIMARY KEY (`no`) -) COLLATE = 'utf8mb4_general_ci' ENGINE = Aria; -############################## ## 통계 테이블 ############################## CREATE TABLE `statistic` (