버그 수정..

This commit is contained in:
2020-03-06 20:01:11 +09:00
parent 33c7b4c440
commit 573d313cc8
5 changed files with 52 additions and 24 deletions
+23
View File
@@ -30,6 +30,15 @@ $db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env'); $gameStor = KVStorage::getStorage($db, 'game_env');
switch($btn) { switch($btn) {
case "분당김": case "분당김":
$locked = false;
for($i = 0; $i < 10; $i++){
if(tryLock()){
$locked = true;
break;
}
usleep(500000);
}
$gameStor->cacheValues(['turntime', 'starttime', 'tnmt_time']); $gameStor->cacheValues(['turntime', 'starttime', 'tnmt_time']);
$turntime = (new \DateTimeImmutable($gameStor->turntime))->sub(new \DateInterval("PT{$minute}M")); $turntime = (new \DateTimeImmutable($gameStor->turntime))->sub(new \DateInterval("PT{$minute}M"));
$starttime = (new \DateTimeImmutable($gameStor->starttime))->sub(new \DateInterval("PT{$minute}M")); $starttime = (new \DateTimeImmutable($gameStor->starttime))->sub(new \DateInterval("PT{$minute}M"));
@@ -45,8 +54,19 @@ case "분당김":
$db->update('auction', [ $db->update('auction', [
'expire'=>$db->sqleval('DATE_SUB(expire, INTERVAL %i MINUTE)', $minute) 'expire'=>$db->sqleval('DATE_SUB(expire, INTERVAL %i MINUTE)', $minute)
], true); ], true);
if($locked){
unlock();
}
break; break;
case "분지연": case "분지연":
$locked = false;
for($i = 0; $i < 5; $i++){
if(tryLock()){
$locked = true;
break;
}
sleep(0.5);
}
$gameStor->cacheValues(['turntime', 'starttime', 'tnmt_time']); $gameStor->cacheValues(['turntime', 'starttime', 'tnmt_time']);
$turntime = (new \DateTimeImmutable($gameStor->turntime))->add(new \DateInterval("PT{$minute}M")); $turntime = (new \DateTimeImmutable($gameStor->turntime))->add(new \DateInterval("PT{$minute}M"));
$starttime = (new \DateTimeImmutable($gameStor->starttime))->add(new \DateInterval("PT{$minute}M")); $starttime = (new \DateTimeImmutable($gameStor->starttime))->add(new \DateInterval("PT{$minute}M"));
@@ -62,6 +82,9 @@ case "분지연":
$db->update('auction', [ $db->update('auction', [
'expire'=>$db->sqleval('DATE_ADD(expire, INTERVAL %i MINUTE)', $minute) 'expire'=>$db->sqleval('DATE_ADD(expire, INTERVAL %i MINUTE)', $minute)
], true); ], true);
if($locked){
unlock();
}
break; break;
case "토너분당김": case "토너분당김":
$tnmt_time = new \DateTime($gameStor->tnmt_time); $tnmt_time = new \DateTime($gameStor->tnmt_time);
+2 -2
View File
@@ -150,7 +150,7 @@ function cityInfo(General $generalObj) {
$city['nationTextColor'] = newColor($nation['color']); $city['nationTextColor'] = newColor($nation['color']);
$city['nationColor'] = $nation['color']; $city['nationColor'] = $nation['color'];
$city['region'] = CityConst::$regionMap[$city['region']]; $city['region'] = CityConst::$regionMap[$city['region']];
$city['level'] = CityConst::$levelMap[$city['level']]; $city['levelText'] = CityConst::$levelMap[$city['level']];
$officerQuery = []; $officerQuery = [];
$officerName = [ $officerName = [
@@ -1151,7 +1151,7 @@ function checkDelay() {
$threshold = 3; $threshold = 3;
} }
else{ else{
$threshold = 20;//TODO:디버깅용. 꼭 고칠것. 원래 값은 6이었음. $threshold = 6;
} }
//지연 해야할 밀린 턴 횟수 //지연 해야할 밀린 턴 횟수
$iter = intdiv($timeMinDiff, $term); $iter = intdiv($timeMinDiff, $term);
+6 -6
View File
@@ -191,7 +191,7 @@ function calcCityRiceIncome(array $rawCity, int $officerCnt, bool $isCapital, in
$trustRatio = $rawCity['trust'] / 200 + 0.5;//0.5 ~ 1 $trustRatio = $rawCity['trust'] / 200 + 0.5;//0.5 ~ 1
$cityIncome = $rawCity['pop'] * $rawCity['agri'] / $rawCity['agri'] * $trustRatio / 30; $cityIncome = $rawCity['pop'] * $rawCity['agri'] / $rawCity['agri2'] * $trustRatio / 30;
$cityIncome *= 1 + $rawCity['secu']/$rawCity['secu2']/10; $cityIncome *= 1 + $rawCity['secu']/$rawCity['secu2']/10;
$cityIncome *= pow(1.05, $officerCnt); $cityIncome *= pow(1.05, $officerCnt);
if($isCapital){ if($isCapital){
@@ -238,7 +238,7 @@ function getGoldIncome(int $nationID, int $nationLevel, float $taxRate, int $cap
$cityID = $rawCity['city']; $cityID = $rawCity['city'];
foreach ([2,3,4] as $officerLevel) { foreach ([2,3,4] as $officerLevel) {
$officerCnt = 0; $officerCnt = 0;
if($officers[$rawCity['officer'.$officerLevel]] == $cityID){ if($officers[$rawCity['officer'.$officerLevel]]??0 == $cityID){
$officerCnt += 1; $officerCnt += 1;
} }
} }
@@ -261,7 +261,7 @@ function processWarIncome() {
continue; continue;
} }
$nationID = $nation['nation']; $nationID = $nation['nation'];
$income = getWarGoldIncome($nation['type'], $cityListByNation[$nationID]); $income = getWarGoldIncome($nation['type'], $cityListByNation[$nationID]??[]);
$db->update('nation', [ $db->update('nation', [
'gold'=>$db->sqleval('gold + %i', $income) 'gold'=>$db->sqleval('gold + %i', $income)
], 'nation=%i', $nationID); ], 'nation=%i', $nationID);
@@ -274,7 +274,7 @@ function processWarIncome() {
], true); ], true);
} }
function getWarGoldIncome(string $nationType, $cityList){ function getWarGoldIncome(string $nationType, array $cityList){
$nationTypeObj = buildNationTypeClass($nationType); $nationTypeObj = buildNationTypeClass($nationType);
$cityIncome = 0; $cityIncome = 0;
@@ -443,7 +443,7 @@ function getWallIncome(int $nationID, int $nationLevel, float $taxRate, int $cap
$cityID = $rawCity['city']; $cityID = $rawCity['city'];
foreach ([2,3,4] as $officerLevel) { foreach ([2,3,4] as $officerLevel) {
$officerCnt = 0; $officerCnt = 0;
if($officers[$rawCity['officer'.$officerLevel]] == $cityID){ if($officers[$rawCity['officer'.$officerLevel]]??0 == $cityID){
$officerCnt += 1; $officerCnt += 1;
} }
} }
@@ -605,7 +605,7 @@ function disaster() {
function($rawGeneral) use ($city, $year, $month){ function($rawGeneral) use ($city, $year, $month){
return new General($rawGeneral, $city, $year, $month, false); return new General($rawGeneral, $city, $year, $month, false);
}, },
$generalListByCity[$city['city']] $generalListByCity[$city['city']]??[]
); );
SabotageInjury($generalList, '재난'); SabotageInjury($generalList, '재난');
+19 -14
View File
@@ -49,7 +49,7 @@ class che_첩보 extends Command\GeneralCommand{
$this->setCity(); $this->setCity();
$this->setNation(['tech']); $this->setNation(['tech']);
$this->setDestCity($this->arg['destCityID'], []); $this->setDestCity($this->arg['destCityID'], null);
$this->setDestNation($this->destCity['nation'], ['tech']); $this->setDestNation($this->destCity['nation'], ['tech']);
[$reqGold, $reqRice] = $this->getCost(); [$reqGold, $reqRice] = $this->getCost();
@@ -61,6 +61,11 @@ class che_첩보 extends Command\GeneralCommand{
]; ];
} }
public function getBrief():string{
$cityName = $this->destCity['name'];
return "{$cityName}】에 {$this->getName()} 실행";
}
public function getCommandDetailTitle():string{ public function getCommandDetailTitle():string{
$name = $this->getName(); $name = $this->getName();
[$reqGold, $reqRice] = $this->getCost(); [$reqGold, $reqRice] = $this->getCost();
@@ -121,7 +126,7 @@ class che_첩보 extends Command\GeneralCommand{
$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'); $destCityGeneralList = $db->query('SELECT crew, crewtype FROM general WHERE city = %i AND nation = %i', $destCityID, $destNationID);
$totalCrew = Util::arraySum($destCityGeneralList, 'crew'); $totalCrew = Util::arraySum($destCityGeneralList, 'crew');
$totalGenCnt = count($destCityGeneralList); $totalGenCnt = count($destCityGeneralList);
$byCrewType = Util::arrayGroupBy($destCityGeneralList, 'crewtype'); $byCrewType = Util::arrayGroupBy($destCityGeneralList, 'crewtype');
@@ -207,21 +212,21 @@ class che_첩보 extends Command\GeneralCommand{
public function getForm(): string public function getForm(): string
{ {
$form = []; $currentCityID = $this->generalObj->getCityID();
$form[] = \sammo\getMapHtml(); ob_start();
?>
$form[] = <<<EOT <?=\sammo\getMapHtml()?><br>
선택된 도시에 첩보를 실행합니다.<br> 선택된 도시에 첩보를 실행합니다.<br>
인접도시일 경우 많은 정보를 얻을 수 있습니다.<br> 인접도시일 경우 많은 정보를 얻을 수 있습니다.<br>
목록을 선택하거나 도시를 클릭하세요.<br> 목록을 선택하거나 도시를 클릭하세요.<br>
<select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'> <select class='formInput' name="destCityID" id="destCityID" size='1' style='color:white;background-color:black;'><br>
EOT; <?=\sammo\optionsForCities()?><br>
$form[] = \sammo\optionsForCities(); </select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
$form[] = '</select>'; <br>
$form[] = '<input type=submit value="첩보">'; <br>
$form[] = printCitiesBasedOnDistance($this->generalObj->getCityID(), 3); <?=printCitiesBasedOnDistance($currentCityID, 3)?>
<?php
return join("\n",$form); return ob_get_clean();
} }
+2 -2
View File
@@ -1,6 +1,6 @@
<table style='width:100%;' class='tb_layout bg2'> <table style='width:100%;' class='tb_layout bg2'>
<tr><td colspan=8 style='text-align:center;height:20px;color:<?=$nationTextColor?>;background-color:<?=$nationColor?>;font-weight:bold;font-size:13px;'> <?=$region?> | <?=$level?> 】 <?=$name?></td></tr> <tr><td colspan=8 style='text-align:center;height:20px;color:<?=$nationTextColor?>;background-color:<?=$nationColor?>;font-weight:bold;font-size:13px;'> <?=$region?> | <?=$levelText?> 】 <?=$name?></td></tr>
<tr><td colspan=8 style='text-align:center;height:20px;color:<?=$nationTextColor?>;background-color:<?=$nationColor?>'><b><?=$nationName?'공 백 지':"지배 국가 【 {$nationName} 】"?></b></td> <tr><td colspan=8 style='text-align:center;height:20px;color:<?=$nationTextColor?>;background-color:<?=$nationColor?>'><b><?=$nationName?"지배 국가 【 {$nationName} 】":'공 백 지'?></b></td>
</tr> </tr>
<tr> <tr>
<td rowspan=2 style='text-align:center;' class='bg1'><b>주민</b></td> <td rowspan=2 style='text-align:center;' class='bg1'><b>주민</b></td>