버그 수정

This commit is contained in:
2020-04-20 00:47:35 +09:00
parent 8d41dead5d
commit 3a44782b05
10 changed files with 137 additions and 54 deletions
+3
View File
@@ -268,6 +268,9 @@ function pushNationHistory(int $nationID, ?array $history, ?int $year=null, ?int
if(!$history){
return;
}
if(!$nationID){
return;
}
$db = DB::db();
if($year === null || $month === null){
+9 -4
View File
@@ -85,7 +85,8 @@ function processGoldIncome() {
." // 지급률 : ".tab2((string)round($ratio*100,2),5," ")
." % // 결과금 : ".tab2((string)$nation['gold'],6," ");
$incomeLog = "이번 수입은 금 <C>$income</>입니다.";
$incomeText = number_format($income);
$incomeLog = "이번 수입은 금 <C>$incomeText</>입니다.";
$db->update('nation', [
'gold'=>$nation['gold']
@@ -101,7 +102,9 @@ function processGoldIncome() {
if($generalObj->getVar('officer_level') > 4){
$logger->pushGeneralActionLog($incomeLog, $logger::PLAIN);
}
$logger->pushGeneralActionLog("봉급으로 금 <C>$gold</>을 받았습니다.", $logger::PLAIN);
$goldText = number_format($gold);
$logger->pushGeneralActionLog("봉급으로 금 <C>$goldText</>을 받았습니다.", $logger::PLAIN);
$generalObj->applyDB($db);
}
}
@@ -357,7 +360,8 @@ function processRiceIncome() {
." // 지급률 : ".tab2((string)round($ratio*100,2),5," ")
." % // 결과곡 : ".tab2((string)$nation['rice'],6," ");
$incomeLog = "이번 수입은 쌀 <C>$income</>입니다.";
$incomeText = number_format($income);
$incomeLog = "이번 수입은 쌀 <C>$incomeText</>입니다.";
$db->update('nation', [
'rice'=>$nation['rice']
@@ -373,7 +377,8 @@ function processRiceIncome() {
if($generalObj->getVar('officer_level') > 4){
$logger->pushGeneralActionLog($incomeLog, $logger::PLAIN);
}
$logger->pushGeneralActionLog("봉급으로 쌀 <C>$rice</>을 받았습니다.", $logger::PLAIN);
$riceText = number_format($rice);
$logger->pushGeneralActionLog("봉급으로 쌀 <C>$riceText</>을 받았습니다.", $logger::PLAIN);
$generalObj->applyDB($db);
}
}
+19 -19
View File
@@ -660,8 +660,8 @@ function setGift($tnmt_type, $tnmt, $phase) {
'gold'=>$db->sqleval('gold + %i', $cost)
], 'no=%i', $general['no']);
$db->update('rank_data', [
"{$tp2}g" => $db->sqleval('%b + 1', "{$tp2}g")
], 'general_id = %i', $general['no']);
'value' => $db->sqleval('value + 1')
], 'general_id = %i AND type = %s', $general['no'], "{$tp2}g");
//포상 장수 이름, 금액
$logger = new ActionLogger($generalID, 0, $admin['year'], $admin['month']);
@@ -683,8 +683,8 @@ function setGift($tnmt_type, $tnmt, $phase) {
'gold'=>$db->sqleval('gold + %i', $cost)
], 'no=%i', $general['no']);
$db->update('rank_data', [
"{$tp2}g" => $db->sqleval('%b + 1', "{$tp2}g")
], 'general_id = %i', $general['no']);
'value' => $db->sqleval('value + 1')
], 'general_id = %i AND type = %s', $general['no'], "{$tp2}g");
//포상 장수 이름, 금액
$resultHelper[$generalID]['reward'] += $cost;
@@ -699,8 +699,8 @@ function setGift($tnmt_type, $tnmt, $phase) {
'gold'=>$db->sqleval('gold + %i', $cost)
], 'no=%i', $general['no']);
$db->update('rank_data', [
"{$tp2}g" => $db->sqleval('%b + 2', "{$tp2}g")
], 'general_id = %i', $general['no']);
'value' => $db->sqleval('value + 2')
], 'general_id = %i AND type = %s', $general['no'], "{$tp2}g");
//포상 장수 이름, 금액
$resultHelper[$generalID]['reward'] += $cost;
@@ -715,8 +715,8 @@ function setGift($tnmt_type, $tnmt, $phase) {
'gold'=>$db->sqleval('gold + %i', $cost)
], 'no=%i', $general['no']);
$db->update('rank_data', [
"{$tp2}g" => $db->sqleval('%b + 2', "{$tp2}g")
], 'general_id = %i', $general['no']);
'value' => $db->sqleval('value + 2')
], 'general_id = %i AND type = %s', $general['no'], "{$tp2}g");
//포상 장수 이름, 금액
$resultHelper[$generalID]['reward'] += $cost;
@@ -727,15 +727,15 @@ function setGift($tnmt_type, $tnmt, $phase) {
}
//우승자 명성 돈
$cost = $admin['develcost'] * 8;
foreach($db->query('SELECT no, name FROM tournament WHERE grp>=6 AND no > 0') as $general){
foreach($db->query('SELECT no, name FROM tournament WHERE grp>=60 AND no > 0') as $general){
$generalID = $general['no'];
$db->update('general', [
'experience'=>$db->sqleval('experience + 200'),
'gold'=>$db->sqleval('gold + %i', $cost)
], 'no=%i', $general['no']);
$db->update('rank_data', [
"{$tp2}g" => $db->sqleval('%b + 2', "{$tp2}g")
], 'general_id = %i', $general['no']);
'value' => $db->sqleval('value + 2')
], 'general_id = %i AND type = %s', $general['no'], "{$tp2}g");
//포상 장수 이름, 금액
$resultHelper[$generalID]['reward'] += $cost;
@@ -1103,18 +1103,18 @@ function fight($tnmt_type, $tnmt, $phs, $group, $g1, $g2, $type) {
}
$db->update('rank_data', [
"{$tp2}{$gen1resKey}" => $db->sqleval('%b + 1', "{$tp2}{$gen1resKey}")
], 'no=%i',$gen1['no']);
'value' => $db->sqleval('value + 1')
], 'general_id=%i AND type = %s',$gen1['no'], "{$tp2}{$gen1resKey}");
$db->update('rank_data', [
"{$tp2}g" => $db->sqleval('%b + %i', "{$tp2}g", $gl1)
], 'no=%i',$gen1['no']);
'value' => $db->sqleval('value + %i', $gl1),
], 'general_id=%i AND type = %s',$gen1['no'], "{$tp2}g");
$db->update('rank_data', [
"{$tp2}{$gen2resKey}" => $db->sqleval('%b + 1', "{$tp2}{$gen2resKey}")
], 'no=%i',$gen2['no']);
'value' => $db->sqleval('value + 1'),
], 'general_id=%i AND type = %s',$gen2['no'], "{$tp2}{$gen2resKey}");
$db->update('rank_data', [
"{$tp2}g" => $db->sqleval('%b + %i', "{$tp2}g", $gl2)
], 'no=%i',$gen2['no']);
'value' => $db->sqleval('value + %i', $gl2)
], 'general_id=%i AND type = %s',$gen2['no'], "{$tp2}g");
+4 -4
View File
@@ -74,22 +74,22 @@ class ActionLogger{
}
public function flush(){
if($this->generalHistoryLog){
if($this->generalHistoryLog && $this->generalID){
pushGeneralHistory($this->generalID, $this->generalHistoryLog, $this->year, $this->month);
$this->generalHistoryLog = [];
}
if($this->generalActionLog){
if($this->generalActionLog && $this->generalID){
pushGenLog($this->generalID, $this->generalActionLog, $this->year, $this->month);
$this->generalActionLog = [];
}
if($this->generalBattleResultLog){
if($this->generalBattleResultLog && $this->generalID){
pushBatRes($this->generalID, $this->generalBattleResultLog, $this->year, $this->month);
$this->generalBattleResultLog = [];
}
if($this->generalBattleDetailLog){
if($this->generalBattleDetailLog && $this->generalID){
pushBatLog($this->generalID, $this->generalBattleDetailLog, $this->year, $this->month);
$this->generalBattleDetailLog = [];
}
+12 -2
View File
@@ -29,9 +29,14 @@ class che_랜덤임관 extends Command\GeneralCommand{
static public $reqArg = false;
protected function argTest():bool{
if($this->arg === null){
$this->arg = null;
return true;
//TODO: 구현
/*if($this->arg === null){
return true;
}
$destNationIDList = $this->arg['destNationIDList']??null;
//null은 에러, []는 정상
@@ -53,7 +58,7 @@ class che_랜덤임관 extends Command\GeneralCommand{
'destNationIDList' => $destNationIDList
];
return true;
return true;*/
}
protected function init(){
@@ -71,9 +76,11 @@ class che_랜덤임관 extends Command\GeneralCommand{
ConstraintHelper::AllowJoinAction(),
];
/*
if($this->arg['destNationIDList']??false){
$this->runnableConstraints[] = ConstraintHelper::ExistsAllowJoinNation($relYear, $this->arg['destNationIDList']);
}
*/
}
public function getCost():array{
@@ -103,7 +110,10 @@ class che_랜덤임관 extends Command\GeneralCommand{
$relYear = $env['year'] - $env['startyear'];
/*
$notIn = array_merge($general->getAuxVar('joinedNations')??[], $this->arg['destNationIDList']);
*/
$notIn = null;
$destNation = null;
+2 -2
View File
@@ -145,8 +145,8 @@ class che_증여 extends Command\GeneralCommand{
$destGeneral->increaseVarWithLimit($resKey, $amount);
$general->increaseVarWithLimit($resKey, -$amount, 0);
$destGeneral->getLogger()->pushGeneralActionLog("{$general->getName()}</>에게서 {$resName} <C>{$amountText}</>을 증여 받았습니다.", ActionLogger::PLAIN);
$logger->pushGeneralActionLog("{$destGeneral->getName()}에게 {$resName} <C>$amountText</>을 증여했습니다. <1>$date</>");
$destGeneral->getLogger()->pushGeneralActionLog("<Y>{$general->getName()}</>에게서 {$resName} <C>{$amountText}</>을 증여 받았습니다.", ActionLogger::PLAIN);
$logger->pushGeneralActionLog("<Y>{$destGeneral->getName()}</>에게 {$resName} <C>$amountText</>을 증여했습니다. <1>$date</>");
$exp = 70;
$ded = 100;
+7
View File
@@ -84,6 +84,13 @@ class che_출병 extends Command\GeneralCommand{
return 0;
}
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{
$commandName = $this->getName();
$failReason = $this->testRunnable();
+1 -1
View File
@@ -182,7 +182,7 @@ class che_몰수 extends Command\NationCommand{
], 'nation=%i', $nationID);
$destGeneral->getLogger()->pushGeneralActionLog("{$resName} {$amountText}을 몰수 당했습니다.", ActionLogger::PLAIN);
$logger->pushGeneralActionLog("{$destGeneral->getName()}에게서 {$resName} <C>$amountText</>을 몰수했습니다. <1>$date</>");
$logger->pushGeneralActionLog("<Y>{$destGeneral->getName()}</>에게서 {$resName} <C>$amountText</>을 몰수했습니다. <1>$date</>");
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->applyDB($db);
+79 -21
View File
@@ -200,9 +200,13 @@ class GeneralAI
$warTargetNation[$warNationID] = 1;
}
}
$warTargetNation[0] = 0;
$this->warTargetNation = $warTargetNation;
if(!$onWar){
$warTargetNation[0] = 1;
}
$this->warTargetNation = $warTargetNation;
$minWarTerm = $db->queryFirstField('SELECT min(term) FROM diplomacy WHERE me = %i AND state=1', $nationID);
if ($minWarTerm === null) {
@@ -1057,6 +1061,7 @@ class GeneralAI
if(!$cmd->isRunnable()){
return null;
}
return $cmd;
}
@@ -1148,6 +1153,7 @@ class GeneralAI
if(!$cmd->isRunnable()){
return null;
}
return $cmd;
}
@@ -1222,6 +1228,7 @@ class GeneralAI
if(!$cmd->isRunnable()){
return null;
}
return $cmd;
}
@@ -1327,6 +1334,7 @@ class GeneralAI
if(!$cmd->isRunnable()){
return null;
}
return $cmd;
}
@@ -1449,6 +1457,7 @@ class GeneralAI
if(!$cmd->isRunnable()){
return null;
}
return $cmd;
}
@@ -1481,6 +1490,7 @@ class GeneralAI
if(!$cmd->isRunnable()){
return null;
}
return $cmd;
}
@@ -1619,7 +1629,6 @@ class GeneralAI
$nationStor->setValue("last천도Trial_{$this->nation['nation']}", [$general->getVar('officer_level'), $general->getTurnTime()]);
return $cmd;
}
@@ -1845,7 +1854,8 @@ class GeneralAI
return null;
}
return Util::choiceRandomUsingWeightPair($cmdList);
$cmd = Util::choiceRandomUsingWeightPair($cmdList);
return $cmd;
}
@@ -2149,9 +2159,6 @@ class GeneralAI
if (!$this->attackable) {
return null;
}
if($this->dipState !== self::d전쟁){
return null;
}
$general = $this->getGeneralObj();
$city = $this->city;
@@ -2162,13 +2169,24 @@ class GeneralAI
$db = DB::db();
if ($city['front'] <= 1) {
if($general->getVar('train') < $this->nationPolicy->properWarTrainAtmos){
return null;
}
if($general->getVar('atmos') < $this->nationPolicy->properWarTrainAtmos){
return null;
}
if($city['front'] === 0){
return null;
}
if ($city['front'] === 1 && $this->dipState === self::d전쟁) {
return null;
}
$attackableNations = [];
foreach ($this->warTargetNation as $targetNationID => $state) {
if ($state == 1) {
if ($this->dipState === self::d전쟁 && $state == 1) {
continue;
}
$attackableNations[] = $targetNationID;
@@ -2185,7 +2203,12 @@ class GeneralAI
throw new \RuntimeException('출병 불가' . $cityID . var_export($attackableNations, true) . var_export($nearCities, true));
}
return buildGeneralCommandClass('che_출병', $general, $this->env, ['destCityID' => Util::choiceRandom($attackableCities)]);
$cmd = buildGeneralCommandClass('che_출병', $general, $this->env, ['destCityID' => Util::choiceRandom($attackableCities)]);
if(!$cmd->isRunnable()){
return null;
}
return $cmd;
}
@@ -2404,6 +2427,11 @@ class GeneralAI
$availableTypeCnt += 1;
}
if($availableTypeCnt === 0){
//무능장은 인탐을 하세요.
return null;
}
if(!Util::randBool($warpProp)){
return null;
}
@@ -2426,7 +2454,10 @@ class GeneralAI
}
$realDevelRate += $develVal;
}
$realDevelRate /= $availableTypeCnt;
if($realDevelRate >= 0.95){
continue;
}
@@ -2445,6 +2476,7 @@ class GeneralAI
if(!$cmd->isRunnable()){
return null;
}
return $cmd;
}
@@ -2461,6 +2493,7 @@ class GeneralAI
if(!$cmd->isRunnable()){
return null;
}
return $cmd;
}
@@ -2526,6 +2559,7 @@ class GeneralAI
if(!$cmd->isRunnable()){
return null;
}
return $cmd;
}
@@ -2556,6 +2590,7 @@ class GeneralAI
if(!$cmd->isRunnable()){
return null;
}
return $cmd;
}
@@ -2565,6 +2600,7 @@ class GeneralAI
if(!$cmd->isRunnable()){
return null;
}
return $cmd;
}
@@ -2580,6 +2616,7 @@ class GeneralAI
if(!$cmd->isRunnable()){
return null;
}
return $cmd;
}
@@ -2593,6 +2630,7 @@ class GeneralAI
if(!$cmd->isRunnable()){
return null;
}
return $cmd;
}
@@ -2616,6 +2654,7 @@ class GeneralAI
if(!$cmd->isRunnable()){
return null;
}
return $cmd;
}
}
@@ -2644,6 +2683,7 @@ class GeneralAI
if(!$cmd->isRunnable()){
return null;
}
return $cmd;
}
@@ -2695,7 +2735,8 @@ class GeneralAI
{
$general = $this->general;
if($general->getNationID() == 0){
return buildGeneralCommandClass('che_견문', $this->general, $this->env);
$cmd = buildGeneralCommandClass('che_견문', $this->general, $this->env);
return $cmd;
}
@@ -2710,7 +2751,8 @@ class GeneralAI
$candidate[] = 'che_인재탐색';
return buildGeneralCommandClass(Util::choiceRandom($candidate), $this->general, $this->env);
$cmd = buildGeneralCommandClass(Util::choiceRandom($candidate), $this->general, $this->env);
return $cmd;
}
protected function categorizeNationCities():void{
@@ -2966,25 +3008,32 @@ class GeneralAI
if($general->getVar('officer_level') === 12 && $this->generalPolicy->can선양){
$result = $this->do선양();
if($result !== null){
$result->reason='do선양';
return $result;
}
}
if($npcType == 5){
return $this->do집합();
$result = $this->do집합();
$result->reason='do집합';
return $result;
}
if(!($reservedCommand instanceof Command\General\휴식)){
$reservedCommand->reason='do예약턴';
return $reservedCommand;
}
if ($general->getVar('injury') > 10) {
return buildGeneralCommandClass('che_요양', $general, $this->env);
$result = buildGeneralCommandClass('che_요양', $general, $this->env);
$result->reason='do요양';
return $result;
}
if($npcType == 2 && $nationID == 0){
$result = $this->do거병();
if($result !== null){
$result->reason='do거병';
return $result;
}
}
@@ -2992,24 +3041,30 @@ class GeneralAI
if($nationID === 0 && $this->generalPolicy->can국가선택){
$result = $this->do국가선택();
if($result !== null){
$result->reason='do국가선택';
return $result;
}
return $this->do중립();
$result = $this->do중립();
$result->reason='do중립';
return $result;
}
if($npcType >= 2 && $general->getVar('officer_level') == 12 && !$this->nation['capital']){
//방랑군 건국
$result = $this->do건국();
if($result !== null){
$result->reason='do건국';
return $result;
}
$result = $this->do방랑군이동();
if($result !== null){
$result->reason='do방랑군이동';
return $result;
}
$result = $this->do해산();
if($result !== null){
$result->reason='do해산';
return $result;
}
}
@@ -3021,11 +3076,14 @@ class GeneralAI
/** @var ?GeneralCommand */
$result = $this->{'do'.$actionName}();
if($result !== null){
$result->reason='do'.$actionName;
return $result;
}
}
return $this->do중립();
$result = $this->do중립();
$result->reason='do중립';
return $result;
}
protected function calcNationDevelopedRate()
@@ -3139,11 +3197,11 @@ class GeneralAI
return [
'trust' => [$city['trust'] / 100, self::t통솔장],
'pop' => [$city['pop'] / $city['pop_max'], self::t통솔장],
'agri' => [$city['agri'] / $city['agri_max'], self::t통솔],
'comm' => [$city['comm'] / $city['comm_max'], self::t통솔],
'secu' => [$city['secu'] / $city['secu_max'], self::t통솔],
'def' => [$city['def'] / $city['def_max'], self::t통솔],
'wall' => [$city['wall'] / $city['wall_max'], self::t통솔],
'agri' => [$city['agri'] / $city['agri_max'], self::t],
'comm' => [$city['comm'] / $city['comm_max'], self::t],
'secu' => [$city['secu'] / $city['secu_max'], self::t],
'def' => [$city['def'] / $city['def_max'], self::t],
'wall' => [$city['wall'] / $city['wall_max'], self::t],
];
}
+1 -1
View File
@@ -269,7 +269,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
}
$generalCommandObj = $ai->chooseGeneralTurn($generalCommandObj); // npc AI 처리
LogText("turn", "General: {$general->getName()}[{$general->getID()},{$general->getStaticNation()['name']}]; run; {$generalCommandObj->getBrief()}");
LogText("turn", "General, {$general->getName()}, {$general->getID()}, {$general->getStaticNation()['name']}, {$generalCommandObj->getBrief()}, {$generalCommandObj->reason}, ");
}
if(!$turnObj->processBlocked()){