커맨드 유효성을 2개에서 3개구성으로 변경

This commit is contained in:
2020-05-04 19:51:11 +09:00
parent f25f5008f1
commit 77248ad4d8
100 changed files with 4124 additions and 3420 deletions
+3 -7
View File
@@ -48,11 +48,11 @@ class che_NPC능동 extends Command\GeneralCommand{
$this->setNation();
$this->reservableConstraints=[
$this->permissionConstraints=[
ConstraintHelper::MustBeNPC()
];
$this->runnableConstraints=[
$this->fullConditionConstraints=[
];
@@ -70,12 +70,8 @@ class che_NPC능동 extends Command\GeneralCommand{
return 0;
}
public function canDisplay():bool{
return false;
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+66 -52
View File
@@ -1,17 +1,21 @@
<?php
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
General,
use\sammo\{
DB,
Util,
JosaUtil,
General,
ActionLogger,
GameConst, GameUnitConst,
GameConst,
GameUnitConst,
LastTurn,
Command
};
use function \sammo\{
use function\sammo\{
tryUniqueItemLottery,
printCitiesBasedOnDistance
};
@@ -22,83 +26,95 @@ use sammo\CityConst;
class che_강행 extends Command\GeneralCommand{
class che_강행 extends Command\GeneralCommand
{
static protected $actionName = '강행';
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
protected function argTest(): bool
{
if ($this->arg === null) {
return false;
}
if(!key_exists('destCityID', $this->arg)){
if (!key_exists('destCityID', $this->arg)) {
return false;
}
if(!key_exists($this->arg['destCityID'], CityConst::all())){
if (!key_exists($this->arg['destCityID'], CityConst::all())) {
return false;
}
$this->arg = [
'destCityID'=>$this->arg['destCityID']
'destCityID' => $this->arg['destCityID']
];
return true;
}
protected function init(){
$general = $this->generalObj;
protected function init()
{
$this->setCity();
$this->setNation();
$this->setDestCity($this->arg['destCityID'], []);
$this->minConditionConstraints = [];
}
protected function initWithArg()
{
$this->setDestCity($this->arg['destCityID'], true);
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
ConstraintHelper::NotSameDestCity(),
$this->fullConditionConstraints = [
ConstraintHelper::NotSameDestCity(),
ConstraintHelper::NearCity(3),
ConstraintHelper::ReqGeneralGold($reqGold),
ConstraintHelper::ReqGeneralRice($reqRice),
];
}
public function getCommandDetailTitle():string{
public function getCommandDetailTitle(): string
{
$name = $this->getName();
[$reqGold, $reqRice] = $this->getCost();
$title = "{$name}(통솔경험";
if($reqGold > 0){
if ($reqGold > 0) {
$title .= ", 자금{$reqGold}";
}
if($reqRice > 0){
if ($reqRice > 0) {
$title .= ", 군량{$reqRice}";
}
$title .= ', 병력,훈련,사기↓)';
return $title;
}
public function getCost():array{
public function getCost(): array
{
$env = $this->env;
return [$env['develcost'] * 5, 0];
}
public function getPreReqTurn():int{
public function getPreReqTurn(): int
{
return 0;
}
public function getPostReqTurn():int{
public function getPostReqTurn(): int
{
return 0;
}
public function getBrief():string{
public function getBrief(): string
{
$commandName = $this->getName();
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
$josaRo = JosaUtil::pick($destCityName, '로');
return "{$destCityName}{$josaRo} {$commandName}";
}
public function getFailString():string{
public function getFailString(): string
{
$commandName = $this->getName();
$failReason = $this->testRunnable();
if($failReason === null){
$failReason = $this->testFullConditionMet();
if ($failReason === null) {
throw new \RuntimeException('실행 가능한 커맨드에 대해 실패 이유를 수집');
}
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
@@ -106,8 +122,9 @@ class che_강행 extends Command\GeneralCommand{
return "{$failReason} <G><b>{$destCityName}</b></>{$josaRo} {$commandName} 실패.";
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -128,16 +145,16 @@ class che_강행 extends Command\GeneralCommand{
$exp = 100;
$general->setVar('city', $destCityID);
if($general->getVar('officer_level') == 12 && $this->nation['level'] == 0){
if ($general->getVar('officer_level') == 12 && $this->nation['level'] == 0) {
$generalList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no!=%i', $general->getNationID(), $general->getID());
if($generalList){
if ($generalList) {
$db->update('general', [
'city'=>$destCityID
'city' => $destCityID
], 'no IN %li and nation=%i', $generalList, $general->getNationID());
}
foreach($generalList as $targetGeneralID){
foreach ($generalList as $targetGeneralID) {
$targetLogger = new ActionLogger($targetGeneralID, $general->getNationID(), $env['year'], $env['month']);
$targetLogger->pushGeneralActionLog("방랑군 세력이 <G><b>{$destCityName}</b></>{$josaRo} 강행했습니다.", ActionLogger::PLAIN);
$targetLogger->flush();
@@ -153,7 +170,6 @@ class che_강행 extends Command\GeneralCommand{
$general->applyDB($db);
return true;
}
public function getJSFiles(): array
@@ -170,19 +186,17 @@ class che_강행 extends Command\GeneralCommand{
ob_start();
?>
<?=\sammo\getMapHtml()?><br>
선택된 도시로 강행합니다.<br>
최대 3칸내 도시로만 강행이 가능합니다.<br>
목록을 선택하거나 도시를 클릭하세요.<br>
<?=$currentCityName?> => <select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'><br>
<?=\sammo\optionsForCities()?><br>
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
<br>
<br>
<?=printCitiesBasedOnDistance($currentCityID, 3)?>
<?= \sammo\getMapHtml() ?><br>
선택된 도시로 강행합니다.<br>
최대 3칸내 도시로만 강행이 가능합니다.<br>
목록을 선택하거나 도시를 클릭하세요.<br>
<?= $currentCityName ?> => <select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'><br>
<?= \sammo\optionsForCities() ?><br>
</select> <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
<br>
<br>
<?= printCitiesBasedOnDistance($currentCityID, 3) ?>
<?php
return ob_get_clean();
}
}
}
+4 -3
View File
@@ -30,7 +30,8 @@ class che_거병 extends Command\GeneralCommand{
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$env = $this->env;
@@ -40,7 +41,7 @@ class che_거병 extends Command\GeneralCommand{
$relYear = $env['year'] - $env['startyear'];
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::BeNeutral(),
ConstraintHelper::BeOpeningPart($relYear+1),
ConstraintHelper::AllowJoinAction(),
@@ -60,7 +61,7 @@ class che_거병 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+92 -73
View File
@@ -1,17 +1,21 @@
<?php
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
General,
use\sammo\{
DB,
Util,
JosaUtil,
General,
ActionLogger,
GameConst, GameUnitConst,
GameConst,
GameUnitConst,
LastTurn,
Command
};
use function \sammo\{
use function\sammo\{
tryUniqueItemLottery,
getAllNationStaticInfo
};
@@ -25,69 +29,80 @@ use function sammo\GetNationColors;
use function sammo\newColor;
class che_건국 extends Command\GeneralCommand{
class che_건국 extends Command\GeneralCommand
{
static protected $actionName = '건국';
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
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;
$nationName = $this->arg['nationName'] ?? null;
$nationType = $this->arg['nationType'] ?? null;
$colorType = $this->arg['colorType'] ?? null;
if($nationName === null || $nationType === null || $colorType === null){
if ($nationName === null || $nationType === null || $colorType === null) {
return false;
}
if(!is_string($nationName) || !is_string($nationType) || !is_int($colorType)){
if (!is_string($nationName) || !is_string($nationType) || !is_int($colorType)) {
return false;
}
if(mb_strwidth($nationName) > 18 || $nationName == ''){
if (mb_strwidth($nationName) > 18 || $nationName == '') {
return false;
}
if(!key_exists($colorType, GetNationColors())){
if (!key_exists($colorType, GetNationColors())) {
return false;
}
try{
try {
$nationTypeClass = buildNationTypeClass($nationType);
}
catch(\InvalidArgumentException $e){
} catch (\InvalidArgumentException $e) {
return false;
}
$this->arg = [
'nationName'=>$nationName,
'nationType'=>$nationType,
'colorType'=>$colorType
'nationName' => $nationName,
'nationType' => $nationType,
'colorType' => $colorType
];
return true;
}
protected function init(){
$general = $this->generalObj;
protected function init()
{
$env = $this->env;
$nationName = $this->arg['nationName'];
$nationType = $this->arg['nationType'];
$colorType = $this->arg['colorType'];
$this->setCity();
$this->setNation(['gennum']);
$relYear = $env['year'] - $env['startyear'];
$this->runnableConstraints=[
$this->minConditionConstraints = [
ConstraintHelper::BeOpeningPart($relYear + 1),
ConstraintHelper::ReqNationValue('level', '국가규모', '==', 0, '정식 국가가 아니어야합니다.')
];
}
protected function initWithArg()
{
$env = $this->env;
$relYear = $env['year'] - $env['startyear'];
$nationName = $this->arg['nationName'];
$nationType = $this->arg['nationType'];
$colorType = $this->arg['colorType'];
$this->fullConditionConstraints = [
ConstraintHelper::BeLord(),
ConstraintHelper::WanderingNation(),
ConstraintHelper::ReqNationValue('gennum', '수하 장수', '>=', 2),
ConstraintHelper::BeOpeningPart($relYear+1),
ConstraintHelper::BeOpeningPart($relYear + 1),
ConstraintHelper::CheckNationNameDuplicate($nationName),
ConstraintHelper::AllowJoinAction(),
ConstraintHelper::ConstructableCity(),
@@ -101,20 +116,24 @@ class che_건국 extends Command\GeneralCommand{
return "{$nationName}{$josaUl} 건국";
}
public function getCost():array{
public function getCost(): array
{
return [0, 0];
}
public function getPreReqTurn():int{
public function getPreReqTurn(): int
{
return 0;
}
public function getPostReqTurn():int{
public function getPostReqTurn(): int
{
return 0;
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -155,16 +174,16 @@ class che_건국 extends Command\GeneralCommand{
$general->addDedication($ded);
$db->update('city', [
'nation'=>$general->getNationID(),
'conflict'=>'{}'
'nation' => $general->getNationID(),
'conflict' => '{}'
], 'city=%i', $general->getCityID());
$db->update('nation', [
'name'=>$nationName,
'color'=>$colorType,
'level'=>1,
'type'=>$nationType,
'capital'=>$general->getCityID()
'name' => $nationName,
'color' => $colorType,
'level' => 1,
'type' => $nationType,
'capital' => $general->getCityID()
], 'nation=%i', $general->getNationID());
refreshNationStaticInfo();
@@ -180,7 +199,7 @@ class che_건국 extends Command\GeneralCommand{
public function getForm(): string
{
if(count(getAllNationStaticInfo()) >= $this->env['maxnation']){
if (count(getAllNationStaticInfo()) >= $this->env['maxnation']) {
return '더 이상 건국은 불가능합니다.';
}
@@ -213,44 +232,44 @@ class che_건국 extends Command\GeneralCommand{
}
}
*/
ob_start();
?>
현재 도시에서 나라를 세웁니다. 중, 소도시에서만 가능합니다.<br>
현재 도시에서 나라를 세웁니다. 중, 소도시에서만 가능합니다.<br>
<?php foreach(GameConst::$availableNationType as $nationType):
$nationClass = buildNationTypeClass($nationType);
<?php foreach (GameConst::$availableNationType as $nationType) :
$nationClass = buildNationTypeClass($nationType);
[$name, $pros, $cons] = [$nationClass->getName(), $nationClass::$pros, $nationClass::$cons];
?>
- <?=$name?> : <span style='color:cyan;'><?=$pros?></span> <span style='color:magenta;'><?=$cons?></span><br>
<?php endforeach; ?>
<br>
국명 : <input type='text' class='formInput' name="nationName" id="nationName" size='18' maxlength='18' style='color:white;background-color:black;'>
색깔 : <select class='formInput' name='colorType' id='colorType' size='1'>
[$name, $pros, $cons] = [$nationClass->getName(), $nationClass::$pros, $nationClass::$cons];
?>
<?php foreach(GetNationColors() as $idx=>$color):
/*
- <?= $name ?> : <span style='color:cyan;'><?= $pros ?></span> <span style='color:magenta;'><?= $cons ?></span><br>
<?php endforeach; ?>
<br>
국명 : <input type='text' class='formInput' name="nationName" id="nationName" size='18' maxlength='18' style='color:white;background-color:black;'>
색깔 : <select class='formInput' name='colorType' id='colorType' size='1'>
<?php foreach (GetNationColors() as $idx => $color) :
/*
if($colorUsed[$color] > 0){
continue;
}
*/
?>
<option value="<?=$idx?>" style='background-color:<?=$color?>;color:<?=newColor($color)?>';>국가명</option>
<?php endforeach; ?>
</select>
성향 : <select class='formInput' name='nationType' id='nationType' size='1'>
?>
<option value="<?= $idx ?>" style='background-color:<?= $color ?>;color:<?= newColor($color) ?>' ;>국가명</option>
<?php endforeach; ?>
</select>
성향 : <select class='formInput' name='nationType' id='nationType' size='1'>
<?php foreach(GameConst::$availableNationType as $nationType):
$nationTypeName = buildNationTypeClass($nationType)->getName();
?>
<option value='<?=$nationType?>' style=background-color:black;color:white;><?=$nationTypeName?></option>
<?php endforeach; ?>
</select>
<input type=button id="commonSubmit" value="<?=$this->getName()?>">
<?php foreach (GameConst::$availableNationType as $nationType) :
$nationTypeName = buildNationTypeClass($nationType)->getName();
?>
<option value='<?= $nationType ?>' style=background-color:black;color:white;><?= $nationTypeName ?></option>
<?php endforeach; ?>
</select>
<input type=button id="commonSubmit" value="<?= $this->getName() ?>">
<?php
return ob_get_clean();
}
}
}
+4 -3
View File
@@ -28,11 +28,12 @@ class che_견문 extends Command\GeneralCommand{
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$this->runnableConstraints=[
$this->fullConditionConstraints=[
];
}
@@ -55,7 +56,7 @@ class che_견문 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+17 -5
View File
@@ -56,24 +56,36 @@ class che_군량매매 extends Command\GeneralCommand{
return "군량 {$this->arg['amount']}{$buyRiceText}";
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$this->setCity();
$this->setNation();
$this->minConditionConstraints=[
ConstraintHelper::ReqCityTrader($general->getVar('npc')),
ConstraintHelper::OccupiedCity(true),
ConstraintHelper::SuppliedCity(),
];
}
protected function initWithArg()
{
$general = $this->generalObj;
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::ReqCityTrader($general->getVar('npc')),
ConstraintHelper::OccupiedCity(true),
ConstraintHelper::SuppliedCity(),
];
if($this->arg['buyRice']){
$this->runnableConstraints[] = ConstraintHelper::ReqGeneralGold(1);
$this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralGold(1);
}
else{
$this->runnableConstraints[] = ConstraintHelper::ReqGeneralRice(1);
$this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralRice(1);
}
}
@@ -90,7 +102,7 @@ class che_군량매매 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+4 -3
View File
@@ -30,7 +30,8 @@ class che_귀환 extends Command\GeneralCommand{
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
@@ -39,7 +40,7 @@ class che_귀환 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotWanderingNation(),
ConstraintHelper::NotCapital(true),
@@ -64,7 +65,7 @@ class che_귀환 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -31,7 +31,8 @@ class che_기술연구 extends che_상업투자{
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
@@ -40,7 +41,7 @@ class che_기술연구 extends che_상업투자{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotWanderingNation(),
ConstraintHelper::OccupiedCity(),
@@ -53,7 +54,7 @@ class che_기술연구 extends che_상업투자{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+4 -3
View File
@@ -28,7 +28,8 @@ class che_단련 extends Command\GeneralCommand{
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
@@ -37,7 +38,7 @@ class che_단련 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::ReqGeneralCrew(),
ConstraintHelper::ReqGeneralValue('train', '훈련', '>=', GameConst::$defaultTrainLow),
@@ -77,7 +78,7 @@ class che_단련 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+25 -7
View File
@@ -53,21 +53,39 @@ class che_등용 extends Command\GeneralCommand{
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$this->setCity();
$this->setNation(['gennum', 'scout']);
$relYear = $this->env['year'] - $this->env['startyear'];
$this->permissionConstraints=[
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
];
$this->minConditionConstraints=[
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotOpeningPart($relYear),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::SuppliedCity(),
];
}
protected function initWithArg()
{
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation'], 0);
$this->setDestGeneral($destGeneral);
[$reqGold, $reqRice] = $this->getCost();
$relYear = $this->env['year'] - $this->env['startyear'];
$this->runnableConstraints=[
ConstraintHelper::ReqEnvValue('join_mode', '==', 'onlyRandom', '랜덤 임관만 가능합니다'),
$this->fullConditionConstraints=[
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotOpeningPart($relYear),
ConstraintHelper::OccupiedCity(),
@@ -77,9 +95,9 @@ class che_등용 extends Command\GeneralCommand{
ConstraintHelper::ReqGeneralGold($reqGold),
ConstraintHelper::ReqGeneralRice($reqRice),
];
if($this->destGeneralObj->getVar('officer_level') == 12){
$this->runnableConstraints[] = ConstraintHelper::AlwaysFail('군주에게는 등용장을 보낼 수 없습니다.');
$this->fullConditionConstraints[] = ConstraintHelper::AlwaysFail('군주에게는 등용장을 보낼 수 없습니다.');
}
}
@@ -113,7 +131,7 @@ class che_등용 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+11 -7
View File
@@ -70,22 +70,26 @@ class che_등용수락 extends Command\GeneralCommand{
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$this->setNation(['gennum', 'scout']);
$this->permissionConstraints = [
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
];
}
protected function initWithArg()
{
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation'], 0);
$this->setDestGeneral($destGeneral);
$this->setDestNation($this->arg['destNationID'], ['gennum', 'scout']);
$relYear = $this->env['year'] - $this->env['startyear'];
$this->reservableConstraints = [
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
];
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::ReqEnvValue('join_mode', '==', 'onlyRandom', '랜덤 임관만 가능합니다'),
ConstraintHelper::NotOpeningPart($relYear),
ConstraintHelper::ExistsDestNation(),
@@ -109,7 +113,7 @@ class che_등용수락 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -26,7 +26,6 @@ use sammo\MustNotBeReachedException;
class che_랜덤임관 extends Command\GeneralCommand{
static protected $actionName = '랜덤임관';
static public $reqArg = false;
protected function argTest():bool{
$this->arg = null;
@@ -61,7 +60,8 @@ class che_랜덤임관 extends Command\GeneralCommand{
return true;*/
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$env = $this->env;
@@ -71,14 +71,14 @@ class che_랜덤임관 extends Command\GeneralCommand{
$relYear = $env['year'] - $env['startyear'];
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::BeNeutral(),
ConstraintHelper::AllowJoinAction(),
];
/*
if($this->arg['destNationIDList']??false){
$this->runnableConstraints[] = ConstraintHelper::ExistsAllowJoinNation($relYear, $this->arg['destNationIDList']);
$this->fullConditionConstraints[] = ConstraintHelper::ExistsAllowJoinNation($relYear, $this->arg['destNationIDList']);
}
*/
}
@@ -96,7 +96,7 @@ class che_랜덤임관 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -29,14 +29,15 @@ class che_모반시도 extends Command\GeneralCommand{
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$this->setCity();
$this->setNation();
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::BeChief(),
ConstraintHelper::OccupiedCity(),
@@ -59,7 +60,7 @@ class che_모반시도 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -30,14 +30,15 @@ class che_물자조달 extends Command\GeneralCommand{
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$this->setCity();
$this->setNation();
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotWanderingNation(),
ConstraintHelper::OccupiedCity(),
@@ -63,7 +64,7 @@ class che_물자조달 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+2 -2
View File
@@ -40,7 +40,7 @@ class che_방랑 extends Command\GeneralCommand{
$relYear = $env['year'] - $env['startyear'];
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::BeLord(),
ConstraintHelper::NotWanderingNation(),
ConstraintHelper::NotOpeningPart($relYear),
@@ -63,7 +63,7 @@ class che_방랑 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -36,7 +36,7 @@ class che_사기진작 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotWanderingNation(),
ConstraintHelper::OccupiedCity(),
@@ -69,7 +69,7 @@ class che_사기진작 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -45,7 +45,7 @@ class che_상업투자 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotWanderingNation(),
ConstraintHelper::OccupiedCity(),
@@ -128,7 +128,7 @@ class che_상업투자 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+60 -42
View File
@@ -1,9 +1,13 @@
<?php
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
General, DummyGeneral,
use\sammo\{
DB,
Util,
JosaUtil,
General,
DummyGeneral,
ActionLogger,
GameConst,
LastTurn,
@@ -11,9 +15,9 @@ use \sammo\{
Command
};
use function \sammo\{
use function\sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalRatioDomestic,
CriticalScoreEx,
tryUniqueItemLottery
};
@@ -22,45 +26,55 @@ use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
class che_선양 extends Command\GeneralCommand{
class che_선양 extends Command\GeneralCommand
{
static protected $actionName = '선양';
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
protected function argTest(): bool
{
if ($this->arg === null) {
return false;
}
//NOTE: 사망 직전에 '선양' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
if(!key_exists('destGeneralID', $this->arg)){
if (!key_exists('destGeneralID', $this->arg)) {
return false;
}
$destGeneralID = $this->arg['destGeneralID'];
if(!is_int($destGeneralID)){
if (!is_int($destGeneralID)) {
return false;
}
if($destGeneralID <= 0){
if ($destGeneralID <= 0) {
return false;
}
if($destGeneralID == $this->generalObj->getID()){
if ($destGeneralID == $this->generalObj->getID()) {
return false;
}
$this->arg = [
'destGeneralID'=>$destGeneralID
'destGeneralID' => $destGeneralID
];
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$this->setNation();
$this->minConditionConstraints = [
ConstraintHelper::BeLord()
];
}
protected function initWithArg()
{
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'nation'], 1);
$this->setDestGeneral($destGeneral);
$this->runnableConstraints=[
ConstraintHelper::BeLord(),
$this->fullConditionConstraints = [
ConstraintHelper::BeLord(),
ConstraintHelper::ExistsDestGeneral(),
ConstraintHelper::FriendlyDestGeneral(),
ConstraintHelper::DisallowDiplomacyStatus(
@@ -70,15 +84,18 @@ class che_선양 extends Command\GeneralCommand{
];
}
public function getCost():array{
public function getCost(): array
{
return [0, 0];
}
public function getPreReqTurn():int{
public function getPreReqTurn(): int
{
return 0;
}
public function getPostReqTurn():int{
public function getPostReqTurn(): int
{
return 0;
}
@@ -89,8 +106,9 @@ class che_선양 extends Command\GeneralCommand{
return "{$destGeneralName}】에게 {$name}";
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -105,7 +123,7 @@ class che_선양 extends Command\GeneralCommand{
$destGeneralName = $destGeneral->getName();
$nationName = $this->nation['name'];
$logger = $general->getLogger();
$destLogger = $destGeneral->getLogger();
@@ -138,26 +156,26 @@ class che_선양 extends Command\GeneralCommand{
//TODO: 암행부처럼 보여야...
$db = DB::db();
$destRawGenerals = $db->query('SELECT no,name,officer_level,npc FROM general WHERE nation != 0 AND nation = %i AND no != %i ORDER BY npc,binary(name)',$this->generalObj->getNationID(), $this->generalObj->getID());
$destRawGenerals = $db->query('SELECT no,name,officer_level,npc FROM general WHERE nation != 0 AND nation = %i AND no != %i ORDER BY npc,binary(name)', $this->generalObj->getNationID(), $this->generalObj->getID());
ob_start();
?>
군주의 자리를 다른 장수에게 물려줍니다.<br>
장수를 선택하세요.<br>
<select class='formInput' name="destGeneralID" id="destGeneralID" size='1' style='color:white;background-color:black;'>
<?php foreach($destRawGenerals as $destGeneral):
$color = \sammo\getNameColor($destGeneral['npc']);
if($color){
$color = " style='color:{$color}'";
}
$name = $destGeneral['name'];
if($destGeneral['officer_level'] >= 5){
$name = "*{$name}*";
}
?>
<option value='<?=$destGeneral['no']?>' <?=$color?>><?=$name?></option>
<?php endforeach; ?>
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
군주의 자리를 다른 장수에게 물려줍니다.<br>
장수를 선택하세요.<br>
<select class='formInput' name="destGeneralID" id="destGeneralID" size='1' style='color:white;background-color:black;'>
<?php foreach ($destRawGenerals as $destGeneral) :
$color = \sammo\getNameColor($destGeneral['npc']);
if ($color) {
$color = " style='color:{$color}'";
}
$name = $destGeneral['name'];
if ($destGeneral['officer_level'] >= 5) {
$name = "*{$name}*";
}
?>
<option value='<?= $destGeneral['no'] ?>' <?= $color ?>><?= $name ?></option>
<?php endforeach; ?>
</select> <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
<?php
return ob_get_clean();
}
}
}
@@ -33,7 +33,7 @@ class che_소집해제 extends Command\GeneralCommand{
$this->setCity();
$this->setNation();
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::ReqGeneralCrew(),
];
@@ -58,7 +58,7 @@ class che_소집해제 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+81 -56
View File
@@ -1,18 +1,24 @@
<?php
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil, Session, KVStorage,
General,
use\sammo\{
DB,
Util,
JosaUtil,
Session,
KVStorage,
General,
ActionLogger,
GameConst, GameUnitConst,
GameConst,
GameUnitConst,
LastTurn,
Command,
ServConfig
};
use function \sammo\{
use function\sammo\{
getDexCall,
getTechCall,
tryUniqueItemLottery,
@@ -24,7 +30,8 @@ use \sammo\Constraint\ConstraintHelper;
class che_숙련전환 extends Command\GeneralCommand{
class che_숙련전환 extends Command\GeneralCommand
{
static protected $actionName = '숙련전환';
static public $reqArg = true;
@@ -36,103 +43,121 @@ class che_숙련전환 extends Command\GeneralCommand{
protected $destArmType;
/** @var string */
protected $destArmTypeName;
protected function argTest():bool{
if($this->arg === null){
protected function argTest(): bool
{
if ($this->arg === null) {
return false;
}
if(!key_exists('srcArmType', $this->arg)){
if (!key_exists('srcArmType', $this->arg)) {
return false;
}
if(!key_exists('destArmType', $this->arg)){
if (!key_exists('destArmType', $this->arg)) {
return false;
}
$srcArmType = $this->arg['srcArmType'];
$destArmType = $this->arg['destArmType'];
if(!is_int($srcArmType)){
if (!is_int($srcArmType)) {
return false;
}
if(!key_exists($srcArmType, GameUnitConst::allType())){
if (!key_exists($srcArmType, GameUnitConst::allType())) {
return false;
}
if(!is_int($destArmType)){
if (!is_int($destArmType)) {
return false;
}
if(!key_exists($destArmType, GameUnitConst::allType())){
if (!key_exists($destArmType, GameUnitConst::allType())) {
return false;
}
if($srcArmType === $destArmType){
if ($srcArmType === $destArmType) {
return false;
}
$this->arg = [
'srcArmType'=>$srcArmType,
'destArmType'=>$destArmType
'srcArmType' => $srcArmType,
'destArmType' => $destArmType
];
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$this->setCity();
$this->setNation();
[$reqGold, $reqRice] = $this->getCost();
$this->minConditionConstraints = [
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::ReqGeneralGold($reqGold),
ConstraintHelper::ReqGeneralRice($reqRice),
];
}
protected function initWithArg()
{
$this->srcArmType = $this->arg['srcArmType'];
$this->srcArmTypeName = GameUnitConst::allType()[$this->srcArmType];
$this->destArmType = $this->arg['destArmType'];
$this->destArmTypeName = GameUnitConst::allType()[$this->destArmType];
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
ConstraintHelper::NotBeNeutral(),
$this->fullConditionConstraints = [
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::ReqGeneralGold($reqGold),
ConstraintHelper::ReqGeneralRice($reqRice),
];
}
public function getBrief():string{
public function getBrief(): string
{
return "{$this->srcArmTypeName}】숙련을 【{$this->destArmTypeName}】숙련으로 전환";
}
public function getCommandDetailTitle():string{
public function getCommandDetailTitle(): string
{
$name = $this->getName();
[$reqGold, $reqRice] = $this->getCost();
$title = "{$name}(통솔경험";
if($reqGold > 0){
if ($reqGold > 0) {
$title .= ", 자금{$reqGold}";
}
if($reqRice > 0){
if ($reqRice > 0) {
$title .= ", 군량{$reqRice}";
}
$title .= ')';
return $title;
}
public function getCost():array{
public function getCost(): array
{
$env = $this->env;
return [$env['develcost'], $env['develcost']];
}
public function getPreReqTurn():int{
public function getPreReqTurn(): int
{
return 0;
}
public function getPostReqTurn():int{
public function getPostReqTurn(): int
{
return 0;
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -143,14 +168,14 @@ class che_숙련전환 extends Command\GeneralCommand{
$logger = $general->getLogger();
$srcDex = $general->getVar('dex'.$this->srcArmType);
$srcDex = $general->getVar('dex' . $this->srcArmType);
$cutDex = Util::toInt($srcDex * 0.3);
$cutDexText = number_format($cutDex);
$addDex = Util::toInt($cutDex * 2 / 3);
$addDexText = number_format($addDex);
$general->increaseVar('dex'.$this->srcArmType, -$cutDex);
$general->increaseVar('dex'.$this->destArmType, $addDex);
$general->increaseVar('dex' . $this->srcArmType, -$cutDex);
$general->increaseVar('dex' . $this->destArmType, $addDex);
$josaUl = JosaUtil::pick($cutDex, '을');
$josaRo = JosaUtil::pick($addDex, '로');
@@ -170,17 +195,17 @@ class che_숙련전환 extends Command\GeneralCommand{
return true;
}
public function getForm(): string
{
$db = DB::db();
$general = $this->generalObj;
$dexSrcTexts = [];
$dexDestTexts = [];
foreach(GameUnitConst::allType() as $armType => $armName){
$dexVal = $general->getVar('dex'.$armType);
foreach (GameUnitConst::allType() as $armType => $armName) {
$dexVal = $general->getVar('dex' . $armType);
$dexValText = number_format($dexVal);
$cutDex = Util::toInt($dexVal * 0.3);
$addDex = Util::toInt($cutDex * 2 / 3);
@@ -195,23 +220,23 @@ class che_숙련전환 extends Command\GeneralCommand{
ob_start();
?>
본인의 특정 병종 숙련을 30% 줄이고, 줄어든 숙련 중 2/3(20%p)를 다른 병종 숙련으로 전환합니다.<br>
본인의 특정 병종 숙련을 30% 줄이고, 줄어든 숙련 중 2/3(20%p)를 다른 병종 숙련으로 전환합니다.<br>
<select class='formInput' name="srcArmType" id="srcArmType" size='1' style='color:white;background-color:black;'>
<?php foreach($dexSrcTexts as $armType=>$infoText): ?>
<option value="<?=$armType?>"><?=$infoText?></option>
<?php endforeach; ?>
</select>
숙련을
<select class='formInput' name="srcArmType" id="srcArmType" size='1' style='color:white;background-color:black;'>
<?php foreach ($dexSrcTexts as $armType => $infoText) : ?>
<option value="<?= $armType ?>"><?= $infoText ?></option>
<?php endforeach; ?>
</select>
숙련을
<select class='formInput' name="destArmType" id="destArmType" size='1' style='color:white;background-color:black;'>
<?php foreach($dexDestTexts as $armType=>$infoText): ?>
<option value="<?=$armType?>"><?=$infoText?></option>
<?php endforeach; ?>
</select>
숙련으로 <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
<select class='formInput' name="destArmType" id="destArmType" size='1' style='color:white;background-color:black;'>
<?php foreach ($dexDestTexts as $armType => $infoText) : ?>
<option value="<?= $armType ?>"><?= $infoText ?></option>
<?php endforeach; ?>
</select>
숙련으로 <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
<?php
return ob_get_clean();
}
}
}
+2 -2
View File
@@ -34,7 +34,7 @@ class che_요양 extends Command\GeneralCommand{
$this->setNation();
$this->runnableConstraints=[
$this->fullConditionConstraints=[
];
}
@@ -52,7 +52,7 @@ class che_요양 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+69 -44
View File
@@ -1,17 +1,21 @@
<?php
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
General,
use\sammo\{
DB,
Util,
JosaUtil,
General,
ActionLogger,
GameConst, GameUnitConst,
GameConst,
GameUnitConst,
LastTurn,
Command
};
use function \sammo\{
use function\sammo\{
tryUniqueItemLottery,
printCitiesBasedOnDistance
};
@@ -22,83 +26,103 @@ use sammo\CityConst;
class che_이동 extends Command\GeneralCommand{
class che_이동 extends Command\GeneralCommand
{
static protected $actionName = '이동';
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
protected function argTest(): bool
{
if ($this->arg === null) {
return false;
}
if(!key_exists('destCityID', $this->arg)){
if (!key_exists('destCityID', $this->arg)) {
return false;
}
if(!key_exists($this->arg['destCityID'], CityConst::all())){
if (!key_exists($this->arg['destCityID'], CityConst::all())) {
return false;
}
$this->arg = [
'destCityID'=>$this->arg['destCityID']
'destCityID' => $this->arg['destCityID']
];
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$this->setCity();
$this->setNation();
$this->setDestCity($this->arg['destCityID'], []);
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
ConstraintHelper::NotSameDestCity(),
$this->minConditionConstraints = [
ConstraintHelper::ReqGeneralGold($reqGold),
ConstraintHelper::ReqGeneralRice($reqRice),
];
}
protected function initWithArg()
{
$this->setDestCity($this->arg['destCityID'], true);
[$reqGold, $reqRice] = $this->getCost();
$this->fullConditionConstraints = [
ConstraintHelper::NotSameDestCity(),
ConstraintHelper::NearCity(1),
ConstraintHelper::ReqGeneralGold($reqGold),
ConstraintHelper::ReqGeneralRice($reqRice),
];
}
public function getCommandDetailTitle():string{
public function getCommandDetailTitle(): string
{
$name = $this->getName();
[$reqGold, $reqRice] = $this->getCost();
$title = "{$name}(통솔경험";
if($reqGold > 0){
if ($reqGold > 0) {
$title .= ", 자금{$reqGold}";
}
if($reqRice > 0){
if ($reqRice > 0) {
$title .= ", 군량{$reqRice}";
}
$title .= ', 사기↓)';
return $title;
}
public function getCost():array{
public function getCost(): array
{
$env = $this->env;
return [$env['develcost'], 0];
}
public function getPreReqTurn():int{
public function getPreReqTurn(): int
{
return 0;
}
public function getPostReqTurn():int{
public function getPostReqTurn(): int
{
return 0;
}
public function getBrief():string{
public function getBrief(): string
{
$commandName = $this->getName();
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
$josaRo = JosaUtil::pick($destCityName, '로');
return "{$destCityName}{$josaRo} {$commandName}";
}
public function getFailString():string{
public function getFailString(): string
{
$commandName = $this->getName();
$failReason = $this->testRunnable();
if($failReason === null){
$failReason = $this->testFullConditionMet();
if ($failReason === null) {
throw new \RuntimeException('실행 가능한 커맨드에 대해 실패 이유를 수집');
}
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
@@ -106,8 +130,9 @@ class che_이동 extends Command\GeneralCommand{
return "{$failReason} <G><b>{$destCityName}</b></>{$josaRo} {$commandName} 실패.";
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -129,14 +154,14 @@ class che_이동 extends Command\GeneralCommand{
$general->setVar('city', $destCityID);
if($general->getVar('officer_level') == 12 && $this->nation['level'] == 0){
if ($general->getVar('officer_level') == 12 && $this->nation['level'] == 0) {
$generalList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND no!=%i', $general->getNationID(), $general->getID());
if($generalList){
if ($generalList) {
$db->update('general', [
'city'=>$destCityID
'city' => $destCityID
], 'no IN %li', $generalList);
}
foreach($generalList as $targetGeneralID){
foreach ($generalList as $targetGeneralID) {
$targetLogger = new ActionLogger($targetGeneralID, $general->getNationID(), $env['year'], $env['month']);
$targetLogger->pushGeneralActionLog("방랑군 세력이 <G><b>{$destCityName}</b></>{$josaRo} 이동했습니다.", ActionLogger::PLAIN);
$targetLogger->flush();
@@ -168,17 +193,17 @@ class che_이동 extends Command\GeneralCommand{
ob_start();
?>
<?=\sammo\getMapHtml()?><br>
선택된 도시로 이동합니다.<br>
인접 도시로만 이동이 가능합니다.<br>
목록을 선택하거나 도시를 클릭하세요.<br>
<?=$currentCityName?> => <select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'><br>
<?=\sammo\optionsForCities()?><br>
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
<br>
<br>
<?=printCitiesBasedOnDistance($currentCityID, 1)?>
<?= \sammo\getMapHtml() ?><br>
선택된 도시로 이동합니다.<br>
인접 도시로만 이동이 가능합니다.<br>
목록을 선택하거나 도시를 클릭하세요.<br>
<?= $currentCityName ?> => <select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'><br>
<?= \sammo\optionsForCities() ?><br>
</select> <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
<br>
<br>
<?= printCitiesBasedOnDistance($currentCityID, 1) ?>
<?php
return ob_get_clean();
}
}
}
@@ -40,7 +40,7 @@ class che_인재탐색 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotWanderingNation(),
ConstraintHelper::ReqGeneralGold($reqGold),
@@ -51,7 +51,7 @@ class che_인재탐색 extends Command\GeneralCommand{
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} 탐색이 제한되고 있습니다.");
$this->fullConditionConstraints[] = ConstraintHelper::AlwaysFail("현재 <D>{$nationName}</>{$josaUn} 탐색이 제한되고 있습니다.");
}
}
@@ -84,7 +84,7 @@ class che_인재탐색 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+19 -12
View File
@@ -82,6 +82,22 @@ class che_임관 extends Command\GeneralCommand{
$this->setCity();
$this->setNation();
$relYear = $env['year'] - $env['startyear'];
$this->permissionConstraints=[
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다')
];
$this->minConditionConstraints=[
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
ConstraintHelper::BeNeutral(),
ConstraintHelper::AllowJoinAction()
];
}
protected function initWithArg()
{
$destGeneralID = $this->arg['destGeneralID']??null;
$destNationID = $this->arg['destNationID']??null;
if($destGeneralID !== null){
@@ -92,13 +108,9 @@ class che_임관 extends Command\GeneralCommand{
$this->setDestNation($destNationID, ['gennum', 'scout']);
}
$env = $this->env;
$relYear = $env['year'] - $env['startyear'];
$this->reservableConstraints=[
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다')
];
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
ConstraintHelper::BeNeutral(),
ConstraintHelper::ExistsDestNation(),
@@ -107,11 +119,6 @@ class che_임관 extends Command\GeneralCommand{
];
}
public function canDisplay(): bool
{
return ($this->env['join_mode']??'') != 'onlyRandom';
}
public function getCost():array{
return [0, 0];
}
@@ -132,7 +139,7 @@ class che_임관 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+15 -7
View File
@@ -63,14 +63,23 @@ class che_장비매매 extends Command\GeneralCommand{
$this->setCity();
$this->setNation();
$this->minConditionConstraints=[
ConstraintHelper::ReqCityTrader($general->getVar('npc')),
];
}
protected function initWithArg()
{
$general = $this->generalObj;
$itemType = $this->arg['itemType'];
$itemTypeName = static::$itemMap[$itemType];
$itemCode = $this->arg['itemCode'];
$itemClass = buildItemClass($itemCode);
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::ReqCityTrader($general->getVar('npc')),
ConstraintHelper::ReqCityCapacity('secu', '치안 수치', $itemClass->getReqSecu()),
ConstraintHelper::ReqGeneralGold($reqGold),
@@ -78,15 +87,14 @@ class che_장비매매 extends Command\GeneralCommand{
];
if($itemCode === 'None'){
$this->runnableConstraints[] = ConstraintHelper::ReqGeneralValue($itemType, $itemTypeName, '!=', 'None');
$this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralValue($itemType, $itemTypeName, '!=', 'None');
}
else if($itemCode == $general->getVar($itemType)){
$this->runnableConstraints[] = ConstraintHelper::AlwaysFail('이미 가지고 있습니다.');
$this->fullConditionConstraints[] = ConstraintHelper::AlwaysFail('이미 가지고 있습니다.');
}
else if($itemType != 'item' && !buildItemClass($general->getVar($itemType))->isBuyable()){
$this->runnableConstraints[] = ConstraintHelper::AlwaysFail('이미 진귀한 것을 가지고 있습니다.');
$this->fullConditionConstraints[] = ConstraintHelper::AlwaysFail('이미 진귀한 것을 가지고 있습니다.');
}
}
public function getCost():array{
@@ -128,7 +136,7 @@ class che_장비매매 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -37,7 +37,7 @@ class che_전투태세 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotWanderingNation(),
ConstraintHelper::OccupiedCity(),
@@ -65,7 +65,7 @@ class che_전투태세 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -44,7 +44,7 @@ class che_정착장려 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotWanderingNation(),
ConstraintHelper::OccupiedCity(),
@@ -118,7 +118,7 @@ class che_정착장려 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -44,7 +44,7 @@ class che_주민선정 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotWanderingNation(),
ConstraintHelper::OccupiedCity(),
@@ -119,7 +119,7 @@ class che_주민선정 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+89 -70
View File
@@ -1,9 +1,13 @@
<?php
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
General, DummyGeneral,
use\sammo\{
DB,
Util,
JosaUtil,
General,
DummyGeneral,
ActionLogger,
GameConst,
LastTurn,
@@ -11,9 +15,9 @@ use \sammo\{
Command
};
use function \sammo\{
use function\sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalRatioDomestic,
CriticalScoreEx,
tryUniqueItemLottery
};
@@ -22,108 +26,123 @@ use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
class che_증여 extends Command\GeneralCommand{
class che_증여 extends Command\GeneralCommand
{
static protected $actionName = '증여';
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
protected function argTest(): bool
{
if ($this->arg === null) {
return false;
}
//NOTE: 사망 직전에 '증여' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
if(!key_exists('isGold', $this->arg)){
if (!key_exists('isGold', $this->arg)) {
return false;
}
if(!key_exists('amount', $this->arg)){
if (!key_exists('amount', $this->arg)) {
return false;
}
if(!key_exists('destGeneralID', $this->arg)){
if (!key_exists('destGeneralID', $this->arg)) {
return false;
}
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
$destGeneralID = $this->arg['destGeneralID'];
if(!is_numeric($amount)){
if (!is_numeric($amount)) {
return false;
}
$amount = Util::round($amount, -2);
$amount = Util::valueFit($amount, 100, GameConst::$maxResourceActionAmount);
if($amount <= 0){
if ($amount <= 0) {
return false;
}
if(!is_bool($isGold)){
if (!is_bool($isGold)) {
return false;
}
if(!is_int($destGeneralID)){
if (!is_int($destGeneralID)) {
return false;
}
if($destGeneralID <= 0){
if ($destGeneralID <= 0) {
return false;
}
if($destGeneralID == $this->generalObj->getID()){
if ($destGeneralID == $this->generalObj->getID()) {
return false;
}
$this->arg = [
'isGold'=>$isGold,
'amount'=>$amount,
'destGeneralID'=>$destGeneralID
'isGold' => $isGold,
'amount' => $amount,
'destGeneralID' => $destGeneralID
];
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$this->setCity();
$this->setNation();
$this->minConditionConstraints = [
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::SuppliedCity(),
];
}
protected function initWithArg()
{
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'nation'], 1);
$this->setDestGeneral($destGeneral);
$this->runnableConstraints=[
ConstraintHelper::NotBeNeutral(),
$this->fullConditionConstraints = [
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::SuppliedCity(),
ConstraintHelper::ExistsDestGeneral(),
ConstraintHelper::FriendlyDestGeneral()
];
if($this->arg['isGold']){
$this->runnableConstraints[] = ConstraintHelper::ReqGeneralGold(GameConst::$generalMinimumGold);
if ($this->arg['isGold']) {
$this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralGold(GameConst::$generalMinimumGold);
} else {
$this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralRice(GameConst::$generalMinimumRice);
}
else{
$this->runnableConstraints[] = ConstraintHelper::ReqGeneralRice(GameConst::$generalMinimumRice);
}
}
public function getCommandDetailTitle():string{
public function getCommandDetailTitle(): string
{
$name = $this->getName();
return "{$name}(통솔경험)";
}
public function getCost():array{
public function getCost(): array
{
return [0, 0];
}
public function getPreReqTurn():int{
public function getPreReqTurn(): int
{
return 0;
}
public function getPostReqTurn():int{
public function getPostReqTurn(): int
{
return 0;
}
public function getBrief(): string
{
$destGeneralName = $this->destGeneralObj->getName();
$resText = $this->arg['isGold']?'금':'쌀';
$resText = $this->arg['isGold'] ? '금' : '쌀';
$name = $this->getName();
return "{$destGeneralName}】에게 {$resText} {$this->arg['amount']}{$name}";
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -134,13 +153,13 @@ class che_증여 extends Command\GeneralCommand{
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
$resKey = $isGold?'gold':'rice';
$resName = $isGold?'금':'쌀';
$resKey = $isGold ? 'gold' : 'rice';
$resName = $isGold ? '금' : '쌀';
$destGeneral = $this->destGeneralObj;
$amount = Util::valueFit($amount, 0, $general->getVar($resKey) - ($isGold?GameConst::$generalMinimumGold:GameConst::$generalMinimumRice));
$amount = Util::valueFit($amount, 0, $general->getVar($resKey) - ($isGold ? GameConst::$generalMinimumGold : GameConst::$generalMinimumRice));
$amountText = number_format($amount, 0);
$logger = $general->getLogger();
$destGeneral->increaseVarWithLimit($resKey, $amount);
@@ -169,35 +188,35 @@ class che_증여 extends Command\GeneralCommand{
//TODO: 암행부처럼 보여야...
$db = DB::db();
$destRawGenerals = $db->query('SELECT no,name,officer_level,npc,gold,rice FROM general WHERE nation != 0 AND nation = %i AND no != %i ORDER BY npc,binary(name)',$this->generalObj->getNationID(), $this->generalObj->getID());
$destRawGenerals = $db->query('SELECT no,name,officer_level,npc,gold,rice FROM general WHERE nation != 0 AND nation = %i AND no != %i ORDER BY npc,binary(name)', $this->generalObj->getNationID(), $this->generalObj->getID());
ob_start();
?>
자신의 자금이나 군량을 다른 장수에게 증여합니다.<br>
장수를 선택하세요.<br>
<select class='formInput' name="destGeneralID" id="destGeneralID" size='1' style='color:white;background-color:black;'>
<?php foreach($destRawGenerals as $destGeneral):
$color = \sammo\getNameColor($destGeneral['npc']);
if($color){
$color = " style='color:{$color}'";
}
$name = $destGeneral['name'];
if($destGeneral['officer_level'] >= 5){
$name = "*{$name}*";
}
?>
<option value='<?=$destGeneral['no']?>' <?=$color?>><?=$name?>(금:<?=$destGeneral['gold']?>, 쌀:<?=$destGeneral['rice']?>)</option>
<?php endforeach; ?>
</select>
<select class='formInput' name="isGold" id="isGold" size='1' style='color:white;background-color:black;'>
<option value="true">금</option>
<option value="false">쌀</option>
</select>
<select class='formInput' name="amount" id="amount" size='1' style='color:white;background-color:black;'>
<?php foreach(GameConst::$resourceActionAmountGuide as $amount): ?>
<option value='<?=$amount?>'><?=$amount?></option>
<?php endforeach; ?>
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
자신의 자금이나 군량을 다른 장수에게 증여합니다.<br>
장수를 선택하세요.<br>
<select class='formInput' name="destGeneralID" id="destGeneralID" size='1' style='color:white;background-color:black;'>
<?php foreach ($destRawGenerals as $destGeneral) :
$color = \sammo\getNameColor($destGeneral['npc']);
if ($color) {
$color = " style='color:{$color}'";
}
$name = $destGeneral['name'];
if ($destGeneral['officer_level'] >= 5) {
$name = "*{$name}*";
}
?>
<option value='<?= $destGeneral['no'] ?>' <?= $color ?>><?= $name ?>(금:<?= $destGeneral['gold'] ?>, 쌀:<?= $destGeneral['rice'] ?>)</option>
<?php endforeach; ?>
</select>
<select class='formInput' name="isGold" id="isGold" size='1' style='color:white;background-color:black;'>
<option value="true">금</option>
<option value="false">쌀</option>
</select>
<select class='formInput' name="amount" id="amount" size='1' style='color:white;background-color:black;'>
<?php foreach (GameConst::$resourceActionAmountGuide as $amount) : ?>
<option value='<?= $amount ?>'><?= $amount ?></option>
<?php endforeach; ?>
</select> <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
<?php
return ob_get_clean();
}
}
}
+2 -2
View File
@@ -38,7 +38,7 @@ class che_집합 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::SuppliedCity(),
@@ -65,7 +65,7 @@ class che_집합 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+178 -167
View File
@@ -1,18 +1,24 @@
<?php
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil, Session, KVStorage,
General,
use\sammo\{
DB,
Util,
JosaUtil,
Session,
KVStorage,
General,
ActionLogger,
GameConst, GameUnitConst,
GameConst,
GameUnitConst,
LastTurn,
Command,
ServConfig
};
use function \sammo\{
use function\sammo\{
getTechCall,
tryUniqueItemLottery,
getTechAbil
@@ -23,7 +29,8 @@ use \sammo\Constraint\ConstraintHelper;
class che_징병 extends Command\GeneralCommand{
class che_징병 extends Command\GeneralCommand
{
static protected $actionName = '징병';
static protected $costOffset = 1;
static public $reqArg = true;
@@ -37,7 +44,7 @@ class che_징병 extends Command\GeneralCommand{
protected $reqCrewType;
/** @var \sammo\GameUnitDetail */
protected $currCrewType;
static protected $isInitStatic = false;
protected static function initStatic()
{
@@ -45,52 +52,64 @@ class che_징병 extends Command\GeneralCommand{
static::$defaultAtmos = GameConst::$defaultAtmosLow;
}
protected function argTest():bool{
if($this->arg === null){
protected function argTest(): bool
{
if ($this->arg === null) {
return false;
}
if(!key_exists('crewType', $this->arg)){
if (!key_exists('crewType', $this->arg)) {
return false;
}
if(!key_exists('amount', $this->arg)){
if (!key_exists('amount', $this->arg)) {
return false;
}
$crewType = $this->arg['crewType'];
$amount = $this->arg['amount'];
if(!is_int($crewType)){
if (!is_int($crewType)) {
return false;
}
if(!is_numeric($amount)){
if (!is_numeric($amount)) {
return false;
}
$amount = (int)$amount;
$amount = (int) $amount;
if(GameUnitConst::byID($crewType) === null){
if (GameUnitConst::byID($crewType) === null) {
return false;
}
if($amount < 0){
if ($amount < 0) {
return false;
}
$this->arg = [
'crewType'=>$crewType,
'amount'=>$amount
'crewType' => $crewType,
'amount' => $amount
];
return true;
}
protected function init(){
$general = $this->generalObj;
protected function init()
{
$this->setCity();
$this->setNation(['tech']);
$this->minConditionConstraints = [
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::ReqCityCapacity('pop', '주민', GameConst::$minAvailableRecruitPop + 100),
ConstraintHelper::ReqCityTrust(20),
];
}
protected function initWithArg()
{
$general = $this->generalObj;
$leadership = $general->getLeadership(false);
$currCrewType = $general->getCrewTypeObj();
$maxCrew = $leadership * 100;
$reqCrewType = GameUnitConst::byID($this->arg['crewType']);
if($reqCrewType->id == $currCrewType->id){
if ($reqCrewType->id == $currCrewType->id) {
$maxCrew -= $general->getVar('crew');
}
$this->maxCrew = Util::valueFit($this->arg['amount'], 100, $maxCrew);
@@ -100,9 +119,9 @@ class che_징병 extends Command\GeneralCommand{
$this->currCrewType = $currCrewType;
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
ConstraintHelper::NotBeNeutral(),
$this->fullConditionConstraints = [
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::ReqCityCapacity('pop', '주민', GameConst::$minAvailableRecruitPop + $reqCrew),
ConstraintHelper::ReqCityTrust(20),
@@ -111,26 +130,28 @@ class che_징병 extends Command\GeneralCommand{
ConstraintHelper::ReqGeneralCrewMargin($reqCrewType->id),
ConstraintHelper::AvailableRecruitCrewType($reqCrewType->id)
];
}
public function getBrief():string{
public function getBrief(): string
{
$crewTypeName = $this->reqCrewType->name;
$amount = $this->reqCrew;
$commandName = static::getName();
return "{$crewTypeName}{$amount}{$commandName}";
}
public function getCommandDetailTitle():string{
public function getCommandDetailTitle(): string
{
return "{$this->getName()}(통솔경험)";
}
public function getCost():array{
if(!$this->isArgValid){
public function getCost(): array
{
if (!$this->isArgValid) {
return [0, 0];
}
$reqGold = $this->reqCrewType->costWithTech($this->nation['tech'], $this->maxCrew);
$reqGold = $this->generalObj->onCalcDomestic('징병', 'cost', $reqGold, ['armType'=>$this->reqCrewType->armType]);
$reqGold = $this->generalObj->onCalcDomestic('징병', 'cost', $reqGold, ['armType' => $this->reqCrewType->armType]);
$reqGold *= static::$costOffset;
$reqRice = $this->maxCrew / 100;
@@ -138,17 +159,20 @@ class che_징병 extends Command\GeneralCommand{
$reqRice = Util::round($reqRice);
return [$reqGold, $reqRice];
}
public function getPreReqTurn():int{
public function getPreReqTurn(): int
{
return 0;
}
public function getPostReqTurn():int{
public function getPostReqTurn(): int
{
return 0;
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -168,7 +192,7 @@ class che_징병 extends Command\GeneralCommand{
$logger = $general->getLogger();
if($reqCrewType->id == $currCrewType->id && $currCrew > 0){
if ($reqCrewType->id == $currCrewType->id && $currCrew > 0) {
$logger->pushGeneralActionLog("{$crewTypeName} <C>{$reqCrewText}</>명을 추가{$this->getName()}했습니다. <1>$date</>");
$train = ($currCrew * $general->getVar('train') + $reqCrew * static::$defaultTrain) / ($currCrew + $reqCrew);
$atmos = ($currCrew * $general->getVar('atmos') + $reqCrew * static::$defaultAtmos) / ($currCrew + $reqCrew);
@@ -176,8 +200,7 @@ class che_징병 extends Command\GeneralCommand{
$general->increaseVar('crew', $reqCrew);
$general->setVar('train', $train);
$general->setVar('atmos', $atmos);
}
else{
} else {
$logger->pushGeneralActionLog("{$crewTypeName} <C>{$reqCrewText}</>명을 {$this->getName()}했습니다. <1>$date</>");
$general->setVar('crewtype', $reqCrewType->id);
$general->setVar('crew', $reqCrew);
@@ -188,10 +211,10 @@ class che_징병 extends Command\GeneralCommand{
$newTrust = Util::valueFit($this->city['trust'] - ($reqCrew / $this->city['pop']) / static::$costOffset * 100, 0);
$db->update('city', [
'trust'=>$newTrust,
'pop'=>$this->city['pop'] - $reqCrew
'trust' => $newTrust,
'pop' => $this->city['pop'] - $reqCrew
], 'city=%i', $general->getCityID());
$exp = Util::round($reqCrew / 100);
$ded = Util::round($reqCrew / 100);
@@ -219,7 +242,7 @@ class che_징병 extends Command\GeneralCommand{
'js/recruitCrewForm.js'
];
}
public function getForm(): string
{
$db = DB::db();
@@ -227,74 +250,72 @@ class che_징병 extends Command\GeneralCommand{
$general = $this->generalObj;
[$nationLevel, $tech] = $db->queryFirstList('SELECT level,tech FROM nation WHERE nation=%i', $general->getNationID());
if(!$nationLevel){
if (!$nationLevel) {
$nationLevel = 0;
}
if(!$tech){
if (!$tech) {
$tech = 0;
}
$ownCities = [];
$ownRegions = [];
$year = $this->env['year'];
$startyear = $this->env['startyear'];
$relativeYear = $year - $startyear;
foreach(DB::db()->query('SELECT city, region from city where nation = %i', $general->getNationID()) as $city){
foreach (DB::db()->query('SELECT city, region from city where nation = %i', $general->getNationID()) as $city) {
$ownCities[$city['city']] = 1;
$ownRegions[$city['region']] = 1;
}
$leadership = $general->getLeadership();
$fullLeadership = $general->getLeadership(false);
$abil = getTechAbil($tech);
$armTypes = [];
foreach(GameUnitConst::allType() as $armType => $armName){
foreach (GameUnitConst::allType() as $armType => $armName) {
$armTypeCrews = [];
foreach(GameUnitConst::byType($armType) as $unit){
foreach (GameUnitConst::byType($armType) as $unit) {
$crewObj = new \stdClass;
$crewObj->showDefault = 'true';
$crewObj->id = $unit->id;
if($unit->reqTech == 0){
if ($unit->reqTech == 0) {
$crewObj->bgcolor = 'green';
}
else{
} else {
$crewObj->bgcolor = 'limegreen';
}
if(!$unit->isValid($ownCities, $ownRegions, $relativeYear, $tech)){
if (!$unit->isValid($ownCities, $ownRegions, $relativeYear, $tech)) {
$crewObj->showDefault = 'false';
$crewObj->bgcolor = 'red';
}
$crewObj->baseRice = $general->onCalcDomestic($this->getName(), 'rice', $unit->riceWithTech($tech), ['armType'=>$unit->armType]);
$crewObj->baseCost = $general->onCalcDomestic($this->getName(), 'cost', $unit->costWithTech($tech), ['armType'=>$unit->armType]);
$crewObj->baseRice = $general->onCalcDomestic($this->getName(), 'rice', $unit->riceWithTech($tech), ['armType' => $unit->armType]);
$crewObj->baseCost = $general->onCalcDomestic($this->getName(), 'cost', $unit->costWithTech($tech), ['armType' => $unit->armType]);
$crewObj->name = $unit->name;
$crewObj->attack = $unit->attack + $abil;
$crewObj->defence = $unit->defence + $abil;
$crewObj->speed = $unit->speed;
$crewObj->avoid = $unit->avoid;
if($this->env['show_img_level'] < 2) {
$crewObj->img = ServConfig::$sharedIconPath."/default.jpg";
if ($this->env['show_img_level'] < 2) {
$crewObj->img = ServConfig::$sharedIconPath . "/default.jpg";
} else {
$crewObj->img = ServConfig::$gameImagePath . "/crewtype" . $unit->id . ".png";
}
else{
$crewObj->img = ServConfig::$gameImagePath."/crewtype".$unit->id.".png";
}
$crewObj->baseRiceShort = round($crewObj->baseRice, 1);
$crewObj->baseCostShort = round($crewObj->baseCost, 1);
$crewObj->info = join('<br>', $unit->info);
$armTypeCrews[] = $crewObj;
}
$armTypes[] = [$armName, $armTypeCrews];
@@ -310,100 +331,90 @@ class che_징병 extends Command\GeneralCommand{
ob_start();
?>
<font size=2>병사를 모집합니다.
<?php if($commandName=='징병'): ?>
훈련과 사기치는 낮지만 가격이 저렴합니다.<br>
<?php else: ?>
훈련과 사기치는 높지만 자금이 많이 듭니다.
<?php endif; ?>
가능한 수보다 많게 입력하면 가능한 최대 병사를 모집합니다.<br>
이미 병사가 있는 경우 추가<?=$commandName?>되며, 병종이 다를경우는 기존의 병사는 소집해제됩니다.<br>
현재 <?=$commandName?> 가능한 병종은 <font color=green>녹색</font>으로 표시되며,<br>
현재 <?=$commandName?> 가능한 특수병종은 <font color=limegreen>초록색</font>으로 표시됩니다.<br>
<font size=2>병사를 모집합니다.
<?php if ($commandName == '징병') : ?>
훈련과 사기치는 낮지만 가격이 저렴합니다.<br>
<?php else : ?>
훈련과 사기치는 높지만 자금이 많이 듭니다.
<?php endif; ?>
가능한 수보다 많게 입력하면 가능한 최대 병사를 모집합니다.<br>
이미 병사가 있는 경우 추가<?= $commandName ?>되며, 병종이 다를경우는 기존의 병사는 소집해제됩니다.<br>
현재 <?= $commandName ?> 가능한 병종은 <font color=green>녹색</font>으로 표시되며,<br>
현재 <?= $commandName ?> 가능한 특수병종은 <font color=limegreen>초록색</font>으로 표시됩니다.<br>
<table class='tb_layout' style='margin:auto;'>
<thead>
<tr><td colspan=11><div style='float:right'><input type='checkbox' id="show_unavailable_troops">불가능한 병종 표시</input></div>
<?php if($commandName=='모병'): ?>
<div style='text-align:center;'>모병은 가격 2배의 자금이 소요됩니다.</div>
<?php endif; ?>
</td></tr>
<tr>
<td colspan=11 align=center class='bg2'>
현재 기술력 : <?=$techLevelText?>
현재 통솔 : <?=$leadership?><?=($leadership!=$fullLeadership)?"({$fullLeadership})":''?>
현재 병종 : <?=$crewTypeObj->name?>
현재 병사 : <?=$crew?>
현재 자금 : <?=$gold?>
</td>
</tr>
<tr>
<td width=64 align=center class='bg1'>사진</td>
<td width=64 align=center class='bg1'>병종</td>
<td width=40 align=center class='bg1'>공격</td>
<td width=40 align=center class='bg1'>방어</td>
<td width=40 align=center class='bg1'>기동</td>
<td width=40 align=center class='bg1'>회피</td>
<td width=40 align=center class='bg1'>가격</td>
<td width=40 align=center class='bg1'>군량</td>
<td width=180 align=center class='bg1'>병사수</td>
<td width=50 align=center class='bg1'>행동</td>
<td width=300 align=center class='bg1'>특징</td>
</tr>
</thead>
<tbody>
<?php foreach($armTypes as [$armName,$armTypeCrews]): ?>
<tr><td colspan=11><?=$armName?> 계열</td></tr>
<?php foreach($armTypeCrews as $crewObj): ?>
<tr
id="crewType<?=$crewObj->id?>"
class="show_default_<?=$crewObj->showDefault?>"
style='height:64px;background-color:<?=$crewObj->bgcolor?>'
data-rice="<?=$crewObj->baseRice?>"
data-cost="<?=$crewObj->baseCost?>"
>
<td style='background:#222222 no-repeat center url("<?=$crewObj->img?>");background-size:64px'></td>
<td style='text-align:center;vertical-align:middle;'><?=$crewObj->name?></td>
<td style='text-align:center;vertical-align:middle;'><?=$crewObj->attack?></td>
<td style='text-align:center;vertical-align:middle;'><?=$crewObj->defence?></td>
<td style='text-align:center;vertical-align:middle;'><?=$crewObj->speed?></td>
<td style='text-align:center;vertical-align:middle;'><?=$crewObj->avoid?></td>
<td style='text-align:center;vertical-align:middle;'><?=$crewObj->baseCostShort?></td>
<td style='text-align:center;vertical-align:middle;'><?=$crewObj->baseRiceShort?></td>
<td style='text-align:center;vertical-align:middle;' class='input_form' data-crewtype='<?=$crewObj->id?>'>
<input type=button value='절반' class='btn_half'
><input type=button value='채우기' class='btn_fill'
><input type=button value='가득' class='btn_full'
><br>
<input type=text data-crewtype='<?=$crewObj->id?>' class=form_double name=double maxlength=3 size=3
style=text-align:right;color:white;background-color:black
>00명
<input type=text class=form_cost name=cost maxlength=5 size=5 readonly
style=text-align:right;color:white;background-color:black>원
</td>
<td style='position:relative;height:64px;'><input
type=submit value='<?=$commandName?>' class='submit_btn'
style='width:100%;height:44px;margin:10px 0;display:block;position: absolute;left:0;top:0;'
></td>
<td><?=$crewObj->info?></td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</tbody>
</table>
<input type='hidden' id='amount' value='1'>
<input type='hidden' id='crewType' value='<?=$crewTypeObj->id?>'>
<script>
window.currentTech = <?=$tech?>;
window.leadership = <?=$leadership?>;
window.fullLeadership = <?=$fullLeadership?>;
window.currentCrewType = <?=$crewTypeObj->id?>;
window.currentCrew = <?=$crew?>;
window.currentGold = <?=$gold?>;
window.is모병 = <?=($this->getName()=='모병')?'true':'false'?>;
</script>
<?php
<table class='tb_layout' style='margin:auto;'>
<thead>
<tr>
<td colspan=11>
<div style='float:right'><input type='checkbox' id="show_unavailable_troops">불가능한 병종 표시</input></div>
<?php if ($commandName == '모병') : ?>
<div style='text-align:center;'>모병은 가격 2배의 자금이 소요됩니다.</div>
<?php endif; ?>
</td>
</tr>
<tr>
<td colspan=11 align=center class='bg2'>
현재 기술력 : <?= $techLevelText ?>
현재 통솔 : <?= $leadership ?><?= ($leadership != $fullLeadership) ? "({$fullLeadership})" : '' ?>
현재 병종 : <?= $crewTypeObj->name ?>
현재 병사 : <?= $crew ?>
현재 자금 : <?= $gold ?>
</td>
</tr>
<tr>
<td width=64 align=center class='bg1'>사진</td>
<td width=64 align=center class='bg1'>병종</td>
<td width=40 align=center class='bg1'>공격</td>
<td width=40 align=center class='bg1'>방어</td>
<td width=40 align=center class='bg1'>기동</td>
<td width=40 align=center class='bg1'>회피</td>
<td width=40 align=center class='bg1'>가격</td>
<td width=40 align=center class='bg1'>군량</td>
<td width=180 align=center class='bg1'>병사수</td>
<td width=50 align=center class='bg1'>행동</td>
<td width=300 align=center class='bg1'>특징</td>
</tr>
</thead>
<tbody>
<?php foreach ($armTypes as [$armName, $armTypeCrews]) : ?>
<tr>
<td colspan=11><?= $armName ?> 계열</td>
</tr>
<?php foreach ($armTypeCrews as $crewObj) : ?>
<tr id="crewType<?= $crewObj->id ?>" class="show_default_<?= $crewObj->showDefault ?>" style='height:64px;background-color:<?= $crewObj->bgcolor ?>' data-rice="<?= $crewObj->baseRice ?>" data-cost="<?= $crewObj->baseCost ?>">
<td style='background:#222222 no-repeat center url("<?= $crewObj->img ?>");background-size:64px'></td>
<td style='text-align:center;vertical-align:middle;'><?= $crewObj->name ?></td>
<td style='text-align:center;vertical-align:middle;'><?= $crewObj->attack ?></td>
<td style='text-align:center;vertical-align:middle;'><?= $crewObj->defence ?></td>
<td style='text-align:center;vertical-align:middle;'><?= $crewObj->speed ?></td>
<td style='text-align:center;vertical-align:middle;'><?= $crewObj->avoid ?></td>
<td style='text-align:center;vertical-align:middle;'><?= $crewObj->baseCostShort ?></td>
<td style='text-align:center;vertical-align:middle;'><?= $crewObj->baseRiceShort ?></td>
<td style='text-align:center;vertical-align:middle;' class='input_form' data-crewtype='<?= $crewObj->id ?>'>
<input type=button value='절반' class='btn_half'><input type=button value='채우기' class='btn_fill'><input type=button value='가득' class='btn_full'><br>
<input type=text data-crewtype='<?= $crewObj->id ?>' class=form_double name=double maxlength=3 size=3 style=text-align:right;color:white;background-color:black>00명
<input type=text class=form_cost name=cost maxlength=5 size=5 readonly style=text-align:right;color:white;background-color:black>원
</td>
<td style='position:relative;height:64px;'><input type=submit value='<?= $commandName ?>' class='submit_btn' style='width:100%;height:44px;margin:10px 0;display:block;position: absolute;left:0;top:0;'></td>
<td><?= $crewObj->info ?></td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</tbody>
</table>
<input type='hidden' id='amount' value='1'>
<input type='hidden' id='crewType' value='<?= $crewTypeObj->id ?>'>
<script>
window.currentTech = <?= $tech ?>;
window.leadership = <?= $leadership ?>;
window.fullLeadership = <?= $fullLeadership ?>;
window.currentCrewType = <?= $crewTypeObj->id ?>;
window.currentCrew = <?= $crew ?>;
window.currentGold = <?= $gold ?>;
window.is모병 = <?= ($this->getName() == '모병') ? 'true' : 'false' ?>;
</script>
<?php
return ob_get_clean();
}
}
}
+80 -63
View File
@@ -1,17 +1,21 @@
<?php
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
General,
use\sammo\{
DB,
Util,
JosaUtil,
General,
ActionLogger,
GameConst, GameUnitConst,
GameConst,
GameUnitConst,
LastTurn,
Command
};
use function \sammo\{
use function\sammo\{
tryUniqueItemLottery,
searchDistance,
printCitiesBasedOnDistance
@@ -23,89 +27,111 @@ use sammo\CityConst;
class che_첩보 extends Command\GeneralCommand{
class che_첩보 extends Command\GeneralCommand
{
static protected $actionName = '첩보';
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
protected function argTest(): bool
{
if ($this->arg === null) {
return false;
}
if(!key_exists('destCityID', $this->arg)){
if (!key_exists('destCityID', $this->arg)) {
return false;
}
if(!key_exists($this->arg['destCityID'], CityConst::all())){
if (!key_exists($this->arg['destCityID'], CityConst::all())) {
return false;
}
$this->arg = [
'destCityID'=>$this->arg['destCityID']
'destCityID' => $this->arg['destCityID']
];
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$this->setCity();
$this->setNation(['tech']);
$this->setDestCity($this->arg['destCityID'], null);
$this->setDestNation($this->destCity['nation'], ['tech']);
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
$this->minConditionConstraints = [
ConstraintHelper::NotOccupiedDestCity(),
ConstraintHelper::ReqGeneralGold($reqGold),
ConstraintHelper::ReqGeneralRice($reqRice),
];
}
public function getBrief():string{
protected function initWithArg()
{
$this->setDestCity($this->arg['destCityID']);
$this->setDestNation($this->destCity['nation'], ['tech']);
[$reqGold, $reqRice] = $this->getCost();
$this->fullConditionConstraints = [
ConstraintHelper::NotOccupiedDestCity(),
ConstraintHelper::ReqGeneralGold($reqGold),
ConstraintHelper::ReqGeneralRice($reqRice),
];
}
public function getBrief(): string
{
$cityName = $this->destCity['name'];
return "{$cityName}】에 {$this->getName()} 실행";
}
public function getCommandDetailTitle():string{
public function getCommandDetailTitle(): string
{
$name = $this->getName();
[$reqGold, $reqRice] = $this->getCost();
$title = "{$name}(통솔경험";
if($reqGold > 0){
if ($reqGold > 0) {
$title .= ", 자금{$reqGold}";
}
if($reqRice > 0){
if ($reqRice > 0) {
$title .= ", 군량{$reqRice}";
}
$title .= ')';
return $title;
}
public function getCost():array{
public function getCost(): array
{
$env = $this->env;
return [$env['develcost'], $env['develcost']];
}
public function getPreReqTurn():int{
public function getPreReqTurn(): int
{
return 0;
}
public function getPostReqTurn():int{
public function getPostReqTurn(): int
{
return 0;
}
public function getFailString():string{
public function getFailString(): string
{
$commandName = $this->getName();
$failReason = $this->testRunnable();
if($failReason === null){
$failReason = $this->testFullConditionMet();
if ($failReason === null) {
throw new \RuntimeException('실행 가능한 커맨드에 대해 실패 이유를 수집');
}
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
return "{$failReason} <G><b>{$destCityName}</b></>에 {$commandName} 실패.";
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -124,13 +150,13 @@ class che_첩보 extends Command\GeneralCommand{
$logger = $general->getLogger();
$dist = searchDistance($general->getCityID(), 2, false)[$destCityID]??3;
$dist = searchDistance($general->getCityID(), 2, false)[$destCityID] ?? 3;
$destCityGeneralList = $db->query('SELECT crew, crewtype FROM general WHERE city = %i AND nation = %i', $destCityID, $destNationID);
$totalCrew = Util::arraySum($destCityGeneralList, 'crew');
$totalGenCnt = count($destCityGeneralList);
$byCrewType = Util::arrayGroupBy($destCityGeneralList, 'crewtype');
$popText = number_format($destCity['pop']);
$trustText = number_format($destCity['trust'], 1);
$agriText = number_format($destCity['agri']);
@@ -143,50 +169,43 @@ class che_첩보 extends Command\GeneralCommand{
$cityDevel = "【<M>첩보</>】농업:{$agriText}, 상업:{$commText}, 치안:{$secuText}, 수비:{$defText}, 성벽:{$wallText}";
$logger->pushGeneralActionLog("누군가가 <G><b>{$destCityName}</b></>{$josaUl} 살피는 것 같습니다.");
if($dist < 1){
if ($dist < 1) {
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>의 정보를 많이 얻었습니다. <1>$date</>");
$logger->pushGeneralActionLog($cityBrief, ActionLogger::RAWTEXT);
$logger->pushGeneralActionLog($cityDevel, ActionLogger::RAWTEXT);
$logger->pushGeneralActionLog('【<S>병종</>】 '. join(' ', Util::mapWithKey(function($crewType, $value){
$logger->pushGeneralActionLog('【<S>병종</>】 ' . join(' ', Util::mapWithKey(function ($crewType, $value) {
$crewTypeText = mb_substr(GameUnitConst::byID($crewType)->name, 0, 2);
$cnt = count($value);
return "{$crewTypeText}:{$cnt}";
}, $destCityGeneralList)), ActionLogger::RAWTEXT);
if($this->destNation['nation'] && $general->getNationID()){
if ($this->destNation['nation'] && $general->getNationID()) {
$techDiff = floor($this->destNation['tech']) - floor($this->nation['tech']);
if($techDiff >= 1000){
if ($techDiff >= 1000) {
$techText = '<M>↑</>압도';
}
else if($techDiff >= 250){
} else if ($techDiff >= 250) {
$techText = '<Y>▲</>우위';
}
else if($techDiff >= -250){
} else if ($techDiff >= -250) {
$techText = '<W>↕</>대등';
}
else if($techDiff >= -1000){
} else if ($techDiff >= -1000) {
$techText = '<G>▼</>열위';
}
else{
} else {
$techText = '<C>↓</>미미';
}
$logger->pushGeneralActionLog("【<span class='ev_notice'>{$this->destNation['name']}</span>】아국대비기술:{$techText}");
}
}
else if($dist == 2){
} else if ($dist == 2) {
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>의 정보를 어느 정도 얻었습니다. <1>$date</>");
$logger->pushGeneralActionLog($cityBrief, ActionLogger::RAWTEXT);
$logger->pushGeneralActionLog($cityDevel, ActionLogger::RAWTEXT);
}
else{
} else {
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>의 소문만 들을 수 있었습니다. <1>$date</>");
$logger->pushGeneralActionLog($cityBrief, ActionLogger::RAWTEXT);
}
$exp = Util::randRangeInt(1, 100);
$ded = Util::randRangeInt(1, 70);
[$reqGold, $reqRice] = $this->getCost();
$general->increaseVarWithLimit('gold', -$reqGold, 0);
$general->increaseVarWithLimit('rice', -$reqRice, 0);
@@ -212,19 +231,17 @@ class che_첩보 extends Command\GeneralCommand{
$currentCityID = $this->generalObj->getCityID();
ob_start();
?>
<?=\sammo\getMapHtml()?><br>
선택된 도시에 첩보를 실행합니다.<br>
인접도시일 경우 많은 정보를 얻을 수 있습니다.<br>
목록을 선택하거나 도시를 클릭하세요.<br>
<select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'><br>
<?=\sammo\optionsForCities()?><br>
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
<br>
<br>
<?=printCitiesBasedOnDistance($currentCityID, 3)?>
<?= \sammo\getMapHtml() ?><br>
선택된 도시에 첩보를 실행합니다.<br>
인접도시일 경우 많은 정보를 얻을 수 있습니다.<br>
목록을 선택하거나 도시를 클릭하세요.<br>
<select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'><br>
<?= \sammo\optionsForCities() ?><br>
</select> <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
<br>
<br>
<?= printCitiesBasedOnDistance($currentCityID, 3) ?>
<?php
return ob_get_clean();
return ob_get_clean();
}
}
}
+91 -63
View File
@@ -1,17 +1,21 @@
<?php
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
General,
use\sammo\{
DB,
Util,
JosaUtil,
General,
ActionLogger,
GameConst, GameUnitConst,
GameConst,
GameUnitConst,
LastTurn,
Command
};
use function \sammo\{
use function\sammo\{
tryUniqueItemLottery,
processWar
};
@@ -22,38 +26,58 @@ use sammo\CityConst;
class che_출병 extends Command\GeneralCommand{
class che_출병 extends Command\GeneralCommand
{
static protected $actionName = '출병';
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
protected function argTest(): bool
{
if ($this->arg === null) {
return false;
}
if(!key_exists('destCityID', $this->arg)){
if (!key_exists('destCityID', $this->arg)) {
return false;
}
if(!key_exists($this->arg['destCityID'], CityConst::all())){
if (!key_exists($this->arg['destCityID'], CityConst::all())) {
return false;
}
$this->arg = [
'destCityID'=>$this->arg['destCityID']
'destCityID' => $this->arg['destCityID']
];
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$this->setCity();
$this->setNation(['war', 'gennum', 'tech', 'gold', 'rice', 'color', 'type', 'level', 'capital']);
$this->setDestCity($this->arg['destCityID'], null);
[$reqGold, $reqRice] = $this->getCost();
$relYear = $this->env['year'] - $this->env['startyear'];
$this->minConditionConstraints = [
ConstraintHelper::NotOpeningPart($relYear+1),
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::ReqGeneralCrew(),
ConstraintHelper::ReqGeneralRice($reqRice),
];
$this->runnableConstraints=[
}
protected function initWithArg()
{
$this->setDestCity($this->arg['destCityID']);
[$reqGold, $reqRice] = $this->getCost();
$relYear = $this->env['year'] - $this->env['startyear'];
$this->fullConditionConstraints = [
ConstraintHelper::NotOpeningPart($relYear),
ConstraintHelper::NotSameDestCity(),
ConstraintHelper::NotBeNeutral(),
@@ -65,36 +89,42 @@ class che_출병 extends Command\GeneralCommand{
];
}
public function getCommandDetailTitle():string{
public function getCommandDetailTitle(): string
{
$name = $this->getName();
//[$reqGold, $reqRice] = $this->getCost();
return "{$name}(통솔경험, 병종숙련, 군량↓)";
}
public function getCost():array{
return [0, Util::round($this->generalObj->getVar('crew')/100)];
public function getCost(): array
{
return [0, Util::round($this->generalObj->getVar('crew') / 100)];
}
public function getPreReqTurn():int{
public function getPreReqTurn(): int
{
return 0;
}
public function getPostReqTurn():int{
public function getPostReqTurn(): int
{
return 0;
}
public function getBrief():string{
public function getBrief(): string
{
$commandName = $this->getName();
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
$josaRo = JosaUtil::pick($destCityName, '로');
return "{$destCityName}{$josaRo} {$commandName}";
}
public function getFailString():string{
public function getFailString(): string
{
$commandName = $this->getName();
$failReason = $this->testRunnable();
if($failReason === null){
$failReason = $this->testFullConditionMet();
if ($failReason === null) {
throw new \RuntimeException('실행 가능한 커맨드에 대해 실패 이유를 수집');
}
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
@@ -102,8 +132,9 @@ class che_출병 extends Command\GeneralCommand{
return "{$failReason} <G><b>{$destCityName}</b></>{$josaRo} {$commandName} 실패.";
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -117,10 +148,10 @@ class che_출병 extends Command\GeneralCommand{
$attackerCityID = $general->getCityID();
$finalTargetCityID = $this->destCity['city'];
$finalTargetCityName = $this->destCity['name'];
$logger = $general->getLogger();
@@ -136,62 +167,61 @@ class che_출병 extends Command\GeneralCommand{
do {
//1: 최단 거리 도시 중 공격 대상이 있는가 확인
//2: 최단 거리 + 1 도시 중 공격 대상이 있는가 확인
foreach($distanceList as $dist => $distCitiesInfo){
if($dist > $minDist + 1){
foreach ($distanceList as $dist => $distCitiesInfo) {
if ($dist > $minDist + 1) {
break;
}
$currDist = $dist;
foreach($distCitiesInfo as [$distCityID, $distCityNation]){
if($distCityNation !== $attackerNationID){
foreach ($distCitiesInfo as [$distCityID, $distCityNation]) {
if ($distCityNation !== $attackerNationID) {
$candidateCities[] = $distCityID;
}
}
if($candidateCities){
if ($candidateCities) {
break 2;
}
}
//3: 최단 거리 도시 중 아군 도시 선택
foreach($distanceList[$minDist] as [$distCityID, $distCityNation]){
if($distCityNation === $attackerNationID){
foreach ($distanceList[$minDist] as [$distCityID, $distCityNation]) {
if ($distCityNation === $attackerNationID) {
$candidateCities[] = $distCityID;
}
}
}while(false);
$defenderCityID = (int)Util::choiceRandom($candidateCities);
} while (false);
$defenderCityID = (int) Util::choiceRandom($candidateCities);
$defenderCityName = $this->destCity['name'];
$this->setDestCity($defenderCityID, null);
$this->setDestCity($defenderCityID);
$josaRo = JosaUtil::pick($defenderCityName, '로');
if($attackerNationID == $defenderNationID){
$logger->pushGeneralActionLog("본국입니다. <G><b>{$defenderCityName}</b></>{$josaRo} 으로 이동합니다. <1>$date</>");
$this->alternative = new che_이동($general, $this->env, ['destCityID'=>$defenderCityID]);
if ($attackerNationID == $defenderNationID) {
$logger->pushGeneralActionLog("본국입니다. <G><b>{$defenderCityName}</b></>{$josaRo} 으로 이동합니다. <1>$date</>");
$this->alternative = new che_이동($general, $this->env, ['destCityID' => $defenderCityID]);
return false;
}
if($finalTargetCityID !== $defenderCityID){
if ($finalTargetCityID !== $defenderCityID) {
$josaRo = JosaUtil::pick($finalTargetCityName, '로');
$josaUl = JosaUtil::pick($defenderCityName, '을');
if($minDist == $currDist){
if ($minDist == $currDist) {
$logger->pushGeneralActionLog("<G><b>{$finalTargetCityName}</b></>{$josaRo} 가기 위해 <G><b>{$defenderCityName}</b></>{$josaUl} 거쳐야 합니다. <1>$date</>");
}
else{
} else {
$logger->pushGeneralActionLog("<G><b>{$finalTargetCityName}</b></>{$josaRo} 가는 도중 <G><b>{$defenderCityName}</b></>{$josaUl} 거치기로 합니다. <1>$date</>");
}
}
$db->update('city', [
'state'=>43,
'term'=>3
'state' => 43,
'term' => 3
], 'city=%i', $defenderCityID);
$this->destCity['state'] = 43;
$this->destCity['term'] = 3;
$general->addDex($general->getCrewTypeObj(), $general->getVar('crew')/100);
$general->addDex($general->getCrewTypeObj(), $general->getVar('crew') / 100);
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->applyDB($db);
@@ -200,7 +230,7 @@ class che_출병 extends Command\GeneralCommand{
tryUniqueItemLottery($general);
$general->applyDB($db);
return true;
}
@@ -216,17 +246,15 @@ class che_출병 extends Command\GeneralCommand{
$srcCityName = \sammo\CityConst::byID($this->generalObj->getCityID())->name;
ob_start();
?>
<?=\sammo\getMapHtml()?><br>
선택된 도시를 향해 침공을 합니다.<br>
침공 경로에 적군의 도시가 있다면 전투를 벌입니다.<br>
목록을 선택하거나 도시를 클릭하세요.<br>
<?=$srcCityName?> =><select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'>
<?=\sammo\optionsForCities()?><br>
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
<br>
<?= \sammo\getMapHtml() ?><br>
선택된 도시를 향해 침공을 합니다.<br>
침공 경로에 적군의 도시가 있다면 전투를 벌입니다.<br>
목록을 선택하거나 도시를 클릭하세요.<br>
<?= $srcCityName ?> =><select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'>
<?= \sammo\optionsForCities() ?><br>
</select> <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
<br>
<?php
return ob_get_clean();
return ob_get_clean();
}
}
}
+2 -2
View File
@@ -38,7 +38,7 @@ class che_하야 extends Command\GeneralCommand{
$relYear = $env['year'] - $env['startyear'];
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotOpeningPart($relYear),
ConstraintHelper::NotLord(),
@@ -58,7 +58,7 @@ class che_하야 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+2 -2
View File
@@ -40,7 +40,7 @@ class che_해산 extends Command\GeneralCommand{
$this->setCity();
$this->setNation(['gennum']);
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::BeLord(),
ConstraintHelper::WanderingNation(),
];
@@ -59,7 +59,7 @@ class che_해산 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+65 -47
View File
@@ -1,9 +1,12 @@
<?php
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
General,
use\sammo\{
DB,
Util,
JosaUtil,
General,
ActionLogger,
GameConst,
LastTurn,
@@ -11,9 +14,9 @@ use \sammo\{
Command
};
use function \sammo\{
use function\sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalRatioDomestic,
CriticalScoreEx,
tryUniqueItemLottery
};
@@ -22,84 +25,99 @@ use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
class che_헌납 extends Command\GeneralCommand{
class che_헌납 extends Command\GeneralCommand
{
static protected $actionName = '헌납';
static public $reqArg = true;
protected function argTest():bool{
if($this->arg === null){
protected function argTest(): bool
{
if ($this->arg === null) {
return false;
}
if(!key_exists('isGold', $this->arg)){
if (!key_exists('isGold', $this->arg)) {
return false;
}
if(!key_exists('amount', $this->arg)){
if (!key_exists('amount', $this->arg)) {
return false;
}
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
if(!is_numeric($amount)){
if (!is_numeric($amount)) {
return false;
}
$amount = Util::round($amount, -2);
$amount = Util::valueFit($amount, 100, GameConst::$maxResourceActionAmount);
if(!is_bool($isGold)){
if (!is_bool($isGold)) {
return false;
}
$this->arg = [
'isGold'=>$isGold,
'amount'=>$amount
'isGold' => $isGold,
'amount' => $amount
];
return true;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$this->setCity();
$this->setNation();
$this->runnableConstraints=[
ConstraintHelper::NotBeNeutral(),
$this->minConditionConstraints = [
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::SuppliedCity(),
];
if($this->arg['isGold']){
$this->runnableConstraints[] = ConstraintHelper::ReqGeneralGold(GameConst::$generalMinimumGold);
}
else{
$this->runnableConstraints[] = ConstraintHelper::ReqGeneralRice(GameConst::$generalMinimumRice);
}
}
protected function initWithArg()
{
$this->fullConditionConstraints = [
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::SuppliedCity(),
];
if ($this->arg['isGold']) {
$this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralGold(GameConst::$generalMinimumGold);
} else {
$this->fullConditionConstraints[] = ConstraintHelper::ReqGeneralRice(GameConst::$generalMinimumRice);
}
}
public function getBrief(): string
{
$resText = $this->arg['isGold']?'금':'쌀';
$resText = $this->arg['isGold'] ? '금' : '쌀';
$name = $this->getName();
return "{$resText} {$this->arg['amount']}{$name}";
}
public function getCommandDetailTitle():string{
public function getCommandDetailTitle(): string
{
$name = $this->getName();
return "{$name}(통솔경험)";
}
public function getCost():array{
public function getCost(): array
{
return [0, 0];
}
public function getPreReqTurn():int{
public function getPreReqTurn(): int
{
return 0;
}
public function getPostReqTurn():int{
public function getPostReqTurn(): int
{
return 0;
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -110,16 +128,16 @@ class che_헌납 extends Command\GeneralCommand{
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
$resKey = $isGold?'gold':'rice';
$resName = $isGold?'금':'쌀';
$resKey = $isGold ? 'gold' : 'rice';
$resName = $isGold ? '금' : '쌀';
$amount = Util::valueFit($amount, 0, $general->getVar($resKey));
$amountText = number_format($amount, 0);
$logger = $general->getLogger();
$db->update('nation', [
$resKey=>$db->sqleval('%b + %i', $resKey, $amount)
$resKey => $db->sqleval('%b + %i', $resKey, $amount)
], 'nation=%i', $general->getNationID());
$general->increaseVarWithLimit($resKey, -$amount, 0);
@@ -144,17 +162,17 @@ class che_헌납 extends Command\GeneralCommand{
{
ob_start();
?>
자신의 자금이나 군량을 국가 재산으로 헌납합니다.<br>
<select id='isGold' name="isGold" size=1 style=color:white;background-color:black>
<option value='true'>금</option>
<option value='false'>쌀</option>
</select>
<select name=amount id='amount' size=1 style=text-align:right;color:white;background-color:black>
<?php foreach(GameConst::$resourceActionAmountGuide as $amount): ?>
<option value='<?=$amount?>'><?=$amount?></option>
<?php endforeach; ?>
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
자신의 자금이나 군량을 국가 재산으로 헌납합니다.<br>
<select id='isGold' name="isGold" size=1 style=color:white;background-color:black>
<option value='true'>금</option>
<option value='false'>쌀</option>
</select>
<select name=amount id='amount' size=1 style=text-align:right;color:white;background-color:black>
<?php foreach (GameConst::$resourceActionAmountGuide as $amount) : ?>
<option value='<?= $amount ?>'><?= $amount ?></option>
<?php endforeach; ?>
</select> <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
<?php
return ob_get_clean();
}
}
}
+101 -76
View File
@@ -1,17 +1,21 @@
<?php
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
General,
use\sammo\{
DB,
Util,
JosaUtil,
General,
ActionLogger,
GameConst, GameUnitConst,
GameConst,
GameUnitConst,
LastTurn,
Command
};
use function \sammo\{
use function\sammo\{
searchDistance,
printCitiesBasedOnDistance
};
@@ -22,44 +26,44 @@ use sammo\CityConst;
class che_화계 extends Command\GeneralCommand{
class che_화계 extends Command\GeneralCommand
{
static protected $actionName = '화계';
static public $reqArg = true;
static protected $statType = 'intel';
static protected $injuryGeneral = true;
protected function argTest():bool{
if($this->arg === null){
protected function argTest(): bool
{
if ($this->arg === null) {
return false;
}
if(!key_exists('destCityID', $this->arg)){
if (!key_exists('destCityID', $this->arg)) {
return false;
}
if(!key_exists($this->arg['destCityID'], CityConst::all())){
if (!key_exists($this->arg['destCityID'], CityConst::all())) {
return false;
}
$this->arg = [
'destCityID'=>$this->arg['destCityID']
'destCityID' => $this->arg['destCityID']
];
return true;
}
protected function calcSabotageAttackProb():float{
protected function calcSabotageAttackProb(): float
{
$statType = static::$statType;
$general = $this->generalObj;
$nation = $this->nation;
if($statType === 'leadership'){
if ($statType === 'leadership') {
$genScore = $general->getLeadership();
}
else if($statType === 'strength'){
} else if ($statType === 'strength') {
$genScore = $general->getStrength();
}
else if($statType === 'intel'){
} else if ($statType === 'intel') {
$genScore = $general->getIntel();
}
else{
} else {
throw new \sammo\MustNotBeReachedException();
}
@@ -68,29 +72,27 @@ class che_화계 extends Command\GeneralCommand{
return $prob;
}
protected function calcSabotageDefenceProb(array $destCityGeneralList):float{
protected function calcSabotageDefenceProb(array $destCityGeneralList): float
{
$statType = static::$statType;
$destCity = $this->destCity;
$destNation = $this->destNation;
$destNationID = $destNation['nation'];
$maxGenScore = 0;
foreach($destCityGeneralList as $destGeneral){
foreach ($destCityGeneralList as $destGeneral) {
/** @var General $destGeneral */
if($destGeneral->getNationID() != $destNationID){
if ($destGeneral->getNationID() != $destNationID) {
continue;
}
if($statType === 'leadership'){
if ($statType === 'leadership') {
$genScore = $destGeneral->getLeadership();
}
else if($statType === 'strength'){
} else if ($statType === 'strength') {
$genScore = $destGeneral->getStrength();
}
else if($statType === 'intel'){
} else if ($statType === 'intel') {
$genScore = $destGeneral->getIntel();
}
else{
} else {
throw new \sammo\MustNotBeReachedException();
}
$maxGenScore = max($maxGenScore, $genScore);
@@ -103,17 +105,35 @@ class che_화계 extends Command\GeneralCommand{
return $prob;
}
protected function init(){
protected function init()
{
$general = $this->generalObj;
$this->setCity();
$this->setDestCity($this->arg['destCityID'], null); //xxx: 이대로라면 메인 페이지 갱신시마다 DB query를 하게 된다.
[$reqGold, $reqRice] = $this->getCost();
$this->minConditionConstraints = [
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::SuppliedCity(),
ConstraintHelper::ReqGeneralGold($reqGold),
ConstraintHelper::ReqGeneralRice($reqRice),
];
}
protected function initWithArg()
{
$this->setDestCity($this->arg['destCityID']);
$this->setDestNation($this->destCity['nation']);
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
$this->fullConditionConstraints = [
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(),
ConstraintHelper::SuppliedCity(),
@@ -128,58 +148,65 @@ class che_화계 extends Command\GeneralCommand{
];
}
public function getCommandDetailTitle():string{
public function getCommandDetailTitle(): string
{
$name = $this->getName();
$statTypeBase = [
'leadership'=>'통솔경험',
'strength'=>'무력경험',
'intel'=>'지력경험',
'leadership' => '통솔경험',
'strength' => '무력경험',
'intel' => '지력경험',
];
$statType = $statTypeBase[static::$statType];
[$reqGold, $reqRice] = $this->getCost();
$title = "{$name}({$statType}";
if($reqGold > 0){
if ($reqGold > 0) {
$title .= ", 자금{$reqGold}";
}
if($reqRice > 0){
if ($reqRice > 0) {
$title .= ", 군량{$reqRice}";
}
$title .= ')';
return $title;
}
public function getCost():array{
public function getCost(): array
{
$env = $this->env;
$cost = $env['develcost'] * 5;
return [$cost, $cost];
}
public function getPreReqTurn():int{
public function getPreReqTurn(): int
{
return 0;
}
public function getPostReqTurn():int{
public function getPostReqTurn(): int
{
return 0;
}
public function getBrief():string{
public function getBrief(): string
{
$commandName = $this->getName();
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
return "{$destCityName}】에 {$commandName}실행";
}
public function getFailString():string{
public function getFailString(): string
{
$commandName = $this->getName();
$failReason = $this->testRunnable();
if($failReason === null){
$failReason = $this->testFullConditionMet();
if ($failReason === null) {
throw new \RuntimeException('실행 가능한 커맨드에 대해 실패 이유를 수집');
}
$destCityName = CityConst::byID($this->arg['destCityID'])->name;
return "{$failReason} <G><b>{$destCityName}</b></>에 {$commandName} 실패.";
}
protected function affectDestCity(int $injuryCount){
protected function affectDestCity(int $injuryCount)
{
$general = $this->generalObj;
$date = $general->getTurnTime($general::TURNTIME_HM);
@@ -198,9 +225,9 @@ class che_화계 extends Command\GeneralCommand{
$destCity['comm'] -= $commAmount;
DB::db()->update('city', [
'state'=>32,
'agri'=>$destCity['agri'],
'comm'=>$destCity['comm']
'state' => 32,
'agri' => $destCity['agri'],
'comm' => $destCity['comm']
], 'city=%i', $destCityID);
$agriAmountText = number_format($agriAmount);
@@ -217,8 +244,9 @@ class che_화계 extends Command\GeneralCommand{
);
}
public function run():bool{
if(!$this->isRunnable()){
public function run(): bool
{
if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
@@ -239,13 +267,13 @@ class che_화계 extends Command\GeneralCommand{
$logger = $general->getLogger();
$dist = searchDistance($general->getCityID(), 5, false)[$destCityID]??99;
$dist = searchDistance($general->getCityID(), 5, false)[$destCityID] ?? 99;
$destCityGeneralList = [];
$cityGeneralID = $db->queryFirstColumn('SELECT no FROM general WHERE city = %i AND nation = %i', $destCityID, $destNationID);
$destCityGeneralList = General::createGeneralObjListFromDB($cityGeneralID, ['name', 'city', 'nation', 'officer_level', 'leadership', 'horse', 'strength', 'weapon', 'intel', 'book', 'item', 'last_turn', 'injury', 'special', 'special2', 'injury', 'crew', 'atmos', 'train'], 2);
foreach($destCityGeneralList as &$destCityGeneral){
foreach ($destCityGeneralList as &$destCityGeneral) {
$destCityGeneral->setRawCity($this->destCity);
unset($destCityGeneral);
}
@@ -255,7 +283,7 @@ class che_화계 extends Command\GeneralCommand{
$prob = GameConst::$sabotageDefaultProb + $this->calcSabotageAttackProb() - $this->calcSabotageDefenceProb($destCityGeneralList);
$prob /= $dist;
if(!Util::randBool($prob)){
if (!Util::randBool($prob)) {
$josaYi = JosaUtil::pick($commandName, '이');
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>에 {$commandName}{$josaYi} 실패했습니다. <1>$date</>");
@@ -267,7 +295,7 @@ class che_화계 extends Command\GeneralCommand{
$general->increaseVarWithLimit('rice', -$reqRice, 0);
$general->addExperience($exp);
$general->addDedication($ded);
$general->increaseVar($statType.'_exp', 1);
$general->increaseVar($statType . '_exp', 1);
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
@@ -275,17 +303,16 @@ class che_화계 extends Command\GeneralCommand{
return false;
}
if(static::$injuryGeneral){
if (static::$injuryGeneral) {
$injuryCount = \sammo\SabotageInjury($destCityGeneralList, '계략');
}
else{
} else {
$injuryCount = 0;
}
$this->affectDestCity($injuryCount);
$itemObj = $general->getItem();
if($itemObj->isConsumableNow('GeneralCommand', '계략') && $itemObj->isConsumableNow('GeneralCommand', '계략')){
if ($itemObj->isConsumableNow('GeneralCommand', '계략') && $itemObj->isConsumableNow('GeneralCommand', '계략')) {
$itemName = $itemObj->getName();
$itemRawName = $itemObj->getRawName();
$josaUl = JosaUtil::pick($itemRawName, '을');
@@ -295,13 +322,13 @@ class che_화계 extends Command\GeneralCommand{
$exp = Util::randRangeInt(201, 300);
$ded = Util::randRangeInt(141, 210);
[$reqGold, $reqRice] = $this->getCost();
$general->increaseVarWithLimit('gold', -$reqGold, 0);
$general->increaseVarWithLimit('rice', -$reqRice, 0);
$general->addExperience($exp);
$general->addDedication($ded);
$general->increaseVar($statType.'_exp', 1);
$general->increaseVar($statType . '_exp', 1);
$general->increaseRankVar('firenum', 1);
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
@@ -325,18 +352,16 @@ class che_화계 extends Command\GeneralCommand{
ob_start();
?>
<?=\sammo\getMapHtml()?><br>
선택된 도시에 <?=$commandName?><?=$josaUl?> 실행합니다.<br>
목록을 선택하거나 도시를 클릭하세요.<br>
<select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'><br>
<?=\sammo\optionsForCities()?><br>
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
<br>
<br>
<?=printCitiesBasedOnDistance($currentCityID, 2)?>
<?= \sammo\getMapHtml() ?><br>
선택된 도시에 <?= $commandName ?><?= $josaUl ?> 실행합니다.<br>
목록을 선택하거나 도시를 클릭하세요.<br>
<select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'><br>
<?= \sammo\optionsForCities() ?><br>
</select> <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
<br>
<br>
<?= printCitiesBasedOnDistance($currentCityID, 2) ?>
<?php
return ob_get_clean();
}
}
}
+2 -2
View File
@@ -35,7 +35,7 @@ class che_훈련 extends Command\GeneralCommand{
$this->setCity();
$this->setNation();
$this->runnableConstraints=[
$this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotWanderingNation(),
ConstraintHelper::OccupiedCity(),
@@ -73,7 +73,7 @@ class che_훈련 extends Command\GeneralCommand{
}
public function run():bool{
if(!$this->isRunnable()){
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
+4 -2
View File
@@ -14,8 +14,10 @@ class 휴식 extends Command\GeneralCommand{
return true;
}
protected function init(){
$this->runnableConstraints=[];
protected function init()
{
$this->minConditionConstraints=[];
$this->fullConditionConstraints=[];
}
public function getCost():array{