fix: ReqCities, ReqRegion 버그
This commit is contained in:
@@ -261,7 +261,7 @@ class GetConst extends \sammo\BaseAPI
|
||||
$crewtypeMap[$crewtypeObj->id] = [
|
||||
'value'=>(string)$crewtypeObj->id,
|
||||
'name'=>$crewtypeObj->name,
|
||||
'info'=>$crewtypeObj->getInfo(),
|
||||
'info'=>$crewtypeObj->getInfoArr(),
|
||||
];
|
||||
}
|
||||
$iActionInfo['crewtype'] = $crewtypeMap;
|
||||
|
||||
@@ -297,7 +297,7 @@ class che_징병 extends Command\GeneralCommand
|
||||
}
|
||||
*/
|
||||
|
||||
$crewObj->notAvailable = !$unit->isValid($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->baseCost = $general->onCalcDomestic($this->getName(), 'cost', $unit->costWithTech($tech), ['armType' => $unit->armType]);
|
||||
@@ -313,7 +313,7 @@ class che_징병 extends Command\GeneralCommand
|
||||
$crewObj->img = ServConfig::$gameImagePath . "/crewtype" . $unit->id . ".png";
|
||||
}
|
||||
|
||||
$crewObj->info = $unit->getInfo();
|
||||
$crewObj->info = $unit->getInfoArr();
|
||||
|
||||
$armCrewType['values'][] = $crewObj;
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ class GameUnitConstBase{
|
||||
[
|
||||
1402, self::T_WIZARD, '백귀병',
|
||||
80, 130, 7, 5, 0.6, 9, 11,
|
||||
[new ReqTech(2000), new ReqRegions('오환')],
|
||||
[new ReqTech(2000), new ReqCities('오환')],
|
||||
[self::T_SIEGE=>1.2],
|
||||
[self::T_SIEGE=>0.8],
|
||||
['저렴하고 튼튼합니다.'],
|
||||
@@ -263,7 +263,7 @@ class GameUnitConstBase{
|
||||
[
|
||||
1403, self::T_WIZARD, '흑귀병',
|
||||
130, 80, 7, 5, 0.6, 11, 9,
|
||||
[new ReqTech(2000), new ReqRegions('왜')],
|
||||
[new ReqTech(2000), new ReqCities('왜')],
|
||||
[self::T_SIEGE=>1.2],
|
||||
[self::T_SIEGE=>0.8],
|
||||
['저렴하고 강력합니다.'],
|
||||
@@ -442,11 +442,6 @@ class GameUnitConstBase{
|
||||
$iActionList,
|
||||
] = $rawUnit;
|
||||
|
||||
foreach($reqConstraints as $value){
|
||||
/** @var GameUnitConstraint\BaseGameUnitConstraint $value */
|
||||
$info[] = $value->getInfo();
|
||||
}
|
||||
|
||||
$unit = new GameUnitDetail(
|
||||
$id,
|
||||
$armType,
|
||||
|
||||
@@ -5,18 +5,28 @@ namespace sammo\GameUnitConstraint;
|
||||
use sammo\CityConst;
|
||||
use sammo\General;
|
||||
|
||||
class ReqCities extends BaseGameUnitConstraint {
|
||||
class ReqCities extends BaseGameUnitConstraint
|
||||
{
|
||||
|
||||
public readonly array $reqCities;
|
||||
public function __construct(...$reqCities)
|
||||
{
|
||||
$this->reqCities = $reqCities;
|
||||
$dstReqCities = [];
|
||||
if (count($reqCities) == 0) {
|
||||
$this->reqCities = [];
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($reqCities as $city) {
|
||||
$dstReqCities[CityConst::byName($city)->id] = $city;
|
||||
}
|
||||
$this->reqCities = $dstReqCities;
|
||||
}
|
||||
|
||||
public function test(General $general, array $ownCities, array $ownRegions, int $relativeYear, int $tech, array $nationAux): bool
|
||||
{
|
||||
foreach ($this->reqCities as $city) {
|
||||
if (key_exists($city, $ownCities)) {
|
||||
foreach ($this->reqCities as $cityID => $cityName) {
|
||||
if (key_exists($cityID, $ownCities)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -26,12 +36,7 @@ class ReqCities extends BaseGameUnitConstraint {
|
||||
|
||||
public function getInfo(): string
|
||||
{
|
||||
$cityNames = [];
|
||||
foreach ($this->reqCities as $city) {
|
||||
$cityNames[] = CityConst::byID($city)->name;
|
||||
}
|
||||
|
||||
$cityNameText = implode(', ', $cityNames);
|
||||
$cityNameText = implode(', ', $this->reqCities);
|
||||
return "{$cityNameText} 소유시 가능";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,20 +5,30 @@ namespace sammo\GameUnitConstraint;
|
||||
use sammo\CityConst;
|
||||
use sammo\General;
|
||||
|
||||
class ReqRegions extends BaseGameUnitConstraint {
|
||||
class ReqRegions extends BaseGameUnitConstraint
|
||||
{
|
||||
|
||||
public readonly array $reqRegions;
|
||||
public function __construct(...$reqRegions)
|
||||
{
|
||||
$this->reqRegions = $reqRegions;
|
||||
$dstReqRegions = [];
|
||||
if (count($reqRegions) == 0) {
|
||||
$this->reqRegions = [];
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($reqRegions as $region) {
|
||||
$dstReqRegions[CityConst::$regionMap[$region]] = $region;
|
||||
}
|
||||
|
||||
$this->reqRegions = $dstReqRegions;
|
||||
}
|
||||
|
||||
public function test(General $general, array $ownCities, array $ownRegions, int $relativeYear, int $tech, array $nationAux): bool
|
||||
{
|
||||
foreach ($this->reqRegions as $region) {
|
||||
if (key_exists($region, $ownRegions)) {
|
||||
foreach ($this->reqRegions as $regionID => $regionText) {
|
||||
if (key_exists($regionID, $ownRegions)) {
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +37,7 @@ class ReqRegions extends BaseGameUnitConstraint {
|
||||
|
||||
public function getInfo(): string
|
||||
{
|
||||
$regionNames = [];
|
||||
foreach ($this->reqRegions as $region) {
|
||||
$regionNames[] = CityConst::$regionMap[$region];
|
||||
}
|
||||
|
||||
$regionNameText = implode(', ', $regionNames);
|
||||
$regionNameText = implode(', ', $this->reqRegions);
|
||||
return "{$regionNameText} 지역 소유시 가능";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class GameUnitDetail implements iAction
|
||||
public $iActionList;
|
||||
public array $reqConstraints;
|
||||
|
||||
protected ?string $info;
|
||||
protected ?array $info = null;
|
||||
|
||||
public function __construct(
|
||||
int $id,
|
||||
@@ -42,6 +42,7 @@ class GameUnitDetail implements iAction
|
||||
array $reqConstraints,
|
||||
array $attackCoef,
|
||||
array $defenceCoef,
|
||||
public readonly array $baseInfo,
|
||||
?array $initSkillTrigger,
|
||||
?array $phaseSkillTrigger,
|
||||
?array $iActionList,
|
||||
@@ -75,20 +76,24 @@ class GameUnitDetail implements iAction
|
||||
}
|
||||
}
|
||||
|
||||
public function getInfo(): string
|
||||
{
|
||||
public function getInfoArr(): array {
|
||||
if($this->info !== null){
|
||||
return $this->info;
|
||||
}
|
||||
|
||||
$info = [];
|
||||
$info = $this->baseInfo;
|
||||
foreach ($this->reqConstraints as $constraint) {
|
||||
$info[] = $constraint->getInfo();
|
||||
}
|
||||
$this->info = join("\n<br>", $info);
|
||||
$this->info = $info;
|
||||
return $this->info;
|
||||
}
|
||||
|
||||
public function getInfo(): string
|
||||
{
|
||||
return join("\n<br>", $this->getInfoArr());
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return StringUtil::subStringForWidth($this->name, 0, 4);
|
||||
@@ -198,13 +203,13 @@ class GameUnitDetail implements iAction
|
||||
return $defaultWar;
|
||||
}
|
||||
|
||||
public function isValid($ownCities, $ownRegions, $relativeYear, $tech)
|
||||
public function isValid(General $general, $ownCities, $ownRegions, $relativeYear, $tech, $nationAux = [])
|
||||
{
|
||||
//음수 없음
|
||||
$relativeYear = max(0, $relativeYear);
|
||||
|
||||
foreach($this->reqConstraints as $constraint){
|
||||
if(!$constraint->test($ownCities, $ownRegions, $relativeYear, $tech)){
|
||||
if(!$constraint->test($general, $ownCities, $ownRegions, $relativeYear, $tech, $nationAux)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2570,7 +2570,7 @@ class GeneralAI
|
||||
|
||||
$types = [];
|
||||
foreach (GameUnitConst::byType($armType) as $crewtype) {
|
||||
if ($crewtype->isValid($cities, $regions, $relYear, $tech)) {
|
||||
if ($crewtype->isValid($general, $cities, $regions, $relYear, $tech)) {
|
||||
$score = $crewtype->pickScore($tech);
|
||||
$types[$crewtype->id] = $score;
|
||||
}
|
||||
@@ -2584,7 +2584,7 @@ class GeneralAI
|
||||
|
||||
if ($this->generalPolicy->can고급병종) {
|
||||
$currCrewType = $general->getCrewTypeObj();
|
||||
if ($currCrewType->isValid($cities, $regions, $relYear, $tech)) {
|
||||
if ($currCrewType->isValid($general, $cities, $regions, $relYear, $tech)) {
|
||||
$reqTechObj = $currCrewType->reqConstraints['reqTech'] ?? null;
|
||||
if($reqTechObj){
|
||||
$reqTech = $reqTechObj->getValue($tech);
|
||||
|
||||
Reference in New Issue
Block a user