feat: General::penaltyList
This commit is contained in:
@@ -4,6 +4,7 @@ namespace sammo;
|
|||||||
use sammo\Enums\GeneralLiteQueryMode;
|
use sammo\Enums\GeneralLiteQueryMode;
|
||||||
use sammo\Enums\GeneralQueryMode;
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Enums\MessageType;
|
use sammo\Enums\MessageType;
|
||||||
|
use sammo\Enums\PenaltyKey;
|
||||||
|
|
||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
@@ -174,7 +175,9 @@ function do추방(General $general, int $myOfficerLevel):?string{
|
|||||||
$generalName = $general->getVar('name');
|
$generalName = $general->getVar('name');
|
||||||
$nationID = $general->getNationID();
|
$nationID = $general->getNationID();
|
||||||
|
|
||||||
|
if($general->hasPenalty(PenaltyKey::NoBanGeneral)){
|
||||||
|
return '추방할 수 없는 상태입니다.';
|
||||||
|
}
|
||||||
|
|
||||||
//추방할사람이 외교권자이면 불가
|
//추방할사람이 외교권자이면 불가
|
||||||
$permission = checkSecretPermission($general->getRaw());
|
$permission = checkSecretPermission($general->getRaw());
|
||||||
|
|||||||
@@ -10,4 +10,5 @@ enum PenaltyKey: string{
|
|||||||
case NoTopSecret = 'noTopSecret';
|
case NoTopSecret = 'noTopSecret';
|
||||||
case NoChief = 'noChief';
|
case NoChief = 'noChief';
|
||||||
case NoAmbassador = 'noAmbassador';
|
case NoAmbassador = 'noAmbassador';
|
||||||
|
case NoBanGeneral = 'noBanGeneral';
|
||||||
}
|
}
|
||||||
+27
-1
@@ -7,6 +7,7 @@ use sammo\Command\GeneralCommand;
|
|||||||
use sammo\Enums\GeneralAccessLogColumn;
|
use sammo\Enums\GeneralAccessLogColumn;
|
||||||
use sammo\Enums\GeneralQueryMode;
|
use sammo\Enums\GeneralQueryMode;
|
||||||
use sammo\Enums\InheritanceKey;
|
use sammo\Enums\InheritanceKey;
|
||||||
|
use sammo\Enums\PenaltyKey;
|
||||||
use sammo\Enums\RankColumn;
|
use sammo\Enums\RankColumn;
|
||||||
use sammo\WarUnitTrigger as WarUnitTrigger;
|
use sammo\WarUnitTrigger as WarUnitTrigger;
|
||||||
|
|
||||||
@@ -28,6 +29,10 @@ class General extends GeneralBase implements iAction
|
|||||||
protected $logActivatedSkill = [];
|
protected $logActivatedSkill = [];
|
||||||
protected $isFinished = false;
|
protected $isFinished = false;
|
||||||
|
|
||||||
|
|
||||||
|
/** @var Map<PenaltyKey,int|float|string> */
|
||||||
|
protected Map $penaltyList;
|
||||||
|
|
||||||
/** @var ?iAction */
|
/** @var ?iAction */
|
||||||
protected $nationType = null;
|
protected $nationType = null;
|
||||||
/** @var ?iAction */
|
/** @var ?iAction */
|
||||||
@@ -86,6 +91,16 @@ class General extends GeneralBase implements iAction
|
|||||||
$this->rankVarRead = new Map();
|
$this->rankVarRead = new Map();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$penaltyList = new Map();
|
||||||
|
foreach(Json::decode($raw['penalty'] ?? '{}') as $rawPenaltyKey => $penaltyValue){
|
||||||
|
$penaltyKey = PenaltyKey::tryFrom($rawPenaltyKey);
|
||||||
|
if($penaltyKey === null){
|
||||||
|
throw new \InvalidArgumentException('Invalid PenaltyKey: ' . $rawPenaltyKey);
|
||||||
|
}
|
||||||
|
$penaltyList[$penaltyKey] = $penaltyValue;
|
||||||
|
}
|
||||||
|
$this->penaltyList = $penaltyList;
|
||||||
|
|
||||||
$this->accessLogRead = $rawAccessLog;
|
$this->accessLogRead = $rawAccessLog;
|
||||||
|
|
||||||
|
|
||||||
@@ -244,6 +259,17 @@ class General extends GeneralBase implements iAction
|
|||||||
return $this->crewType;
|
return $this->crewType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasPenalty(PenaltyKey $penaltyKey): bool
|
||||||
|
{
|
||||||
|
return $this->penaltyList->hasKey($penaltyKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return Map<PenaltyKey,int|float|string> */
|
||||||
|
function getPenaltyList(): Map
|
||||||
|
{
|
||||||
|
return $this->penaltyList;
|
||||||
|
}
|
||||||
|
|
||||||
function calcRecentWarTurn(int $turnTerm): int
|
function calcRecentWarTurn(int $turnTerm): int
|
||||||
{
|
{
|
||||||
$cacheKey = "recent_war_turn_{$turnTerm}";
|
$cacheKey = "recent_war_turn_{$turnTerm}";
|
||||||
@@ -372,7 +398,7 @@ class General extends GeneralBase implements iAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->calcCache[$cKey] = $statValue;
|
$this->calcCache[$cKey] = $statValue;
|
||||||
|
|
||||||
return $statValue;
|
return $statValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user