From af9cbb47ef44c9c26f0b989ec4bddbb734804769 Mon Sep 17 00:00:00 2001 From: hide_d Date: Mon, 26 Nov 2018 04:05:34 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B2=AB=20=ED=99=94=EB=A9=B4=20=EB=9D=84?= =?UTF-8?q?=EC=9A=B0=EA=B8=B0=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func.old.php | 58 +++++++++---------- hwe/func.php | 47 +++------------ hwe/func_converter.php | 21 +++---- hwe/func_template.php | 7 ++- hwe/index.php | 54 ++++++++--------- hwe/join.php | 25 +++----- hwe/join_post.php | 4 +- hwe/sammo/ActionItem/che_Dummy.php | 34 ++++++++--- hwe/sammo/ActionItem/che_계략_삼략.php | 10 ++-- hwe/sammo/ActionItem/che_계략_육도.php | 10 ++-- hwe/sammo/ActionItem/che_계략_이추.php | 10 ++-- hwe/sammo/ActionItem/che_계략_향낭.php | 10 ++-- hwe/sammo/ActionItem/che_의술_청낭서.php | 10 ++-- hwe/sammo/ActionItem/che_의술_태평청령.php | 10 ++-- hwe/sammo/ActionItem/che_치료_도소연명.php | 10 ++-- hwe/sammo/ActionItem/che_치료_무후행군.php | 10 ++-- hwe/sammo/ActionItem/che_치료_오석산.php | 10 ++-- hwe/sammo/ActionItem/che_치료_정력견혈.php | 10 ++-- hwe/sammo/ActionItem/che_치료_칠엽청점.php | 10 ++-- hwe/sammo/ActionItem/che_치료_환약.php | 10 ++-- hwe/sammo/ActionPersonality/che_왕좌.php | 2 +- hwe/sammo/BaseItem.php | 26 +++++++-- hwe/sammo/Command/BaseCommand.php | 31 +++++++--- hwe/sammo/Command/General/che_NPC능동.php | 5 +- hwe/sammo/Command/General/che_강행.php | 5 +- hwe/sammo/Command/General/che_거병.php | 6 +- hwe/sammo/Command/General/che_건국.php | 5 +- hwe/sammo/Command/General/che_견문.php | 2 +- hwe/sammo/Command/General/che_군량매매.php | 5 +- hwe/sammo/Command/General/che_귀환.php | 2 +- hwe/sammo/Command/General/che_기술연구.php | 2 +- hwe/sammo/Command/General/che_농지개간.php | 2 +- hwe/sammo/Command/General/che_단련.php | 2 +- hwe/sammo/Command/General/che_등용.php | 7 ++- hwe/sammo/Command/General/che_랜덤임관.php | 6 +- .../{che_모반.php => che_모반시도.php} | 9 +-- hwe/sammo/Command/General/che_모병.php | 2 +- hwe/sammo/Command/General/che_물자조달.php | 2 +- hwe/sammo/Command/General/che_방랑.php | 2 +- hwe/sammo/Command/General/che_사기진작.php | 5 +- hwe/sammo/Command/General/che_상업투자.php | 6 +- hwe/sammo/Command/General/che_선동.php | 2 +- hwe/sammo/Command/General/che_선양.php | 5 +- hwe/sammo/Command/General/che_성벽보수.php | 2 +- hwe/sammo/Command/General/che_소집해제.php | 2 +- hwe/sammo/Command/General/che_수비강화.php | 2 +- hwe/sammo/Command/General/che_요양.php | 2 +- hwe/sammo/Command/General/che_이동.php | 5 +- hwe/sammo/Command/General/che_인재탐색.php | 4 +- hwe/sammo/Command/General/che_임관.php | 5 +- hwe/sammo/Command/General/che_장비매매.php | 5 +- hwe/sammo/Command/General/che_전투태세.php | 2 +- hwe/sammo/Command/General/che_정착장려.php | 4 +- hwe/sammo/Command/General/che_주민선정.php | 4 +- hwe/sammo/Command/General/che_증여.php | 5 +- hwe/sammo/Command/General/che_집합.php | 3 +- hwe/sammo/Command/General/che_징병.php | 7 ++- hwe/sammo/Command/General/che_첩보.php | 5 +- hwe/sammo/Command/General/che_출병.php | 5 +- hwe/sammo/Command/General/che_치안강화.php | 2 +- hwe/sammo/Command/General/che_탈취.php | 2 +- hwe/sammo/Command/General/che_파괴.php | 2 +- hwe/sammo/Command/General/che_하야.php | 2 +- hwe/sammo/Command/General/che_해산.php | 8 +-- hwe/sammo/Command/General/che_헌납.php | 5 +- hwe/sammo/Command/General/che_화계.php | 5 +- hwe/sammo/Command/General/che_훈련.php | 2 +- ...ntraintHelper.php => ConstraintHelper.php} | 0 hwe/sammo/GameConstBase.php | 5 ++ hwe/sammo/General.php | 4 +- hwe/sammo/Scenario/NPC.php | 4 +- hwe/sql/schema.sql | 2 +- src/sammo/Util.php | 23 +++++++- 73 files changed, 350 insertions(+), 289 deletions(-) rename hwe/sammo/Command/General/{che_모반.php => che_모반시도.php} (92%) rename hwe/sammo/Constraint/{ContraintHelper.php => ConstraintHelper.php} (100%) diff --git a/hwe/func.old.php b/hwe/func.old.php index 277fc986..643cf6e4 100644 --- a/hwe/func.old.php +++ b/hwe/func.old.php @@ -137,17 +137,11 @@ function getRandGenName() { -function cityInfo() { +function cityInfo(General $generalObj) { $db = DB::db(); - $connect=$db->get(); - $userID = Session::getUserID(); - - $query = "select no,city from general where owner='{$userID}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $me = MYDB_fetch_array($result); // 도시 정보 - $city = getCity($me['city']); + $city = $generalObj->getRawCity(); $nation = getNationStaticInfo($city['nation']); @@ -181,29 +175,35 @@ function cityInfo() { echo "지배 국가 【 {$nation['name']} 】"; } - if($city['gen1'] > 0) { - $query = "select name from general where no='{$city['gen1']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $gen1 = MYDB_fetch_array($result); - } else { - $gen1 = ['name'=>'-']; + $officers = []; + $reqOfficersID = []; + + if ($city['gen1'] > 0) { + $reqOfficersID[] = $city['gen1']; + } + else{ + $officers[1] = '-'; } - if($city['gen2'] > 0) { - $query = "select name from general where no='{$city['gen2']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $gen2 = MYDB_fetch_array($result); - } else { - $gen2 = ['name'=>'-']; + if ($city['gen2'] > 0) { + $reqOfficersID[] = $city['gen2']; + } + else{ + $officers[2] = '-'; } - if($city['gen3'] > 0) { - $query = "select name from general where no='{$city['gen3']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $gen3 = MYDB_fetch_array($result); - } else { - $gen3 = ['name'=>'-']; + if ($city['gen3'] > 0) { + $reqOfficersID[] = $city['gen3']; } + else{ + $officers[3] = '-'; + } + + foreach($db->queryAllLists('SELECT level, name FROM general WHERE no IN %li', $reqOfficersID) as [$level, $name]){ + $officers[$level] = $name; + } + + echo " @@ -214,7 +214,7 @@ function cityInfo() { 민심 ".bar($trust)." 태수 - {$gen1['name']} + {$officers[1]} {$city['pop']}/{$city['pop2']} @@ -228,7 +228,7 @@ function cityInfo() { 치안 ".bar($secu)." 군사 - {$gen2['name']} + {$officers[2]} {$city['agri']}/{$city['agri2']} @@ -243,7 +243,7 @@ function cityInfo() { 시세 ".bar($trade)." 시중 - {$gen3['name']} + {$officers[3]} {$city['def']}/{$city['def2']} diff --git a/hwe/func.php b/hwe/func.php index 459b4ebf..3aa49cc5 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -427,20 +427,13 @@ function commandGroup($typename, $type=0) { } } -function printCommandTable() { +function printCommandTable(General $generalObj) { $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); - $connect=$db->get(); $userID = Session::getUserID(); - $gameStor->cacheAll(); + $gameStor->turnOnCache(); $env = $gameStor->getAll(); - $admin = $gameStor->getAll(); - - $session = Session::getInstance(); - $generalID = $session->generalID; - - $generalObj = General::createGeneralObjFromDB($generalID); ?> ;color:white;width:110px;font-size:13px; value='실 행' onclick='refreshing(this, 3,form2)'>;color:white;width:110px;font-size:13px; value='갱 신' onclick='refreshing(this, 0,0)'>;color:white;width:160px;font-size:13px; value='로비로' onclick=location.replace('../')>
@@ -275,7 +277,7 @@ else if($session->userGrade == 4){ - +
@@ -326,7 +328,7 @@ if ($me['newmsg'] == 1) { MessageBox("개인 서신이 도착했습니다!"); } if ($me['newvote'] == 1) { - $develcost = $admin['develcost']*5; + $develcost = $gameStor->develcost*5; MessageBox("설문조사에 참여하시면 금{$develcost}과 유니크템을 드립니다! (우측 상단 설문조사 메뉴)"); } ?> diff --git a/hwe/join.php b/hwe/join.php index 68e2c861..be3f1bf8 100644 --- a/hwe/join.php +++ b/hwe/join.php @@ -42,9 +42,9 @@ var defaultStatMax = ; var charInfoText = ; @@ -120,20 +120,11 @@ if ($admin['show_img_level'] >= 1 && $member['grade'] >= 1 && $member['picture'] 성격 diff --git a/hwe/join_post.php b/hwe/join_post.php index 3ddb9464..4287ff0a 100644 --- a/hwe/join_post.php +++ b/hwe/join_post.php @@ -204,8 +204,8 @@ if ($admin['show_img_level'] >= 1 && $member['grade'] >= 1 && $member['picture'] } //성격 랜덤시 -if ($character == 11) { - $character = rand()%10; +if (!in_array($character, GameConst::$availablePersonality)){ + $character = Util::choiceRandom(GameConst::$availablePersonality); } //상성 랜덤 $affinity = rand()%150 + 1; diff --git a/hwe/sammo/ActionItem/che_Dummy.php b/hwe/sammo/ActionItem/che_Dummy.php index ba2c671b..c07dd405 100644 --- a/hwe/sammo/ActionItem/che_Dummy.php +++ b/hwe/sammo/ActionItem/che_Dummy.php @@ -10,17 +10,33 @@ use function sammo\getItemCost2; //XXX:임시용! class che_Dummy extends \sammo\BaseItem{ - static $id; - static $name; - static $info; - static $cost; - static $consumable = false; + protected $_id; + protected $_name; + protected $_info; + protected $_cost; + protected $_consumable = false; + + function getID(){ + return $this->_id; + } + function getName(){ + return $this->_name; + } + function getInfo(){ + return $this->_info; + } + function getCost(){ + return $this->_cost; + } + function isConsumable(){ + return $this->_consumable; + } public function __construct(int $itemCode) { - $this->id = $itemCode = true; - [$this->name, $this->info] = getItemInfo($itemCode); - $this->cost = getItemCost2($itemCode); - $this->consumable = isConsumable($itemCode); + $this->_id = $itemCode = true; + [$this->_name, $this->_info] = getItemInfo($itemCode); + $this->_cost = getItemCost2($itemCode); + $this->_consumable = isConsumable($itemCode); } } \ No newline at end of file diff --git a/hwe/sammo/ActionItem/che_계략_삼략.php b/hwe/sammo/ActionItem/che_계략_삼략.php index 2cefe851..8cfa8dc5 100644 --- a/hwe/sammo/ActionItem/che_계략_삼략.php +++ b/hwe/sammo/ActionItem/che_계략_삼략.php @@ -5,11 +5,11 @@ use \sammo\General; class che_계략_삼략 extends \sammo\BaseItem{ - static $id = 22; - static $name = '삼략(계략)'; - static $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p'; - static $cost = 200; - static $consumable = false; + protected static $id = 22; + protected static $name = '삼략(계략)'; + protected static $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p'; + protected static $cost = 200; + protected static $consumable = false; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '계략'){ diff --git a/hwe/sammo/ActionItem/che_계략_육도.php b/hwe/sammo/ActionItem/che_계략_육도.php index f1951901..3b68334c 100644 --- a/hwe/sammo/ActionItem/che_계략_육도.php +++ b/hwe/sammo/ActionItem/che_계략_육도.php @@ -5,11 +5,11 @@ use \sammo\General; class che_계략_육도 extends \sammo\BaseItem{ - static $id = 21; - static $name = '육도(계략)'; - static $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p'; - static $cost = 200; - static $consumable = false; + protected static $id = 21; + protected static $name = '육도(계략)'; + protected static $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p'; + protected static $cost = 200; + protected static $consumable = false; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '계략'){ diff --git a/hwe/sammo/ActionItem/che_계략_이추.php b/hwe/sammo/ActionItem/che_계략_이추.php index 85f78f86..0a4a7ea0 100644 --- a/hwe/sammo/ActionItem/che_계략_이추.php +++ b/hwe/sammo/ActionItem/che_계략_이추.php @@ -5,11 +5,11 @@ use \sammo\General; class che_계략_이추 extends \sammo\BaseItem{ - static $id = 5; - static $name = '이추(계략)'; - static $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +10%p'; - static $cost = 1000; - static $consumable = true; + protected static $id = 5; + protected static $name = '이추(계략)'; + protected static $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +10%p'; + protected static $cost = 1000; + protected static $consumable = true; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '계략'){ diff --git a/hwe/sammo/ActionItem/che_계략_향낭.php b/hwe/sammo/ActionItem/che_계략_향낭.php index e4a7833a..f9d4620e 100644 --- a/hwe/sammo/ActionItem/che_계략_향낭.php +++ b/hwe/sammo/ActionItem/che_계략_향낭.php @@ -5,11 +5,11 @@ use \sammo\General; class che_계략_향낭 extends \sammo\BaseItem{ - static $id = 5; - static $name = '항냥(계략)'; - static $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p'; - static $cost = 3000; - static $consumable = true; + protected static $id = 5; + protected static $name = '항냥(계략)'; + protected static $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p'; + protected static $cost = 3000; + protected static $consumable = true; public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ if($turnType == '계략'){ diff --git a/hwe/sammo/ActionItem/che_의술_청낭서.php b/hwe/sammo/ActionItem/che_의술_청낭서.php index 66683d35..31d97d11 100644 --- a/hwe/sammo/ActionItem/che_의술_청낭서.php +++ b/hwe/sammo/ActionItem/che_의술_청낭서.php @@ -7,11 +7,11 @@ use \sammo\GeneralTriggerCaller; class che_의술_청낭서 extends \sammo\BaseItem{ - static $id = 23; - static $name = '청낭서(의술)'; - static $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복
[전투] 페이즈마다 20% 확률로 치료 발동(아군 피해 1/3 감소)'; - static $cost = 200; - static $consumable = false; + protected static $id = 23; + protected static $name = '청낭서(의술)'; + protected static $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복
[전투] 페이즈마다 20% 확률로 치료 발동(아군 피해 1/3 감소)'; + protected static $cost = 200; + protected static $consumable = false; public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ return new GeneralTriggerCaller([ diff --git a/hwe/sammo/ActionItem/che_의술_태평청령.php b/hwe/sammo/ActionItem/che_의술_태평청령.php index 5827946a..80584636 100644 --- a/hwe/sammo/ActionItem/che_의술_태평청령.php +++ b/hwe/sammo/ActionItem/che_의술_태평청령.php @@ -7,11 +7,11 @@ use \sammo\GeneralTriggerCaller; class che_의술_태평청령 extends \sammo\BaseItem{ - static $id = 24; - static $name = '태평청령(의술)'; - static $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복
[전투] 페이즈마다 20% 확률로 치료 발동(아군 피해 1/3 감소)'; - static $cost = 200; - static $consumable = false; + protected static $id = 24; + protected static $name = '태평청령(의술)'; + protected static $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복
[전투] 페이즈마다 20% 확률로 치료 발동(아군 피해 1/3 감소)'; + protected static $cost = 200; + protected static $consumable = false; public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ return new GeneralTriggerCaller([ diff --git a/hwe/sammo/ActionItem/che_치료_도소연명.php b/hwe/sammo/ActionItem/che_치료_도소연명.php index a70e01de..0bcc81b8 100644 --- a/hwe/sammo/ActionItem/che_치료_도소연명.php +++ b/hwe/sammo/ActionItem/che_치료_도소연명.php @@ -7,11 +7,11 @@ use \sammo\GeneralTriggerCaller; class che_치료_도소연명 extends \sammo\BaseItem{ - static $id = 9; - static $name = '도소연명(치료)'; - static $info = '[군사] 턴 실행 전 부상 회복.'; - static $cost = 200; - static $consumable = false; + protected static $id = 9; + protected static $name = '도소연명(치료)'; + protected static $info = '[군사] 턴 실행 전 부상 회복.'; + protected static $cost = 200; + protected static $consumable = false; public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ return new GeneralTriggerCaller([ diff --git a/hwe/sammo/ActionItem/che_치료_무후행군.php b/hwe/sammo/ActionItem/che_치료_무후행군.php index 5fc27641..db8ec030 100644 --- a/hwe/sammo/ActionItem/che_치료_무후행군.php +++ b/hwe/sammo/ActionItem/che_치료_무후행군.php @@ -7,11 +7,11 @@ use \sammo\GeneralTriggerCaller; class che_치료_무후행군 extends \sammo\BaseItem{ - static $id = 8; - static $name = '무후행군(치료)'; - static $info = '[군사] 턴 실행 전 부상 회복.'; - static $cost = 200; - static $consumable = false; + protected static $id = 8; + protected static $name = '무후행군(치료)'; + protected static $info = '[군사] 턴 실행 전 부상 회복.'; + protected static $cost = 200; + protected static $consumable = false; public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ return new GeneralTriggerCaller([ diff --git a/hwe/sammo/ActionItem/che_치료_오석산.php b/hwe/sammo/ActionItem/che_치료_오석산.php index 4140cd55..8ac45760 100644 --- a/hwe/sammo/ActionItem/che_치료_오석산.php +++ b/hwe/sammo/ActionItem/che_치료_오석산.php @@ -7,11 +7,11 @@ use \sammo\GeneralTriggerCaller; class che_치료_오석산 extends \sammo\BaseItem{ - static $id = 7; - static $name = '오석산(치료)'; - static $info = '[군사] 턴 실행 전 부상 회복.'; - static $cost = 200; - static $consumable = false; + protected static $id = 7; + protected static $name = '오석산(치료)'; + protected static $info = '[군사] 턴 실행 전 부상 회복.'; + protected static $cost = 200; + protected static $consumable = false; public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ return new GeneralTriggerCaller([ diff --git a/hwe/sammo/ActionItem/che_치료_정력견혈.php b/hwe/sammo/ActionItem/che_치료_정력견혈.php index 26e257ba..ac0b097c 100644 --- a/hwe/sammo/ActionItem/che_치료_정력견혈.php +++ b/hwe/sammo/ActionItem/che_치료_정력견혈.php @@ -7,11 +7,11 @@ use \sammo\GeneralTriggerCaller; class che_치료_정력견혈 extends \sammo\BaseItem{ - static $id = 11; - static $name = '정력견혈(치료)'; - static $info = '[군사] 턴 실행 전 부상 회복.'; - static $cost = 200; - static $consumable = false; + protected static $id = 11; + protected static $name = '정력견혈(치료)'; + protected static $info = '[군사] 턴 실행 전 부상 회복.'; + protected static $cost = 200; + protected static $consumable = false; public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ return new GeneralTriggerCaller([ diff --git a/hwe/sammo/ActionItem/che_치료_칠엽청점.php b/hwe/sammo/ActionItem/che_치료_칠엽청점.php index 01029ff6..6d597661 100644 --- a/hwe/sammo/ActionItem/che_치료_칠엽청점.php +++ b/hwe/sammo/ActionItem/che_치료_칠엽청점.php @@ -7,11 +7,11 @@ use \sammo\GeneralTriggerCaller; class che_치료_칠엽청점 extends \sammo\BaseItem{ - static $id = 10; - static $name = '칠엽청점(치료)'; - static $info = '[군사] 턴 실행 전 부상 회복.'; - static $cost = 200; - static $consumable = false; + protected static $id = 10; + protected static $name = '칠엽청점(치료)'; + protected static $info = '[군사] 턴 실행 전 부상 회복.'; + protected static $cost = 200; + protected static $consumable = false; public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ return new GeneralTriggerCaller([ diff --git a/hwe/sammo/ActionItem/che_치료_환약.php b/hwe/sammo/ActionItem/che_치료_환약.php index 9b6c59ac..e38c4fa5 100644 --- a/hwe/sammo/ActionItem/che_치료_환약.php +++ b/hwe/sammo/ActionItem/che_치료_환약.php @@ -7,11 +7,11 @@ use \sammo\GeneralTriggerCaller; class che_치료_환약 extends \sammo\BaseItem{ - static $id = 1; - static $name = '환약(치료)'; - static $info = '[군사] 턴 실행 전 부상 회복. 1회용'; - static $cost = 100; - static $consumable = true; + protected static $id = 1; + protected static $name = '환약(치료)'; + protected static $info = '[군사] 턴 실행 전 부상 회복. 1회용'; + protected static $cost = 100; + protected static $consumable = true; public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ return new GeneralTriggerCaller([ diff --git a/hwe/sammo/ActionPersonality/che_왕좌.php b/hwe/sammo/ActionPersonality/che_왕좌.php index f4c93664..eb8a2289 100644 --- a/hwe/sammo/ActionPersonality/che_왕좌.php +++ b/hwe/sammo/ActionPersonality/che_왕좌.php @@ -3,7 +3,7 @@ namespace sammo\ActionPersonality; use \sammo\iAction; use \sammo\General; -class che_대의 implements iAction{ +class che_왕좌 implements iAction{ use \sammo\DefaultAction; static $id = 0; diff --git a/hwe/sammo/BaseItem.php b/hwe/sammo/BaseItem.php index f16072d8..0909c4c3 100644 --- a/hwe/sammo/BaseItem.php +++ b/hwe/sammo/BaseItem.php @@ -7,11 +7,27 @@ use \sammo\General; class BaseItem implements iAction{ use \sammo\DefaultAction; - static $id = 0; - static $name = '-'; - static $info = ''; - static $cost = null; - static $consumable = false; + protected static $id = 0; + protected static $name = '-'; + protected static $info = ''; + protected static $cost = null; + protected static $consumable = false; + + function getID(){ + return $this->id; + } + function getName(){ + return $this->name; + } + function getInfo(){ + return $this->info; + } + function getCost(){ + return $this->cost; + } + function isConsumable(){ + return $this->consumable; + } function isValidTurnItem(string $actionType, string $command):bool{ return false; diff --git a/hwe/sammo/Command/BaseCommand.php b/hwe/sammo/Command/BaseCommand.php index 5a97d118..6385fe5b 100644 --- a/hwe/sammo/Command/BaseCommand.php +++ b/hwe/sammo/Command/BaseCommand.php @@ -3,7 +3,7 @@ namespace sammo\Command; use \sammo\{ Util, JosaUtil, DB, - General, + General, GameConst, ActionLogger }; @@ -47,7 +47,7 @@ abstract class BaseCommand{ protected $alternative = null; - static private $isInitStatic = false; + static protected $isInitStatic = false; protected static function initStatic(){ } @@ -62,7 +62,7 @@ abstract class BaseCommand{ $this->logger = $generalObj->getLogger(); $this->env = $env; $this->arg = $arg; - if ($this->argTest()) { + if (!$this->argTest()) { return; } $this->isArgValid = true; @@ -102,7 +102,8 @@ abstract class BaseCommand{ if($hasArgs){ return; } - $this->city = $db->queryFirstRow('SELECT %lb FROM city WHERE city=%i', $args, $this->generalObj->getVar('city')); + + $this->city = $db->queryFirstRow('SELECT %l FROM city WHERE city=%i', Util::formatListOfBackticks($args), $this->generalObj->getVar('city')); if($this->generalObj->getRawCity() === null){ $this->generalObj->setRawCity($this->city); } @@ -115,6 +116,12 @@ abstract class BaseCommand{ return; } + $nationID = $this->generalObj->getNationID(); + if($nationID == 0){ + $this->nation = $this->generalObj->getStaticNation(); + return; + } + $defaultArgs = ['nation', 'name', 'color', 'type', 'level', 'capital']; $args = array_unique(array_merge($defaultArgs, $args)); if($args == $defaultArgs){ @@ -135,8 +142,10 @@ abstract class BaseCommand{ 'gennum'=>1 ]; + + $db = DB::db(); - $destNation = $db->queryFirstRow('SELECT %lb FROM nation WHERE nation=%i', $args, $nationNo); + $destNation = $db->queryFirstRow('SELECT %l FROM nation WHERE nation=%i', Util::formatListOfBackticks($args), $nationID); if($destNation === null){ $destNation = []; foreach($args as $arg){ @@ -163,13 +172,13 @@ abstract class BaseCommand{ $this->destCity = $db->queryFirstRow('SELECT * FROM city WHERE city=%i', $cityNo); return; } - $this->destCity = $db->queryFirstRow('SELECT %lb FROM city WHERE city=%i', $args, $cityNo); + $this->destCity = $db->queryFirstRow('SELECT %l FROM city WHERE city=%i', Util::formatListOfBackticks($args), $cityNo); } - protected function setDestNation(int $nationNo, ?array $args = null){ + protected function setDestNation(int $nationID, ?array $args = null){ $this->resetTestCache(); if($args === null || $args === []){ - $this->destNation = getNationStaticInfo($nationNo); + $this->destNation = getNationStaticInfo($nationID); return; } @@ -190,7 +199,7 @@ abstract class BaseCommand{ ]; $db = DB::db(); - $destNation = $db->queryFirstRow('SELECT %lb FROM nation WHERE nation=%i', $args, $nationNo); + $destNation = $db->queryFirstRow('SELECT %l FROM nation WHERE nation=%i', Util::formatListOfBackticks($args), $nationID); if($destNation === null){ $destNation = []; foreach($args as $arg){ @@ -287,7 +296,11 @@ abstract class BaseCommand{ } public function isReservable():bool{ + if($this->reservable !== null){ + return $this->reservable; + } + return $this->testReservable() === null; } public function isArgValid():bool{ diff --git a/hwe/sammo/Command/General/che_NPC능동.php b/hwe/sammo/Command/General/che_NPC능동.php index bf26b1d7..831f18c2 100644 --- a/hwe/sammo/Command/General/che_NPC능동.php +++ b/hwe/sammo/Command/General/che_NPC능동.php @@ -1,5 +1,5 @@ arg === null){ + return false; + } if(!key_exists('optionText', $this->arg)){ return false; } diff --git a/hwe/sammo/Command/General/che_강행.php b/hwe/sammo/Command/General/che_강행.php index 11155644..209f7c24 100644 --- a/hwe/sammo/Command/General/che_강행.php +++ b/hwe/sammo/Command/General/che_강행.php @@ -1,5 +1,5 @@ arg === null){ + return false; + } if(!key_exists('destCityID', $this->arg)){ return false; } diff --git a/hwe/sammo/Command/General/che_거병.php b/hwe/sammo/Command/General/che_거병.php index c408415b..7c2df244 100644 --- a/hwe/sammo/Command/General/che_거병.php +++ b/hwe/sammo/Command/General/che_거병.php @@ -1,5 +1,5 @@ setCity(); $this->setNation(); - if(!key_exists($colorType, GetNationColors())){ - return false; - } - $relYear = $env['year'] - $env['startyear']; $this->runnableConstraints=[ diff --git a/hwe/sammo/Command/General/che_건국.php b/hwe/sammo/Command/General/che_건국.php index aa8944eb..60bbbb4a 100644 --- a/hwe/sammo/Command/General/che_건국.php +++ b/hwe/sammo/Command/General/che_건국.php @@ -1,5 +1,5 @@ arg === null){ + return false; + } $nationName = $this->arg['nationName']??null; $nationType = $this->arg['nationType']??null; $colorType = $this->arg['colorType']??null; diff --git a/hwe/sammo/Command/General/che_견문.php b/hwe/sammo/Command/General/che_견문.php index 13d183ce..a52b38ea 100644 --- a/hwe/sammo/Command/General/che_견문.php +++ b/hwe/sammo/Command/General/che_견문.php @@ -1,5 +1,5 @@ arg === null){ + return false; + } $buyRice = $this->arg['buyRice']??null; if(!is_bool($buyRice)){ return false; diff --git a/hwe/sammo/Command/General/che_귀환.php b/hwe/sammo/Command/General/che_귀환.php index 896ea20e..7ab96634 100644 --- a/hwe/sammo/Command/General/che_귀환.php +++ b/hwe/sammo/Command/General/che_귀환.php @@ -1,5 +1,5 @@ arg === null){ + return false; + } //NOTE: 사망 직전에 '등용' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음 if(!key_exists('destGeneralID', $this->arg)){ return false; @@ -74,7 +77,7 @@ class che_등용 extends Command\GeneralCommand{ ]; if($this->destGeneralObj->getVar('level') == 12){ - $this->runnableConstraints[] = ['AlwaysFail', '군주에게는 등용장을 보낼 수 없습니다.']; + $this->runnableConstraints[] = ConstraintHelper::AlwaysFail('군주에게는 등용장을 보낼 수 없습니다.'); } } diff --git a/hwe/sammo/Command/General/che_랜덤임관.php b/hwe/sammo/Command/General/che_랜덤임관.php index 95e39679..4a2bd560 100644 --- a/hwe/sammo/Command/General/che_랜덤임관.php +++ b/hwe/sammo/Command/General/che_랜덤임관.php @@ -1,5 +1,5 @@ arg === null){ + return false; + } $destNationIDList = $this->arg['destNationIDList']??null; //null은 에러, []는 정상 diff --git a/hwe/sammo/Command/General/che_모반.php b/hwe/sammo/Command/General/che_모반시도.php similarity index 92% rename from hwe/sammo/Command/General/che_모반.php rename to hwe/sammo/Command/General/che_모반시도.php index f6e9f793..96175262 100644 --- a/hwe/sammo/Command/General/che_모반.php +++ b/hwe/sammo/Command/General/che_모반시도.php @@ -1,5 +1,5 @@ arg = null; @@ -34,9 +34,6 @@ class che_모반 extends Command\GeneralCommand{ $general = $this->generalObj; $this->setNation(); - - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'nation'], 1); - $this->setDestGeneral($destGeneral); $this->runnableConstraints=[ ConstraintHelper::NotBeNeutral(), diff --git a/hwe/sammo/Command/General/che_모병.php b/hwe/sammo/Command/General/che_모병.php index dc9a9241..ea715b26 100644 --- a/hwe/sammo/Command/General/che_모병.php +++ b/hwe/sammo/Command/General/che_모병.php @@ -1,5 +1,5 @@ getVar('crew')/100), 0]; + $general = $this->generalObj; + return [Util::round($general->getVar('crew')/100), 0]; } public function getPreReqTurn():int{ diff --git a/hwe/sammo/Command/General/che_상업투자.php b/hwe/sammo/Command/General/che_상업투자.php index d3c12f93..51993447 100644 --- a/hwe/sammo/Command/General/che_상업투자.php +++ b/hwe/sammo/Command/General/che_상업투자.php @@ -1,5 +1,5 @@ '무력경험', 'intel'=>'지력경험', ]; - $statType = $statType[static::$statKey]; + $statType = $statTypeBase[static::$statKey]; [$reqGold, $reqRice] = $this->getCost(); $title = "{$name}({$statType}"; @@ -79,7 +79,7 @@ class che_상업투자 extends Command\GeneralCommand{ public function getCost():array{ $develCost = $this->env['develcost']; - $reqGold = $general->onCalcDomestic(static::$actionKey, 'cost', $develCost); + $reqGold = $this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost); $reqRice = 0; return [$reqGold, $reqRice]; diff --git a/hwe/sammo/Command/General/che_선동.php b/hwe/sammo/Command/General/che_선동.php index cdbe0c69..a154355e 100644 --- a/hwe/sammo/Command/General/che_선동.php +++ b/hwe/sammo/Command/General/che_선동.php @@ -1,5 +1,5 @@ arg === null){ + return false; + } //NOTE: 사망 직전에 '선양' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음 if(!key_exists('destGeneralID', $this->arg)){ return false; diff --git a/hwe/sammo/Command/General/che_성벽보수.php b/hwe/sammo/Command/General/che_성벽보수.php index 74e6ef10..2fb0dda5 100644 --- a/hwe/sammo/Command/General/che_성벽보수.php +++ b/hwe/sammo/Command/General/che_성벽보수.php @@ -1,5 +1,5 @@ arg === null){ + return false; + } if(!key_exists('destCityID', $this->arg)){ return false; } diff --git a/hwe/sammo/Command/General/che_인재탐색.php b/hwe/sammo/Command/General/che_인재탐색.php index e8a6e6d9..3d219a5c 100644 --- a/hwe/sammo/Command/General/che_인재탐색.php +++ b/hwe/sammo/Command/General/che_인재탐색.php @@ -1,5 +1,5 @@ nation['gennum'] >= GameConst::$initialNationGenLimit){ + if($this->nation['nation'] != 0 && $relYear < 3 && $this->nation['gennum'] >= GameConst::$initialNationGenLimit){ $nationName = $this->nation['name']; $josaUn = JosaUtil::pick($nationName, '은'); $this->runnableConstraints[] = ConstraintHelper::AlwaysFail("현재 {$nationName}{$josaUn} 탐색이 제한되고 있습니다."); diff --git a/hwe/sammo/Command/General/che_임관.php b/hwe/sammo/Command/General/che_임관.php index 1d27d72e..6496ec26 100644 --- a/hwe/sammo/Command/General/che_임관.php +++ b/hwe/sammo/Command/General/che_임관.php @@ -1,5 +1,5 @@ arg === null){ + return false; + } $destNationID = $this->arg['destNationID']??null; $destGeneralID = $this->arg['destGeneralID']??null; diff --git a/hwe/sammo/Command/General/che_장비매매.php b/hwe/sammo/Command/General/che_장비매매.php index 8898364f..40372d47 100644 --- a/hwe/sammo/Command/General/che_장비매매.php +++ b/hwe/sammo/Command/General/che_장비매매.php @@ -1,5 +1,5 @@ arg === null){ + return false; + } $itemType = $this->arg['itemType']??null; if(!in_array($itemType, array_keys(static::$itemMap))){ return false; diff --git a/hwe/sammo/Command/General/che_전투태세.php b/hwe/sammo/Command/General/che_전투태세.php index 8a41e12f..8c8d769c 100644 --- a/hwe/sammo/Command/General/che_전투태세.php +++ b/hwe/sammo/Command/General/che_전투태세.php @@ -1,5 +1,5 @@ env['develcost'] * 2; $reqGold = 0; - $reqRice = $general->onCalcDomestic(static::$actionKey, 'cost', $develCost); + $reqRice = $this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost); return [$reqGold, $reqRice]; } diff --git a/hwe/sammo/Command/General/che_주민선정.php b/hwe/sammo/Command/General/che_주민선정.php index e1bf8f35..64409a74 100644 --- a/hwe/sammo/Command/General/che_주민선정.php +++ b/hwe/sammo/Command/General/che_주민선정.php @@ -1,5 +1,5 @@ env['develcost'] * 2; $reqGold = 0; - $reqRice = $general->onCalcDomestic(static::$actionKey, 'cost', $develCost); + $reqRice = $this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost); return [$reqGold, $reqRice]; } diff --git a/hwe/sammo/Command/General/che_증여.php b/hwe/sammo/Command/General/che_증여.php index badb2345..7c4b7d47 100644 --- a/hwe/sammo/Command/General/che_증여.php +++ b/hwe/sammo/Command/General/che_증여.php @@ -1,5 +1,5 @@ arg === null){ + return false; + } //NOTE: 사망 직전에 '증여' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음 if(!key_exists('isGold', $this->arg)){ return false; diff --git a/hwe/sammo/Command/General/che_집합.php b/hwe/sammo/Command/General/che_집합.php index 0470bd19..bf105877 100644 --- a/hwe/sammo/Command/General/che_집합.php +++ b/hwe/sammo/Command/General/che_집합.php @@ -1,5 +1,5 @@ setCity(); $this->setNation(); - $this->setDestCity($this->arg['destCityID'], []); [$reqGold, $reqRice] = $this->getCost(); diff --git a/hwe/sammo/Command/General/che_징병.php b/hwe/sammo/Command/General/che_징병.php index ac296c35..f5e993aa 100644 --- a/hwe/sammo/Command/General/che_징병.php +++ b/hwe/sammo/Command/General/che_징병.php @@ -1,5 +1,5 @@ arg === null){ + return false; + } if(!key_exists('crewType', $this->arg)){ return false; } @@ -111,7 +114,7 @@ class che_징병 extends Command\GeneralCommand{ return [0, 0]; } $reqGold = $this->reqCrewType->costWithTech($this->nation['tech'], $this->reqCrew); - $reqGold = $general->onCalcDomestic('징병', 'cost', $reqGold, ['armType'=>$this->reqCrewType->armType]); + $reqGold = $this->generalObj->onCalcDomestic('징병', 'cost', $reqGold, ['armType'=>$this->reqCrewType->armType]); $reqGold *= static::$costOffset; $reqRice = $this->reqCrew / 100; return [$reqGold, $reqRice]; diff --git a/hwe/sammo/Command/General/che_첩보.php b/hwe/sammo/Command/General/che_첩보.php index 217b1489..b2407aac 100644 --- a/hwe/sammo/Command/General/che_첩보.php +++ b/hwe/sammo/Command/General/che_첩보.php @@ -1,5 +1,5 @@ arg === null){ + return false; + } if(!key_exists('destCityID', $this->arg)){ return false; } diff --git a/hwe/sammo/Command/General/che_출병.php b/hwe/sammo/Command/General/che_출병.php index 90c0a05d..4e8ed457 100644 --- a/hwe/sammo/Command/General/che_출병.php +++ b/hwe/sammo/Command/General/che_출병.php @@ -1,5 +1,5 @@ arg === null){ + return false; + } if(!key_exists('destCityID', $this->arg)){ return false; } diff --git a/hwe/sammo/Command/General/che_치안강화.php b/hwe/sammo/Command/General/che_치안강화.php index a5de71ad..fd5d6bce 100644 --- a/hwe/sammo/Command/General/che_치안강화.php +++ b/hwe/sammo/Command/General/che_치안강화.php @@ -1,5 +1,5 @@ setCity(); $this->setNation(['gennum']); - if(!key_exists($colorType, GetNationColors())){ - return false; - } - - $relYear = $env['year'] - $env['startyear']; - $this->runnableConstraints=[ ConstraintHelper::BeLord(), ConstraintHelper::WanderingNation(), diff --git a/hwe/sammo/Command/General/che_헌납.php b/hwe/sammo/Command/General/che_헌납.php index 923a94b0..fd324e9f 100644 --- a/hwe/sammo/Command/General/che_헌납.php +++ b/hwe/sammo/Command/General/che_헌납.php @@ -1,5 +1,5 @@ arg === null){ + return false; + } if(!key_exists('isGold', $this->arg)){ return false; } diff --git a/hwe/sammo/Command/General/che_화계.php b/hwe/sammo/Command/General/che_화계.php index 566e1954..f0aed35e 100644 --- a/hwe/sammo/Command/General/che_화계.php +++ b/hwe/sammo/Command/General/che_화계.php @@ -1,5 +1,5 @@ arg === null){ + return false; + } if(!key_exists('destCityID', $this->arg)){ return false; } diff --git a/hwe/sammo/Command/General/che_훈련.php b/hwe/sammo/Command/General/che_훈련.php index 4be8d035..e5c9605a 100644 --- a/hwe/sammo/Command/General/che_훈련.php +++ b/hwe/sammo/Command/General/che_훈련.php @@ -1,5 +1,5 @@ queryFirstRow('SELECT $lb FROM general WHERE no = %i', $generalID); + $rawGeneral = $db->queryFirstRow('SELECT %l FROM general WHERE no = %i', Util::formatListOfBackticks($column), $generalID); if(!$rawGeneral){ return new DummyGeneral($constructMode > 0); } diff --git a/hwe/sammo/Scenario/NPC.php b/hwe/sammo/Scenario/NPC.php index 0fb9b75f..5239f8a1 100644 --- a/hwe/sammo/Scenario/NPC.php +++ b/hwe/sammo/Scenario/NPC.php @@ -203,10 +203,10 @@ class NPC{ } if($this->ego == null || $isFictionMode){ - $ego = mt_rand(0, 9);//TODO: 나중에 성격을 따로 분리할 경우 클래스를 참조. + $ego = Util::choiceRandom(GameConst::$availablePersonality); } else{ - $ego = \sammo\CharCall($this->ego); + $ego = Util::getClassName(\sammo\getPersonalityClass($this->ego)); } $affinity = $this->affinity; diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index 25f60482..8a505bea 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -71,7 +71,7 @@ CREATE TABLE `general` ( `history` MEDIUMTEXT NULL DEFAULT '', `belong` INT(2) NULL DEFAULT '1', `betray` INT(2) NULL DEFAULT '0', - `personal` INT(2) NULL DEFAULT '0', + `personal` VARCHAR(20) NOT NULL DEFAULT 'None', `special` VARCHAR(20) NOT NULL DEFAULT 'None', `specage` INT(2) NULL DEFAULT '0', `special2` VARCHAR(20) NOT NULL DEFAULT 'None', diff --git a/src/sammo/Util.php b/src/sammo/Util.php index 96f83fb5..b8735d6d 100644 --- a/src/sammo/Util.php +++ b/src/sammo/Util.php @@ -579,7 +579,7 @@ class Util extends \utilphp\util } public static function getClassNameFromObj($object){ - $reflect = new ReflectionClass($object); + $reflect = new \ReflectionClass($object); return $reflect->getShortName(); } @@ -603,4 +603,25 @@ class Util extends \utilphp\util } return true; } + + /** + * MeekroDB에서 %lb의 처리가 이상하여 따로 만든 코드 + */ + public static function formatListOfBackticks(array $array):string{ + if(!$array){ + throw new MustNotBeReachedException('backtick 목록에 없음'); + } + //.이 들어간 경우에는 분리해서 묶어야함. + return join(',', array_map(function($value){ + $value = trim($value, " \t\r\n\0\x0b`"); + if(strpos($value, '.') !== false){ + $value = explode('.', $value); + $value = array_map(function($str){ + return trim($value, " \t\r\n\0\x0b`"); + }, $value); + $value = join('`.`', $value); + } + return "`{$value}`"; + }, $array)); + } };