- 유산 포인트 - 기수 뒤로도 누적되는 포인트 - 생존, 최대 임관년 수, 최대 연속 내정 성공, 병종 상성 우위 횟수, 전투 횟수, 계략 성공 횟수, 천통 기여(규모 상승, 천통 수뇌, 천통 군주), 숙련도, 토너먼트, 베팅 당첨 - 유산 관리 페이지 제공 - 태수국 - 181년 1월에 자동 생성되는 u장수국 - 시간이 지나면 사실상 자동 소멸 - 유저국과는 4칸 거리, 서로는 2칸 거리 - 이 시스템으로 인해 m장 거병 차단 - NPC 원조시 불가침 - 1년 세수만큼 받은 경우 24개월 불가침 제안 - 최소 6개월 - 불가침을 받지 않고 추가 원조한 경우 계속해서 기간 상승 - 단, 불가침 수락 전에 선포를 할 수 있음 Reviewed-on: https://storage.hided.net/gitea/devsam/core/pulls/187 Co-authored-by: hide_d <hided62@gmail.com> Co-committed-by: hide_d <hided62@gmail.com>
246 lines
7.4 KiB
PHP
246 lines
7.4 KiB
PHP
<?php
|
|
namespace sammo\Command\General;
|
|
|
|
use \sammo\{
|
|
DB, Util, JosaUtil,
|
|
General,
|
|
ActionLogger,
|
|
GameConst, GameUnitConst,
|
|
LastTurn,
|
|
Command,
|
|
Json,
|
|
KVStorage
|
|
};
|
|
|
|
|
|
use function \sammo\{
|
|
tryUniqueItemLottery,
|
|
getInvitationList,
|
|
getNationStaticInfo,
|
|
};
|
|
|
|
use \sammo\Constraint\Constraint;
|
|
use \sammo\Constraint\ConstraintHelper;
|
|
use sammo\CityConst;
|
|
|
|
|
|
|
|
class che_임관 extends Command\GeneralCommand{
|
|
static protected $actionName = '임관';
|
|
static public $reqArg = true;
|
|
|
|
protected function argTest():bool{
|
|
if($this->arg === null){
|
|
return false;
|
|
}
|
|
$destNationID = $this->arg['destNationID']??null;
|
|
|
|
if($destNationID === null){
|
|
return false;
|
|
}
|
|
|
|
if(!is_int($destNationID)){
|
|
return false;
|
|
}
|
|
if($destNationID < 1){
|
|
return false;
|
|
}
|
|
|
|
$this->arg = [
|
|
'destNationID' => $destNationID
|
|
];
|
|
|
|
return true;
|
|
}
|
|
|
|
protected function init(){
|
|
|
|
$general = $this->generalObj;
|
|
$env = $this->env;
|
|
|
|
$this->setCity();
|
|
$this->setNation();
|
|
|
|
$relYear = $env['year'] - $env['startyear'];
|
|
|
|
$this->permissionConstraints=[
|
|
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다')
|
|
];
|
|
|
|
$this->minConditionConstraints=[
|
|
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
|
|
ConstraintHelper::BeNeutral(),
|
|
ConstraintHelper::AllowJoinAction()
|
|
];
|
|
|
|
}
|
|
|
|
public function getCommandDetailTitle():string{
|
|
return '지정한 국가로 임관';
|
|
}
|
|
|
|
public function canDisplay():bool{
|
|
return $this->env['join_mode'] !== 'onlyRandom';
|
|
}
|
|
|
|
protected function initWithArg()
|
|
{
|
|
$destNationID = $this->arg['destNationID'];
|
|
$this->setDestNation($destNationID, ['gennum', 'scout']);
|
|
|
|
$env = $this->env;
|
|
$relYear = $env['year'] - $env['startyear'];
|
|
$this->fullConditionConstraints=[
|
|
ConstraintHelper::ReqEnvValue('join_mode', '!=', 'onlyRandom', '랜덤 임관만 가능합니다'),
|
|
ConstraintHelper::BeNeutral(),
|
|
ConstraintHelper::ExistsDestNation(),
|
|
ConstraintHelper::AllowJoinDestNation($relYear),
|
|
ConstraintHelper::AllowJoinAction()
|
|
];
|
|
}
|
|
|
|
public function getCost():array{
|
|
return [0, 0];
|
|
}
|
|
|
|
public function getPreReqTurn():int{
|
|
return 0;
|
|
}
|
|
|
|
public function getPostReqTurn():int{
|
|
return 0;
|
|
}
|
|
|
|
public function getBrief():string{
|
|
$commandName = $this->getName();
|
|
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
|
$josaRo = JosaUtil::pick($destNationName, '로');
|
|
return "【{$destNationName}】{$josaRo} {$commandName}";
|
|
}
|
|
|
|
public function run():bool{
|
|
if(!$this->hasFullConditionMet()){
|
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
|
}
|
|
|
|
$db = DB::db();
|
|
$env = $this->env;
|
|
|
|
$general = $this->generalObj;
|
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
|
$generalName = $general->getName();
|
|
$josaYi = JosaUtil::pick($generalName, '이');
|
|
|
|
$destNation = $this->destNation;
|
|
$gennum = $destNation['gennum'];
|
|
$destNationID = $destNation['nation'];
|
|
$destNationName = $destNation['name'];
|
|
|
|
$logger = $general->getLogger();
|
|
|
|
$logger->pushGeneralActionLog("<D>{$destNationName}</>에 임관했습니다. <1>$date</>");
|
|
$logger->pushGeneralHistoryLog("<D><b>{$destNationName}</b></>에 임관");
|
|
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>에 <S>임관</>했습니다.");
|
|
|
|
if($gennum < GameConst::$initialNationGenLimit) {
|
|
$exp = 700;
|
|
}
|
|
else {
|
|
$exp = 100;
|
|
}
|
|
|
|
$general->setVar('nation', $destNationID);
|
|
$general->setVar('officer_level', 1);
|
|
$general->setVar('officer_city', 0);
|
|
$general->setVar('belong', 1);
|
|
|
|
if($this->destGeneralObj !== null){
|
|
$general->setVar('city', $this->destGeneralObj->getCityID());
|
|
}
|
|
else{
|
|
$targetCityID = $db->queryFirstField('SELECT city FROM general WHERE nation = %i AND officer_level=12', $destNationID);
|
|
$general->setVar('city', $targetCityID);
|
|
}
|
|
|
|
$db->update('nation', [
|
|
'gennum'=>$db->sqleval('gennum + 1')
|
|
], 'nation=%i', $destNationID);
|
|
\sammo\refreshNationStaticInfo();
|
|
|
|
$relYear = $env['year'] - $env['startyear'];
|
|
if($general->getNPCType() == 1 || $relYear >= 3){
|
|
$joinedNations = $general->getAuxVar('joinedNations')??[];
|
|
$joinedNations[] = $destNationID;
|
|
$general->setAuxVar('joinedNations', $joinedNations);
|
|
}
|
|
|
|
$general->addExperience($exp);
|
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
|
$general->checkStatChange();
|
|
tryUniqueItemLottery($general);
|
|
$general->applyDB($db);
|
|
|
|
return true;
|
|
}
|
|
|
|
public function getForm(): string
|
|
{
|
|
$db = DB::db();
|
|
|
|
$generalObj = $this->generalObj;
|
|
|
|
$env = $this->env;
|
|
|
|
$joinedNations = $generalObj->getAuxVar('joinedNations')??[];
|
|
|
|
$nationList = $db->query('SELECT nation,`name`,color,scout,gennum FROM nation');
|
|
shuffle($nationList);
|
|
$nationList = Util::convertArrayToDict($nationList, 'nation');
|
|
//NOTE: join 안할것임
|
|
$scoutMsgs = KVStorage::getValuesFromInterNamespace($db, 'nation_env', 'scout_msg');
|
|
foreach($scoutMsgs as $nationID=>$scoutMsg){
|
|
$nationList[$nationID]['scoutmsg'] = $scoutMsg;
|
|
}
|
|
|
|
$hiddenItems = [];
|
|
|
|
foreach($nationList as &$nation){
|
|
if($env['year'] < $env['startyear']+3 && $nation['gennum'] >= GameConst::$initialNationGenLimit){
|
|
$nation['availableJoin'] = false;
|
|
}
|
|
else if($nation['scout'] == 1) {
|
|
$nation['availableJoin'] = false;
|
|
}
|
|
else{
|
|
$nation['availableJoin'] = true;
|
|
}
|
|
|
|
if(in_array($nation['nation'], $joinedNations)){
|
|
$nation['availableJoin'] = false;
|
|
}
|
|
|
|
if(Util::starts_with($nation['name'], 'ⓤ')){
|
|
$hiddenItems[$nation['nation']] = $nation['nation'];
|
|
}
|
|
}
|
|
unset($nation);
|
|
ob_start();
|
|
?>
|
|
국가에 임관합니다.<br>
|
|
이미 임관/등용되었던 국가는 다시 임관할 수 없습니다.<br>
|
|
바로 군주의 위치로 이동합니다.<br>
|
|
임관할 국가를 목록에서 선택하세요.<br>
|
|
<select class='formInput' name="destNationID" id="destNationID" size='1' style='color:white;background-color:black;'>
|
|
<?php foreach($nationList as $nation): ?>
|
|
<?php if(key_exists($nation['nation'], $hiddenItems)){ continue; } ?>
|
|
<option
|
|
value='<?=$nation['nation']?>'
|
|
style='<?=$nation['availableJoin']?'':'background-color:red;'?>'
|
|
>【<?=$nation['name']?> 】</option>
|
|
<?php endforeach; ?>
|
|
<input type=button id="commonSubmit" value="<?=$this->getName()?>">
|
|
<?=getInvitationList($nationList)?>
|
|
<?php
|
|
return ob_get_clean();
|
|
}
|
|
}
|