fix: GameUnitDetail의 info를 기존방식으로 변경

This commit is contained in:
2025-01-21 17:23:07 +00:00
parent 84fee0f1f2
commit 76625cf472
5 changed files with 10 additions and 31 deletions
+1 -1
View File
@@ -261,7 +261,7 @@ class GetConst extends \sammo\BaseAPI
$crewtypeMap[$crewtypeObj->id] = [ $crewtypeMap[$crewtypeObj->id] = [
'value'=>(string)$crewtypeObj->id, 'value'=>(string)$crewtypeObj->id,
'name'=>$crewtypeObj->name, 'name'=>$crewtypeObj->name,
'info'=>$crewtypeObj->getInfoArr(), 'info'=>$crewtypeObj->info,
]; ];
} }
$iActionInfo['crewtype'] = $crewtypeMap; $iActionInfo['crewtype'] = $crewtypeMap;
+1 -10
View File
@@ -276,7 +276,6 @@ class che_징병 extends Command\GeneralCommand
'values' => [], 'values' => [],
]; ];
$crewTypes = [];
foreach (GameUnitConst::byType($armType) as $unit) { foreach (GameUnitConst::byType($armType) as $unit) {
$crewObj = new \stdClass; $crewObj = new \stdClass;
@@ -289,14 +288,6 @@ class che_징병 extends Command\GeneralCommand
$reqMinRelYearObj = $unit->reqConstraints['reqMinRelYear'] ?? null; $reqMinRelYearObj = $unit->reqConstraints['reqMinRelYear'] ?? null;
$crewObj->reqYear = $reqMinRelYearObj ? $reqMinRelYearObj->reqMinRelYear : 0; $crewObj->reqYear = $reqMinRelYearObj ? $reqMinRelYearObj->reqMinRelYear : 0;
/*
if ($unit->reqTech == 0) {
$crewObj->bgcolor = 'green';
} else {
$crewObj->bgcolor = 'limegreen';
}
*/
$crewObj->notAvailable = !$unit->isValid($general, $ownCities, $ownRegions, $relativeYear, $tech); $crewObj->notAvailable = !$unit->isValid($general, $ownCities, $ownRegions, $relativeYear, $tech);
$crewObj->baseRice = $general->onCalcDomestic($this->getName(), 'rice', $unit->riceWithTech($tech), ['armType' => $unit->armType]); $crewObj->baseRice = $general->onCalcDomestic($this->getName(), 'rice', $unit->riceWithTech($tech), ['armType' => $unit->armType]);
@@ -313,7 +304,7 @@ class che_징병 extends Command\GeneralCommand
$crewObj->img = ServConfig::$gameImagePath . "/crewtype" . $unit->id . ".png"; $crewObj->img = ServConfig::$gameImagePath . "/crewtype" . $unit->id . ".png";
} }
$crewObj->info = $unit->getInfoArr(); $crewObj->info = $unit->info;
$armCrewType['values'][] = $crewObj; $armCrewType['values'][] = $crewObj;
} }
+5
View File
@@ -442,6 +442,11 @@ class GameUnitConstBase{
$iActionList, $iActionList,
] = $rawUnit; ] = $rawUnit;
foreach($reqConstraints as $constraint){
/** @var \sammo\GameUnitConstraint\BaseGameUnitConstraint $constraint */
$info[] = $constraint->getInfo();
}
$unit = new GameUnitDetail( $unit = new GameUnitDetail(
$id, $id,
$armType, $armType,
+2 -16
View File
@@ -26,7 +26,6 @@ class GameUnitDetail implements iAction
public $iActionList; public $iActionList;
public array $reqConstraints; public array $reqConstraints;
protected ?array $info = null;
public function __construct( public function __construct(
int $id, int $id,
@@ -42,7 +41,7 @@ class GameUnitDetail implements iAction
array $reqConstraints, array $reqConstraints,
array $attackCoef, array $attackCoef,
array $defenceCoef, array $defenceCoef,
public readonly array $baseInfo, public readonly array $info,
?array $initSkillTrigger, ?array $initSkillTrigger,
?array $phaseSkillTrigger, ?array $phaseSkillTrigger,
?array $iActionList, ?array $iActionList,
@@ -76,22 +75,9 @@ class GameUnitDetail implements iAction
} }
} }
public function getInfoArr(): array {
if($this->info !== null){
return $this->info;
}
$info = $this->baseInfo;
foreach ($this->reqConstraints as $constraint) {
$info[] = $constraint->getInfo();
}
$this->info = $info;
return $this->info;
}
public function getInfo(): string public function getInfo(): string
{ {
return join("\n<br>", $this->getInfoArr()); return join("\n<br>", $this->info);
} }
public function getShortName(): string public function getShortName(): string
+1 -4
View File
@@ -176,10 +176,7 @@ export type GameUnitType = {
magicCoef: number; magicCoef: number;
cost: number; cost: number;
rice: number; rice: number;
reqTech: number; reqConstraints: Record<string, unknown>[];
reqCities: CityID[] | null;
reqRegions: MapRegionID[] | null;
reqYear: number;
attackCoef: Record<CrewTypeID | ArmTypeID, number> | null | []; attackCoef: Record<CrewTypeID | ArmTypeID, number> | null | [];
defenceCoef: Record<CrewTypeID | ArmTypeID, number> | null | []; defenceCoef: Record<CrewTypeID | ArmTypeID, number> | null | [];
info: string | string[]; info: string | string[];