버그 수정

This commit is contained in:
2019-04-21 21:15:53 +09:00
parent 16fed754a9
commit 0e50216cee
12 changed files with 67 additions and 42 deletions
+7 -7
View File
@@ -145,14 +145,14 @@ abstract class BaseCommand{
$db = DB::db();
$destNation = $db->queryFirstRow('SELECT %l FROM nation WHERE nation=%i', Util::formatListOfBackticks($args), $nationID);
if($destNation === null){
$destNation = [];
$nation = $db->queryFirstRow('SELECT %l FROM nation WHERE nation=%i', Util::formatListOfBackticks($args), $nationID);
if($nation === null){
$nation = [];
foreach($args as $arg){
$destNation[$arg] = $defaultValues[$arg];
$nation[$arg] = $defaultValues[$arg];
}
}
$this->destNation = $destNation;
$this->nation = $nation;
}
protected function setDestGeneral(General $destGeneralObj){
@@ -246,7 +246,7 @@ abstract class BaseCommand{
'general'=>$this->generalObj->getRaw(),
'city'=>$this->city,
'nation'=>$this->nation,
'arg'=>$this->arg,
'cmd_arg'=>$this->arg,
'destGeneral'=>$this->destGeneralObj->getRaw(),
'destCity'=>$this->destCity,
@@ -282,7 +282,7 @@ abstract class BaseCommand{
'general'=>$this->generalObj->getRaw(),
'city'=>$this->city,
'nation'=>$this->nation,
'arg'=>$this->arg,
'cmd_arg'=>$this->arg,
'destGeneral'=>$this->destGeneralObj?$this->destGeneralObj->getRaw():null,
'destCity'=>$this->destCity,
@@ -191,6 +191,8 @@ class che_인재탐색 extends Command\GeneralCommand{
$isOurNation = $this->nation['scout'] == 0;
$age = $env['year'] - 20;
$newNPC = new \sammo\Scenario\NPC(
Util::randRangeInt(1, 150),
\sammo\getRandGenName(),
@@ -201,7 +203,7 @@ class che_인재탐색 extends Command\GeneralCommand{
$power,
$intel,
$isOurNation?1:0,
$env['year'] - 20,
$age,
$env['year'] + Util::randRangeInt(10, 50),
null,
null
+3 -2
View File
@@ -57,14 +57,15 @@ class che_징병 extends Command\GeneralCommand{
if(!is_int($crewType)){
return false;
}
if(!is_int($amount)){
if(!is_numeric($amount)){
return false;
}
$amount = (int)$amount;
if(GameUnitConst::byID($crewType) === null){
return false;
}
if($amount < 100){
if($amount < 0){
return false;
}
$this->arg = [
@@ -157,14 +157,14 @@ class che_불가침제의 extends Command\NationCommand{
$now = new \DateTime($date);
$validUntil = new \DateTime($date);
$validMinutes = max(30, $turnterm*3);
$validMinutes = max(30, $env['turnterm']*3);
$validUntil->add(new \DateInterval("PT{$validMinutes}M"));
$msg = new DiplomaticMessage(
Message::MSGTYPE_DIPLOMACY,
$src,
$dest,
"{$srcNation['name']}{$year}{$month}까지 불가침 제의 서신",
"{$nationName}{$year}{$month}까지 불가침 제의 서신",
$now,
$validUntil,
[
@@ -177,7 +177,7 @@ class che_불가침제의 extends Command\NationCommand{
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->applyDB($db);
$destGeneral->applyDB($db);
$destLogger->flush();
return true;
}
@@ -134,7 +134,7 @@ class che_선전포고 extends Command\NationCommand{
], '(me=%i AND you=%i) OR (me=%i AND you=%i)', $nationID, $destNationID, $destNationID, $nationID);
//국메로 저장
$text = "【외교】{$env['year']}{$env['month']}월:{$nationNation}에서 {$destNationName}에 선전포고";
$text = "【외교】{$env['year']}{$env['month']}월:{$nationName}에서 {$destNationName}에 선전포고";
$src = new MessageTarget(
$general->getID(),
@@ -164,7 +164,7 @@ class che_선전포고 extends Command\NationCommand{
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->applyDB($db);
$destGeneral->applyDB($db);
$destLogger->flush();
return true;
}
+9
View File
@@ -16,6 +16,15 @@ class 휴식 extends Command\NationCommand{
protected function init(){
//아무것도 하지 않음
}
public function getPreReqTurn():int{
return 0;
}
public function getPostReqTurn():int{
return 0;
}
public function getCost():array{
return [0, 0];
}
+1
View File
@@ -1,6 +1,7 @@
<?php
namespace sammo\Constraint;
use \sammo\GameConst;
class BeOpeningPart extends Constraint{
const REQ_VALUES = Constraint::REQ_INT_ARG;
+26 -17
View File
@@ -26,6 +26,8 @@ abstract class Constraint{
protected $nation = null;
protected $arg = null;
protected $cmd_arg = null;
protected $destGeneral = null;
protected $destCity = null;
protected $destNation = null;
@@ -40,38 +42,43 @@ abstract class Constraint{
return static::REQ_VALUES;
}
public function general(array $general){
public function setGeneral(array $general){
$this->general = $general;
$this->tested = false;
$this->reason = null;
}
public function city(array $city){
public function setCity(array $city){
$this->city = $city;
$this->tested = false;
$this->reason = null;
}
public function nation(array $nation){
public function setNation(array $nation){
$this->nation = $nation;
$this->tested = false;
$this->reason = null;
}
public function arg($arg){
public function setArg($arg){
$this->arg = $arg;
$this->tested = false;
$this->reason = null;
}
public function setCmdArg($cmd_arg){
$this->cmd_arg = $cmd_arg;
$this->tested = false;
$this->reason = null;
}
public function destGeneral(array $general){
public function setDestGeneral(array $general){
$this->destGeneral = $general;
$this->tested = false;
$this->reason = null;
}
public function destCity(array $city){
public function setDestCity(array $city){
$this->destCity = $city;
$this->tested = false;
$this->reason = null;
}
public function destNation(array $nation){
public function setDestNation(array $nation){
$this->destNation = $nation;
$this->tested = false;
$this->reason = null;
@@ -84,14 +91,14 @@ abstract class Constraint{
continue;
}
switch($key){
case 'general': $self->general($value); break;
case 'city': $self->city($value); break;
case 'nation': $self->nation($value); break;
case 'arg': $self->arg($value); break;
case 'general': $self->setGeneral($value); break;
case 'city': $self->setCity($value); break;
case 'nation': $self->setNation($value); break;
case 'cmd_arg': $self->setCmdArg($value); break;
case 'destGeneral': $self->destGeneral($value); break;
case 'destCity': $self->destCity($value); break;
case 'destNation': $self->destNation($value); break;
case 'destGeneral': $self->setDestGeneral($value); break;
case 'destCity': $self->setDestCity($value); break;
case 'destNation': $self->setDestNation($value); break;
}
}
@@ -169,7 +176,7 @@ abstract class Constraint{
}
public function reason():?string{
if(!$this->tested === false){
if($this->tested === false){
throw new \RuntimeException(get_class($this).'::test가 실행되지 않음');
}
return $this->reason;
@@ -186,11 +193,13 @@ abstract class Constraint{
/** @var \sammo\Constraint\Constraint $contraint */
$constraint = call_user_func($method,$input);
assert($constraint !== null);
assert($constraint instanceof Constraint);
assert(count($constraintArgs) < 3);
if(count($constraintArgs) > 1){
if(count($constraintArgs) == 2){
$arg = $constraintArgs[1];
$constraint->arg($arg);
$constraint->setArg($arg);
}
+7 -7
View File
@@ -69,11 +69,11 @@ class ConstraintHelper{
}
static function DisallowDiplomacyStatus(int $nationID, array $disallowList):array{
return [__FUNCTION__, $nationID, $disallowList];
return [__FUNCTION__, [$nationID, $disallowList]];
}
static function ExistsAllowJoinNation(int $relYear, array $excludeNationList):array{
return [__FUNCTION__, $relYear, $excludeNationList];
return [__FUNCTION__, [$relYear, $excludeNationList]];
}
static function ExistsDestGeneral():array{
@@ -145,7 +145,7 @@ class ConstraintHelper{
}
static function RemainCityCapacity($key, string $actionName):array{
return [__FUNCTION__, $key, $actionName];
return [__FUNCTION__, [$key, $actionName]];
}
static function RemainCityTrust(string $actionName):array{
@@ -153,7 +153,7 @@ class ConstraintHelper{
}
static function ReqCityCapacity($key, string $keyNick, $reqVal):array{
return [__FUNCTION__, $key, $keyNick, $reqVal];
return [__FUNCTION__, [$key, $keyNick, $reqVal]];
}
static function ReqCityTrust(float $minTrust):array{
@@ -165,7 +165,7 @@ class ConstraintHelper{
}
static function ReqEnvValue($key, string $keyNick, string $comp, $reqVal, string $failMessage):array{
return [__FUNCTION__, $key, $keyNick, $comp, $reqVal, $failMessage];
return [__FUNCTION__, [$key, $keyNick, $comp, $reqVal, $failMessage]];
}
static function ReqGeneralAtmosMargin(int $maxAtmos):array{
@@ -193,7 +193,7 @@ class ConstraintHelper{
}
static function ReqGeneralValue($key, string $keyNick, string $comp, $reqVal):array{
return [__FUNCTION__, $key, $keyNick, $comp, $reqVal];
return [__FUNCTION__, [$key, $keyNick, $comp, $reqVal]];
}
static function ReqNationGold(int $reqGold):array{
@@ -205,7 +205,7 @@ class ConstraintHelper{
}
static function ReqNationValue($key, string $keyNick, string $comp, $reqVal):array{
return [__FUNCTION__, $key, $keyNick, $comp, $reqVal];
return [__FUNCTION__, [$key, $keyNick, $comp, $reqVal]];
}
static function ReqTroopMembers():array{
+1
View File
@@ -1,6 +1,7 @@
<?php
namespace sammo\Constraint;
use \sammo\GameConst;
class NotOpeningPart extends Constraint{
const REQ_VALUES = Constraint::REQ_INT_ARG;
+4 -2
View File
@@ -278,7 +278,7 @@ class GeneralAI{
return [Util::choiceRandomUsingWeight($commandList), null];
}
public function chooseRecruitCrewType():array{
public function chooseRecruitCrewType():?array{
$general = $this->getGeneralObj();
$city = $this->city;
$nation = $this->nation;
@@ -374,7 +374,9 @@ class GeneralAI{
$cost = $general->onCalcDomestic('징병', 'cost', $cost);
$crew = intdiv($gold, $cost);
if($leadership < $crew) { $crew = $leadership; }
if($leadership*100 < $crew) { $crew = $leadership; }
$crew *= 100;
$arg = [
'crewType'=>$type,
'amountCrew'=>$crew
@@ -104,7 +104,7 @@ class SightseeingMessage{
}
public function pickAction():array{
[$type, $texts] = Util::choiceRandomUsingWeightPair(static::$messages);
[$type, $texts] = Util::choiceRandomUsingWeightPair(static::$messages??[]);
$text = Util::choiceRandom($texts);
return [$type, $text];