첫 화면 띄우기 성공

This commit is contained in:
2018-11-26 04:05:34 +09:00
parent 8bb9ed8a18
commit af9cbb47ef
73 changed files with 350 additions and 289 deletions
+22 -9
View File
@@ -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{
+4 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -18,6 +18,9 @@ class che_NPC능동 extends Command\GeneralCommand{
static protected $actionName = 'NPC능동';
protected function argTest():bool{
if($this->arg === null){
return false;
}
if(!key_exists('optionText', $this->arg)){
return false;
}
+4 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -26,6 +26,9 @@ class che_강행 extends Command\GeneralCommand{
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
return false;
}
if(!key_exists('destCityID', $this->arg)){
return false;
}
+1 -5
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -38,10 +38,6 @@ class che_거병 extends Command\GeneralCommand{
$this->setCity();
$this->setNation();
if(!key_exists($colorType, GetNationColors())){
return false;
}
$relYear = $env['year'] - $env['startyear'];
$this->runnableConstraints=[
+4 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -29,6 +29,9 @@ class che_건국 extends Command\GeneralCommand{
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
return false;
}
$nationName = $this->arg['nationName']??null;
$nationType = $this->arg['nationType']??null;
$colorType = $this->arg['colorType']??null;
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
//TODO: 아이템 클래스 재확정 후 재 구현!
@@ -36,6 +36,9 @@ class che_군량매매 extends Command\GeneralCommand{
];
protected function argTest():bool{
if($this->arg === null){
return false;
}
$buyRice = $this->arg['buyRice']??null;
if(!is_bool($buyRice)){
return false;
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
class che_농지개간 extends che_상업투자{
static protected $cityKey = 'agri';
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
+5 -2
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -28,6 +28,9 @@ class che_등용 extends Command\GeneralCommand{
static public $reqArg = true;
protected function argTest():bool{
if($this->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('군주에게는 등용장을 보낼 수 없습니다.');
}
}
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil, TimeUtil,
@@ -27,7 +27,9 @@ class che_랜덤임관 extends Command\GeneralCommand{
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
return false;
}
$destNationIDList = $this->arg['destNationIDList']??null;
//null은 에러, []는 정상
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -21,8 +21,8 @@ use function \sammo\{
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
class che_모반 extends Command\GeneralCommand{
static protected $actionName = '모반';
class che_모반시도 extends Command\GeneralCommand{
static protected $actionName = '모반시도';
protected function argTest():bool{
$this->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(),
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -49,7 +49,8 @@ class che_사기진작 extends Command\GeneralCommand{
}
public function getCost():array{
return [Util::round($this->getVar('crew')/100), 0];
$general = $this->generalObj;
return [Util::round($general->getVar('crew')/100), 0];
}
public function getPreReqTurn():int{
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -36,7 +36,7 @@ class che_상업투자 extends Command\GeneralCommand{
'power'=>'무력경험',
'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];
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
+4 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -27,6 +27,9 @@ class che_선양 extends Command\GeneralCommand{
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
return false;
}
//NOTE: 사망 직전에 '선양' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
if(!key_exists('destGeneralID', $this->arg)){
return false;
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
class che_성벽보수 extends che_상업투자{
static protected $cityKey = 'wall';
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
class che_수비강화 extends che_상업투자{
static protected $cityKey = 'def';
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
+4 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -26,6 +26,9 @@ class che_이동 extends Command\GeneralCommand{
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
return false;
}
if(!key_exists('destCityID', $this->arg)){
return false;
}
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -47,7 +47,7 @@ class che_인재탐색 extends Command\GeneralCommand{
];
$relYear = $env['year'] - $env['startyear'];
if($relYear < 3 && $this->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("현재 <D>{$nationName}</>{$josaUn} 탐색이 제한되고 있습니다.");
+4 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -26,6 +26,9 @@ class che_임관 extends Command\GeneralCommand{
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
return false;
}
$destNationID = $this->arg['destNationID']??null;
$destGeneralID = $this->arg['destGeneralID']??null;
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
//TODO: 아이템 클래스 재확정 후 재 구현!
@@ -35,6 +35,9 @@ class che_장비매매 extends Command\GeneralCommand{
];
protected function argTest():bool{
if($this->arg === null){
return false;
}
$itemType = $this->arg['itemType']??null;
if(!in_array($itemType, array_keys(static::$itemMap))){
return false;
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -58,7 +58,7 @@ class che_정착장려 extends Command\GeneralCommand{
public function getCost():array{
$develCost = $this->env['develcost'] * 2;
$reqGold = 0;
$reqRice = $general->onCalcDomestic(static::$actionKey, 'cost', $develCost);
$reqRice = $this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost);
return [$reqGold, $reqRice];
}
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -58,7 +58,7 @@ class che_주민선정 extends Command\GeneralCommand{
public function getCost():array{
$develCost = $this->env['develcost'] * 2;
$reqGold = 0;
$reqRice = $general->onCalcDomestic(static::$actionKey, 'cost', $develCost);
$reqRice = $this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost);
return [$reqGold, $reqRice];
}
+4 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -27,6 +27,9 @@ class che_증여 extends Command\GeneralCommand{
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
return false;
}
//NOTE: 사망 직전에 '증여' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
if(!key_exists('isGold', $this->arg)){
return false;
+1 -2
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -35,7 +35,6 @@ class che_집합 extends Command\GeneralCommand{
$this->setCity();
$this->setNation();
$this->setDestCity($this->arg['destCityID'], []);
[$reqGold, $reqRice] = $this->getCost();
+5 -2
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -42,6 +42,9 @@ class che_징병 extends Command\GeneralCommand{
}
protected function argTest():bool{
if($this->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];
+4 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -27,6 +27,9 @@ class che_첩보 extends Command\GeneralCommand{
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
return false;
}
if(!key_exists('destCityID', $this->arg)){
return false;
}
+4 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -27,6 +27,9 @@ class che_출병 extends Command\GeneralCommand{
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
return false;
}
if(!key_exists('destCityID', $this->arg)){
return false;
}
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
class che_치안강화 extends che_상업투자{
static protected $cityKey = 'secu';
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
+1 -7
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -40,12 +40,6 @@ class che_해산 extends Command\GeneralCommand{
$this->setCity();
$this->setNation(['gennum']);
if(!key_exists($colorType, GetNationColors())){
return false;
}
$relYear = $env['year'] - $env['startyear'];
$this->runnableConstraints=[
ConstraintHelper::BeLord(),
ConstraintHelper::WanderingNation(),
+4 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -27,6 +27,9 @@ class che_헌납 extends Command\GeneralCommand{
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
return false;
}
if(!key_exists('isGold', $this->arg)){
return false;
}
+4 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
@@ -29,6 +29,9 @@ class che_화계 extends Command\GeneralCommand{
static protected $injuryGeneral = true;
protected function argTest():bool{
if($this->arg === null){
return false;
}
if(!key_exists('destCityID', $this->arg)){
return false;
}
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
namespace sammo\GeneralCommand;
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,