버그 수정

This commit is contained in:
2019-04-24 01:17:21 +09:00
parent dd81dcc9c6
commit 8aa846b349
29 changed files with 79 additions and 51 deletions
+3 -3
View File
@@ -1929,8 +1929,8 @@ function deleteNation(General $general) {
$josaUn = JosaUtil::pick($nationName, '은');
$logger->pushGlobalHistoryLog("<R><b>【멸망】</b></><D><b>{$nationName}</b></>{$josaUn} <R>멸망</>했습니다.");
$oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $general['nation']);
$oldNationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $general['nation']);
$oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $nationID);
$oldNationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nationID);
$oldNation['generals'] = $oldNationGenerals;
$oldNation['aux'] = Json::decode($oldNation['aux']);
@@ -1963,7 +1963,7 @@ function deleteNation(General $general) {
$db->insert('ng_old_nations', [
'server_id'=>UniqueConst::$serverID,
'nation'=>$general['nation'],
'nation'=>$nationID,
'data'=>Json::encode($oldNation)
]);
$db->delete('nation', 'nation=%i', $nationID);
+4 -1
View File
@@ -1075,7 +1075,7 @@ function updateNationState() {
refreshNationStaticInfo();
}
$assemblerCnt = $assemblerCnt[$nation['nation']]??0;
$assemblerCnt = $assemblerCnts[$nation['nation']]??0;
$maxAssemblerCnt = [
1=>0,
2=>1,
@@ -1105,6 +1105,9 @@ function updateNationState() {
'no'=>$npcID
]);
$troopID = $db->insertId();
$db->update('general', [
'troop'=>$troopID
], 'no=%i', $npcID);
//TODO: 5턴간 집합턴 입력
$assemblerCnt += 1;
+1 -1
View File
@@ -123,7 +123,7 @@ function getGeneralIntel($general, $withInjury, $withItem, $withStatAdjust, $use
*
* @return array 계산된 실패, 성공 확률 ('success' => 성공 확률, 'fail' => 실패 확률)
*/
function CriticalRatioDomestic(&$general, $type) {
function CriticalRatioDomestic($general, $type) {
$leader = getGeneralLeadership($general, false, true, true, false);
$power = getGeneralPower($general, false, true, true, false);
$intel = getGeneralIntel($general, false, true, true, false);
+3 -1
View File
@@ -7,6 +7,8 @@ use \sammo\{
ActionLogger
};
use function \sammo\getNationStaticInfo;
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
@@ -261,7 +263,7 @@ abstract class BaseCommand{
public function testRunnable():?string{
if(!$this->isArgValid()){
throw new \InvalidArgumentException('인자가 제대로 설정되지 않았습니다');
throw new \InvalidArgumentException('인자가 제대로 설정되지 않았습니다'.\sammo\Json::encode($this->arg));
}
if($this->runnableConstraints === null){
throw new \InvalidArgumentException('runnableConstraits가 제대로 설정되지 않았습니다');
+3 -1
View File
@@ -29,7 +29,7 @@ class che_NPC능동 extends Command\GeneralCommand{
if(!key_exists('destCityID', $this->arg)){
return false;
}
if(!key_exists($this->arg['destCityID'], CityConst::all())){
if(CityConst::byID($this->arg['destCityID']) === null){
return false;
}
$this->arg = [
@@ -45,6 +45,8 @@ class che_NPC능동 extends Command\GeneralCommand{
protected function init(){
$general = $this->generalObj;
$this->setNation();
$this->runnableConstraints=[
ConstraintHelper::MustBeNPC()
+1 -1
View File
@@ -113,7 +113,7 @@ class che_강행 extends Command\GeneralCommand{
if($generalList){
$db->update('general', [
'city'=>$destCityID
], 'no IN %li', $generalList);
], 'no IN %li and nation=%i', $generalList, $general->getNationID());
}
foreach($generalList as $targetGeneralID){
$targetGeneral = General::createGeneralObjFromDB($targetGeneralID, [], 1);
+1 -1
View File
@@ -96,7 +96,7 @@ class che_거병 extends Command\GeneralCommand{
'bill'=>100,
'strategic_cmd_limit'=>12,
'surlimit'=>72,
'type'=>0,
'type'=>GameConst::$neutralNationType,
'gennum'=>1
]);
$nationID = DB::db()->insertId();
+10 -10
View File
@@ -34,13 +34,13 @@ class che_건국 extends Command\GeneralCommand{
}
$nationName = $this->arg['nationName']??null;
$nationType = $this->arg['nationType']??null;
$colorType = $this->arg['colorType']??null;
$nationColor = $this->arg['nationColor']??null;
if($nationName === null || $nationType === null || $colorType === null){
if($nationName === null || $nationType === null || $nationColor === null){
return false;
}
if(!is_string($nationName) || !is_string($nationType) || !is_int($colorType)){
if(!is_string($nationName) || !is_string($nationType) || !is_int($nationColor)){
return false;
}
@@ -48,7 +48,7 @@ class che_건국 extends Command\GeneralCommand{
return false;
}
if(!key_exists($colorType, GetNationColors())){
if(!key_exists($nationColor, GetNationColors())){
return false;
}
@@ -62,7 +62,7 @@ class che_건국 extends Command\GeneralCommand{
$this->arg = [
'nationName'=>$nationName,
'nationType'=>$nationType,
'colorType'=>$colorType
'nationColor'=>$nationColor
];
return true;
@@ -75,10 +75,10 @@ class che_건국 extends Command\GeneralCommand{
$nationName = $this->arg['nationName'];
$nationType = $this->arg['nationType'];
$colorType = $this->arg['colorType'];
$nationColor = $this->arg['nationColor'];
$this->setCity();
$this->setNation();
$this->setNation(['gennum']);
$relYear = $env['year'] - $env['startyear'];
@@ -120,7 +120,7 @@ class che_건국 extends Command\GeneralCommand{
$nationName = $this->arg['nationName'];
$nationType = $this->arg['nationType'];
$nationColor = GetNationColors()[$this->arg['colorType']];
$nationColor = GetNationColors()[$this->arg['nationColor']];
$cityName = $this->city['name'];
@@ -152,10 +152,10 @@ class che_건국 extends Command\GeneralCommand{
$db->update('city', [
'nation'=>$general->getNationID(),
'conflict'=>'{}'
], $general->getCityID());
], 'city=%i', $general->getCityID());
$db->update('nation', [
'nation'=>$nationName,
'name'=>$nationName,
'color'=>$nationColor,
'level'=>1,
'type'=>$nationType,
@@ -6,7 +6,7 @@ use \sammo\{
General,
ActionLogger,
LastTurn,
Command
Command, GameConst
};
use function sammo\{
@@ -201,15 +201,20 @@ class che_랜덤임관 extends Command\GeneralCommand{
$destNation = Util::choiceRandomUsingWeightPair($randVals);
}
$logger = $general->getLogger();
if(!$destNation){
throw new MustNotBeReachedException();
//임관 가능한 국가가 없다!
$logger->pushGeneralActionLog("임관 가능한 국가가 없습니다. <1>$date</>");
$this->alternative = new che_요양($general, $this->env, null);
return false;
}
$gennum = $destNation['gennum'];
$destNationID = $destNation['nation'];
$destNationName = $destNation['name'];
$logger = $general->getLogger();
$talkList = [
'어쩌다 보니',
@@ -81,8 +81,8 @@ class che_인재탐색 extends Command\GeneralCommand{
$nationID = $general->getNationID();
$genCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc < 2', $nationID);
$npcCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc == 3', $nationID);
$npcOtherCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation!=%i AND npc == 32', $nationID);
$npcCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc = 3', $nationID);
$npcOtherCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation!=%i AND npc = 3', $nationID);
$genCount = Util::valueFit($genCount, 1);
@@ -84,7 +84,7 @@ class che_주민선정 extends Command\GeneralCommand{
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
$score *= Util::randRange(0.8, 1.2);
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
$score = Util::valutFit($score, 1);
$score = Util::valueFit($score, 1);
return $score;
}
+2
View File
@@ -92,6 +92,8 @@ class che_해산 extends Command\GeneralCommand{
refreshNationStaticInfo();
$logger = $general->getLogger();
$logger->pushGeneralActionLog("세력을 해산했습니다. <1>$date</>");
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} 세력을 해산했습니다.");
+1 -2
View File
@@ -15,8 +15,7 @@ class 휴식 extends Command\GeneralCommand{
}
protected function init(){
$this->runnableConstraints=[
];
$this->runnableConstraints=[];
}
public function getCost():array{
+1 -1
View File
@@ -33,7 +33,7 @@ class che_발령 extends Command\NationCommand{
if(!key_exists('destCityID', $this->arg)){
return false;
}
if(!key_exists($this->arg['destCityID'], CityConst::all())){
if(CityConst::byID($this->arg['destCityID']) === null){
return false;
}
$destGeneralID = $this->arg['destGeneralID'];
@@ -8,13 +8,15 @@ use \sammo\{
GameConst,
LastTurn,
GameUnitConst,
Command
Command,
Message, MessageTarget
};
use function \sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalScoreEx
CriticalScoreEx,
GetImageURL
};
use \sammo\Constraint\Constraint;
+3 -1
View File
@@ -15,6 +15,8 @@ class 휴식 extends Command\NationCommand{
protected function init(){
//아무것도 하지 않음
$this->runnableConstraints=[];
}
public function getPreReqTurn():int{
@@ -24,7 +26,7 @@ class 휴식 extends Command\NationCommand{
public function getPostReqTurn():int{
return 0;
}
public function getCost():array{
return [0, 0];
}
+1 -1
View File
@@ -45,7 +45,7 @@ class AllowJoinDestNation extends Constraint{
return false;
}
if($this->destNation['scout'] == 0){
if($this->destNation['scout'] == 1){
$this->reason = "임관이 금지되어 있습니다.";
return false;
}
@@ -4,6 +4,8 @@ namespace sammo\Constraint;
use \sammo\GameUnitConst;
use \sammo\DB;
use \sammo\KVStorage;
use \sammo\CityConst;
class AvailableRecruitCrewType extends Constraint{
const REQ_VALUES = Constraint::REQ_NATION|Constraint::REQ_INT_ARG;
+1 -1
View File
@@ -22,7 +22,7 @@ class BeLord extends Constraint{
$this->checkInputValues();
$this->tested = true;
if($this->general['level'] != 12){
if($this->general['level'] == 12){
return true;
}
-2
View File
@@ -193,9 +193,7 @@ 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) == 2){
$arg = $constraintArgs[1];
+1 -1
View File
@@ -4,7 +4,7 @@ namespace sammo\Constraint;
use \sammo\JosaUtil;
class RemainCityTrust extends Constraint{
class ReqCityTrust extends Constraint{
const REQ_VALUES = Constraint::REQ_CITY|Constraint::REQ_NUMERIC_ARG;
protected $key;
+1 -1
View File
@@ -22,7 +22,7 @@ class ReqGeneralGold extends Constraint{
$this->checkInputValues();
$this->tested = true;
if($this->general['gold'] < $this->arg){
if($this->general['gold'] >= $this->arg){
return true;
}
+1 -1
View File
@@ -22,7 +22,7 @@ class ReqGeneralRice extends Constraint{
$this->checkInputValues();
$this->tested = true;
if($this->general['rice'] < $this->arg){
if($this->general['rice'] >= $this->arg){
return true;
}
+1 -1
View File
@@ -22,7 +22,7 @@ class ReqNationGold extends Constraint{
$this->checkInputValues();
$this->tested = true;
if($this->nation['gold'] < $this->arg){
if($this->nation['gold'] >= $this->arg){
return true;
}
+1 -1
View File
@@ -22,7 +22,7 @@ class ReqNationRice extends Constraint{
$this->checkInputValues();
$this->tested = true;
if($this->nation['rice'] < $this->arg){
if($this->nation['rice'] >= $this->arg){
return true;
}
-2
View File
@@ -1,7 +1,6 @@
<?php
namespace sammo;
class DummyGeneral extends General{
public function __construct(bool $initLogger=true){
$raw = [
@@ -12,7 +11,6 @@ class DummyGeneral extends General{
'level'=>0,
];
$staticNation = getNationStaticInfo($raw['nation']);
$this->raw = $raw;
$this->resultTurn = new LastTurn();
+21 -9
View File
@@ -492,6 +492,10 @@ class GeneralAI{
return [$command, $arg];
}
if($this->nation['level'] == 0){
return ['휴식', null];
}
if($generalObj->getVar('level') == 12 && $this->dipState == self::d평화 && !$this->attackable){
$targetNationID = $this->findWarTarget();
if($targetNationID !== null){
@@ -537,6 +541,8 @@ class GeneralAI{
shuffle($frontCitiesID);
shuffle($supplyCitiesID);
assert($supplyCitiesID);
$commandList = [];
@@ -1281,10 +1287,13 @@ class GeneralAI{
$moveCities[$moveCityID] = $score;
}
return ['che_NPC능동', [
'optionText'=>'순간이동',
'destCityID'=>Util::choiceRandomUsingWeight($moveCities),
]];
if($moveCities){
return ['che_NPC능동', [
'optionText'=>'순간이동',
'destCityID'=>Util::choiceRandomUsingWeight($moveCities),
]];
}
}
return $developTurn;
@@ -1432,10 +1441,13 @@ class GeneralAI{
}
}
return ['che_NPC능동', [
'optionText'=>'순간이동',
'destCityID'=>Util::choiceRandomUsingWeight($attackableCities),
]];
if($attackableCities){
return ['che_NPC능동', [
'optionText'=>'순간이동',
'destCityID'=>Util::choiceRandomUsingWeight($attackableCities),
]];
}
}
if($general->getVar('train') < 90){
@@ -1509,7 +1521,7 @@ class GeneralAI{
}
if($city['nation'] == 0 && ($city['level'] == 5 || $city['level'] == 6)) {
$nationType = Util::choiceRandom(array_keys(getNationTypeList()));
$nationType = Util::choiceRandom(GameConst::$availableNationType);
$nationColor = Util::choiceRandom(array_keys(GetNationColors()));
return ['che_건국', [
'nationName'=>"".mb_substr($general->getName(), 1),
+1
View File
@@ -152,6 +152,7 @@ class NPC{
$this->dex20 = $cavalry;
$this->dex30 = $wizard;
$this->dex40 = $siege;
return $this;
}
public function build($env=[]){