feat(wip): GameUnitConstrint
This commit is contained in:
@@ -21,8 +21,6 @@ class GameUnitConstBase{
|
||||
|
||||
protected static $constID = [];
|
||||
protected static $constName = [];
|
||||
protected static $constCity = [];
|
||||
protected static $constRegion = [];
|
||||
protected static $constType = [];
|
||||
|
||||
protected static $typeData = [
|
||||
@@ -357,22 +355,6 @@ class GameUnitConstBase{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,22 +382,6 @@ class GameUnitConstBase{
|
||||
return static::$constName[$name]??null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \sammo\GameUnitDetail[]
|
||||
*/
|
||||
public static function byCity(int $city): array{
|
||||
static::_generate();
|
||||
return static::$constCity[$city]??[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \sammo\GameUnitDetail[]
|
||||
*/
|
||||
public static function byRegion(int $region): array{
|
||||
static::_generate();
|
||||
return static::$constRegion[$region]??[];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \sammo\GameUnitDetail[]
|
||||
@@ -435,14 +401,12 @@ class GameUnitConstBase{
|
||||
|
||||
protected static function _generate(){
|
||||
|
||||
if(static::$constID || static::$constName || static::$constCity || static::$constRegion || static::$constType){
|
||||
if(static::$constID || static::$constName || static::$constType){
|
||||
return;
|
||||
}
|
||||
|
||||
$constID = [];
|
||||
$constName = [];
|
||||
$constCity = [];
|
||||
$constRegion = [];
|
||||
$constType = [];
|
||||
|
||||
foreach(static::$_buildData as $rawUnit){
|
||||
@@ -457,10 +421,7 @@ class GameUnitConstBase{
|
||||
$magicCoef,
|
||||
$cost,
|
||||
$rice,
|
||||
$reqTech,
|
||||
$reqCities,
|
||||
$reqRegions,
|
||||
$reqYear,
|
||||
$reqConstraints,
|
||||
$attackCoef,
|
||||
$defenceCoef,
|
||||
$info,
|
||||
@@ -469,21 +430,9 @@ class GameUnitConstBase{
|
||||
$iActionList,
|
||||
] = $rawUnit;
|
||||
|
||||
if($reqYear > 0){
|
||||
$info[] = "{$reqYear}년 경과 후 사용 가능";
|
||||
}
|
||||
|
||||
$constraints = [];
|
||||
if($reqTech > 0){
|
||||
$constraints[] = GameUnitConstraintHelper::ReqTech($reqTech);
|
||||
}
|
||||
|
||||
if($reqCities !== null){
|
||||
$constraints[] = GameUnitConstraintHelper::ReqCities($reqCities);
|
||||
}
|
||||
|
||||
if($reqRegions !== null){
|
||||
$constraints[] = GameUnitConstraintHelper::ReqRegions($reqRegions);
|
||||
foreach($reqConstraints as $value){
|
||||
/** @var GameUnitConstraint\BaseGameUnitConstraint $value */
|
||||
$info[] = $value->getInfo();
|
||||
}
|
||||
|
||||
$unit = new GameUnitDetail(
|
||||
@@ -498,14 +447,12 @@ class GameUnitConstBase{
|
||||
$cost,
|
||||
$rice,
|
||||
$reqConstraints,
|
||||
$reqYear,
|
||||
$attackCoef,
|
||||
$defenceCoef,
|
||||
$info,
|
||||
$initSkillTrigger,
|
||||
$phaseSkillTrigger,
|
||||
$iActionList,
|
||||
$constraints
|
||||
$iActionList
|
||||
);
|
||||
|
||||
$constID[$id] = $unit;
|
||||
@@ -515,31 +462,10 @@ class GameUnitConstBase{
|
||||
}
|
||||
$constType[$armType][$id] = $unit;
|
||||
|
||||
if($unit->reqCities){
|
||||
foreach($unit->reqCities as $reqCity){
|
||||
if(!key_exists($reqCity, $constCity)){
|
||||
$constCity[$reqCity] = [];
|
||||
}
|
||||
$constCity[$reqCity][$id] = $unit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($unit->reqRegions){
|
||||
foreach($unit->reqRegions as $reqRegion){
|
||||
if(!key_exists($reqRegion, $constRegion)){
|
||||
$constRegion[$reqRegion] = [];
|
||||
}
|
||||
$constRegion[$reqRegion][$id] = $unit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static::$constID = $constID;
|
||||
static::$constName = $constName;
|
||||
static::$constCity = $constCity;
|
||||
static::$constRegion = $constRegion;
|
||||
static::$constType = $constType;
|
||||
|
||||
static::_generateOptional();
|
||||
|
||||
Reference in New Issue
Block a user