임관 추가. 유니크 복권 추첨을 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
+9 -15
View File
@@ -1695,25 +1695,19 @@ function CheckHall($no) {
}
}
function uniqueItemEx(int $generalID, ActionLogger $logger, string $acquireType='아이템'):bool {
//TODO: 이름 바꾸기
function tryUniqueItemLottery(General $general, string $acquireType='아이템'):bool{
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$general = $db->queryFirstRow('SELECT no,name,nation,npc,weap,book,horse,item FROM general WHERE no=%i', $generalID);
if(!$general){
if($general->getVar('npc') >= 2){
return false;
}
if($general['npc'] >= 2) {
return false;
}
if($general['horse'] > 6 || $general['weap'] > 6 || $general['book'] > 6 || $general['item'] > 6){
if($general->getVar('npc') > 6 || $general->getVar('weap') > 6 || $general->getVar('book') > 6 || $general->getVar('item') > 6){
return false;
}
$scenario = $gameStor->scenario;
$genCount = $db->queryFirstField('SELECT count(*) FROM general WHERE npc<2');
if ($scenario < 100) {
@@ -1768,16 +1762,16 @@ function uniqueItemEx(int $generalID, ActionLogger $logger, string $acquireType=
[$itemType, $itemCode] = Util::choiceRandom($availableUnique);
$nationName = getNationStaticInfo($general['nation'])['name'];
$generalName = $general['name'];
$nationName = $general->getStaticNation()['name'];
$generalName = $general->getNation();
$josaYi = JosaUtil::pick($generalName, '이');
$itemName = ($itemTypes[$itemType])($itemCode);
$josaUl = JosaUtil::pick($itemName, '을');
$db->update('general', [
$itemType=>$itemCode
], 'no=%i', $generalID);
$general->setVar($itemType, $itemCode);
$logger = $general->getLogger();
$logger->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 습득했습니다!");
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <C>{$itemName}</>{$josaUl} 습득했습니다!");
+59
View File
@@ -1,6 +1,65 @@
<?php
namespace sammo;
function process_22(&$general) {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$log = [];
$alllog = [];
$history = [];
$date = substr($general['turntime'],11,5);
$admin = $gameStor->getValues(['startyear','year','month','develcost']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$city = MYDB_fetch_array($result);
$command = DecodeCommand($general['turn0']);
$who = $command[1];
$query = "select * from general where no='$who'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$you = MYDB_fetch_array($result);
$cost = Util::round($admin['develcost'] + ($you['experience'] + $you['dedication'])/1000) * 10;
if(!$you) {
$log[] = "<C>●</>{$admin['month']}월:없는 장수입니다. 등용 실패. <1>$date</>";
} elseif($admin['year'] < $admin['startyear']+3) {
$log[] = "<C>●</>{$admin['month']}월:초반 제한중입니다. 등용 실패. <1>$date</>";
} elseif($city['nation'] != $general['nation']) {
$log[] = "<C>●</>{$admin['month']}월:아국이 아닙니다. 등용 실패. <1>$date</>";
} elseif($city['supply'] == 0) {
$log[] = "<C>●</>{$admin['month']}월:고립된 도시입니다. 등용 실패. <1>$date</>";
} elseif($general['gold'] < $cost) {
$log[] = "<C>●</>{$admin['month']}월:자금이 모자랍니다. 등용 실패. <1>$date</>";
} else {
$log[] = "<C>●</>{$admin['month']}월:<Y>{$you['name']}</>에게 등용 권유 서신을 보냈습니다. <1>$date</>";
$exp = 100;
$ded = 200;
// 성격 보정
$exp = CharExperience($exp, $general['personal']);
$ded = CharDedication($ded, $general['personal']);
$msg = ScoutMessage::buildScoutMessage($general['no'], $who, $reason);
if($msg){
$msg->send(true);
}
$general['intel2']++;
$query = "update general set resturn='SUCCESS',gold=gold-'$cost',intel2='{$general['intel2']}',dedication=dedication+'$ded',experience=experience+'$exp' where no='{$general['no']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$log = checkAbility($general, $log);
}
pushGenLog($general, $log);
}
function process_25(&$general) {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
-59
View File
@@ -1,65 +1,6 @@
<?php
namespace sammo;
function process_22(&$general) {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$log = [];
$alllog = [];
$history = [];
$date = substr($general['turntime'],11,5);
$admin = $gameStor->getValues(['startyear','year','month','develcost']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$city = MYDB_fetch_array($result);
$command = DecodeCommand($general['turn0']);
$who = $command[1];
$query = "select * from general where no='$who'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$you = MYDB_fetch_array($result);
$cost = Util::round($admin['develcost'] + ($you['experience'] + $you['dedication'])/1000) * 10;
if(!$you) {
$log[] = "<C>●</>{$admin['month']}월:없는 장수입니다. 등용 실패. <1>$date</>";
} elseif($admin['year'] < $admin['startyear']+3) {
$log[] = "<C>●</>{$admin['month']}월:초반 제한중입니다. 등용 실패. <1>$date</>";
} elseif($city['nation'] != $general['nation']) {
$log[] = "<C>●</>{$admin['month']}월:아국이 아닙니다. 등용 실패. <1>$date</>";
} elseif($city['supply'] == 0) {
$log[] = "<C>●</>{$admin['month']}월:고립된 도시입니다. 등용 실패. <1>$date</>";
} elseif($general['gold'] < $cost) {
$log[] = "<C>●</>{$admin['month']}월:자금이 모자랍니다. 등용 실패. <1>$date</>";
} else {
$log[] = "<C>●</>{$admin['month']}월:<Y>{$you['name']}</>에게 등용 권유 서신을 보냈습니다. <1>$date</>";
$exp = 100;
$ded = 200;
// 성격 보정
$exp = CharExperience($exp, $general['personal']);
$ded = CharDedication($ded, $general['personal']);
$msg = ScoutMessage::buildScoutMessage($general['no'], $who, $reason);
if($msg){
$msg->send(true);
}
$general['intel2']++;
$query = "update general set resturn='SUCCESS',gold=gold-'$cost',intel2='{$general['intel2']}',dedication=dedication+'$ded',experience=experience+'$exp' where no='{$general['no']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$log = checkAbility($general, $log);
}
pushGenLog($general, $log);
}
function process_25(&$general) {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
+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;
}
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace sammo\Constraint;
use \sammo\GameConst;
class AllowJoinAction extends Constraint{
const REQ_VALUES = Constraint::REQ_GENERAL;
public function checkInputValues(bool $throwExeception=true){
if(!parent::checkInputValues($throwExeception) && !$throwException){
return false;
}
if(!key_exists('makelimit', $this->general)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require makelimit in general");
}
return true;
}
public function test():bool{
$this->checkInputValues();
$this->tested = true;
if($this->general['makelimit'] == 0){
return true;
}
$joinActionLimit = GameConst::$joinActionLimit;
$this->reason = "재야가 된지 {$joinActionLimit}턴이 지나야 합니다.";
return false;
}
}
@@ -0,0 +1,61 @@
<?php
namespace sammo\Constraint;
use \sammo\DB;
use \sammo\GameConst;
class AllowJoinDestNation extends Constraint{
const REQ_VALUES = Constraint::REQ_GENERAL|Constraint::REQ_DEST_NATION|Constraint::REQ_INT_ARG;
protected $relYear;
public function checkInputValues(bool $throwExeception=true){
if(!parent::checkInputValues($throwExeception) && !$throwException){
return false;
}
if(!key_exists('scout', $this->nation)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require scout in nation");
}
if(!key_exists('gennum', $this->nation)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require gennum in nation");
}
if(!key_exists('nations', $this->general)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require nations in nation");
}
$this->relYear = $this->arg;
return true;
}
public function test():bool{
$this->checkInputValues();
$this->tested = true;
$db = DB::db();
if($relYear < GameConst::$openingPartYear && $this->destNation['gennum'] >= GameConst::$initialNationGenLimit){
$this->reason = "임관이 제한되고 있습니다.";
return false;
}
if($this->destNation['scout'] == 0){
$this->reason = "임관이 금지되어 있습니다.";
return false;
}
$joinedNations = Json::decode($this->general['nations']);
if(in_array($this->destNation['nation'], $joinedNations)){
$this->reason = "이미 임관했었던 국가입니다.";
return false;
}
return true;
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
namespace sammo\Constraint;
class NotCapital extends Constraint{
class AllowWar extends Constraint{
const REQ_VALUES = Constraint::REQ_NATION;
public function checkInputValues(bool $throwExeception=true){
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace sammo\Constraint;
class BeNeutral extends Constraint{
const REQ_VALUES = Constraint::REQ_GENERAL;
public function checkInputValues(bool $throwExeception=true){
if(!parent::checkInputValues($throwExeception) && !$throwException){
return false;
}
if(!key_exists('nation', $this->general)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require nation in general");
}
return true;
}
public function test():bool{
$this->checkInputValues();
$this->tested = true;
if($this->general['nation'] == 0){
return true;
}
$this->reason = "재야가 아닙니다.";
return false;
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace sammo\Constraint;
class ExistsDestGeneral extends Constraint{
const REQ_VALUES = Constraint::REQ_DEST_NATION;
public function checkInputValues(bool $throwExeception=true){
if(!parent::checkInputValues($throwExeception) && !$throwException){
return false;
}
return true;
}
public function test():bool{
$this->checkInputValues();
$this->tested = true;
if($this->destNation['nation']){
return true;
}
$this->reason = "없는 국가입니다.";
return false;
}
}
@@ -2,7 +2,7 @@
namespace sammo\Constraint;
class NoOpeningPart extends Constraint{
class NotBeNeutral extends Constraint{
const REQ_VALUES = Constraint::REQ_GENERAL;
public function checkInputValues(bool $throwExeception=true){
@@ -10,9 +10,9 @@ class NoOpeningPart extends Constraint{
return false;
}
if(!key_exists('level', $this->general)){
if(!key_exists('nation', $this->general)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require level in general");
throw new \InvalidArgumentException("require nation in general");
}
return true;
@@ -22,7 +22,7 @@ class NoOpeningPart extends Constraint{
$this->checkInputValues();
$this->tested = true;
if($this->general['level'] != 0){
if($this->general['nation'] != 0){
return true;
}
@@ -2,7 +2,7 @@
namespace sammo\Constraint;
class NoOpeningPart extends Constraint{
class NotOpeningPart extends Constraint{
const REQ_VALUES = Constraint::REQ_INT_ARG;
protected $relYear;
@@ -2,7 +2,7 @@
namespace sammo\Constraint;
class NoWanderingNation extends Constraint{
class NotWanderingNation extends Constraint{
const REQ_VALUES = Constraint::REQ_NATION;
public function checkInputValues(bool $throwExeception=true){
+2
View File
@@ -96,6 +96,8 @@ class GameConstBase
/** @var int 초반 제한 기간 */
public static $openingPartYear = 3;
/** @var int 거병,임관 제한 기간 */
public static $joinActionLimit = 12;
/** @var array 선택 가능한 국가 성향 */
public static $availableNationType = [
+1 -1
View File
@@ -558,7 +558,7 @@ class General implements iAction{
$rawGeneral = $db->queryFirstRow('SELECT $lb FROM general WHERE no = %i', $generalID);
if(!$rawGeneral){
throw new NoDBResultException("generalID에 해당하는 장수가 없음: {$generalID}");
return new DummyGeneral($constructMode > 0);
}
$general = new static($rawGeneral, null, $year, $month, $constructMode > 1);