Files
core/hwe/sammo/StaticEvent/event_부대탑승즉시이동.php
T
Hide_D 477b77b59f feat: StaticEventHandler 처리기 추가
- 커맨드 종료 시점에 호출
  - pre, post 각각이 필요한지는 논의 필요
  - 일단 용도에 따라 pre, post 둘중에 하나만 처리
- eventType으로는 full qualified class name 사용
  - 꼭 그럴필요는 없지만, 커맨드에 한해서는 이렇게
2024-09-18 14:54:11 +00:00

46 lines
1.2 KiB
PHP

<?php
namespace sammo\StaticEvent;
use sammo\DB;
use sammo\Enums\GeneralLiteQueryMode;
use sammo\General;
use sammo\GeneralLite;
class event_부대탑승즉시이동 extends \sammo\BaseStaticEvent
{
function run(GeneralLite|General $general, null|GeneralLite|General $destGeneral, array $env, array $params): bool | string
{
$troopID = $params['troopID'] ?? null;
if ($troopID === null) {
return "troopID is null";
}
if (!is_int($troopID)) {
return "troopID is not int";
}
$destGeneral = GeneralLite::createObjFromDB($troopID, ['nation', 'city', 'troop'], GeneralLiteQueryMode::Core);
if ($destGeneral === null) {
return "destGeneral is null";
}
if($destGeneral->getID() !== $destGeneral->getVar('troop')){
return "destGeneral is not troop";
}
if($destGeneral->getNationID() !== $general->getNationID()){
return "destGeneral is not same nation";
}
if($destGeneral->getCityID() === $general->getCityID()){
return true;
}
$general->setVar('city', $destGeneral->getCityID());
$general->applyDB(DB::db());
return true;
}
}