fix: 유니크를 얻는 턴이 아니더라도 환불은 하도록 수정

This commit is contained in:
2021-09-16 21:38:43 +09:00
parent a437675781
commit ef96c7d074
12 changed files with 73 additions and 48 deletions
+13 -6
View File
@@ -1286,12 +1286,11 @@ function addAge()
$generalAux = Json::decode($general['aux']); $generalAux = Json::decode($general['aux']);
$updateVars = []; $updateVars = [];
if(key_exists('inheritSpecificSpecialWar', $generalAux)){ if (key_exists('inheritSpecificSpecialWar', $generalAux)) {
$special2 = $generalAux['inheritSpecificSpecialWar']; $special2 = $generalAux['inheritSpecificSpecialWar'];
unset($generalAux['inheritSpecificSpecialWar']); unset($generalAux['inheritSpecificSpecialWar']);
$updateVars['aux'] = Json::encode($generalAux); $updateVars['aux'] = Json::encode($generalAux);
} } else {
else{
$special2 = SpecialityHelper::pickSpecialWar( $special2 = SpecialityHelper::pickSpecialWar(
$general, $general,
($generalAux['prev_types_special2']) ?? [] ($generalAux['prev_types_special2']) ?? []
@@ -1666,7 +1665,12 @@ function rollbackInheritUniqueTrial(General $general, string $itemKey, string $r
$general->applyDB($db); $general->applyDB($db);
} }
function tryInheritUniqueItem(General $general, string $acquireType = '아이템'): bool function tryRollbackInheritUniqueItem(General $general): void
{
tryInheritUniqueItem($general, 'Rollback', true);
}
function tryInheritUniqueItem(General $general, string $acquireType = '아이템', bool $justRollback = false): bool
{ {
$ownerID = $general->getVar('owner'); $ownerID = $general->getVar('owner');
if (!$ownerID) { if (!$ownerID) {
@@ -1769,6 +1773,9 @@ function tryInheritUniqueItem(General $general, string $acquireType = '아이템
if ($ownTarget === null) { if ($ownTarget === null) {
return false; return false;
} }
if ($justRollback) {
return false;
}
LogText("선택유니크획득{$ownerID}", $ownTarget); LogText("선택유니크획득{$ownerID}", $ownTarget);
@@ -1859,9 +1866,9 @@ function tryUniqueItemLottery(General $general, string $acquireType = '아이템
$result = false; $result = false;
$prob /= sqrt(2); $prob /= sqrt(2);
$moreProb = pow(2, 1/4); $moreProb = pow(2, 1 / 4);
if($general->getAuxVar('inheritRandomUnique')){ if ($general->getAuxVar('inheritRandomUnique')) {
//포인트로 랜덤 유니크 획득 //포인트로 랜덤 유니크 획득
$prob = 1; $prob = 1;
LogText("{$general->getName()}, {$general->getID()} 유산 포인트 유니크", $prob); LogText("{$general->getName()}, {$general->getID()} 유산 포인트 유니크", $prob);
+6 -5
View File
@@ -4,7 +4,7 @@ namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
General, General,
CityConst, CityConst,
ActionLogger, ActionLogger,
LastTurn, LastTurn,
Command Command
@@ -13,6 +13,7 @@ use \sammo\{
use \sammo\Constraint\Constraint; use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper; use \sammo\Constraint\ConstraintHelper;
use function sammo\tryRollbackInheritUniqueItem;
class che_NPC능동 extends Command\GeneralCommand{ class che_NPC능동 extends Command\GeneralCommand{
static protected $actionName = 'NPC능동'; static protected $actionName = 'NPC능동';
@@ -46,7 +47,7 @@ class che_NPC능동 extends Command\GeneralCommand{
$general = $this->generalObj; $general = $this->generalObj;
$this->setNation(); $this->setNation();
$this->permissionConstraints=[ $this->permissionConstraints=[
ConstraintHelper::MustBeNPC() ConstraintHelper::MustBeNPC()
@@ -65,7 +66,7 @@ class che_NPC능동 extends Command\GeneralCommand{
public function getCost():array{ public function getCost():array{
return [0, 0]; return [0, 0];
} }
public function getPreReqTurn():int{ public function getPreReqTurn():int{
return 0; return 0;
} }
@@ -97,11 +98,11 @@ class che_NPC능동 extends Command\GeneralCommand{
$this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $this->setResultTurn(new LastTurn(static::getName(), $this->arg));
} }
tryRollbackInheritUniqueItem($general);
$general->applyDB($db); $general->applyDB($db);
return true; return true;
} }
} }
@@ -14,6 +14,8 @@ use \sammo\{
use \sammo\Constraint\Constraint; use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper; use \sammo\Constraint\ConstraintHelper;
use function sammo\tryRollbackInheritUniqueItem;
class che_모반시도 extends Command\GeneralCommand{ class che_모반시도 extends Command\GeneralCommand{
static protected $actionName = '모반시도'; static protected $actionName = '모반시도';
@@ -29,7 +31,7 @@ class che_모반시도 extends Command\GeneralCommand{
$this->setCity(); $this->setCity();
$this->setNation(); $this->setNation();
$this->fullConditionConstraints=[ $this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(), ConstraintHelper::NotBeNeutral(),
ConstraintHelper::BeChief(), ConstraintHelper::BeChief(),
@@ -43,7 +45,7 @@ class che_모반시도 extends Command\GeneralCommand{
public function getCost():array{ public function getCost():array{
return [0, 0]; return [0, 0];
} }
public function getPreReqTurn():int{ public function getPreReqTurn():int{
return 0; return 0;
} }
@@ -72,7 +74,7 @@ class che_모반시도 extends Command\GeneralCommand{
$lordName = $lordGeneral->getName(); $lordName = $lordGeneral->getName();
$nationName = $this->nation['name']; $nationName = $this->nation['name'];
$logger = $general->getLogger(); $logger = $general->getLogger();
$lordLogger = $lordGeneral->getLogger(); $lordLogger = $lordGeneral->getLogger();
@@ -82,7 +84,7 @@ class che_모반시도 extends Command\GeneralCommand{
$lordGeneral->setVar('officer_city', 0); $lordGeneral->setVar('officer_city', 0);
$lordGeneral->multiplyVar('experience', 0.7); $lordGeneral->multiplyVar('experience', 0.7);
$josaYi = JosaUtil::pick($generalName, '이'); $josaYi = JosaUtil::pick($generalName, '이');
$logger->pushGlobalHistoryLog("<Y><b>【모반】</b></><Y>{$generalName}</>{$josaYi} <D><b>{$nationName}</b></>의 군주 자리를 찬탈했습니다."); $logger->pushGlobalHistoryLog("<Y><b>【모반】</b></><Y>{$generalName}</>{$josaYi} <D><b>{$nationName}</b></>의 군주 자리를 찬탈했습니다.");
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <Y>{$lordName}</>에게서 군주자리를 찬탈"); $logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <Y>{$lordName}</>에게서 군주자리를 찬탈");
@@ -95,11 +97,12 @@ class che_모반시도 extends Command\GeneralCommand{
$this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange(); $general->checkStatChange();
tryRollbackInheritUniqueItem($general);
$general->applyDB($db); $general->applyDB($db);
$lordGeneral->applyDB($db); $lordGeneral->applyDB($db);
return true; return true;
} }
} }
+6 -5
View File
@@ -3,7 +3,7 @@ namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
General, General,
ActionLogger, ActionLogger,
GameConst, GameUnitConst, GameConst, GameUnitConst,
LastTurn, LastTurn,
@@ -15,7 +15,7 @@ use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst; use sammo\CityConst;
use function sammo\DeleteConflict; use function sammo\DeleteConflict;
use function sammo\refreshNationStaticInfo; use function sammo\refreshNationStaticInfo;
use function sammo\tryRollbackInheritUniqueItem;
class che_방랑 extends Command\GeneralCommand{ class che_방랑 extends Command\GeneralCommand{
static protected $actionName = '방랑'; static protected $actionName = '방랑';
@@ -34,7 +34,7 @@ class che_방랑 extends Command\GeneralCommand{
$this->setNation(); $this->setNation();
$relYear = $env['year'] - $env['startyear']; $relYear = $env['year'] - $env['startyear'];
$this->fullConditionConstraints=[ $this->fullConditionConstraints=[
ConstraintHelper::BeLord(), ConstraintHelper::BeLord(),
ConstraintHelper::NotWanderingNation(), ConstraintHelper::NotWanderingNation(),
@@ -48,7 +48,7 @@ class che_방랑 extends Command\GeneralCommand{
public function getCost():array{ public function getCost():array{
return [0, 0]; return [0, 0];
} }
public function getPreReqTurn():int{ public function getPreReqTurn():int{
return 0; return 0;
} }
@@ -85,7 +85,7 @@ class che_방랑 extends Command\GeneralCommand{
$logger->pushGlobalHistoryLog("<R><b>【방랑】</b></><D><b>{$generalName}</b></>{$josaUn} <R>방랑</>의 길을 떠납니다."); $logger->pushGlobalHistoryLog("<R><b>【방랑】</b></><D><b>{$generalName}</b></>{$josaUn} <R>방랑</>의 길을 떠납니다.");
$logger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>{$josaUl} 버리고 방랑"); $logger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>{$josaUl} 버리고 방랑");
//분쟁기록 모두 지움 //분쟁기록 모두 지움
DeleteConflict($nationID); DeleteConflict($nationID);
// 국명, 색깔 바꿈 국가 레벨 0, 성향리셋, 기술0 // 국명, 색깔 바꿈 국가 레벨 0, 성향리셋, 기술0
@@ -123,6 +123,7 @@ class che_방랑 extends Command\GeneralCommand{
refreshNationStaticInfo(); refreshNationStaticInfo();
$this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $this->setResultTurn(new LastTurn(static::getName(), $this->arg));
tryRollbackInheritUniqueItem($general);
$general->applyDB($db); $general->applyDB($db);
return true; return true;
+2
View File
@@ -20,6 +20,7 @@ use function\sammo\tryUniqueItemLottery;
use \sammo\Constraint\Constraint; use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper; use \sammo\Constraint\ConstraintHelper;
use function sammo\tryRollbackInheritUniqueItem;
class che_선양 extends Command\GeneralCommand class che_선양 extends Command\GeneralCommand
{ {
@@ -136,6 +137,7 @@ class che_선양 extends Command\GeneralCommand
$this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange(); $general->checkStatChange();
tryRollbackInheritUniqueItem($general);
$general->applyDB($db); $general->applyDB($db);
$destGeneral->applyDB($db); $destGeneral->applyDB($db);
@@ -3,7 +3,7 @@ namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
General, General,
ActionLogger, ActionLogger,
GameConst, GameUnitConst, GameConst, GameUnitConst,
LastTurn, LastTurn,
@@ -13,6 +13,8 @@ use \sammo\{
use \sammo\Constraint\Constraint; use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper; use \sammo\Constraint\ConstraintHelper;
use function sammo\tryRollbackInheritUniqueItem;
class che_소집해제 extends Command\GeneralCommand{ class che_소집해제 extends Command\GeneralCommand{
static protected $actionName = '소집해제'; static protected $actionName = '소집해제';
@@ -27,7 +29,7 @@ class che_소집해제 extends Command\GeneralCommand{
$this->setCity(); $this->setCity();
$this->setNation(); $this->setNation();
$this->fullConditionConstraints=[ $this->fullConditionConstraints=[
ConstraintHelper::ReqGeneralCrew(), ConstraintHelper::ReqGeneralCrew(),
]; ];
@@ -43,7 +45,7 @@ class che_소집해제 extends Command\GeneralCommand{
public function getCost():array{ public function getCost():array{
return [0, 0]; return [0, 0];
} }
public function getPreReqTurn():int{ public function getPreReqTurn():int{
return 0; return 0;
} }
@@ -70,7 +72,7 @@ class che_소집해제 extends Command\GeneralCommand{
$exp = 70; $exp = 70;
$ded = 100; $ded = 100;
$db->update('city', [ $db->update('city', [
'pop'=>$db->sqleval('pop + %i', $crew) 'pop'=>$db->sqleval('pop + %i', $crew)
], 'city=%i', $general->getCityID()); ], 'city=%i', $general->getCityID());
@@ -80,10 +82,11 @@ class che_소집해제 extends Command\GeneralCommand{
$general->addDedication($ded); $general->addDedication($ded);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange(); $general->checkStatChange();
tryRollbackInheritUniqueItem($general);
$general->applyDB($db); $general->applyDB($db);
return true; return true;
} }
} }
+7 -6
View File
@@ -3,7 +3,7 @@ namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
General, General,
ActionLogger, ActionLogger,
GameConst, GameUnitConst, GameConst, GameUnitConst,
LastTurn, LastTurn,
@@ -13,7 +13,7 @@ use \sammo\{
use \sammo\Constraint\Constraint; use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper; use \sammo\Constraint\ConstraintHelper;
use function sammo\tryRollbackInheritUniqueItem;
class che_요양 extends Command\GeneralCommand{ class che_요양 extends Command\GeneralCommand{
static protected $actionName = '요양'; static protected $actionName = '요양';
@@ -28,7 +28,7 @@ class che_요양 extends Command\GeneralCommand{
$general = $this->generalObj; $general = $this->generalObj;
$this->setNation(); $this->setNation();
$this->fullConditionConstraints=[ $this->fullConditionConstraints=[
]; ];
@@ -37,7 +37,7 @@ class che_요양 extends Command\GeneralCommand{
public function getCost():array{ public function getCost():array{
return [0, 0]; return [0, 0];
} }
public function getPreReqTurn():int{ public function getPreReqTurn():int{
return 0; return 0;
} }
@@ -56,7 +56,7 @@ class che_요양 extends Command\GeneralCommand{
$general = $this->generalObj; $general = $this->generalObj;
$date = $general->getTurnTime($general::TURNTIME_HM); $date = $general->getTurnTime($general::TURNTIME_HM);
$crew = $general->getVar('crew'); $crew = $general->getVar('crew');
$logger = $general->getLogger(); $logger = $general->getLogger();
@@ -71,10 +71,11 @@ class che_요양 extends Command\GeneralCommand{
$general->addDedication($ded); $general->addDedication($ded);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange(); $general->checkStatChange();
tryRollbackInheritUniqueItem($general);
$general->applyDB($db); $general->applyDB($db);
return true; return true;
} }
} }
+2
View File
@@ -15,6 +15,7 @@ use \sammo\Json;
use function \sammo\searchDistance; use function \sammo\searchDistance;
use function \sammo\printCitiesBasedOnDistance; use function \sammo\printCitiesBasedOnDistance;
use function sammo\tryRollbackInheritUniqueItem;
use \sammo\Constraint\Constraint; use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper; use \sammo\Constraint\ConstraintHelper;
@@ -217,6 +218,7 @@ class che_첩보 extends Command\GeneralCommand
$general->increaseVar('leadership_exp', 1); $general->increaseVar('leadership_exp', 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange(); $general->checkStatChange();
tryRollbackInheritUniqueItem($general);
$general->applyDB($db); $general->applyDB($db);
return true; return true;
+8 -7
View File
@@ -3,7 +3,7 @@ namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
General, General,
ActionLogger, ActionLogger,
GameConst, GameUnitConst, GameConst, GameUnitConst,
LastTurn, LastTurn,
@@ -14,7 +14,7 @@ use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper; use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst; use sammo\CityConst;
use function sammo\tryRollbackInheritUniqueItem;
class che_하야 extends Command\GeneralCommand{ class che_하야 extends Command\GeneralCommand{
static protected $actionName = '하야'; static protected $actionName = '하야';
@@ -32,7 +32,7 @@ class che_하야 extends Command\GeneralCommand{
$this->setNation(); $this->setNation();
$relYear = $env['year'] - $env['startyear']; $relYear = $env['year'] - $env['startyear'];
$this->fullConditionConstraints=[ $this->fullConditionConstraints=[
ConstraintHelper::NotBeNeutral(), ConstraintHelper::NotBeNeutral(),
ConstraintHelper::NotOpeningPart($relYear), ConstraintHelper::NotOpeningPart($relYear),
@@ -43,7 +43,7 @@ class che_하야 extends Command\GeneralCommand{
public function getCost():array{ public function getCost():array{
return [0, 0]; return [0, 0];
} }
public function getPreReqTurn():int{ public function getPreReqTurn():int{
return 0; return 0;
} }
@@ -67,7 +67,7 @@ class che_하야 extends Command\GeneralCommand{
$nationID = $this->nation['nation']; $nationID = $this->nation['nation'];
$nationName = $this->nation['name']; $nationName = $this->nation['name'];
$logger = $general->getLogger(); $logger = $general->getLogger();
$logger->pushGeneralActionLog("<D><b>{$nationName}</b></>에서 하야했습니다. <1>$date</>"); $logger->pushGeneralActionLog("<D><b>{$nationName}</b></>에서 하야했습니다. <1>$date</>");
@@ -101,13 +101,14 @@ class che_하야 extends Command\GeneralCommand{
$general->setVar('officer_city', 0); $general->setVar('officer_city', 0);
$general->setVar('belong', 0); $general->setVar('belong', 0);
$general->setVar('makelimit', 12); $general->setVar('makelimit', 12);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange(); $general->checkStatChange();
tryRollbackInheritUniqueItem($general);
$general->applyDB($db); $general->applyDB($db);
return true; return true;
} }
} }
+6 -7
View File
@@ -3,7 +3,7 @@ namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
General, General,
ActionLogger, ActionLogger,
GameConst, GameUnitConst, GameConst, GameUnitConst,
LastTurn, LastTurn,
@@ -16,13 +16,12 @@ use \sammo\Constraint\ConstraintHelper;
use sammo\CityConst; use sammo\CityConst;
use function sammo\refreshNationStaticInfo; use function sammo\refreshNationStaticInfo;
use function sammo\deleteNation; use function sammo\deleteNation;
use function sammo\tryRollbackInheritUniqueItem;
class che_해산 extends Command\GeneralCommand{ class che_해산 extends Command\GeneralCommand{
static protected $actionName = '해산'; static protected $actionName = '해산';
protected function argTest():bool{ protected function argTest():bool{
$this->arg = []; $this->arg = [];
return true; return true;
@@ -45,7 +44,7 @@ class che_해산 extends Command\GeneralCommand{
public function getCost():array{ public function getCost():array{
return [0, 0]; return [0, 0];
} }
public function getPreReqTurn():int{ public function getPreReqTurn():int{
return 0; return 0;
} }
@@ -96,11 +95,11 @@ class che_해산 extends Command\GeneralCommand{
$oldGeneral->setVar('makelimit', 12); $oldGeneral->setVar('makelimit', 12);
$oldGeneral->applyDB($db); $oldGeneral->applyDB($db);
} }
tryRollbackInheritUniqueItem($general);
$general->applyDB($db); $general->applyDB($db);
return true; return true;
} }
} }
+3
View File
@@ -14,6 +14,7 @@ use \sammo\Command;
use function \sammo\searchDistance; use function \sammo\searchDistance;
use function \sammo\printCitiesBasedOnDistance; use function \sammo\printCitiesBasedOnDistance;
use function sammo\tryRollbackInheritUniqueItem;
use \sammo\Constraint\Constraint; use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper; use \sammo\Constraint\ConstraintHelper;
@@ -294,6 +295,7 @@ class che_화계 extends Command\GeneralCommand
$this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange(); $general->checkStatChange();
tryRollbackInheritUniqueItem($general);
$general->applyDB($db); $general->applyDB($db);
return false; return false;
} }
@@ -327,6 +329,7 @@ class che_화계 extends Command\GeneralCommand
$general->increaseRankVar('firenum', 1); $general->increaseRankVar('firenum', 1);
$this->setResultTurn(new LastTurn(static::getName(), $this->arg)); $this->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange(); $general->checkStatChange();
tryRollbackInheritUniqueItem($general);
$general->applyDB($db); $general->applyDB($db);
return true; return true;
+4 -2
View File
@@ -7,9 +7,11 @@ use \sammo\JosaUtil;
use \sammo\LastTurn; use \sammo\LastTurn;
use \sammo\DB; use \sammo\DB;
use function sammo\tryRollbackInheritUniqueItem;
class 휴식 extends Command\GeneralCommand{ class 휴식 extends Command\GeneralCommand{
static protected $actionName = '휴식'; static protected $actionName = '휴식';
protected function argTest():bool{ protected function argTest():bool{
return true; return true;
} }
@@ -39,7 +41,7 @@ class 휴식 extends Command\GeneralCommand{
$logger->pushGeneralActionLog("아무것도 실행하지 않았습니다. <1>$date</>"); $logger->pushGeneralActionLog("아무것도 실행하지 않았습니다. <1>$date</>");
$this->setResultTurn(new LastTurn()); $this->setResultTurn(new LastTurn());
tryRollbackInheritUniqueItem($general);
$general->applyDB(DB::db()); $general->applyDB(DB::db());
return true; return true;
} }