From e916f2fc40545c5c66274f4eac24beab52537cb8 Mon Sep 17 00:00:00 2001 From: hide_d Date: Fri, 6 Mar 2020 20:01:11 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/_119_b.php | 23 ++++++++++++++++++ hwe/func.php | 4 ++-- hwe/func_time_event.php | 12 +++++----- hwe/sammo/Command/General/che_첩보.php | 33 +++++++++++++++----------- hwe/templates/mainCityInfo.php | 4 ++-- 5 files changed, 52 insertions(+), 24 deletions(-) diff --git a/hwe/_119_b.php b/hwe/_119_b.php index dac24a98..abd42422 100644 --- a/hwe/_119_b.php +++ b/hwe/_119_b.php @@ -30,6 +30,15 @@ $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); switch($btn) { case "분당김": + $locked = false; + for($i = 0; $i < 10; $i++){ + if(tryLock()){ + $locked = true; + break; + } + usleep(500000); + } + $gameStor->cacheValues(['turntime', 'starttime', 'tnmt_time']); $turntime = (new \DateTimeImmutable($gameStor->turntime))->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', [ 'expire'=>$db->sqleval('DATE_SUB(expire, INTERVAL %i MINUTE)', $minute) ], true); + if($locked){ + unlock(); + } break; case "분지연": + $locked = false; + for($i = 0; $i < 5; $i++){ + if(tryLock()){ + $locked = true; + break; + } + sleep(0.5); + } $gameStor->cacheValues(['turntime', 'starttime', 'tnmt_time']); $turntime = (new \DateTimeImmutable($gameStor->turntime))->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', [ 'expire'=>$db->sqleval('DATE_ADD(expire, INTERVAL %i MINUTE)', $minute) ], true); + if($locked){ + unlock(); + } break; case "토너분당김": $tnmt_time = new \DateTime($gameStor->tnmt_time); diff --git a/hwe/func.php b/hwe/func.php index 013657c9..d5477012 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -150,7 +150,7 @@ function cityInfo(General $generalObj) { $city['nationTextColor'] = newColor($nation['color']); $city['nationColor'] = $nation['color']; $city['region'] = CityConst::$regionMap[$city['region']]; - $city['level'] = CityConst::$levelMap[$city['level']]; + $city['levelText'] = CityConst::$levelMap[$city['level']]; $officerQuery = []; $officerName = [ @@ -1151,7 +1151,7 @@ function checkDelay() { $threshold = 3; } else{ - $threshold = 20;//TODO:디버깅용. 꼭 고칠것. 원래 값은 6이었음. + $threshold = 6; } //지연 해야할 밀린 턴 횟수 $iter = intdiv($timeMinDiff, $term); diff --git a/hwe/func_time_event.php b/hwe/func_time_event.php index 918f9cb1..20a5aae3 100644 --- a/hwe/func_time_event.php +++ b/hwe/func_time_event.php @@ -191,7 +191,7 @@ function calcCityRiceIncome(array $rawCity, int $officerCnt, bool $isCapital, in $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 *= pow(1.05, $officerCnt); if($isCapital){ @@ -238,7 +238,7 @@ function getGoldIncome(int $nationID, int $nationLevel, float $taxRate, int $cap $cityID = $rawCity['city']; foreach ([2,3,4] as $officerLevel) { $officerCnt = 0; - if($officers[$rawCity['officer'.$officerLevel]] == $cityID){ + if($officers[$rawCity['officer'.$officerLevel]]??0 == $cityID){ $officerCnt += 1; } } @@ -261,7 +261,7 @@ function processWarIncome() { continue; } $nationID = $nation['nation']; - $income = getWarGoldIncome($nation['type'], $cityListByNation[$nationID]); + $income = getWarGoldIncome($nation['type'], $cityListByNation[$nationID]??[]); $db->update('nation', [ 'gold'=>$db->sqleval('gold + %i', $income) ], 'nation=%i', $nationID); @@ -274,7 +274,7 @@ function processWarIncome() { ], true); } -function getWarGoldIncome(string $nationType, $cityList){ +function getWarGoldIncome(string $nationType, array $cityList){ $nationTypeObj = buildNationTypeClass($nationType); $cityIncome = 0; @@ -443,7 +443,7 @@ function getWallIncome(int $nationID, int $nationLevel, float $taxRate, int $cap $cityID = $rawCity['city']; foreach ([2,3,4] as $officerLevel) { $officerCnt = 0; - if($officers[$rawCity['officer'.$officerLevel]] == $cityID){ + if($officers[$rawCity['officer'.$officerLevel]]??0 == $cityID){ $officerCnt += 1; } } @@ -605,7 +605,7 @@ function disaster() { function($rawGeneral) use ($city, $year, $month){ return new General($rawGeneral, $city, $year, $month, false); }, - $generalListByCity[$city['city']] + $generalListByCity[$city['city']]??[] ); SabotageInjury($generalList, '재난'); diff --git a/hwe/sammo/Command/General/che_첩보.php b/hwe/sammo/Command/General/che_첩보.php index 4d93a97d..e3283e9b 100644 --- a/hwe/sammo/Command/General/che_첩보.php +++ b/hwe/sammo/Command/General/che_첩보.php @@ -49,7 +49,7 @@ class che_첩보 extends Command\GeneralCommand{ $this->setCity(); $this->setNation(['tech']); - $this->setDestCity($this->arg['destCityID'], []); + $this->setDestCity($this->arg['destCityID'], null); $this->setDestNation($this->destCity['nation'], ['tech']); [$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{ $name = $this->getName(); [$reqGold, $reqRice] = $this->getCost(); @@ -121,7 +126,7 @@ class che_첩보 extends Command\GeneralCommand{ $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'); $totalGenCnt = count($destCityGeneralList); $byCrewType = Util::arrayGroupBy($destCityGeneralList, 'crewtype'); @@ -207,21 +212,21 @@ class che_첩보 extends Command\GeneralCommand{ public function getForm(): string { - $form = []; - $form[] = \sammo\getMapHtml(); - - $form[] = <<generalObj->getCityID(); + ob_start(); +?> +
선택된 도시에 첩보를 실행합니다.
인접도시일 경우 많은 정보를 얻을 수 있습니다.
목록을 선택하거나 도시를 클릭하세요.
-'; - $form[] = ''; - $form[] = printCitiesBasedOnDistance($this->generalObj->getCityID(), 3); - - return join("\n",$form); +
+
+
+ + - 【 | - + 【 | + 주민