diff --git a/hwe/a_bestGeneral.php b/hwe/a_bestGeneral.php index c28d1b26..c22b33d9 100644 --- a/hwe/a_bestGeneral.php +++ b/hwe/a_bestGeneral.php @@ -143,7 +143,7 @@ $types = [ ["베 팅 당 첨", "int", function($v){$v['value'] = $v['betwin']; return $v; }], ["베 팅 수 익 금", "int", function($v){$v['value'] = $v['betwingold']; return $v; }], ["베 팅 수 익 률", "percent", function($v){ - if($v['betgold'] < 1000){ + if($v['betgold'] < GameConst::$defaultGold){ $v['value'] = 0; } else{ diff --git a/hwe/c_auction.php b/hwe/c_auction.php index 6a20bda6..5c84edb3 100644 --- a/hwe/c_auction.php +++ b/hwe/c_auction.php @@ -99,8 +99,8 @@ if ($btn == "판매") { $msg = "ㆍ즉시판매가는 시작판매가의 110% 이상이어야 합니다."; $valid = 0; } - if ($amount > $me['rice'] - 1000) { - $msg = "ㆍ기본 군량 1000은 거래할 수 없습니다."; + if ($amount > $me['rice'] - GameConst::$defaultRice) { + $msg = "ㆍ기본 군량 ".GameConst::$defaultRice."은 거래할 수 없습니다."; $valid = 0; } if ($valid == 1) { @@ -148,8 +148,8 @@ if ($btn == "판매") { $msg = "ㆍ즉시판매가보다 높을 수 없습니다."; $valid = 0; } - if ($value > $me['gold'] - 1000) { - $msg = "ㆍ기본 자금 1000은 거래할 수 없습니다."; + if ($value > $me['gold'] - GameConst::$defaultGold) { + $msg = "ㆍ기본 자금 ".GameConst::$defaultGold."은 거래할 수 없습니다."; $valid = 0; } if ($valid == 1) { @@ -201,8 +201,8 @@ if ($btn == "판매") { $msg2 = "ㆍ즉시구매가는 시작구매가의 90% 이하이어야 합니다."; $valid = 0; } - if ($cost > $me['gold'] - 1000) { - $msg2 = "ㆍ기본 자금 1000은 거래할 수 없습니다."; + if ($cost > $me['gold'] - GameConst::$defaultGold) { + $msg2 = "ㆍ기본 자금 ".GameConst::$defaultGold."은 거래할 수 없습니다."; $valid = 0; } if ($valid == 1) { @@ -249,8 +249,8 @@ if ($btn == "판매") { $msg2 = "ㆍ즉시구매가보다 낮을 수 없습니다."; $valid = 0; } - if ($value > $me['rice'] - 1000) { - $msg2 = "ㆍ기본 군량 1000은 거래할 수 없습니다."; + if ($value > $me['rice'] - GameConst::$defaultRice) { + $msg2 = "ㆍ기본 군량 ".GameConst::$defaultRice."은 거래할 수 없습니다."; $valid = 0; } if ($valid == 1) { diff --git a/hwe/c_myBossInfo.php b/hwe/c_myBossInfo.php index 75f31509..2470d34d 100644 --- a/hwe/c_myBossInfo.php +++ b/hwe/c_myBossInfo.php @@ -109,13 +109,13 @@ if($btn == "추방") { $gold = 0; $rice = 0; // 금쌀1000이상은 남김 - if($general['gold'] > 1000) { - $gold = $general['gold'] - 1000; - $general['gold'] = 1000; + if($general['gold'] > GameConst::$defaultGold) { + $gold = $general['gold'] - GameConst::$defaultGold; + $general['gold'] = GameConst::$defaultGold; } - if($general['rice'] > 1000) { - $rice = $general['rice'] - 1000; - $general['rice'] = 1000; + if($general['rice'] > GameConst::$defaultRice) { + $rice = $general['rice'] - GameConst::$defaultRice; + $general['rice'] = GameConst::$defaultRice; } if($dipcount1 > 0) { diff --git a/hwe/func.old.php b/hwe/func.old.php index c8309ba8..b8a273c7 100644 --- a/hwe/func.old.php +++ b/hwe/func.old.php @@ -2149,7 +2149,7 @@ function CheckHall($no) { //토너승률인데 50회 미만시 스킵 if($typeName === 'tirate' && $general['ti'] < 50) { continue; } //수익률인데 1000미만시 스킵 - if($typeName === 'betrate' && $general['betgold'] < 1000) { continue; } + if($typeName === 'betrate' && $general['betgold'] < GameConst::$defaultGold) { continue; } if($general[$typeName]<=0){ continue; diff --git a/hwe/func.php b/hwe/func.php index 4938903d..fc84ddf5 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -2118,20 +2118,19 @@ function getNation($nation) { return $nation; } -function deleteNation($general) { +function deleteNation(General $general) { $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); - $connect=$db->get(); - $history = []; - $date = substr($general['turntime'],11,5); + [$year, $month] = $gameStor->getValuesAsArray(['year', 'month']); + $nation = $general->getStaticNation(); + $nationName = $nation['name']; + $nationID = $nation['nation']; - $admin = $gameStor->getValues(['year', 'month']); + $logger = $general->getLogger(); - $nation = getNationStaticInfo($general['nation']); - - $josaUn = JosaUtil::pick($nation['name'], '은'); - $history[] = "●{$admin['year']}년 {$admin['month']}월:【멸망】{$nation['name']}{$josaUn} 멸망했습니다."; + $josaUn = JosaUtil::pick($nationName, '은'); + $logger->pushGlobalHistoryLog("【멸망】{$nationName}{$josaUn} 멸망했습니다."); $oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $general['nation']); $oldNationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $general['nation']); @@ -2139,14 +2138,23 @@ function deleteNation($general) { $oldNation['aux'] = Json::decode($oldNation['aux']); // 전 장수 재야로 // 전 장수 소속 무소속으로 - $query = "update general set belong=0,troop=0,level=0,nation=0,makelimit=12 where nation='{$general['nation']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $db->update('general', [ + 'belong'=>0, + 'troop'=>0, + 'level'=>0, + 'nation'=>0, + 'makelimit'=>12, + ], 'nation=%i', $nationID); // 도시 공백지로 - $query = "update city set nation=0,front=0,gen1=0,gen2=0,gen3=0 where nation='{$general['nation']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $db->update('city', [ + 'nation'=>0, + 'front'=>0, + 'gen1'=>0, + 'gen2'=>0, + 'gen3'=>0, + ], 'nation=%i', $nationID); // 부대 삭제 - $query = "delete from troop where nation='{$general['nation']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $db->delete('troop', 'nation=%i', $nationID); // 국가 삭제 $db->insert('ng_old_nations', [ @@ -2154,14 +2162,10 @@ function deleteNation($general) { 'nation'=>$general['nation'], 'data'=>Json::encode($oldNation) ]); - - $query = "delete from nation where nation='{$general['nation']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $db->delete('nation', 'nation=%i', $nationID); // 외교 삭제 - $query = "delete from diplomacy where me='{$general['nation']}' or you='{$general['nation']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $db->delete('diplomacy', 'me = %i OR you = %i', $nationID, $nationID); - pushWorldHistory($history, $admin['year'], $admin['month']); refreshNationStaticInfo(); } @@ -2169,21 +2173,18 @@ function nextRuler(General $general) { //TODO: General로 변경 $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); - $connect=$db->get(); + + [$year, $month] = $gameStor->getValuesAsArray(['year', 'month']); + $nation = $general->getStaticNation(); + $nationName = $nation['name']; + $nationID = $nation['nation']; - $admin = $gameStor->getValues(['year', 'month']); - $query = "select nation,name from nation where nation='{$general['nation']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $nation = MYDB_fetch_array($result); - - $query = "select no,name from general where nation='{$general['nation']}' and level!='12' and level>='9' order by level desc"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $corecount = MYDB_num_rows($result); + $chiefList = $db->query('SELECT no,name,npc FROM general WHERE nation=%i and level!= 12 AND level >= 9 order by level desc'); //npc or npc유저인 경우 후계 찾기 - if($general['npc'] > 0) { - $query = "select no,name,nation,IF(ABS(affinity-'{$general['affinity']}')>75,150-ABS(affinity-'{$general['affinity']}'),ABS(affinity-'{$general['affinity']}')) as npcmatch2 from general where nation='{$general['nation']}' and level!=12 and npc>0 order by npcmatch2,rand() limit 0,1"; + if($general->getVar('npc') > 0) { + $npcList = $db->query$query = "select no,name,nation,IF(ABS(affinity-'{$general['affinity']}')>75,150-ABS(affinity-'{$general['affinity']}'),ABS(affinity-'{$general['affinity']}')) as npcmatch2 from general where nation='{$general['nation']}' and level!=12 and npc>0 order by npcmatch2,rand() limit 0,1"; $npcresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $npccount = MYDB_num_rows($npcresult); } else { diff --git a/hwe/func_process_personnel.php b/hwe/func_process_personnel.php index 73cac8c3..5d272b40 100644 --- a/hwe/func_process_personnel.php +++ b/hwe/func_process_personnel.php @@ -74,72 +74,6 @@ function process_47(&$general) { pushGenLog($general, $log); } -function process_54(&$general) { - $db = DB::db(); - $gameStor = KVStorage::getStorage($db, 'game_env'); - $connect=$db->get(); - - $log = []; - $youlog = []; - $alllog = []; - $history = []; - $date = substr($general['turntime'],11,5); - - $admin = $gameStor->getValues(['year','month']); - - $command = DecodeCommand($general['turn0']); - $who = $command[1]; - - $query = "select no,name,nation from general where no='$who'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $nextruler = MYDB_fetch_array($result); - - $query = "select nation,name from nation where nation='{$general['nation']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $nation = MYDB_fetch_array($result); - - //현재 외교 진행중(통합제의중)일때 - $query = "select state from diplomacy where me='{$general['nation']}' and state='4'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $dipcount = MYDB_num_rows($result); - - if($nextruler['name'] == "") { - $log[] = "●{$admin['month']}월:잘못된 장수입니다. 선양 실패. <1>$date"; - } elseif($general['level'] != 12) { - $log[] = "●{$admin['month']}월:군주가 아닙니다. 선양 실패. <1>$date"; - } elseif($nextruler['nation'] != $general['nation']) { - $log[] = "●{$admin['month']}월:잘못된 장수입니다. 선양 실패. <1>$date"; - } elseif($dipcount != 0) { - $log[] = "●{$admin['month']}월:현재 통합 진행중입니다. 선양 실패."; - } else { - //군주 교체 - $query = "update general set level='12' where no='$who'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - // 태수,군사,시중이었다면 해제 - $query = "update city set gen1='0' where gen1='$who'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $query = "update city set gen2='0' where gen2='$who'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $query = "update city set gen3='0' where gen3='$who'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - - $query = "update general set resturn='SUCCESS',level='1',experience=experience*0.7 where no='{$general['no']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - - $josaYi = JosaUtil::pick($general['name'], '이'); - $history[] = "●{$admin['year']}년 {$admin['month']}월:【선양】{$general['name']}{$josaYi} {$nation['name']}의 군주 자리를 {$nextruler['name']}에게 선양했습니다."; - $log[] = "●{$admin['month']}월:{$nextruler['name']}에게 군주의 자리를 물려줍니다. <1>$date"; - $youlog[] = "●{$admin['month']}월:{$general['name']}에게서 군주의 자리를 물려받습니다."; - - pushGeneralHistory($general, "●{$admin['year']}년 {$admin['month']}월:{$nation['name']}의 군주자리를 {$nextruler['name']}에게 선양"); - pushGeneralHistory($nextruler, "●{$admin['year']}년 {$admin['month']}월:{$nation['name']}의 군주자리를 물려 받음"); - pushNationHistory($nation, "●{$admin['year']}년 {$admin['month']}월:{$general['name']}{$josaYi} {$nextruler['name']}에게 선양"); - } - pushGenLog($general, $log); - pushGenLog($nextruler, $youlog); - pushWorldHistory($history, $admin['year'], $admin['month']); -} - function process_56(&$general) { $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); diff --git a/hwe/join_post.php b/hwe/join_post.php index 034bcf59..09d9aad3 100644 --- a/hwe/join_post.php +++ b/hwe/join_post.php @@ -227,8 +227,8 @@ $db->insert('general', [ 'intel' => $intel, 'experience' => $experience, 'dedication' => 0, - 'gold' => 1000, - 'rice' => 1000, + 'gold' => GameConst::$defaultGold, + 'rice' => GameConst::$defaultRice, 'crew' => 0, 'train' => 0, 'atmos' => 0, diff --git a/hwe/sammo/Command/BaseCommand.php b/hwe/sammo/Command/BaseCommand.php index e7c89004..51cf6f90 100644 --- a/hwe/sammo/Command/BaseCommand.php +++ b/hwe/sammo/Command/BaseCommand.php @@ -111,6 +111,10 @@ abstract class BaseCommand{ $defaultArgs = ['nation', 'name', 'color', 'type', 'level', 'capital']; $args = array_unique(array_merge($defaultArgs, $args)); + if($args == $defaultArgs){ + $this->nation = $this->generalObj->getStaticNation(); + return; + } $defaultValues = [ 'nation'=>0, diff --git a/hwe/sammo/Command/General/che_하야.php b/hwe/sammo/Command/General/che_하야.php index 183ca5a6..a23111f6 100644 --- a/hwe/sammo/Command/General/che_하야.php +++ b/hwe/sammo/Command/General/che_하야.php @@ -97,8 +97,8 @@ class che_하야 extends Command\GeneralCommand{ } - $newGold = Util::valueFit($general->getVar('gold'), null, 1000); - $newRice = Util::valueFit($general->getVar('rice'), null, 1000); + $newGold = Util::valueFit($general->getVar('gold'), null, GameConst::$defaultGold); + $newRice = Util::valueFit($general->getVar('rice'), null, GameConst::$defaultRice); $lostGold = $general->getVar('gold') - $newGold; $lostRice = $general->getVar('rice') - $newRice; diff --git a/hwe/sammo/Command/General/che_해산.php b/hwe/sammo/Command/General/che_해산.php new file mode 100644 index 00000000..294feb58 --- /dev/null +++ b/hwe/sammo/Command/General/che_해산.php @@ -0,0 +1,157 @@ +arg = []; + + return true; + } + + protected function init(){ + + $general = $this->generalObj; + $env = $this->env; + + $this->setCity(); + $this->setNation(['gennum']); + + if(!key_exists($colorType, GetNationColors())){ + return false; + } + + $relYear = $env['year'] - $env['startyear']; + + $this->runnableConstraints=[ + ['BeLord'], + ['WanderingNation'], + ]; + } + + public function getCost():array{ + return [0, 0]; + } + + public function getPreReqTurn():int{ + return 0; + } + + public function getPostReqTurn():int{ + return 0; + } + + public function run():bool{ + if(!$this->isRunnable()){ + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + + $db = DB::db(); + $env = $this->env; + + $general = $this->generalObj; + $date = substr($general->getVar('turntime'),11,5); + + $generalName = $general->getName(); + $josaYi = JosaUtil::pick($generalName, '이'); + + $nation = $this->nation; + $nationID = $nation['nation']; + $nationName = $nation['name']; + + if($nation['gennum'] > 1){ + $db->update('general', [ + 'gold'=>GameConst::$defaultGold + ], 'nation=%i AND gold>%i', $nationID, GameConst::$defaultGold); + $db->update('general', [ + 'rice'=>GameConst::$defaultRice + ], 'nation=%i AND gold>%i', $nationID, GameConst::$defaultRice); + } + + DeleteConflict($nationID); + deleteNation($general); + + $diplomacyInit = []; + foreach(getAllNationStaticInfo() as $destNation){ + $destNationID = $destNation['nation']; + $diplomacyInit[] = [ + 'me'=>$destNationID, + 'you'=>$nationID, + 'state'=>2, + 'term'=>0, + ]; + + $diplomacyInit[] = [ + 'me'=>$nationID, + 'you'=>$destNationID, + 'state'=>2, + 'term'=>0, + ]; + } + $db->insert('diplomacy', $diplomacyInit); + + DB::db()->insert('nation', [ + 'name'=>$nationName, + 'color'=>'#330000', + 'gold'=>0, + 'rice'=>GameConst::$baserice, + 'rate'=>20, + 'bill'=>100, + 'sabotagelimit'=>12, + 'surlimit'=>72, + 'type'=>0, + 'gennum'=>1 + ]); + $nationID = DB::db()->insertId(); + + refreshNationStaticInfo(); + + $logger->pushGeneralActionLog("거병에 성공하였습니다. <1>$date"); + $logger->pushGlobalActionLog("{$generalName}{$josaYi} {$cityName}에 거병하였습니다."); + + $logger->pushGlobalHistoryLog("【거병】{$generalName}{$josaYi} 세력을 결성하였습니다."); + $logger->pushGeneralHistoryLog("{$cityName}에서 거병"); + $logger->pushNationalHistoryLog("{$generalName}{$josaYi} {$cityName}에서 거병"); + + $exp = 100; + $ded = 100; + + $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); + $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + + $general->increaseVar('experience', $exp); + $general->increaseVar('dedication', $ded); + $general->setVar('belong', 1); + $general->setVar('level', 12); + $general->setVar('nation', $nationID); + + $general->setResultTurn(new LastTurn(static::getName(), $this->arg)); + $general->checkStatChange(); + $general->applyDB($db); + + return true; + } + + +} \ No newline at end of file diff --git a/hwe/sammo/Engine/Personnel.php b/hwe/sammo/Engine/Personnel.php index b3e232d6..6991a3c0 100644 --- a/hwe/sammo/Engine/Personnel.php +++ b/hwe/sammo/Engine/Personnel.php @@ -130,15 +130,15 @@ class Personnel{ // 재야가 아니면 명성N*10% 공헌N*10%감소 if($general['nation'] != 0){ - // 1000 1000 남기고 환수 - if($general['gold'] > 1000){//XXX: 상수. - $setValues['gold'] = 1000; - $setOriginalNationValues['gold'] = $db->sqleval('gold + %i', $general['gold'] - 1000); + // 기본 금액 남기고 환수 + if($general['gold'] > GameConst::$defaultGold){ + $setValues['gold'] = GameConst::$defaultGold; + $setOriginalNationValues['gold'] = $db->sqleval('gold + %i', $general['gold'] - GameConst::$defaultGold); } - if($general['rice'] > 1000){//XXX: 상수. - $setValues['rice'] = 1000; - $setOriginalNationValues['rice'] = $db->sqleval('rice + %i', $general['rice'] - 1000); + if($general['rice'] > GameConst::$defaultRice){//XXX: 상수. + $setValues['rice'] = GameConst::$defaultRice; + $setOriginalNationValues['rice'] = $db->sqleval('rice + %i', $general['rice'] - GameConst::$defaultRice); } //관직 해제 diff --git a/hwe/sammo/GameConstBase.php b/hwe/sammo/GameConstBase.php index 12845198..5b8f6834 100644 --- a/hwe/sammo/GameConstBase.php +++ b/hwe/sammo/GameConstBase.php @@ -91,6 +91,11 @@ class GameConstBase /** @var int 초기 시작 년도. 실제 값은 시나리오에서 정해지므로 딱히 의미는 없음. */ public static $defaultStartYear = 180; + /** @var int 시작시 금 */ + public static $defaultGold = 1000; + /** @var int 시작시 쌀 */ + public static $defaultRice = 1000; + /** @var int 최대 턴 */ public static $maxTurn = 30; public static $maxNationTurn = 12; diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php index babbde75..9f641790 100644 --- a/hwe/sammo/GeneralAI.php +++ b/hwe/sammo/GeneralAI.php @@ -263,7 +263,7 @@ class GeneralAI{ $commandList['che_물자조달'] = ( (GameConst::$minNationalGold + GameConst::$minNationalRice + 10000) / - Util::valueFit($nation['gold'] + $nation['rice'], 1000) + Util::valueFit($nation['gold'] + $nation['rice'], (GameConst::$defaultGold + GameConst::$defaultRice)/2) ) * 10; return [Util::choiceRandomUsingWeight($commandList), null]; diff --git a/hwe/sammo/Scenario/NPC.php b/hwe/sammo/Scenario/NPC.php index 5b9efa6b..02ca3f42 100644 --- a/hwe/sammo/Scenario/NPC.php +++ b/hwe/sammo/Scenario/NPC.php @@ -41,8 +41,8 @@ class NPC{ 9 => 'ⓞ', //오랑캐? ]; - protected $gold = 1000; - protected $rice = 1000; + protected $gold; + protected $rice; protected $specAge = null; protected $specAge2 = null; @@ -86,6 +86,9 @@ class NPC{ $this->ego = $ego; $this->text = $text; + $this->gold = GameConst::$defaultGold; + $this->rice = GameConst::$defaultRice; + $general = [ 'leader'=>$leadership, 'power'=>$power,