임관 추가. 유니크 복권 추첨을 General 클래스 용으로 변경

This commit is contained in:
2018-10-21 15:20:27 +09:00
parent 6c5c2d40bc
commit ff87555eba
38 changed files with 467 additions and 165 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ use \sammo\{
use function \sammo\{
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
+1 -1
View File
@@ -12,7 +12,7 @@ use \sammo\{
use function \sammo\{
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
@@ -14,7 +14,7 @@ use \sammo\{
use function \sammo\{
uniqueItemEx,
tryUniqueItemLottery,
getItemCost, getItemCost2,
getItemInfo,
getHorseName, getWeapName, getBookName, getItemName
+3 -3
View File
@@ -12,7 +12,7 @@ use \sammo\{
use function \sammo\{
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
@@ -38,8 +38,8 @@ class che_귀환 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
['NoNeutral'],
['NoWanderingNation'],
['NotBeNeutral'],
['NotWanderingNation'],
['NotCapital', 1],
];
}
@@ -14,7 +14,7 @@ use function sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalScoreEx,
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
@@ -40,8 +40,8 @@ class che_기술연구 extends che_상업투자{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
['NoNeutral'],
['NoWanderingNation'],
['NotBeNeutral'],
['NotWanderingNation'],
['OccupiedCity'],
['SuppliedCity'],
['ReqGeneralGold', $reqGold],
@@ -129,10 +129,9 @@ class che_기술연구 extends che_상업투자{
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
tryUniqueItemLottery($general);
$general->applyDB($db);
uniqueItemEx($general->getID(), $logger);
return true;
}
+3 -4
View File
@@ -12,7 +12,7 @@ use \sammo\{
use function \sammo\{
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
@@ -37,7 +37,7 @@ class che_단련 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
['NoNeutral'],
['NotBeNeutral'],
['ReqGeneralCrew'],
['ReqGeneralValue', 'train', '훈련', GameConst::$defaultTrainHigh],
['ReqGeneralValue', 'atmos', '사기', GameConst::$defaultAtmosHigh],
@@ -112,9 +112,8 @@ class che_단련 extends Command\GeneralCommand{
$general->increaseVar($incStat, 1);
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
tryUniqueItemLottery($general);
$general->applyDB($db);
uniqueItemEx($general->getID(), $logger);
return true;
}
+4 -9
View File
@@ -16,7 +16,7 @@ use function \sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalScoreEx,
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
@@ -53,19 +53,14 @@ class che_등용 extends Command\GeneralCommand{
$this->setCity();
$this->setNation();
try{
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation'], 0);
}
catch(NoDBResultException $e){
$destGeneral = new DummyGeneral(false);
}
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['nation'], 0);
$this->setDestGeneral($destGeneral);
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
['NoNeutral'],
['NoOpeningPart'],
['NotBeNeutral'],
['NotOpeningPart'],
['OccupiedCity'],
['SuppliedCity'],
['ExistsDestGeneral'],
@@ -15,7 +15,7 @@ use function \sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalScoreEx,
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
@@ -37,8 +37,8 @@ class che_물자조달 extends Command\GeneralCommand{
$this->setNation();
$this->runnableConstraints=[
['NoNeutral'],
['NoWanderingNation'],
['NotBeNeutral'],
['NotWanderingNation'],
['OccupiedCity'],
['SuppliedCity']
];
@@ -12,7 +12,7 @@ use \sammo\{
use function \sammo\{
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
@@ -36,8 +36,8 @@ class che_사기진작 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
['NoNeutral'],
['NoWanderingNation'],
['NotBeNeutral'],
['NotWanderingNation'],
['OccupiedCity'],
['ReqGeneralCrew'],
['ReqGeneralGold', $reqGold],
@@ -94,10 +94,9 @@ class che_사기진작 extends Command\GeneralCommand{
$general->increaseVar('leader2', 1);
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
tryUniqueItemLottery($general);
$general->applyDB($db);
uniqueItemEx($general->getID(), $logger);
return true;
}
@@ -15,7 +15,7 @@ use function \sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalScoreEx,
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
@@ -43,8 +43,8 @@ class che_상업투자 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
['NoNeutral'],
['NoWanderingNation'],
['NotBeNeutral'],
['NotWanderingNation'],
['OccupiedCity'],
['SuppliedCity'],
['ReqGeneralGold', $reqGold],
@@ -172,9 +172,8 @@ class che_상업투자 extends Command\GeneralCommand{
$general->increaseVar(static::$statKey.'2', 1);
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
tryUniqueItemLottery($general);
$general->applyDB($db);
uniqueItemEx($general->getID(), $logger);
return true;
}
@@ -12,7 +12,7 @@ use \sammo\{
use function \sammo\{
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
+1 -1
View File
@@ -12,7 +12,7 @@ use \sammo\{
use function \sammo\{
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
+1 -1
View File
@@ -12,7 +12,7 @@ use \sammo\{
use function \sammo\{
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
+170
View File
@@ -0,0 +1,170 @@
<?php
namespace sammo\GeneralCommand;
use \sammo\{
DB, Util, JosaUtil,
General,
ActionLogger,
GameConst, GameUnitConst,
LastTurn,
Command
};
use function \sammo\{
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
use sammo\CityConst;
class che_임관 extends Command\GeneralCommand{
static protected $actionName = '임관';
protected function argTest():bool{
$destNationID = $this->arg['destNationID']??null;
$destGeneralID = $this->arg['destGeneralID']??null;
if($destGeneralID === null && $destNationID === null){
return false;
}
if($destGeneralID !== null && $destNationID !== null){
return false;
}
if ($destNationID !== null) {
if(!is_int($destNationID)){
return false;
}
if($destNationID < 1){
return false;
}
$this->arg = [
'destNationID' => $destNationID
];
}
else{
if(!is_int($destGeneralID)){
return false;
}
if($destGeneralID < 1){
return false;
}
$this->arg = [
'destGeneralID' => $destGeneralID
];
}
return true;
}
protected function init(){
$general = $this->generalObj;
$this->setCity();
$this->setNation();
$destGeneralID = $this->arg['destGeneralID']??null;
$destNationID = $this->arg['destNationID']??null;
if($destGeneralID !== null){
$this->setDestGeneral($destGeneralID);
$this->setDestNation($this->destGeneralObj->getVar('nation'));
}
else{
$this->setDestNation($destNationID, ['gennum', 'scout']);
}
$relYear = $env['year'] = $env['startyear'];
$this->runnableConstraints=[
['BeNeutral'],
['ExistsDestNation'],
['AllowJoinDestNation', $relYear],
['AllowJoinAction']
];
}
public function getCost():array{
return [0, 0];
}
public function getPreReqTurn():int{
return 0;
}
public function getPostReqTurn():int{
return 0;
}
public function run():bool{
if(!$this->isRunnable()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
$db = DB::db();
$env = $this->env;
$general = $this->generalObj;
$date = substr($general->getVar('turntime'),11,5);
$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("{$generalName}</>{$josaYi} <D><b>{$destNationName}</b></>에 <S>임관</>했습니다.");
if($gennum < GameConst::$initialNationGenLimit) {
$exp = 700;
}
else {
$exp = 100;
}
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$general->setVar('nation', $destNationID);
$general->setVar('level', 1);
$general->setVar('belong', 1);
if($this->destGeneralObj !== null){
$general->setVar('city', $this->destGeneralObj->getCityID());
}
else{
$targetCityID = $db->queryFirstField('SELECT city FROM nation WHERE nation = %i AND level=12', $destNationID);
$general->setVar('city', $targetCityID);
}
$db->update('nation', [
'gennum'=>$db->sqleval('gennum + 1')
], 'nation=%i', $destNationID);
$relYear = $env['year'] = $env['startyear'];
if($general->getVar('npc') == 1 || $relYear >= 3){
$joinedNations = Join::decode($general->getVar('nations'));
$joinedNations[] = $destNationID;
$general->setVar('nations', Join::encode($joinedNations));
}
$general->increaseVar('experience', $exp);
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
tryUniqueItemLottery($general);
$general->applyDB($db);
return true;
}
}
@@ -14,7 +14,7 @@ use \sammo\{
use function \sammo\{
uniqueItemEx,
tryUniqueItemLottery,
getItemCost, getItemCost2,
getItemInfo,
getHorseName, getWeapName, getBookName, getItemName
@@ -13,7 +13,7 @@ use \sammo\{
use function \sammo\{
uniqueItemEx, getTechCost
tryUniqueItemLottery, getTechCost
};
use \sammo\Constraint\Constraint;
@@ -37,8 +37,8 @@ class che_전투태세 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
['NoNeutral'],
['NoWanderingNation'],
['NotBeNeutral'],
['NotWanderingNation'],
['OccupiedCity'],
['ReqGeneralCrew'],
['ReqGeneralGold', $reqGold],
@@ -125,10 +125,9 @@ class che_전투태세 extends Command\GeneralCommand{
$general->increaseVar('leader2', 3);
$general->setResultTurn($turnResult);
$general->checkStatChange();
tryUniqueItemLottery($general);
$general->applyDB($db);
uniqueItemEx($general->getID(), $logger);
return true;
}
@@ -15,7 +15,7 @@ use function \sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalScoreEx,
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
@@ -43,8 +43,8 @@ class che_정착장려 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
['NoNeutral'],
['NoWanderingNation'],
['NotBeNeutral'],
['NotWanderingNation'],
['OccupiedCity'],
['SuppliedCity'],
['ReqGeneralGold', $reqGold],
@@ -159,9 +159,8 @@ class che_정착장려 extends Command\GeneralCommand{
$general->increaseVar(static::$statKey.'2', 1);
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
tryUniqueItemLottery($general);
$general->applyDB($db);
uniqueItemEx($general->getID(), $logger);
return true;
}
@@ -15,7 +15,7 @@ use function \sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalScoreEx,
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
@@ -42,8 +42,8 @@ class che_주민선정 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
['NoNeutral'],
['NoWanderingNation'],
['NotBeNeutral'],
['NotWanderingNation'],
['OccupiedCity'],
['SuppliedCity'],
['ReqGeneralGold', $reqGold],
@@ -156,9 +156,8 @@ class che_주민선정 extends Command\GeneralCommand{
$general->increaseVar(static::$statKey.'2', 1);
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
tryUniqueItemLottery($general);
$general->applyDB($db);
uniqueItemEx($general->getID(), $logger);
return true;
}
+3 -8
View File
@@ -15,7 +15,7 @@ use function \sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalScoreEx,
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
@@ -69,16 +69,11 @@ class che_증여 extends Command\GeneralCommand{
$this->setCity();
$this->setNation();
try{
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'nation'], 1);
}
catch(NoDBResultException $e){
$destGeneral = new DummyGeneral(false);
}
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'nation'], 1);
$this->setDestGeneral($destGeneral);
$this->runnableConstraints=[
['NoNeutral'],
['NotBeNeutral'],
['OccupiedCity'],
['SuppliedCity'],
['ExistsDestGeneral'],
+3 -4
View File
@@ -12,7 +12,7 @@ use \sammo\{
use function \sammo\{
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
@@ -39,7 +39,7 @@ class che_집합 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
['NoNeutral'],
['NotBeNeutral'],
['OccupiedCity'],
['SuppliedCity'],
['MustBeTroopLeader'],
@@ -105,10 +105,9 @@ class che_집합 extends Command\GeneralCommand{
$general->increaseVar('leader2', 1);
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
tryUniqueItemLottery($general);
$general->applyDB($db);
uniqueItemEx($general->getID(), $logger);
return true;
}
+3 -4
View File
@@ -12,7 +12,7 @@ use \sammo\{
use function \sammo\{
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
@@ -92,7 +92,7 @@ class che_징병 extends Command\GeneralCommand{
[$reqGold, $reqRice] = $this->getCost();
$this->runnableConstraints=[
['NoNeutral'],
['NotBeNeutral'],
['OccupiedCity'],
['ReqCityCapacity', 'pop', '주민', 30000 + $reqCrew],
['ReqCityTrust', 20],
@@ -186,10 +186,9 @@ class che_징병 extends Command\GeneralCommand{
$general->increaseVar('leader2', 1);
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
tryUniqueItemLottery($general);
$general->applyDB($db);
uniqueItemEx($general->getID(), $logger);
return true;
}
+1 -1
View File
@@ -12,7 +12,7 @@ use \sammo\{
use function \sammo\{
uniqueItemEx,
tryUniqueItemLottery,
searchDistance
};
+4 -3
View File
@@ -12,7 +12,7 @@ use \sammo\{
use function \sammo\{
uniqueItemEx,
tryUniqueItemLottery,
processWar
};
@@ -51,7 +51,7 @@ class che_출병 extends Command\GeneralCommand{
$this->runnableConstraints=[
['NotOpeningPart'],
['NearCity', 1],
['NoNeutral'],
['NotBeNeutral'],
['OccupiedCity'],
['ReqGeneralCrew'],
['ReqGeneralRice', $reqRice],
@@ -125,7 +125,8 @@ class che_출병 extends Command\GeneralCommand{
//TODO: 장기적으로 통합해야함
processWar($general->getRaw(), $this->destCity);
uniqueItemEx($general->getID(), $logger);
tryUniqueItemLottery($general);
$general->applyDB($db);
return true;
}
+2 -2
View File
@@ -15,7 +15,7 @@ use function \sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalScoreEx,
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
@@ -55,7 +55,7 @@ class che_헌납 extends Command\GeneralCommand{
$this->setNation();
$this->runnableConstraints=[
['NoNeutral'],
['NotBeNeutral'],
['OccupiedCity'],
['SuppliedCity'],
];
+4 -5
View File
@@ -12,7 +12,7 @@ use \sammo\{
use function \sammo\{
uniqueItemEx
tryUniqueItemLottery
};
use \sammo\Constraint\Constraint;
@@ -35,8 +35,8 @@ class che_훈련 extends Command\GeneralCommand{
$this->setNation();
$this->runnableConstraints=[
['NoNeutral'],
['NoWanderingNation'],
['NotBeNeutral'],
['NotWanderingNation'],
['OccupiedCity'],
['ReqGeneralCrew'],
['ReqGeneralTrainMargin', GameConst::$maxTrainByCommand],
@@ -91,10 +91,9 @@ class che_훈련 extends Command\GeneralCommand{
$general->increaseVar('leader2', 1);
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->checkStatChange();
tryUniqueItemLottery($general);
$general->applyDB($db);
uniqueItemEx($general->getID(), $logger);
return true;
}