버그 수정...

This commit is contained in:
2019-10-06 14:49:41 +09:00
parent 46acfe9470
commit 617ca22f2d
28 changed files with 115 additions and 102 deletions
+2 -2
View File
@@ -252,7 +252,7 @@ abstract class BaseCommand{
'destNation'=>$this->destNation,
];
$this->reasonNotReservable = Constraint::testAll($this->reservableConstraints??[], $constraintInput);
$this->reasonNotReservable = Constraint::testAll($this->reservableConstraints??[], $constraintInput, $this->env);
$this->reservable = $this->reasonNotReservable === null;
return $this->reasonNotReservable;
}
@@ -288,7 +288,7 @@ abstract class BaseCommand{
'destNation'=>$this->destNation,
];
$this->reasonNotRunnable = Constraint::testAll($this->runnableConstraints??[], $constraintInput);
$this->reasonNotRunnable = Constraint::testAll($this->runnableConstraints??[], $constraintInput, $this->env);
$this->runnable = $this->reasonNotRunnable === null;
return $this->reasonNotRunnable;
+1 -1
View File
@@ -71,7 +71,7 @@ class che_귀환 extends Command\GeneralCommand{
$generalLevel = $general->getVar('level');
$target = null;
if(2 <= $generalLevel && 4 <= $generalLevel){
if(2 <= $generalLevel && $generalLevel <= 4){
$target = $db->queryFirstList(
'SELECT city, name FROM city WHERE %b=%i AND nation = %i',
'officer'.$general->getVar('level'), $generalID, $general->getNationID()
@@ -34,7 +34,7 @@ class che_인재탐색 extends Command\GeneralCommand{
$general = $this->generalObj;
$this->setNation(['gennum']);
$this->setNation(['gennum', 'scout']);
$env = $this->env;
[$reqGold, $reqRice] = $this->getCost();
+1
View File
@@ -160,6 +160,7 @@ class che_임관 extends Command\GeneralCommand{
$db->update('nation', [
'gennum'=>$db->sqleval('gennum + 1')
], 'nation=%i', $destNationID);
\sammo\refreshNationStaticInfo();
$relYear = $env['year'] - $env['startyear'];
if($general->getVar('npc') == 1 || $relYear >= 3){
+1 -1
View File
@@ -128,7 +128,7 @@ class che_출병 extends Command\GeneralCommand{
$general->applyDB($db);
//TODO: 장기적으로 통합해야함
$attackerNation = $db->queryFirstRow('SELECT nation, name, color, type, level, capital, tech from nation WHERE nation = %i', $attackerNationID);
$attackerNation = $db->queryFirstRow('SELECT nation, name, color, type, level, capital, tech, gennum from nation WHERE nation = %i', $attackerNationID);
processWar($general, $attackerNation, $this->destCity);
tryUniqueItemLottery($general);
+1
View File
@@ -112,6 +112,7 @@ class che_하야 extends Command\GeneralCommand{
'rice'=>$db->sqleval('rice + %i', $lostRice),
'gennum'=>$db->sqleval('gennum - 1')
], 'nation=%i', $nationID);
\sammo\refreshNationStaticInfo();
$general->setVar('nation', 0);
$general->setVar('level', 0);
+7 -4
View File
@@ -8,13 +8,16 @@ use \sammo\{
GameConst,
LastTurn,
GameUnitConst,
Command
Command,
MessageTarget,
Message
};
use function \sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalScoreEx
CriticalScoreEx,
GetImageURL
};
use \sammo\Constraint\Constraint;
@@ -70,7 +73,7 @@ class che_몰수 extends Command\NationCommand{
$this->setCity();
$this->setNation(['gold', 'rice']);
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'nation'], 1);
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'npc', 'nation'], 1);
$this->setDestGeneral($destGeneral);
$relYear = $env['year'] - $env['startyear'];
@@ -118,7 +121,7 @@ class che_몰수 extends Command\NationCommand{
$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);
if($destGeneral->getVar('npc') >= 2 && Util::randBool(0.01)){
+9 -2
View File
@@ -26,6 +26,8 @@ abstract class Constraint{
protected $nation = null;
protected $arg = null;
protected $env = null;
protected $cmd_arg = null;
protected $destGeneral = null;
@@ -62,6 +64,11 @@ abstract class Constraint{
$this->tested = false;
$this->reason = null;
}
public function setEnv($env){
$this->env = $env;
$this->tested = false;
$this->reason = null;
}
public function setCmdArg($cmd_arg){
$this->cmd_arg = $cmd_arg;
$this->tested = false;
@@ -182,7 +189,7 @@ abstract class Constraint{
return $this->reason;
}
public static function testAll(array $constraintPacks, array $input):?string{
public static function testAll(array $constraintPacks, array $input, array $env):?string{
foreach($constraintPacks as $constraintArgs){
if (!$constraintArgs){
continue;
@@ -194,7 +201,7 @@ abstract class Constraint{
$constraint = call_user_func($method,$input);
assert($constraint instanceof Constraint);
$constraint->setEnv($env);
if(count($constraintArgs) == 2){
$arg = $constraintArgs[1];
$constraint->setArg($arg);
+2 -2
View File
@@ -23,11 +23,11 @@ class ReqEnvValue extends Constraint{
}
if(count($this->arg) == 4){
[$this->key, $this->reqVal, $comp, $this->msg] = $this->arg;
[$this->key, $comp, $this->reqVal, $this->msg] = $this->arg;
if(!in_array($comp, ['>', '>=', '==', '<=', '<', '!=', '===', '!=='])){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("invalid comparator");
throw new \InvalidArgumentException("invalid comparator($comp)");
}
}
else{
+2 -1
View File
@@ -9,7 +9,8 @@ class DummyGeneral extends General{
'city'=>0,
'nation'=>0,
'level'=>0,
'crewtype'=>-1
'crewtype'=>-1,
'turntime'=>'2012-03-04 05:06:07.000000'
];
$this->raw = $raw;
+37 -23
View File
@@ -127,13 +127,20 @@ class GeneralAI{
$this->attackable = ($frontStatus !== null)?$frontStatus:false;
$warTarget = $db->queryAllLists(
'SELECT you, state FROM diplomacy WHERE me = %i AND (state = 1 OR (state = 0 AND term < 5))',
'SELECT you, state FROM diplomacy WHERE me = %i AND (state = 0 OR (state = 1 AND term < 5))',
$nationID
);
$onWar = false;
$warTargetNation = [];
foreach($warTarget as [$warNationID, $warState]){
$warTargetNation[$warNationID] = $warState==0?2:1;
if($warState == 0){
$onWar = true;
$warTargetNation[$warNationID] = 2;
}
else{
$warTargetNation[$warNationID] = 1;
}
}
$warTargetNation[0] = 0;
$this->warTargetNation = $warTargetNation;
@@ -153,20 +160,14 @@ class GeneralAI{
$this->dipState = self::d직전;
}
if(
in_array($this->dipState, [self::d평화, self::d선포]) ||
$env['year'] >= $env['startyear'] + 3 ||
($env['year'] && $env['startyear'] + 2 && $env['month'] > 5)
){
$this->dipState = self::d징병;
}
if($this->attackable){
//전쟁으로 인한 attackable인가?
$onWar = $db->queryFirstField('SELECT you FROM diplomacy WHERE me = %i AND state=0 LIMIT 1', $nationID) !== null;
if($onWar){
$this->dipState = self::d전쟁;
}
else{
$this->dipState = self::d징병;
}
}
}
@@ -194,8 +195,8 @@ class GeneralAI{
];
// 우선 선정
if($develRate['trust'] < 0.95 && Util::randBool($leadership / 40)){
return ['che_선정', null];
if($develRate['trust'] < 1 && Util::randBool($leadership / 60)){
return ['che_주민선정', null];
}
$commandList = [];
@@ -248,7 +249,14 @@ class GeneralAI{
if(!TechLimit($env['startyear'], $env['year'], $nation['tech'])){
$commandObj = buildGeneralCommandClass('che_기술연구', $general, $env);
if($commandObj->isRunnable()){
$commandList['che_기술연구'] = $intel / 4;
if(!TechLimit($env['startyear'], $env['year'], $nation['tech']+1000)){
//한등급 이상 뒤쳐져 있다면, 조금 더 열심히 하자.
$commandList['che_기술연구'] = $intel;
}
else{
$commandList['che_기술연구'] = $intel / 4;
}
}
}
}
@@ -256,7 +264,7 @@ class GeneralAI{
if($develRate['trust'] < 1){
$commandObj = buildGeneralCommandClass('che_주민선정', $general, $env);
if($commandObj->isRunnable()){
$commandList['che_주민선정'] = $leadership / 2;
$commandList['che_주민선정'] = power($leadership * 2, 1 / ($develRate['trust'] + 0.001));
}
}
if($develRate['pop'] < 0.99){
@@ -283,7 +291,7 @@ class GeneralAI{
$commandList['che_물자조달'] = (
(GameConst::$minNationalGold + GameConst::$minNationalRice + 24*5*$env['develcost']) /
Util::valueFit($nation['gold'] + $nation['rice'], (GameConst::$defaultGold + GameConst::$defaultRice)/2)
) * 10;
);
return [Util::choiceRandomUsingWeight($commandList), null];
}
@@ -507,6 +515,8 @@ class GeneralAI{
}
if($generalObj->getVar('level') == 12 && $this->dipState == self::d평화 && !$this->attackable){
$targetNationID = $this->findWarTarget();
if($targetNationID !== null){
return ['che_선전포고', ['destNationID'=>$targetNationID]];
@@ -1357,7 +1367,7 @@ class GeneralAI{
$db = DB::db();
$general = $this->getGeneralObj();
if(!$this->attackable && in_array($this->dipState, [self::d평화, self::d선포])){
if(!$this->attackable && $this->dipState == self::d평화){
if($this->dipState == self::d평화 && $general->getVar('crew')>=1000 && Util::randBool(0.25)){
return ['che_소집해제', null];
}
@@ -1516,7 +1526,7 @@ class GeneralAI{
$db = DB::db();
if($city['front'] <= 1){
throw new \RuntimeException('출병 불가');
throw new \RuntimeException('출병 불가'.$cityID);
}
$attackableNations = [];
@@ -1534,6 +1544,10 @@ class GeneralAI{
$nearCities
);
if(count($attackableCities) == 0){
throw new \RuntimeException('출병 불가'.$cityID.var_export($attackableNations, true).var_export($nearCities, true));
}
return ['che_출병', ['destCityID'=>Util::choiceRandom($attackableCities)]];
}
@@ -1656,7 +1670,7 @@ class GeneralAI{
$nationID = $this->nation['nation'];
$this->devRate = $db->queryFirstRow(
'SELECT sum(pop)/sum(pop2)*100 as pop_p,(sum(agri)+sum(comm)+sum(secu)+sum(def)+sum(wall))/(sum(agri2)+sum(comm2)+sum(secu2)+sum(def2)+sum(wall2))*100 as all_p from city where nation=%i',
'SELECT sum(pop)/sum(pop2) as pop_p,(sum(agri)+sum(comm)+sum(secu)+sum(def)+sum(wall))/(sum(agri2)+sum(comm2)+sum(secu2)+sum(def2)+sum(wall2)) as all_p from city where nation=%i',
$nationID
);
return $this->devRate;
@@ -1676,7 +1690,7 @@ class GeneralAI{
}
$devRate = $this->getNationDevelopedRate();
if(($devRate['pop_p'] + $devRate['all_p']) / 2 < 80){
if(($devRate['pop_p'] + $devRate['all_p']) / 2 < 0.8){
return null;
}
@@ -1829,9 +1843,9 @@ class GeneralAI{
$avg = ($devRate['pop_p'] + $devRate['all_p']) / 2;
if($avg > 95) $rate = 25;
elseif($avg > 70) $rate = 20;
elseif($avg > 50) $rate = 15;
if($avg > 0.95) $rate = 25;
elseif($avg > 0.70) $rate = 20;
elseif($avg > 0.50) $rate = 15;
else $rate = 10;
$db->update('nation', [
+1 -1
View File
@@ -97,7 +97,7 @@ class DyingMessage{
$this->general = $general;
$this->name = $general->getName();
$this->npc = $general->getVar('npc');
if($general['owner'] > 0 && $general->getVar('startage') - $general->getVar('age') > 1){
if($general->getVar('owner') > 0 && $general->getVar('startage') - $general->getVar('age') > 1){
$this->realName = $general->getVar('name2');
}
}
+1 -8
View File
@@ -238,7 +238,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
$general->getVar('level')
)??[];
$hasNationTurn = true;
$nationCommand = $rawNationTurn['action'];
$nationCommand = $rawNationTurn['action']??null;
$nationArg = Json::decode($rawNationTurn['arg']??null);
}
@@ -410,13 +410,6 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
$gameStor->turntime = $currentTurn;
}
// 부상 과도 제한
//TODO: 없애고, 부상 자체가 80 이상 넘지 않도록 처리
$db->update('general', [
'injury'=>80
], 'injury>%i', 80);
//토너먼트 처리
processTournament();
//거래 처리
+1 -1
View File
@@ -52,7 +52,7 @@ class WarUnitGeneral extends WarUnit{
$general->updateVar('recwar', $general->getTurnTime());
}
else if($oppose !== null){
$general->updateVar('recwar', $oppose->getTurnTime());
$general->updateVar('recwar', $oppose->getGeneral()->getTurnTime());
}
}
@@ -32,7 +32,7 @@ class che_위압시도 extends BaseWarUnitTrigger{
return true;
}
$this->activateSkill('위압');
$self->activateSkill('위압');
return true;
}
}
@@ -6,6 +6,7 @@ use sammo\WarUnitCity;
use sammo\WarUnit;
use sammo\GameUnitDetail;
use sammo\ObjectTrigger;
use sammo\Util;
class che_저격시도 extends BaseWarUnitTrigger{
protected $priority = ObjectTrigger::PRIORITY_PRE + 100;
@@ -37,7 +38,7 @@ class che_저격시도 extends BaseWarUnitTrigger{
return true;
}
$this->activateSkill('저격');
$self->activateSkill('저격');
$selfEnv['woundMin'] = $this->woundMin;
$selfEnv['woundMax'] = $this->woundMax;
@@ -22,7 +22,7 @@ class che_전투치료시도 extends BaseWarUnitTrigger{
return true;
}
$this->activateSkill('치료');
$self->activateSkill('치료');
return true;
@@ -25,7 +25,7 @@ class che_회피시도 extends BaseWarUnitTrigger{
return true;
}
$this->activateSkill('특수', '회피시도', '회피');
$self->activateSkill('특수', '회피시도', '회피');
return true;