정적 분석기 결과 반영. 주로 배열 초기화. 변수 이름 실수 수정.

This commit is contained in:
2018-04-06 20:06:28 +09:00
parent 2bce82c73e
commit ffc0fc0c6f
20 changed files with 109 additions and 94 deletions
+1 -2
View File
@@ -1,6 +1,5 @@
<?php
namespace sammo\Event\Action;
use sammo\Util;
use sammo\DB;
/**
@@ -51,7 +50,7 @@ class RaiseInvader extends \sammo\Event\Action{
private function moveCapital(){
$cities = array_map(function ($value) {
return $value;
}, INVADER_LIST);
}, static::INVADER_LIST);
$db = DB::db();
+3 -3
View File
@@ -17,9 +17,9 @@ class RegNPC extends \sammo\Event\Action{
int $intel,
int $birth = 160,
int $death = 300,
string $ego = null,
string $char = null,
string $text = null
$ego = null,
string $char = '',
string $text = ''
){
$this->npc = new \sammo\Scenario\NPC(
$affinity,
+6 -2
View File
@@ -36,7 +36,11 @@ abstract class Condition{
}
//array의 첫번째 값이 Condition이 아닌 경우에는 그냥 배열로 처리함.
return array_map(static::build, $conditionChain);
$result = [];
foreach($conditionChain as $condition){
$result[] = static::build($condition);
}
return $result;
}
protected static function _eval($arg, $env=null){
@@ -47,7 +51,7 @@ abstract class Condition{
];
}
if($arg instanceof Condition){
return $arg->checkCondition($env);
return $arg->eval($env);
}
throw new \InvalidArgumentException('평가 인자는 boolean이거나 Condition 클래스여야 합니다.');
}
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
namespace sammo\Event\Condition;
class Interval extends sammo\Event\Condition{
class Interval extends \sammo\Event\Condition{
//TODO:구현
public function __construct(...$args){
throw new \BadMethodCallException('Not Yet Implmented.');
+6 -4
View File
@@ -3,6 +3,8 @@ namespace sammo\Event\Condition;
class Logic extends \sammo\Event\Condition{
private $mode = 'and';
/** @var \sammo\Event\Condition[] */
private $conditions = [];
const AVAILABLE_LOGIC_NAME = [
'not'=>false,
@@ -26,7 +28,7 @@ class Logic extends \sammo\Event\Condition{
}
public function eval($env=null){
switch($this->$mode){
switch($this->mode){
case 'not':
return $this->logicNot($env);
case 'and':
@@ -41,7 +43,7 @@ class Logic extends \sammo\Event\Condition{
}
private function logicNot($env){
$sub = self::_eval($this->conditions[0], $env);
$result = self::_eval($this->conditions[0], $env);
$result['value'] = !$result['value'];
$result['chain'][] = 'not';
return $result;
@@ -55,7 +57,7 @@ class Logic extends \sammo\Event\Condition{
$sub = self::_eval($cond, $env);
$chain[] = $sub['chain'];
if(!$sub['value']){
$result['value'] = false;
$value = false;
break;
}
}
@@ -74,7 +76,7 @@ class Logic extends \sammo\Event\Condition{
$sub = self::_eval($cond, $env);
$chain[] = $sub['chain'];
if($sub['value']){
$result['value'] = true;
$value = true;
break;
}
}