Files
core/hwe/sammo/Event/Action/InvaderEnding.php
T
Hide_D ee8854451c fix: phan 지시에 따라 일부 버그 수정
- null && key_exists 버그
- or assign이 integer 대상이므로 직접 연산
- false 대신 0 입력한 곳 수정
- 자체 Deprecate 처리한 함수 회피
- 초기화되지 않은 [] 확인하여 처리
- sleep은 정수만 받으므로 usleep으로 변경
- 선언하지 않고 그냥 사용하던 member 변수 선언
- boolean operation 순서 틀린 부분 수정
2021-08-12 23:58:20 +09:00

59 lines
2.0 KiB
PHP

<?php
namespace sammo\Event\Action;
use sammo\ActionLogger;
use sammo\CityConst;
use sammo\DB;
use sammo\KVStorage;
use sammo\Util;
class InvaderEnding extends \sammo\Event\Action{
public function __construct(){
}
public function run(array $env){
//FIXME: 조건 체크를 여기서 하지 말라.
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$logger = new ActionLogger(0, 0, $env['year'], $env['month']);
$isunited = $gameStor->isunited;
if(in_array($isunited, [0, 2])){
return [__CLASS__, "No Invader"];
}
$nationCnt = $db->queryFirstField('SELECT count(*) FROM nation');
if($nationCnt >= 2){
return [__CLASS__, "On Event"];
}
$gameStor = KVStorage::getStorage($db, 'game_env');
$logger = new ActionLogger(0, 0, $env['year'], $env['month']);
$cityCnt = $db->queryFirstField('SELECT count(*) FROM city WHERE nation = 0');
if($cityCnt == 0){
//천통 엔딩
$logger->pushGlobalHistoryLog("<L><b>【이벤트】</b></>이민족을 모두 소탕했습니다!");
$logger->pushGlobalHistoryLog("<L><b>【이벤트】</b></>중원은 당분간 태평성대를 누릴 것입니다.");
}
else if($cityCnt == count(CityConst::all())){
//이민족 엔딩
$logger->pushGlobalHistoryLog("<L><b>【이벤트】</b></>중원은 이민족에 의해 혼란에 빠졌습니다.");
$logger->pushGlobalHistoryLog("<L><b>【이벤트】</b></>백성은 언젠가 영웅이 나타나길 기다립니다.");
}
else{
return [__CLASS__, "On Event"];
}
$gameStor->setValue('isunited', 3);
$logger->flush();
$gameStor->conlimit = $gameStor->conlimit * 100;
$eventID = Util::array_get($env['currentEventID']);
$db->delete('event', 'id = %i', $eventID);
return [__CLASS__, 'Deleted'];
}
}