defulatGold, defaultRice 개념 지정
This commit is contained in:
@@ -111,6 +111,10 @@ abstract class BaseCommand{
|
||||
|
||||
$defaultArgs = ['nation', 'name', 'color', 'type', 'level', 'capital'];
|
||||
$args = array_unique(array_merge($defaultArgs, $args));
|
||||
if($args == $defaultArgs){
|
||||
$this->nation = $this->generalObj->getStaticNation();
|
||||
return;
|
||||
}
|
||||
|
||||
$defaultValues = [
|
||||
'nation'=>0,
|
||||
|
||||
@@ -97,8 +97,8 @@ class che_하야 extends Command\GeneralCommand{
|
||||
|
||||
}
|
||||
|
||||
$newGold = Util::valueFit($general->getVar('gold'), null, 1000);
|
||||
$newRice = Util::valueFit($general->getVar('rice'), null, 1000);
|
||||
$newGold = Util::valueFit($general->getVar('gold'), null, GameConst::$defaultGold);
|
||||
$newRice = Util::valueFit($general->getVar('rice'), null, GameConst::$defaultRice);
|
||||
|
||||
$lostGold = $general->getVar('gold') - $newGold;
|
||||
$lostRice = $general->getVar('rice') - $newRice;
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
namespace sammo\GeneralCommand;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
LastTurn,
|
||||
Command
|
||||
};
|
||||
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
use sammo\CityConst;
|
||||
use function sammo\getNationTypeClass;
|
||||
use function sammo\refreshNationStaticInfo;
|
||||
use function sammo\GetNationColors;
|
||||
use function sammo\getAllNationStaticInfo;
|
||||
use function sammo\DeleteConflict;
|
||||
|
||||
|
||||
|
||||
class che_해산 extends Command\GeneralCommand{
|
||||
static protected $actionName = '해산';
|
||||
|
||||
protected function argTest():bool{
|
||||
$this->arg = [];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
|
||||
$general = $this->generalObj;
|
||||
$env = $this->env;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['gennum']);
|
||||
|
||||
if(!key_exists($colorType, GetNationColors())){
|
||||
return false;
|
||||
}
|
||||
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$this->runnableConstraints=[
|
||||
['BeLord'],
|
||||
['WanderingNation'],
|
||||
];
|
||||
}
|
||||
|
||||
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, '이');
|
||||
|
||||
$nation = $this->nation;
|
||||
$nationID = $nation['nation'];
|
||||
$nationName = $nation['name'];
|
||||
|
||||
if($nation['gennum'] > 1){
|
||||
$db->update('general', [
|
||||
'gold'=>GameConst::$defaultGold
|
||||
], 'nation=%i AND gold>%i', $nationID, GameConst::$defaultGold);
|
||||
$db->update('general', [
|
||||
'rice'=>GameConst::$defaultRice
|
||||
], 'nation=%i AND gold>%i', $nationID, GameConst::$defaultRice);
|
||||
}
|
||||
|
||||
DeleteConflict($nationID);
|
||||
deleteNation($general);
|
||||
|
||||
$diplomacyInit = [];
|
||||
foreach(getAllNationStaticInfo() as $destNation){
|
||||
$destNationID = $destNation['nation'];
|
||||
$diplomacyInit[] = [
|
||||
'me'=>$destNationID,
|
||||
'you'=>$nationID,
|
||||
'state'=>2,
|
||||
'term'=>0,
|
||||
];
|
||||
|
||||
$diplomacyInit[] = [
|
||||
'me'=>$nationID,
|
||||
'you'=>$destNationID,
|
||||
'state'=>2,
|
||||
'term'=>0,
|
||||
];
|
||||
}
|
||||
$db->insert('diplomacy', $diplomacyInit);
|
||||
|
||||
DB::db()->insert('nation', [
|
||||
'name'=>$nationName,
|
||||
'color'=>'#330000',
|
||||
'gold'=>0,
|
||||
'rice'=>GameConst::$baserice,
|
||||
'rate'=>20,
|
||||
'bill'=>100,
|
||||
'sabotagelimit'=>12,
|
||||
'surlimit'=>72,
|
||||
'type'=>0,
|
||||
'gennum'=>1
|
||||
]);
|
||||
$nationID = DB::db()->insertId();
|
||||
|
||||
refreshNationStaticInfo();
|
||||
|
||||
$logger->pushGeneralActionLog("거병에 성공하였습니다. <1>$date</>");
|
||||
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <G><b>{$cityName}</b></>에 거병하였습니다.");
|
||||
|
||||
$logger->pushGlobalHistoryLog("<Y><b>【거병】</b></><D><b>{$generalName}</b></>{$josaYi} 세력을 결성하였습니다.");
|
||||
$logger->pushGeneralHistoryLog("<G><b>{$cityName}</b></>에서 거병");
|
||||
$logger->pushNationalHistoryLog("<Y>{$generalName}</>{$josaYi} <G><b>{$cityName}</b></>에서 거병");
|
||||
|
||||
$exp = 100;
|
||||
$ded = 100;
|
||||
|
||||
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
|
||||
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
|
||||
|
||||
$general->increaseVar('experience', $exp);
|
||||
$general->increaseVar('dedication', $ded);
|
||||
$general->setVar('belong', 1);
|
||||
$general->setVar('level', 12);
|
||||
$general->setVar('nation', $nationID);
|
||||
|
||||
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -130,15 +130,15 @@ class Personnel{
|
||||
|
||||
// 재야가 아니면 명성N*10% 공헌N*10%감소
|
||||
if($general['nation'] != 0){
|
||||
// 1000 1000 남기고 환수
|
||||
if($general['gold'] > 1000){//XXX: 상수.
|
||||
$setValues['gold'] = 1000;
|
||||
$setOriginalNationValues['gold'] = $db->sqleval('gold + %i', $general['gold'] - 1000);
|
||||
// 기본 금액 남기고 환수
|
||||
if($general['gold'] > GameConst::$defaultGold){
|
||||
$setValues['gold'] = GameConst::$defaultGold;
|
||||
$setOriginalNationValues['gold'] = $db->sqleval('gold + %i', $general['gold'] - GameConst::$defaultGold);
|
||||
}
|
||||
|
||||
if($general['rice'] > 1000){//XXX: 상수.
|
||||
$setValues['rice'] = 1000;
|
||||
$setOriginalNationValues['rice'] = $db->sqleval('rice + %i', $general['rice'] - 1000);
|
||||
if($general['rice'] > GameConst::$defaultRice){//XXX: 상수.
|
||||
$setValues['rice'] = GameConst::$defaultRice;
|
||||
$setOriginalNationValues['rice'] = $db->sqleval('rice + %i', $general['rice'] - GameConst::$defaultRice);
|
||||
}
|
||||
|
||||
//관직 해제
|
||||
|
||||
@@ -91,6 +91,11 @@ class GameConstBase
|
||||
/** @var int 초기 시작 년도. 실제 값은 시나리오에서 정해지므로 딱히 의미는 없음. */
|
||||
public static $defaultStartYear = 180;
|
||||
|
||||
/** @var int 시작시 금 */
|
||||
public static $defaultGold = 1000;
|
||||
/** @var int 시작시 쌀 */
|
||||
public static $defaultRice = 1000;
|
||||
|
||||
/** @var int 최대 턴 */
|
||||
public static $maxTurn = 30;
|
||||
public static $maxNationTurn = 12;
|
||||
|
||||
@@ -263,7 +263,7 @@ class GeneralAI{
|
||||
|
||||
$commandList['che_물자조달'] = (
|
||||
(GameConst::$minNationalGold + GameConst::$minNationalRice + 10000) /
|
||||
Util::valueFit($nation['gold'] + $nation['rice'], 1000)
|
||||
Util::valueFit($nation['gold'] + $nation['rice'], (GameConst::$defaultGold + GameConst::$defaultRice)/2)
|
||||
) * 10;
|
||||
|
||||
return [Util::choiceRandomUsingWeight($commandList), null];
|
||||
|
||||
@@ -41,8 +41,8 @@ class NPC{
|
||||
9 => 'ⓞ', //오랑캐?
|
||||
];
|
||||
|
||||
protected $gold = 1000;
|
||||
protected $rice = 1000;
|
||||
protected $gold;
|
||||
protected $rice;
|
||||
|
||||
protected $specAge = null;
|
||||
protected $specAge2 = null;
|
||||
@@ -86,6 +86,9 @@ class NPC{
|
||||
$this->ego = $ego;
|
||||
$this->text = $text;
|
||||
|
||||
$this->gold = GameConst::$defaultGold;
|
||||
$this->rice = GameConst::$defaultRice;
|
||||
|
||||
$general = [
|
||||
'leader'=>$leadership,
|
||||
'power'=>$power,
|
||||
|
||||
Reference in New Issue
Block a user