Scenario 세팅 과정에 문제 해결
SetNationFront 함수도 수정
This commit is contained in:
@@ -152,13 +152,11 @@ class ChangeCity extends \sammo\Event\Action{
|
||||
}
|
||||
|
||||
public function run($env=null){
|
||||
|
||||
$target = $this->target;
|
||||
$cities = $this->getTargetCities($env);
|
||||
|
||||
DB::db()->update('city',
|
||||
$this->queries
|
||||
, 'city IN (%li)', $cities);
|
||||
, 'city IN %li', $cities);
|
||||
return [__CLASS__, DB::db()->affectedRows()];
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class RaiseInvader extends \sammo\Event\Action{
|
||||
$db = DB::db();
|
||||
|
||||
|
||||
foreach($db->queryFirstColumn('SELECT capital, nation from nation WHERE capital in (%li)', $cities) as $row){
|
||||
foreach($db->queryFirstColumn('SELECT capital, nation from nation WHERE capital in %li', $cities) as $row){
|
||||
list($oldCapital, $nation) = $row;
|
||||
$newCapital = $db->queryFirstRow('SELECT city from city where nation=%i and city !=%i \
|
||||
order by rand() limit 1', $nation, $oldCapital);
|
||||
@@ -66,7 +66,7 @@ class RaiseInvader extends \sammo\Event\Action{
|
||||
}
|
||||
|
||||
$generals = [];
|
||||
foreach($db->query('SELECT gen1, gen2, gen3 from city where city in (%li)', $cities) as $city){
|
||||
foreach($db->query('SELECT gen1, gen2, gen3 from city where city in %li', $cities) as $city){
|
||||
list($gen1, $gen2, $gen3) = $city;
|
||||
if($gen1 != 0) $generals[]=$gen1;
|
||||
if($gen2 != 0) $generals[]=$gen2;
|
||||
@@ -75,14 +75,14 @@ class RaiseInvader extends \sammo\Event\Action{
|
||||
|
||||
$db->update('general', [
|
||||
'level'=>1
|
||||
], 'no in (%li)', $generals);
|
||||
], 'no in %li', $generals);
|
||||
|
||||
$db->update('city', [
|
||||
'gen1'=>0,
|
||||
'gen2'=>0,
|
||||
'gen3'=>0,
|
||||
'nation'=>0
|
||||
], 'city in (%li)', $cities);
|
||||
], 'city in %li', $cities);
|
||||
}
|
||||
|
||||
public function run($env=null){
|
||||
|
||||
@@ -2,10 +2,14 @@
|
||||
namespace sammo\Event;
|
||||
|
||||
abstract class Condition{
|
||||
public abstract function __construct($args=null);
|
||||
public abstract function eval($env=null);
|
||||
|
||||
public static function build($conditionChain){
|
||||
|
||||
if(is_bool($conditionChain)){
|
||||
return new Condition\ConstBool($conditionChain);
|
||||
}
|
||||
|
||||
if(!is_array($conditionChain)){
|
||||
return $conditionChain;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace sammo\Event\Condition;
|
||||
|
||||
class ConstBool extends sammo\Event\Condition{
|
||||
class ConstBool extends \sammo\Event\Condition{
|
||||
private $fixedResult = true;
|
||||
|
||||
public function __construct(bool $value){
|
||||
|
||||
@@ -9,7 +9,7 @@ class EventHandler{
|
||||
public function __construct($rawCondition, $rawActions){
|
||||
$this->condition = Condition::build($rawCondition);
|
||||
foreach($rawActions as $rawAction){
|
||||
$this->condition = Action::build($rawAction);
|
||||
$this->actions[] = Action::build($rawAction);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user