diff --git a/f_config/config.php b/f_config/config.php index bd6edd1e..9563f586 100644 --- a/f_config/config.php +++ b/f_config/config.php @@ -117,7 +117,7 @@ function logError(string $err, string $errstr, string $errpath, array $trace) ]); } -function logErrorByCustomHandler(int $errno, string $errstr, string $errfile, int $errline, array $errcontext) +function logErrorByCustomHandler(int $errno, string $errstr, string $errfile, int $errline, array $errcontext=null) { if (!(error_reporting() & $errno)) { // This error code is not included in error_reporting, so let it fall diff --git a/hwe/sammo/Event/Action.php b/hwe/sammo/Event/Action.php index 9caa9778..5d242c76 100644 --- a/hwe/sammo/Event/Action.php +++ b/hwe/sammo/Event/Action.php @@ -3,7 +3,7 @@ namespace sammo\Event; abstract class Action{ //public abstract function __construct(...$args); - public abstract function run($env=null); + public abstract function run($env); public static function build($actionArgs):Action{ if(!is_array($actionArgs)){ diff --git a/hwe/sammo/Event/Action/RegNPC.php b/hwe/sammo/Event/Action/RegNPC.php index 611f79df..29eb7fda 100644 --- a/hwe/sammo/Event/Action/RegNPC.php +++ b/hwe/sammo/Event/Action/RegNPC.php @@ -3,6 +3,7 @@ namespace sammo\Event\Action; //이전 RegNPC 함수를 EventAction으로 재구성 class RegNPC extends \sammo\Event\Action{ + /** @var \sammo\Scenario\GeneralBuilder */ private $npc; public function __construct( @@ -22,7 +23,7 @@ class RegNPC extends \sammo\Event\Action{ $text = '' ){ - return (new \sammo\Scenario\GeneralBuilder( + $this->npc=(new \sammo\Scenario\GeneralBuilder( $name, 0, $picturePath, @@ -38,7 +39,7 @@ class RegNPC extends \sammo\Event\Action{ ->setLifeSpan($birth, $death); } - public function run($env=null){ + public function run($env){ $result = $this->npc->fillRemainSpecAsZero($env)->build($env); return [__CLASS__, $result]; } diff --git a/hwe/sammo/Event/Action/RegNeutralNPC.php b/hwe/sammo/Event/Action/RegNeutralNPC.php index b38e5ef9..fe0ecbd5 100644 --- a/hwe/sammo/Event/Action/RegNeutralNPC.php +++ b/hwe/sammo/Event/Action/RegNeutralNPC.php @@ -21,7 +21,7 @@ class RegNeutralNPC extends \sammo\Event\Action{ $char = '', $text = '' ){ - return (new \sammo\Scenario\GeneralBuilder( + $this->npc=(new \sammo\Scenario\GeneralBuilder( $name, 0, $picturePath, diff --git a/hwe/sammo/Event/EventHandler.php b/hwe/sammo/Event/EventHandler.php index b4fe78bf..05cccaa1 100644 --- a/hwe/sammo/Event/EventHandler.php +++ b/hwe/sammo/Event/EventHandler.php @@ -14,7 +14,7 @@ class EventHandler{ } - public function tryRunEvent(array $env=null){ + public function tryRunEvent(array $env){ $result = $this->condition->eval($env); if(!$result['value']){ diff --git a/hwe/sammo/TurnExecutionHelper.php b/hwe/sammo/TurnExecutionHelper.php index d53f492c..12215ec5 100644 --- a/hwe/sammo/TurnExecutionHelper.php +++ b/hwe/sammo/TurnExecutionHelper.php @@ -407,13 +407,22 @@ class TurnExecutionHelper } // 이벤트 핸들러 동작 + $e_env = null; foreach (DB::db()->query('SELECT * from event') as $rawEvent) { + if($e_env === null){ + $e_env = $gameStor->getAll(false); + } $eventID = $rawEvent['id']; $cond = Json::decode($rawEvent['condition']); $action = Json::decode($rawEvent['action']); $event = new Event\EventHandler($cond, $action); + $e_env['currentEventID'] = $eventID; - $event->tryRunEvent(['currentEventID'=>$eventID] + $gameStor->getAll(true)); + $event->tryRunEvent($e_env); + } + + if($e_env !== null){ + $gameStor->resetCache(true); } postUpdateMonthly();