숙련전환 효율 향상

This commit is contained in:
2020-06-06 14:33:21 +09:00
parent cbe8b4012b
commit 8ca365da7b
+242 -242
View File
@@ -1,242 +1,242 @@
<?php <?php
namespace sammo\Command\General; namespace sammo\Command\General;
use\sammo\{ use\sammo\{
DB, DB,
Util, Util,
JosaUtil, JosaUtil,
Session, Session,
KVStorage, KVStorage,
General, General,
ActionLogger, ActionLogger,
GameConst, GameConst,
GameUnitConst, GameUnitConst,
LastTurn, LastTurn,
Command, Command,
ServConfig ServConfig
}; };
use function\sammo\{ use function\sammo\{
getDexCall, getDexCall,
getTechCall, getTechCall,
tryUniqueItemLottery, tryUniqueItemLottery,
getTechAbil getTechAbil
}; };
use \sammo\Constraint\Constraint; use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper; use \sammo\Constraint\ConstraintHelper;
class che_숙련전환 extends Command\GeneralCommand class che_숙련전환 extends Command\GeneralCommand
{ {
static protected $actionName = '숙련전환'; static protected $actionName = '숙련전환';
static public $reqArg = true; static public $reqArg = true;
/** @var int */ /** @var int */
protected $srcArmType; protected $srcArmType;
/** @var string */ /** @var string */
protected $srcArmTypeName; protected $srcArmTypeName;
/** @var int */ /** @var int */
protected $destArmType; protected $destArmType;
/** @var string */ /** @var string */
protected $destArmTypeName; protected $destArmTypeName;
protected function argTest(): bool protected function argTest(): bool
{ {
if ($this->arg === null) { if ($this->arg === null) {
return false; return false;
} }
if (!key_exists('srcArmType', $this->arg)) { if (!key_exists('srcArmType', $this->arg)) {
return false; return false;
} }
if (!key_exists('destArmType', $this->arg)) { if (!key_exists('destArmType', $this->arg)) {
return false; return false;
} }
$srcArmType = $this->arg['srcArmType']; $srcArmType = $this->arg['srcArmType'];
$destArmType = $this->arg['destArmType']; $destArmType = $this->arg['destArmType'];
if (!is_int($srcArmType)) { if (!is_int($srcArmType)) {
return false; return false;
} }
if (!key_exists($srcArmType, GameUnitConst::allType())) { if (!key_exists($srcArmType, GameUnitConst::allType())) {
return false; return false;
} }
if (!is_int($destArmType)) { if (!is_int($destArmType)) {
return false; return false;
} }
if (!key_exists($destArmType, GameUnitConst::allType())) { if (!key_exists($destArmType, GameUnitConst::allType())) {
return false; return false;
} }
if ($srcArmType === $destArmType) { if ($srcArmType === $destArmType) {
return false; return false;
} }
$this->arg = [ $this->arg = [
'srcArmType' => $srcArmType, 'srcArmType' => $srcArmType,
'destArmType' => $destArmType 'destArmType' => $destArmType
]; ];
return true; return true;
} }
protected function init() protected function init()
{ {
$general = $this->generalObj; $general = $this->generalObj;
$this->setCity(); $this->setCity();
$this->setNation(); $this->setNation();
[$reqGold, $reqRice] = $this->getCost(); [$reqGold, $reqRice] = $this->getCost();
$this->minConditionConstraints = [ $this->minConditionConstraints = [
ConstraintHelper::NotBeNeutral(), ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(), ConstraintHelper::OccupiedCity(),
ConstraintHelper::ReqGeneralGold($reqGold), ConstraintHelper::ReqGeneralGold($reqGold),
ConstraintHelper::ReqGeneralRice($reqRice), ConstraintHelper::ReqGeneralRice($reqRice),
]; ];
} }
protected function initWithArg() protected function initWithArg()
{ {
$this->srcArmType = $this->arg['srcArmType']; $this->srcArmType = $this->arg['srcArmType'];
$this->srcArmTypeName = GameUnitConst::allType()[$this->srcArmType]; $this->srcArmTypeName = GameUnitConst::allType()[$this->srcArmType];
$this->destArmType = $this->arg['destArmType']; $this->destArmType = $this->arg['destArmType'];
$this->destArmTypeName = GameUnitConst::allType()[$this->destArmType]; $this->destArmTypeName = GameUnitConst::allType()[$this->destArmType];
[$reqGold, $reqRice] = $this->getCost(); [$reqGold, $reqRice] = $this->getCost();
$this->fullConditionConstraints = [ $this->fullConditionConstraints = [
ConstraintHelper::NotBeNeutral(), ConstraintHelper::NotBeNeutral(),
ConstraintHelper::OccupiedCity(), ConstraintHelper::OccupiedCity(),
ConstraintHelper::ReqGeneralGold($reqGold), ConstraintHelper::ReqGeneralGold($reqGold),
ConstraintHelper::ReqGeneralRice($reqRice), ConstraintHelper::ReqGeneralRice($reqRice),
]; ];
} }
public function getBrief(): string public function getBrief(): string
{ {
return "{$this->srcArmTypeName}】숙련을 【{$this->destArmTypeName}】숙련으로 전환"; return "{$this->srcArmTypeName}】숙련을 【{$this->destArmTypeName}】숙련으로 전환";
} }
public function getCommandDetailTitle(): string public function getCommandDetailTitle(): string
{ {
$name = $this->getName(); $name = $this->getName();
[$reqGold, $reqRice] = $this->getCost(); [$reqGold, $reqRice] = $this->getCost();
$title = "{$name}(통솔경험"; $title = "{$name}(통솔경험";
if ($reqGold > 0) { if ($reqGold > 0) {
$title .= ", 자금{$reqGold}"; $title .= ", 자금{$reqGold}";
} }
if ($reqRice > 0) { if ($reqRice > 0) {
$title .= ", 군량{$reqRice}"; $title .= ", 군량{$reqRice}";
} }
$title .= ')'; $title .= ')';
return $title; return $title;
} }
public function getCost(): array public function getCost(): array
{ {
$env = $this->env; $env = $this->env;
return [$env['develcost'], $env['develcost']]; return [$env['develcost'], $env['develcost']];
} }
public function getPreReqTurn(): int public function getPreReqTurn(): int
{ {
return 0; return 0;
} }
public function getPostReqTurn(): int public function getPostReqTurn(): int
{ {
return 0; return 0;
} }
public function run(): bool public function run(): bool
{ {
if (!$this->hasFullConditionMet()) { if (!$this->hasFullConditionMet()) {
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
} }
$db = DB::db(); $db = DB::db();
$general = $this->generalObj; $general = $this->generalObj;
$date = $general->getTurnTime($general::TURNTIME_HM); $date = $general->getTurnTime($general::TURNTIME_HM);
$logger = $general->getLogger(); $logger = $general->getLogger();
$srcDex = $general->getVar('dex' . $this->srcArmType); $srcDex = $general->getVar('dex' . $this->srcArmType);
$cutDex = Util::toInt($srcDex * 0.25); $cutDex = Util::toInt($srcDex * 0.4);
$cutDexText = number_format($cutDex); $cutDexText = number_format($cutDex);
$addDex = Util::toInt($cutDex * 9 / 10); $addDex = Util::toInt($cutDex * 9 / 10);
$addDexText = number_format($addDex); $addDexText = number_format($addDex);
$general->increaseVar('dex' . $this->srcArmType, -$cutDex); $general->increaseVar('dex' . $this->srcArmType, -$cutDex);
$general->increaseVar('dex' . $this->destArmType, $addDex); $general->increaseVar('dex' . $this->destArmType, $addDex);
$josaUl = JosaUtil::pick($cutDex, '을'); $josaUl = JosaUtil::pick($cutDex, '을');
$josaRo = JosaUtil::pick($addDex, '로'); $josaRo = JosaUtil::pick($addDex, '로');
[$reqGold, $reqRice] = $this->getCost(); [$reqGold, $reqRice] = $this->getCost();
$logger->pushGeneralActionLog("{$this->srcArmTypeName} 숙련 {$cutDexText}{$josaUl} {$this->destArmTypeName} 숙련 {$addDexText}{$josaRo} 전환했습니다. <1>$date</>"); $logger->pushGeneralActionLog("{$this->srcArmTypeName} 숙련 {$cutDexText}{$josaUl} {$this->destArmTypeName} 숙련 {$addDexText}{$josaRo} 전환했습니다. <1>$date</>");
$general->addExperience(10); $general->addExperience(10);
$general->increaseVarWithLimit('gold', -$reqGold, 0); $general->increaseVarWithLimit('gold', -$reqGold, 0);
$general->increaseVarWithLimit('rice', -$reqRice, 0); $general->increaseVarWithLimit('rice', -$reqRice, 0);
$general->increaseVar('leadership_exp', 2); $general->increaseVar('leadership_exp', 2);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange(); $general->checkStatChange();
tryUniqueItemLottery($general); tryUniqueItemLottery($general);
$general->applyDB($db); $general->applyDB($db);
return true; return true;
} }
public function getForm(): string public function getForm(): string
{ {
$db = DB::db(); $db = DB::db();
$general = $this->generalObj; $general = $this->generalObj;
$dexSrcTexts = []; $dexSrcTexts = [];
$dexDestTexts = []; $dexDestTexts = [];
foreach (GameUnitConst::allType() as $armType => $armName) { foreach (GameUnitConst::allType() as $armType => $armName) {
$dexVal = $general->getVar('dex' . $armType); $dexVal = $general->getVar('dex' . $armType);
$dexValText = number_format($dexVal); $dexValText = number_format($dexVal);
$cutDex = Util::toInt($dexVal * 0.25); $cutDex = Util::toInt($dexVal * 0.4);
$addDex = Util::toInt($cutDex * 9 / 10); $addDex = Util::toInt($cutDex * 9 / 10);
$addDexText = number_format($addDex); $addDexText = number_format($addDex);
$newDex = $dexVal - $cutDex; $newDex = $dexVal - $cutDex;
$beforeDexLevel = getDexCall($dexVal); $beforeDexLevel = getDexCall($dexVal);
$afterDexLevel = getDexCall($newDex); $afterDexLevel = getDexCall($newDex);
$dexSrcTexts[$armType] = "{$armName} ({$beforeDexLevel}{$afterDexLevel}, {$addDexText} 전환)"; $dexSrcTexts[$armType] = "{$armName} ({$beforeDexLevel}{$afterDexLevel}, {$addDexText} 전환)";
$dexDestTexts[$armType] = "{$armName} ({$dexValText})"; $dexDestTexts[$armType] = "{$armName} ({$dexValText})";
} }
ob_start(); ob_start();
?> ?>
본인의 특정 병종 숙련을 25% 줄이고, 줄어든 숙련 중 9/10(90%p)를 다른 병종 숙련으로 전환합니다.<br> 본인의 특정 병종 숙련을 40% 줄이고, 줄어든 숙련 중 9/10(90%p)를 다른 병종 숙련으로 전환합니다.<br>
<select class='formInput' name="srcArmType" id="srcArmType" size='1' style='color:white;background-color:black;'> <select class='formInput' name="srcArmType" id="srcArmType" size='1' style='color:white;background-color:black;'>
<?php foreach ($dexSrcTexts as $armType => $infoText) : ?> <?php foreach ($dexSrcTexts as $armType => $infoText) : ?>
<option value="<?= $armType ?>"><?= $infoText ?></option> <option value="<?= $armType ?>"><?= $infoText ?></option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
숙련을 숙련을
<select class='formInput' name="destArmType" id="destArmType" size='1' style='color:white;background-color:black;'> <select class='formInput' name="destArmType" id="destArmType" size='1' style='color:white;background-color:black;'>
<?php foreach ($dexDestTexts as $armType => $infoText) : ?> <?php foreach ($dexDestTexts as $armType => $infoText) : ?>
<option value="<?= $armType ?>"><?= $infoText ?></option> <option value="<?= $armType ?>"><?= $infoText ?></option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
숙련으로 <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br> 숙련으로 <input type=button id="commonSubmit" value="<?= $this->getName() ?>"><br>
<?php <?php
return ob_get_clean(); return ob_get_clean();
} }
} }