유산 포인트 시스템, 추가 기수 대비 (#187)
- 유산 포인트 - 기수 뒤로도 누적되는 포인트 - 생존, 최대 임관년 수, 최대 연속 내정 성공, 병종 상성 우위 횟수, 전투 횟수, 계략 성공 횟수, 천통 기여(규모 상승, 천통 수뇌, 천통 군주), 숙련도, 토너먼트, 베팅 당첨 - 유산 관리 페이지 제공 - 태수국 - 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>
This commit was merged in pull request #187.
This commit is contained in:
@@ -14,7 +14,8 @@ use function sammo\{
|
||||
getDomesticExpLevelBonus,
|
||||
CriticalRatioDomestic,
|
||||
CriticalScoreEx,
|
||||
tryUniqueItemLottery
|
||||
tryUniqueItemLottery,
|
||||
updateMaxDomesticCritical
|
||||
};
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
@@ -93,6 +94,13 @@ class che_기술연구 extends che_상업투자{
|
||||
$exp = $score * 0.7;
|
||||
$ded = $score * 1.0;
|
||||
|
||||
if($pick == 'success'){
|
||||
updateMaxDomesticCritical($general, $score);
|
||||
}
|
||||
else{
|
||||
$general->setAuxVar('max_domestic_critical', 0);
|
||||
}
|
||||
|
||||
$scoreText = number_format($score, 0);
|
||||
|
||||
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil, TimeUtil, Json,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
LastTurn,
|
||||
Command
|
||||
};
|
||||
use \sammo\DB;
|
||||
use \sammo\Util;
|
||||
use \sammo\JosaUtil;
|
||||
use \sammo\TimeUtil;
|
||||
use \sammo\Json;
|
||||
use \sammo\General;
|
||||
use \sammo\ActionLogger;
|
||||
use \sammo\GameConst;
|
||||
use \sammo\GameUnitConst;
|
||||
use \sammo\LastTurn;
|
||||
use \sammo\Command;
|
||||
|
||||
|
||||
use function \sammo\{
|
||||
tryUniqueItemLottery,
|
||||
getInvitationList,
|
||||
getNationStaticInfo
|
||||
};
|
||||
use function \sammo\tryUniqueItemLottery;
|
||||
use function \sammo\getInvitationList;
|
||||
use function \sammo\getNationStaticInfo;
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
@@ -24,10 +25,12 @@ use sammo\MustNotBeReachedException;
|
||||
|
||||
|
||||
|
||||
class che_랜덤임관 extends Command\GeneralCommand{
|
||||
class che_랜덤임관 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '랜덤임관';
|
||||
|
||||
protected function argTest():bool{
|
||||
protected function argTest(): bool
|
||||
{
|
||||
$this->arg = null;
|
||||
return true;
|
||||
|
||||
@@ -71,7 +74,7 @@ class che_랜덤임관 extends Command\GeneralCommand{
|
||||
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::BeNeutral(),
|
||||
ConstraintHelper::AllowJoinAction(),
|
||||
];
|
||||
@@ -83,28 +86,34 @@ class che_랜덤임관 extends Command\GeneralCommand{
|
||||
*/
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
return '무작위 국가로 임관';
|
||||
}
|
||||
|
||||
public function getBrief():string{
|
||||
public function getBrief(): string
|
||||
{
|
||||
return '무작위 국가로 임관';
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
public function getCost(): array
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -126,108 +135,107 @@ class che_랜덤임관 extends Command\GeneralCommand{
|
||||
$destNation = null;
|
||||
|
||||
if ($general->getNPCType() >= 2 && !$env['fiction'] && 1000 <= $env['scenario'] && $env['scenario'] < 2000) {
|
||||
if($notIn){
|
||||
if ($notIn) {
|
||||
$nations = $db->query(
|
||||
'SELECT nation.`name` as `name`,nation.nation as nation,scout,gennum,`affinity` FROM nation join general on general.nation = nation.nation and general.officer_level = 12 WHERE scout=0 and gennum<%i and nation.nation not in %li',
|
||||
$relYear<3?GameConst::$initialNationGenLimit:GameConst::$defaultMaxGeneral,
|
||||
$relYear < 3 ? GameConst::$initialNationGenLimit : GameConst::$defaultMaxGeneral,
|
||||
$notIn
|
||||
);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$nations = $db->query(
|
||||
'SELECT nation.`name` as `name`,nation.nation as nation,scout,gennum,`affinity` FROM nation join general on general.nation = nation.nation and general.officer_level = 12 WHERE scout=0 and gennum<%i',
|
||||
$relYear<3?GameConst::$initialNationGenLimit:GameConst::$defaultMaxGeneral
|
||||
$relYear < 3 ? GameConst::$initialNationGenLimit : GameConst::$defaultMaxGeneral
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
shuffle($nations);
|
||||
|
||||
$allGen = Util::arraySum($nations, 'gennum');
|
||||
|
||||
$maxScore = 1<<30;
|
||||
|
||||
$maxScore = 1 << 30;
|
||||
|
||||
$affinity = $general->getVar('affinity');
|
||||
|
||||
foreach($nations as $testNation){
|
||||
|
||||
foreach ($nations as $testNation) {
|
||||
$affinity = abs($affinity - $testNation['affinity']);
|
||||
$affinity = min($affinity, abs($affinity - 150));
|
||||
|
||||
$score = log($affinity + 1, 2);//0~
|
||||
|
||||
|
||||
$score = log($affinity + 1, 2); //0~
|
||||
|
||||
//쉐킷쉐킷
|
||||
$score += Util::randF();
|
||||
|
||||
$score += sqrt($testNation['gennum']/$allGen);
|
||||
|
||||
if($score < $maxScore){
|
||||
|
||||
$score += sqrt($testNation['gennum'] / $allGen);
|
||||
|
||||
if ($score < $maxScore) {
|
||||
$maxScore = $score;
|
||||
$destNation = $testNation;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$onlyRandom = $env['join_mode'] == 'onlyRandom';
|
||||
$genLimit = GameConst::$defaultMaxGeneral;
|
||||
if($onlyRandom && TimeUtil::IsRangeMonth($env['init_year'], $env['init_month'], 1, $env['year'], $env['month'])){
|
||||
if ($onlyRandom && TimeUtil::IsRangeMonth($env['init_year'], $env['init_month'], 1, $env['year'], $env['month'])) {
|
||||
$genLimit = GameConst::$initialNationGenLimitForRandInit;
|
||||
}
|
||||
else if($relYear < 3){
|
||||
} else if ($relYear < 3) {
|
||||
$genLimit = GameConst::$initialNationGenLimit;
|
||||
}
|
||||
|
||||
$generalsCnt = [];
|
||||
if($notIn){
|
||||
if ($notIn) {
|
||||
$rawGeneralsCnt = $db->query(
|
||||
'SELECT general.nation as nation, nation.gennum, nation.name, npc, count(*) as cnt FROM general JOIN nation ON general.nation = nation.nation WHERE npc < 4 AND nation.gennum < %i AND nation.scout=0 AND nation.nation NOT IN %li GROUP BY general.nation, general.npc',
|
||||
'SELECT general.nation as nation, nation.gennum, nation.name, npc, count(*) as cnt FROM general JOIN nation ON general.nation = nation.nation WHERE npc != 9 AND nation.gennum < %i AND nation.scout=0 AND nation.nation NOT IN %li GROUP BY general.nation, general.npc',
|
||||
$genLimit,
|
||||
$notIn
|
||||
);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$rawGeneralsCnt = $db->query(
|
||||
'SELECT general.nation as nation, nation.gennum, nation.name, npc, count(*) as cnt FROM general JOIN nation ON general.nation = nation.nation WHERE npc < 4 AND nation.gennum < %i AND nation.scout=0 GROUP BY general.nation, general.npc',
|
||||
'SELECT general.nation as nation, nation.gennum, nation.name, npc, count(*) as cnt FROM general JOIN nation ON general.nation = nation.nation WHERE npc != 9 AND nation.gennum < %i AND nation.scout=0 GROUP BY general.nation, general.npc',
|
||||
$genLimit
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
foreach($rawGeneralsCnt as $nation){
|
||||
|
||||
foreach ($rawGeneralsCnt as $nation) {
|
||||
$nationID = $nation['nation'];
|
||||
if(!\key_exists($nationID, $generalsCnt)){
|
||||
if (!\key_exists($nationID, $generalsCnt)) {
|
||||
$generalsCnt[$nationID] = [
|
||||
'nation'=>$nationID,
|
||||
'gennum'=>$nation['gennum'],
|
||||
'name'=>$nation['name'],
|
||||
'cnt'=>0,
|
||||
'nation' => $nationID,
|
||||
'gennum' => $nation['gennum'],
|
||||
'name' => $nation['name'],
|
||||
'cnt' => 0,
|
||||
];
|
||||
$generalsCnt[$nationID]['cnt'] = 0;
|
||||
}
|
||||
|
||||
if($nation['npc'] <= 2){
|
||||
|
||||
if ($nation['npc'] <= 2) {
|
||||
$calcCnt = $nation['cnt'];
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$calcCnt = $nation['cnt'] / 2;
|
||||
}
|
||||
|
||||
if ($general->getNPCType() < 2 && Util::starts_with($nation['name'], 'ⓤ')) {
|
||||
$calcCnt *= 100;
|
||||
}
|
||||
|
||||
$generalsCnt[$nationID]['cnt'] += $calcCnt;
|
||||
}
|
||||
|
||||
$randVals = [];
|
||||
foreach($generalsCnt as $testNation){
|
||||
$randVals[] = [$testNation, 1/$testNation['cnt']];
|
||||
foreach ($generalsCnt as $testNation) {
|
||||
$randVals[] = [$testNation, 1 / $testNation['cnt']];
|
||||
}
|
||||
|
||||
if($randVals){
|
||||
if ($randVals) {
|
||||
$destNation = Util::choiceRandomUsingWeightPair($randVals);
|
||||
}
|
||||
}
|
||||
|
||||
$logger = $general->getLogger();
|
||||
|
||||
if(!$destNation){
|
||||
if (!$destNation) {
|
||||
//임관 가능한 국가가 없다!
|
||||
$logger->pushGeneralActionLog("임관 가능한 국가가 없습니다. <1>$date</>");
|
||||
$logger->pushGeneralActionLog("임관 가능한 국가가 없습니다. <1>$date</>");
|
||||
$this->alternative = new che_요양($general, $this->env, null);
|
||||
return false;
|
||||
}
|
||||
@@ -236,7 +244,7 @@ class che_랜덤임관 extends Command\GeneralCommand{
|
||||
$destNationID = $destNation['nation'];
|
||||
$destNationName = $destNation['name'];
|
||||
|
||||
|
||||
|
||||
|
||||
$talkList = [
|
||||
'어쩌다 보니',
|
||||
@@ -257,10 +265,9 @@ class che_랜덤임관 extends Command\GeneralCommand{
|
||||
$logger->pushGeneralHistoryLog("<D><b>{$destNationName}</b></>에 랜덤 임관");
|
||||
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} {$randomTalk} <D><b>{$destNationName}</b></>에 <S>임관</>했습니다.");
|
||||
|
||||
if($gennum < GameConst::$initialNationGenLimit) {
|
||||
if ($gennum < GameConst::$initialNationGenLimit) {
|
||||
$exp = 700;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$exp = 100;
|
||||
}
|
||||
|
||||
@@ -268,22 +275,21 @@ class che_랜덤임관 extends Command\GeneralCommand{
|
||||
$general->setVar('officer_level', 1);
|
||||
$general->setVar('officer_city', 0);
|
||||
$general->setVar('belong', 1);
|
||||
|
||||
if($this->destGeneralObj !== null){
|
||||
|
||||
if ($this->destGeneralObj !== null) {
|
||||
$general->setVar('city', $this->destGeneralObj->getCityID());
|
||||
}
|
||||
else{
|
||||
} 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')
|
||||
'gennum' => $db->sqleval('gennum + 1')
|
||||
], 'nation=%i', $destNationID);
|
||||
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
if($general->getNPCType() == 1 || $relYear >= 3){
|
||||
$joinedNations = $general->getAuxVar('joinedNations')??[];
|
||||
if ($general->getNPCType() == 1 || $relYear >= 3) {
|
||||
$joinedNations = $general->getAuxVar('joinedNations') ?? [];
|
||||
$joinedNations[] = $destNationID;
|
||||
$general->setAuxVar('joinedNations', $joinedNations);
|
||||
}
|
||||
@@ -296,5 +302,4 @@ class che_랜덤임관 extends Command\GeneralCommand{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ use function \sammo\{
|
||||
getDomesticExpLevelBonus,
|
||||
CriticalRatioDomestic,
|
||||
CriticalScoreEx,
|
||||
tryUniqueItemLottery
|
||||
tryUniqueItemLottery,
|
||||
updateMaxDomesticCritical
|
||||
};
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
@@ -165,6 +166,13 @@ class che_상업투자 extends Command\GeneralCommand{
|
||||
$exp = $score * 0.7;
|
||||
$ded = $score * 1.0;
|
||||
|
||||
if($pick == 'success'){
|
||||
updateMaxDomesticCritical($general, $score);
|
||||
}
|
||||
else{
|
||||
$general->setAuxVar('max_domestic_critical', 0);
|
||||
}
|
||||
|
||||
$scoreText = number_format($score, 0);
|
||||
|
||||
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
||||
@@ -203,6 +211,4 @@ class che_상업투자 extends Command\GeneralCommand{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -202,6 +202,8 @@ class che_임관 extends Command\GeneralCommand{
|
||||
$nationList[$nationID]['scoutmsg'] = $scoutMsg;
|
||||
}
|
||||
|
||||
$hiddenItems = [];
|
||||
|
||||
foreach($nationList as &$nation){
|
||||
if($env['year'] < $env['startyear']+3 && $nation['gennum'] >= GameConst::$initialNationGenLimit){
|
||||
$nation['availableJoin'] = false;
|
||||
@@ -217,7 +219,9 @@ class che_임관 extends Command\GeneralCommand{
|
||||
$nation['availableJoin'] = false;
|
||||
}
|
||||
|
||||
|
||||
if(Util::starts_with($nation['name'], 'ⓤ')){
|
||||
$hiddenItems[$nation['nation']] = $nation['nation'];
|
||||
}
|
||||
}
|
||||
unset($nation);
|
||||
ob_start();
|
||||
@@ -228,6 +232,7 @@ class che_임관 extends Command\GeneralCommand{
|
||||
임관할 국가를 목록에서 선택하세요.<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;'?>'
|
||||
|
||||
@@ -209,7 +209,10 @@ class che_장수대상임관 extends Command\GeneralCommand{
|
||||
$nationList[$nationID]['scoutmsg'] = $scoutMsg;
|
||||
}
|
||||
|
||||
$hiddenItems = [];
|
||||
|
||||
foreach($nationList as &$nation){
|
||||
$nation['hideen'] = false;
|
||||
if($env['year'] < $env['startyear']+3 && $nation['gennum'] >= GameConst::$initialNationGenLimit){
|
||||
$nation['availableJoin'] = false;
|
||||
}
|
||||
@@ -224,7 +227,9 @@ class che_장수대상임관 extends Command\GeneralCommand{
|
||||
$nation['availableJoin'] = false;
|
||||
}
|
||||
|
||||
|
||||
if(Util::starts_with($nation['name'], 'ⓤ')){
|
||||
$hiddenItems[$nation['nation']] = $nation['nation'];
|
||||
}
|
||||
}
|
||||
unset($nation);
|
||||
ob_start();
|
||||
@@ -235,6 +240,7 @@ class che_장수대상임관 extends Command\GeneralCommand{
|
||||
임관할 국가를 목록에서 선택하세요.<br>
|
||||
<select class='formInput' name="destGeneralID" id="destGeneralID" size='1' style='color:white;background-color:black;'>
|
||||
<?php foreach($generalList as $targetGeneral): ?>
|
||||
<?php if(key_exists($targetGeneral['nation'], $hiddenItems)){ continue; } ?>
|
||||
<option value='<?=$targetGeneral['no']?>'><?=getColoredName($targetGeneral['name'],$targetGeneral['npc'])?>【<?=getNationStaticInfo($targetGeneral['nation'])['name']??'재야'?>】</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
@@ -15,7 +15,8 @@ use function \sammo\{
|
||||
getDomesticExpLevelBonus,
|
||||
CriticalRatioDomestic,
|
||||
CriticalScoreEx,
|
||||
tryUniqueItemLottery
|
||||
tryUniqueItemLottery,
|
||||
updateMaxDomesticCritical
|
||||
};
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
@@ -150,6 +151,13 @@ class che_정착장려 extends Command\GeneralCommand{
|
||||
$exp = $score * 0.7;
|
||||
$ded = $score * 1.0;
|
||||
|
||||
if($pick == 'success'){
|
||||
updateMaxDomesticCritical($general, $score);
|
||||
}
|
||||
else{
|
||||
$general->setAuxVar('max_domestic_critical', 0);
|
||||
}
|
||||
|
||||
$score *= 10;
|
||||
|
||||
$scoreText = number_format($score, 0);
|
||||
@@ -187,5 +195,5 @@ class che_정착장려 extends Command\GeneralCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -15,7 +15,8 @@ use function \sammo\{
|
||||
getDomesticExpLevelBonus,
|
||||
CriticalRatioDomestic,
|
||||
CriticalScoreEx,
|
||||
tryUniqueItemLottery
|
||||
tryUniqueItemLottery,
|
||||
updateMaxDomesticCritical
|
||||
};
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
@@ -150,6 +151,13 @@ class che_주민선정 extends Command\GeneralCommand{
|
||||
$exp = $score * 0.7;
|
||||
$ded = $score * 1.0;
|
||||
|
||||
if($pick == 'success'){
|
||||
updateMaxDomesticCritical($general, $score);
|
||||
}
|
||||
else{
|
||||
$general->setAuxVar('max_domestic_critical', 0);
|
||||
}
|
||||
|
||||
$score /= 10;
|
||||
|
||||
$scoreText = number_format($score, 1);
|
||||
|
||||
Reference in New Issue
Block a user