병종이 행동에 전투에 event로 개입 가능하도록 수정 중

This commit is contained in:
2019-04-29 01:01:47 +09:00
parent d4c9a0a47a
commit 17a59cbdd5
8 changed files with 141 additions and 24 deletions
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace sammo;
class GameUnitActionBase implements iAction{
use DefaultAction;
public function getWarPowerMultiplier(WarUnit $unit):array{
return [1, 1];
}
public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
return new WarUnitTriggerCaller([new GameUnitInitTriggerBase($unit)]);
}
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
return new WarUnitTriggerCaller([new GameUnitPhaseTriggerBase($unit)]);
}
}
+39 -6
View File
@@ -18,11 +18,11 @@ class GameUnitConstBase{
protected static $constID = null;
protected static $constName = null;
protected static $constCity = null;
protected static $constRegion = null;
protected static $constType = null;
protected static $constID = [];
protected static $constName = [];
protected static $constCity = [];
protected static $constRegion = [];
protected static $constType = [];
protected static $typeData = [
self::T_FOOTMAN => '보병',
@@ -303,6 +303,34 @@ class GameUnitConstBase{
]
];
public static function addGameUnit(GameUnitDetail $unitType){
static::_generate();
static::$constID[$unitType->id] = $unitType;
static::$constName[$unitType->name] = $unitType;
if(!key_exists($unitType->armType, static::$constType)){
static::$constType[$unitType->armType] = [];
}
static::$constType[$unitType->armType][] = $unitType;
foreach($unitType->reqCities as $reqCity){
if(!key_exists($reqCity, static::$constCity)){
static::$constCity[$reqCity] = [];
}
static::$constCity[$reqCity][] = $unitType;
}
if($unitType->reqRegions){
foreach($unitType->reqRegions as $reqRegion){
if(!key_exists($reqRegion, static::$constRegion)){
static::$constRegion[$reqRegion] = [];
}
static::$constRegion[$reqRegion][] = $unitType;
}
}
}
/**
* @return \sammo\GameUnitDetail[]
*/
@@ -354,6 +382,10 @@ class GameUnitConstBase{
return static::$constType[$type];
}
protected static function _generateOptional(){
//for inheritance
}
protected static function _generate(){
if(static::$constID || static::$constName || static::$constCity || static::$constRegion || static::$constType){
@@ -462,6 +494,7 @@ class GameUnitConstBase{
static::$constCity = $constCity;
static::$constRegion = $constRegion;
static::$constType = $constType;
static::_generateOptional();
}
}
+2 -1
View File
@@ -1,7 +1,8 @@
<?php
namespace sammo;
class GameUnitDetail{
class GameUnitDetail extends GameUnitActionBase{
public $id;
public $armType;
public $name;
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace sammo;
class GameUnitInitTriggerBase extends ObjectTrigger{
static protected $priority = 10000;
public function __construct(WarUnit $unit){
$this->object = $unit;
$this->unitType = $unit->getCrewType();
}
public function action(?array $env=null, $arg=null):?array{
/** @var WarUnitGeneral $attacker */
/** @var WarUnit $defender */
[$attacker, $defender] = $arg;
$attackerCrewType = $attacker->getCrewType();
$defenderCrewType = $defender->getCrewType();
//TODO: 충차는 성벽 상대로 부상입지 않음
return $env;
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace sammo;
class GameUnitPhaseTriggerBase extends ObjectTrigger{
static protected $priority = 10000;
public function __construct(WarUnit $unit){
$this->object = $unit;
$this->unitType = $unit->getCrewType();
}
public function action(?array $env=null, $arg=null):?array{
/** @var WarUnitGeneral $attacker */
/** @var WarUnit $defender */
[$attacker, $defender] = $arg;
$attackerCrewType = $attacker->getCrewType();
$defenderCrewType = $defender->getCrewType();
//TODO: 목우
return $env;
}
}
+8
View File
@@ -377,6 +377,7 @@ class General implements iAction{
$this->specialDomesticObj,
$this->specialWarObj,
$this->personalityObj,
$this->getCrewTypeObj(),
], $this->itemObjs) as $iObj){
if(!$iObj){
@@ -398,6 +399,7 @@ class General implements iAction{
$this->specialDomesticObj,
$this->specialWarObj,
$this->personalityObj,
$this->getCrewTypeObj(),
], $this->itemObjs) as $iObj){
if(!$iObj){
continue;
@@ -416,6 +418,7 @@ class General implements iAction{
$this->specialDomesticObj,
$this->specialWarObj,
$this->personalityObj,
$this->getCrewTypeObj(),
], $this->itemObjs) as $iObj){
if(!$iObj){
continue;
@@ -433,6 +436,7 @@ class General implements iAction{
$this->specialDomesticObj,
$this->specialWarObj,
$this->personalityObj,
$this->getCrewTypeObj(),
], $this->itemObjs) as $iObj){
if(!$iObj){
continue;
@@ -450,6 +454,7 @@ class General implements iAction{
$this->specialDomesticObj,
$this->specialWarObj,
$this->personalityObj,
$this->getCrewTypeObj(),
], $this->itemObjs) as $iObj){
if(!$iObj){
continue;
@@ -470,6 +475,7 @@ class General implements iAction{
$this->specialDomesticObj,
$this->specialWarObj,
$this->personalityObj,
$this->getCrewTypeObj(),
], $this->itemObjs) as $iObj){
if(!$iObj){
continue;
@@ -489,6 +495,7 @@ class General implements iAction{
$this->specialDomesticObj,
$this->specialWarObj,
$this->personalityObj,
$this->getCrewTypeObj(),
], $this->itemObjs) as $iObj){
if(!$iObj){
continue;
@@ -510,6 +517,7 @@ class General implements iAction{
$this->specialDomesticObj,
$this->specialWarObj,
$this->personalityObj,
$this->getCrewTypeObj(),
], $this->itemObjs) as $iObj){
if(!$iObj){
continue;
+1
View File
@@ -95,6 +95,7 @@ class WarUnitGeneral extends WarUnit{
}
function getComputedAvoidRatio():float{
$general = $this->general;
$avoidRatio = $this->getCrewType()->avoid / 100;
$avoidRatio *= $this->getComputedTrain() / 100;