Scenario 세팅 과정에 문제 해결

SetNationFront 함수도 수정
This commit is contained in:
2018-03-31 16:06:24 +09:00
parent 71f5311b1d
commit 31d9bac59c
14 changed files with 65 additions and 76 deletions
+3 -1
View File
@@ -23,7 +23,9 @@ class CityHelper{
$listByNation = [];
foreach (DB::db()->query('SELECT `city` as `id`, `name`, `level`, `nation` from city') as $city) {
$list[$city['id']] = $city;
$id = $city['id'];
$name = $city['name'];
$list[$id] = $city;
$listInv[$city['name']] = $city;
if(!key_exists($id, $listByNation)){
+1 -3
View File
@@ -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()];
}
+4 -4
View File
@@ -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){
+5 -1
View File
@@ -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 -1
View File
@@ -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){
+1 -1
View File
@@ -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);
}
}
+1 -1
View File
@@ -378,7 +378,7 @@ class Scenario{
refreshNationStaticInfo();
foreach(getAllNationStaticInfo() as $nation){
SetNationFront($db->get(), $nation['nation']);
SetNationFront($nation['nation']);
}
}
+4 -3
View File
@@ -96,7 +96,7 @@ class NPC{
$picture = 'default.jpg';
}
$city = $this->city;
$city = $this->locatedCity;
if($city === null){
if($nationID == 0){
$city = Util::choiceRandom(CityHelper::getAllCities())['id'];
@@ -117,9 +117,10 @@ class NPC{
$specage = $age + 1;
$specage2 = $age + 1;
$npcID = $db->queryFirstField('SELECT max(npcid)+1 FROM general');
$db->insert('general',[
'npcid'=>$db->sqleval('max(npcid)+1'),
'npcid'=>$npcID,
'npc'=>2,
'npc_org'=>2,
'affinity'=>$this->affinity,
@@ -127,7 +128,7 @@ class NPC{
'picture'=>$picture,
'nation'=>$nationID,
'city'=>$city,
'leader'=>$this->leader,
'leader'=>$this->leadership,
'power'=>$this->power,
'intel'=>$this->intel,
'experience'=>$experience,
+9 -6
View File
@@ -59,7 +59,7 @@ class Nation{
}, $this->cities);
$capital = \sammo\CityHelper::getCityByName($this->capital)['id'];
$type = \sammo\NationCharCall($this->$type);
$type = \sammo\NationCharCall($this->type);
$db = DB::db();
$otherNations = $db->queryFirstColumn('SELECT nation FROM nation');
@@ -81,29 +81,32 @@ class Nation{
'scoutmsg'=>$this->infoText,
'tech'=>$this->tech,
'totaltech'=>0,
'level'=>$this->level,
'level'=>$this->nationLevel,
'type'=>$type,
]);
$db->update('city', [
'nation'=>$this->id
], 'city IN (%li)', $cities);
], 'city IN %li', $cities);
$diplomacy = [];
foreach($otherNations as $nation){
$diplomacy[] = [
'me'=>$this->$id,
'me'=>$this->id,
'you'=>$nation,
'state'=>2
];
$diplomacy[] = [
'me'=>$nation,
'you'=>$this->$id,
'you'=>$this->id,
'state'=>2
];
}
$db->insert('diplomacy', $diplomacy);
if(count($diplomacy) > 0){
$db->insert('diplomacy', $diplomacy);
}
}
public function postBuild($env=[]){