diff --git a/hwe/sammo/GameUnitConstBase.php b/hwe/sammo/GameUnitConstBase.php
index 9887f2b3..5ed2cc98 100644
--- a/hwe/sammo/GameUnitConstBase.php
+++ b/hwe/sammo/GameUnitConstBase.php
@@ -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();
diff --git a/hwe/sammo/GameUnitConstraint/BaseGameUnitConstraint.php b/hwe/sammo/GameUnitConstraint/BaseGameUnitConstraint.php
new file mode 100644
index 00000000..87d38b74
--- /dev/null
+++ b/hwe/sammo/GameUnitConstraint/BaseGameUnitConstraint.php
@@ -0,0 +1,11 @@
+reqCities as $city) {
+ if (key_exists($city, $ownCities)) {
+ return true;
+ break;
+ }
+ }
+
+ return false;
+ }
+
+ public function getInfo(): string
+ {
+ $cityNames = [];
+ foreach ($this->reqCities as $city) {
+ $cityNames[] = CityConst::byID($city)->name;
+ }
+
+ $cityNameText = implode(', ', $cityNames);
+ return "{$cityNameText} 소유시 가능";
+ }
+}
\ No newline at end of file
diff --git a/hwe/sammo/GameUnitConstraint/ReqMinRelYear.php b/hwe/sammo/GameUnitConstraint/ReqMinRelYear.php
new file mode 100644
index 00000000..d70444c6
--- /dev/null
+++ b/hwe/sammo/GameUnitConstraint/ReqMinRelYear.php
@@ -0,0 +1,44 @@
+= $this->reqMinRelYear;
+ }
+
+ public function getInfo(): string
+ {
+ return "{$this->reqMinRelYear}년 경과 후 사용 가능";
+ }
+}
+
+/*
+
+ if($reqTech > 0){
+ $info[] = "기술력 {$reqTech} 이상 필요";
+ }
+
+ if($reqCities !== null){
+ $reqCities = array_map(function($reqCity) use (&$info){
+ $info[] = "{$reqCity} 소유시 가능";
+ return CityConst::byName($reqCity)->id;
+ }, $reqCities);
+ }
+
+ if($reqRegions !== null){
+ $reqRegions = array_map(function($reqRegion) use (&$info){
+ $info[] = "{$reqRegion} 지역 소유시 가능";
+ return CityConst::$regionMap[$reqRegion];
+ }, $reqRegions);
+ }
+
+*/
\ No newline at end of file
diff --git a/hwe/sammo/GameUnitConstraint/ReqRegions.php b/hwe/sammo/GameUnitConstraint/ReqRegions.php
new file mode 100644
index 00000000..638b7059
--- /dev/null
+++ b/hwe/sammo/GameUnitConstraint/ReqRegions.php
@@ -0,0 +1,36 @@
+reqRegions as $region) {
+ if (key_exists($region, $ownRegions)) {
+ return true;
+ break;
+ }
+ }
+
+ return false;
+ }
+
+ public function getInfo(): string
+ {
+ $regionNames = [];
+ foreach ($this->reqRegions as $region) {
+ $regionNames[] = CityConst::$regionMap[$region];
+ }
+
+ $regionNameText = implode(', ', $regionNames);
+ return "{$regionNameText} 지역 소유시 가능";
+ }
+}
\ No newline at end of file
diff --git a/hwe/sammo/GameUnitConstraint/ReqTech.php b/hwe/sammo/GameUnitConstraint/ReqTech.php
new file mode 100644
index 00000000..e5d48319
--- /dev/null
+++ b/hwe/sammo/GameUnitConstraint/ReqTech.php
@@ -0,0 +1,25 @@
+reqTech) {
+ return false;
+ }
+ }
+
+ public function getInfo(): string
+ {
+ return "기술력 {$this->reqTech} 이상 필요";
+ }
+}
\ No newline at end of file
diff --git a/hwe/sammo/GameUnitConstraintHelper.php b/hwe/sammo/GameUnitConstraintHelper.php
deleted file mode 100644
index 3341e4f8..00000000
--- a/hwe/sammo/GameUnitConstraintHelper.php
+++ /dev/null
@@ -1,26 +0,0 @@
-reqConstraints = $reqConstraints;
$this->attackCoef = $attackCoef;
$this->defenceCoef = $defenceCoef;
- $this->info = $info;
$this->initSkillTrigger = $initSkillTrigger;
$this->phaseSkillTrigger = $phaseSkillTrigger;
$this->iActionList = [];
@@ -78,7 +73,16 @@ class GameUnitDetail implements iAction
public function getInfo(): string
{
- return join("\n
", $this->info);
+ if($this->info !== null){
+ return $this->info;
+ }
+
+ $info = [];
+ foreach ($this->reqConstraints as $constraint) {
+ $info[] = $constraint->getInfo();
+ }
+ $this->info = join("\n
", $info);
+ return $this->info;
}
public function getShortName(): string
@@ -195,8 +199,10 @@ class GameUnitDetail implements iAction
//음수 없음
$relativeYear = max(0, $relativeYear);
- if ($relativeYear < $this->reqYear) {
- return false;
+ foreach($this->reqConstraints as $constraint){
+ if(!$constraint->test($ownCities, $ownRegions, $relativeYear, $tech)){
+ return false;
+ }
}
if ($tech < $this->reqTech) {