fix: RegNPC 버그 수정, event handler 규격 버그 수정

This commit is contained in:
2021-03-19 18:09:53 +09:00
parent 7a939b7024
commit 911cb614a5
6 changed files with 17 additions and 7 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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)){
+3 -2
View File
@@ -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];
}
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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']){
+10 -1
View File
@@ -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();