특기 초기화 추가

This commit is contained in:
2020-05-09 13:14:11 +09:00
parent b6a6ee31ed
commit a31b5ea29d
7 changed files with 188 additions and 11 deletions
+10 -4
View File
@@ -1254,9 +1254,12 @@ function addAge()
[$startYear, $year, $month] = $gameStor->getValuesAsArray(['startyear', 'year', 'month']);
if ($year >= $startYear + 3) {
foreach ($db->query('SELECT no,name,nation,leadership,strength,intel from general where specage<=age and special=%s', GameConst::$defaultSpecialDomestic) as $general) {
foreach ($db->query('SELECT no,name,nation,leadership,strength,intel,aux from general where specage<=age and special=%s', GameConst::$defaultSpecialDomestic) as $general) {
$generalID = $general['no'];
$special = SpecialityHelper::pickSpecialDomestic($general);
$special = SpecialityHelper::pickSpecialDomestic(
$general,
(Json::decode($general['aux'])['prev_types_special2'])??[]
);
$specialClass = buildGeneralSpecialDomesticClass($special);
$specialText = $specialClass->getName();
$db->update('general', [
@@ -1270,9 +1273,12 @@ function addAge()
$logger->pushGeneralHistoryLog("특기 【<b><C>{$specialText}</></b>】{$josaUl} 습득");
}
foreach ($db->query('SELECT no,name,nation,leadership,strength,intel,npc,dex1,dex2,dex3,dex4,dex5 from general where specage2<=age and special2=%s', GameConst::$defaultSpecialWar) as $general) {
foreach ($db->query('SELECT no,name,nation,leadership,strength,intel,npc,dex1,dex2,dex3,dex4,dex5,aux from general where specage2<=age and special2=%s', GameConst::$defaultSpecialWar) as $general) {
$generalID = $general['no'];
$special2 = SpecialityHelper::pickSpecialWar($general);
$special2 = SpecialityHelper::pickSpecialWar(
$general,
(Json::decode($general['aux'])['prev_types_special2'])??[]
);
$specialClass = buildGeneralSpecialWarClass($special2);
$specialText = $specialClass->getName();
@@ -7,8 +7,6 @@ use \sammo\WarUnit;
use sammo\WarUnitTriggerCaller;
use sammo\WarUnitTrigger\che_필살강화_회피불가;
use function sammo\LogText;
class che_필살 extends \sammo\BaseSpecial{
protected $id = 71;
@@ -0,0 +1,29 @@
<?php
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
General,
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command
};
use function \sammo\{
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
class che_내정특기초기화 extends che_전투특기초기화{
static protected $actionName = '내정 특기 초기화';
static protected $specialType = 'special';
static protected $speicalAge = 'specage';
static protected $specialText = '내정 특기';
}
@@ -0,0 +1,130 @@
<?php
namespace sammo\Command\General;
use \sammo\{
DB, Util, JosaUtil,
General,
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command
};
use function \sammo\{
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper;
class che_전투특기초기화 extends Command\GeneralCommand{
static protected $actionName = '전투 특기 초기화';
static protected $specialType = 'special2';
static protected $speicalAge = 'specage2';
static protected $specialText = '전투 특기';
protected function argTest():bool{
$this->arg = null;
return true;
}
protected function init(){
$general = $this->generalObj;
$env = $this->env;
$yearMonth = Util::joinYearMonth($env['year'], $env['month']);
$auxYearMonth = $general->getAuxVar('used_'.$this->getName())??-999;
if($yearMonth < $auxYearMonth + 60){
$this->minConditionConstraints=[
ConstraintHelper::AlwaysFail('초기화한 지 5년이 지나야합니다')
];
$this->fullConditionConstraints=[
ConstraintHelper::AlwaysFail('초기화한 지 5년이 지나야합니다')
];
return;
}
$this->minConditionConstraints=[
ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.'),
];
$this->fullConditionConstraints=[
ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.')
];
}
public function getCommandDetailTitle():string{
$name = $this->getName();
if($this->getPreReqTurn()){
$reqTurn = ($this->getPreReqTurn()+1).'턴, ';
}
else{
$reqTurn = 0;
}
$title = "{$name}({$reqTurn}5년마다 1회)";
return $title;
}
public function getCost():array{
return [0, 0];
}
public function getPreReqTurn():int{
return 1;
}
public function getPostReqTurn():int{
return 0;
}
public function getTermString():string{
$term = $this->getResultTurn()->getTerm();
$termMax = $this->getPreReqTurn() + 1;
return "새로운 적성을 찾는 중... ({$term}/{$termMax})";
}
public function run():bool{
if(!$this->hasFullConditionMet()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
$db = DB::db();
$general = $this->generalObj;
$date = $general->getTurnTime($general::TURNTIME_HM);
$oldTypeKey = 'prev_types_'.static::$specialType;
$specialName = static::$specialText;
$env = $this->env;
$yearMonth = Util::joinYearMonth($env['year'], $env['month']);
$oldSpecialList = $general->getAuxVar($oldTypeKey)??[];
$oldSpecialList[] = $general->getVar(static::$specialType);
$general->setAuxVar($oldTypeKey, $oldSpecialList);
$general->setVar(static::$specialType, 'None');
$general->setVar(static::$speicalAge, $general->getVar('age') + 1);
$general->setAuxVar('used_'.$this->getName(), $yearMonth);
$logger = $general->getLogger();
$logger->pushGeneralActionLog("새로운 {$specialName}를 가질 준비가 되었습니다. <1>$date</>");
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
tryUniqueItemLottery($general);
$general->applyDB($db);
return true;
}
}
+2 -2
View File
@@ -275,8 +275,8 @@ class GameConstBase
'che_선동',
],
'개인'=>[
//'che_내정특기초기화',
//'che_전투특기초기화',
'che_내정특기초기화',
'che_전투특기초기화',
'che_단련',
'che_숙련전환',
'che_견문',
+1 -1
View File
@@ -33,7 +33,7 @@ trait LazyVarUpdater{
}
function unpackAux(){
if($this->raw['auxVar']??null === null){
if(($this->raw['auxVar']??null) === null){
if(!key_exists('aux', $this->raw)){
throw new \RuntimeException('aux is not set');
}
+16 -2
View File
@@ -179,7 +179,7 @@ class SpecialityHelper{
return $result;
}
public static function pickSpecialDomestic(array $general) : string{
public static function pickSpecialDomestic(array $general, array $prevSpecials=[]) : string{
$pAbs = [];
$pRel = [];
@@ -201,6 +201,9 @@ class SpecialityHelper{
if(!$valid){
continue;
}
if(in_array($specialID, $prevSpecials)){
continue;
}
if($weightType === static::WEIGHT_PERCENT){
@@ -226,10 +229,14 @@ class SpecialityHelper{
return $id;
}
if($prevSpecials){
return static::pickSpecialDomestic($general, []);
}
throw new MustNotBeReachedException();
}
public static function pickSpecialWar(array $general) : string{
public static function pickSpecialWar(array $general, array $prevSpecials=[]) : string{
$reqDex = [];
$pAbs = [];
$pRel = [];
@@ -254,6 +261,9 @@ class SpecialityHelper{
if(!$valid){
continue;
}
if(in_array($specialID, $prevSpecials)){
continue;
}
if($cond & self::REQ_DEXTERITY){
@@ -286,6 +296,10 @@ class SpecialityHelper{
return $id;
}
if($prevSpecials){
return static::pickSpecialWar($general, []);
}
throw new MustNotBeReachedException();
}
}