raise event 등록 CreateManyNPC 추가

This commit is contained in:
2020-05-02 02:09:21 +09:00
parent eb232f7bb1
commit 0ef223d80e
3 changed files with 176 additions and 4 deletions
+66
View File
@@ -0,0 +1,66 @@
<?php
namespace sammo;
use Exception;
include('lib.php');
include('func.php');
$session = Session::requireLogin([])->setReadOnly();
if(Session::getInstance()->userGrade < 5){
Json::die([
'reason'=>'권한이 부족합니다.'
]);
}
$eventName = Util::getReq('event', 'string');
$eventArgsJson = Util::getReq('arg', 'string');
if($eventName === null){
Json::die([
'result'=>false,
'reason'=>'event가 지정되지 않았습니다.'
]);
}
$eventArgs = [$eventName];
if($eventArgsJson !== null){
try{
$eventNextArgs = Json::decode($eventArgsJson);
if(is_array($eventArg)){
$eventArgs = array_merge($eventArgs, $eventNextArgs);
}
else{
$eventArgs[] = $eventNextArgs;
}
}
catch(\Exception $e){
Json::die([
'result'=>false,
'reason'=>'arg가 올바른 json이 아닙니다'
]);
}
}
try{
$action = Event\Action::build($eventArgs);
}
catch(Exception $e){
Json::die([
'result'=>false,
'reason'=>$e->getMessage()
]);
}
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$env = $gameStor->getAll();
$result = $action->run($env);
Json::die([
'result'=>true,
'reason'=>'success',
'info'=>$result,
]);