농지개간, 상업투자 구현, General 클래스로 checkStatChange 이동, uniqueItemEx 추가(및 재구현)
This commit is contained in:
@@ -2184,6 +2184,96 @@ function CheckHall($no) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function uniqueItemEx(int $generalID, ActionLogger $logger, string $acquireType='아이템'):bool {
|
||||||
|
//TODO: 이름 바꾸기
|
||||||
|
$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){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($general['npc'] >= 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if($general['horse'] > 6 || $general['weap'] > 6 || $general['book'] > 6 || $general['item'] > 6){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$scenario = $gameStor->scenario;
|
||||||
|
|
||||||
|
$genCount = $db->queryFirstField('SELECT count(*) FROM general WHERE npc<2');
|
||||||
|
|
||||||
|
if ($scenario < 100) {
|
||||||
|
$prob = 1 / ($genCount * 5); // 5~6개월에 하나씩 등장
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$prob = 1 / $genCount; // 1~2개월에 하나씩 등장
|
||||||
|
}
|
||||||
|
|
||||||
|
if($acquireType == '투표'){
|
||||||
|
$prob = 1 / ($genCount * 0.7 / 3); // 투표율 70%, 투표 한번에 2~3개 등장
|
||||||
|
}
|
||||||
|
else if($acquireType == '랜덤 임관'){
|
||||||
|
$prob = 1 / ($genCount / 10/ 2); // 랜임시 2개(10%) 등장(200명중 20명 랜임시도?)
|
||||||
|
}
|
||||||
|
else if($acquireType == '건국'){
|
||||||
|
$prob = 1 / ($genCount / 10/ 4); // 건국시 4개(20%) 등장(200명시 20국 정도 됨)
|
||||||
|
}
|
||||||
|
|
||||||
|
$prob = Util::valueFit($prob, 1/3, 1);
|
||||||
|
|
||||||
|
if(!Util::randBool($prob)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//아이템 습득 상황
|
||||||
|
$availableUnique = [];
|
||||||
|
$itemTypes = [
|
||||||
|
'horse'=>'getHorseName',
|
||||||
|
'weap'=>'getWeapName',
|
||||||
|
'book'=>'getBookName',
|
||||||
|
'item'=>'getItemName'
|
||||||
|
];
|
||||||
|
$itemCodeList = range(7, 26); // [7, 26] 20개
|
||||||
|
|
||||||
|
foreach($itemTypes as $itemType=>$itemNameFunc){
|
||||||
|
foreach($itemCodeList as $itemCode){
|
||||||
|
$availableUnique["{$itemType}_{$itemCode}"] = [$itemType, $itemCode];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: 너무 바보 같다. 장기적으로는 유니크 아이템 테이블 같은게 필요하지 않을까?
|
||||||
|
foreach ($itemTypes as $itemType=>$itemNameFunc) {
|
||||||
|
foreach($db->queryFirstColumn('SELECT %b FROM general WHERE %b > 6', $itemType, $itemType) as $itemCode){
|
||||||
|
unset($availableUnique["{$itemType}_{$itemCode}"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$availableUnique){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
[$itemType, $itemCode] = Util::choiceRandom($availableUnique);
|
||||||
|
|
||||||
|
$nationName = getNationStaticInfo($general['nation'])['name'];
|
||||||
|
$generalName = $general['name'];
|
||||||
|
$josaYi = JosaUtil::pick($generalName, '이');
|
||||||
|
$itemName = ($itemTypes[$itemType])($itemCode);
|
||||||
|
$josaUl = JosaUtil::pick($itemName, '을');
|
||||||
|
|
||||||
|
|
||||||
|
$db->update('general', [
|
||||||
|
$itemType=>$itemCode
|
||||||
|
], 'no=%i', $generalID);
|
||||||
|
|
||||||
|
$logger->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 습득했습니다!");
|
||||||
|
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <C>{$itemName}</>{$josaUl} 습득했습니다!");
|
||||||
|
$logger->pushGlobalHistoryLog("<C><b>【{$acquireType}】</b></><D><b>{$nationName}</b></>의 <Y>{$generalName}</>{$josaYi} <C>{$itemName}</>{$josaUl} 습득했습니다!");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function uniqueItem($general, $log, $vote=0) {
|
function uniqueItem($general, $log, $vote=0) {
|
||||||
//TODO: uniqueItem 재 구현
|
//TODO: uniqueItem 재 구현
|
||||||
|
|||||||
@@ -5,5 +5,7 @@ use \sammo\Util;
|
|||||||
use \sammo\JosaUtil;
|
use \sammo\JosaUtil;
|
||||||
|
|
||||||
class che_농지개간 extends che_상업투자{
|
class che_농지개간 extends che_상업투자{
|
||||||
|
static $cityKey = 'agri';
|
||||||
|
static $actionKey = '농업';
|
||||||
|
static $actionName = '농지 개간';
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
namespace sammo\Command;
|
namespace sammo\Command;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
Util, JosaUtil,
|
DB, Util, JosaUtil,
|
||||||
General,
|
General,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
getGeneralIntel,
|
getGeneralIntel,
|
||||||
@@ -13,6 +13,7 @@ use \sammo\{
|
|||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use function sammo\CriticalScore;
|
use function sammo\CriticalScore;
|
||||||
|
use function sammo\uniqueItemEx;
|
||||||
|
|
||||||
|
|
||||||
class che_상업투자 extends BaseCommand{
|
class che_상업투자 extends BaseCommand{
|
||||||
@@ -47,6 +48,8 @@ class che_상업투자 extends BaseCommand{
|
|||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$trust = Util::valueFit($this->city['trust'], 50);
|
$trust = Util::valueFit($this->city['trust'], 50);
|
||||||
@@ -94,12 +97,24 @@ class che_상업투자 extends BaseCommand{
|
|||||||
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
|
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
|
||||||
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
|
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
|
||||||
|
|
||||||
//TODO: 내정량 상승시 초과 가능?
|
//NOTE: 내정량 상승시 초과 가능?
|
||||||
|
$cityUpdated = [
|
||||||
|
static::$cityKey => Util::valueFit(
|
||||||
|
$this->city[static::$cityKey] + $score,
|
||||||
|
0,
|
||||||
|
$this->city[static::$cityKey.'2']
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
$general->increaseVarWithLimit('gold', -$this->reqGold, 0);
|
$general->increaseVarWithLimit('gold', -$this->reqGold, 0);
|
||||||
|
$general->increaseVar('experience', $exp);
|
||||||
|
$general->increaseVar('dedication', $ded);
|
||||||
|
$general->increaseVar('intel2', 1);
|
||||||
|
$general->updateVar('resturn', 'SUCCESS');
|
||||||
|
$general->applyDB($db);
|
||||||
|
|
||||||
|
$this->checkStatChange();
|
||||||
//TODO:uniqueItemEx에 해당하는 함수 추가
|
uniqueItemEx($general->getVar('no'), $logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,12 @@ class General implements iActionTrigger{
|
|||||||
$nationTypeClass = getNationTypeClass($staticNation['type']);
|
$nationTypeClass = getNationTypeClass($staticNation['type']);
|
||||||
$this->nationType = new $nationTypeClass;
|
$this->nationType = new $nationTypeClass;
|
||||||
$this->levelObj = new TriggerGeneralLevel($this->raw, $city);
|
$this->levelObj = new TriggerGeneralLevel($this->raw, $city);
|
||||||
|
|
||||||
|
$specialDomesticClass = getGeneralSpecialDomesticClass($raw['special']);
|
||||||
|
$this->specialDomesticObj = new $specialDomesticClass;
|
||||||
|
|
||||||
|
//TODO: $specialWarClass 설정
|
||||||
|
|
||||||
$personalityClass = getPersonalityClass($raw['personal']);
|
$personalityClass = getPersonalityClass($raw['personal']);
|
||||||
$this->personalityObj = new $personalityClass;
|
$this->personalityObj = new $personalityClass;
|
||||||
}
|
}
|
||||||
@@ -148,6 +154,38 @@ class General implements iActionTrigger{
|
|||||||
return $db->affectedRows() > 0;
|
return $db->affectedRows() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkStatChange():bool{
|
||||||
|
$logger = $this->getLogger();
|
||||||
|
$limit = GameConst::$upgradeLimit;
|
||||||
|
|
||||||
|
$table = [
|
||||||
|
['통솔', 'leader'],
|
||||||
|
['무력', 'power'],
|
||||||
|
['지력', 'intel'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$result = false;
|
||||||
|
|
||||||
|
foreach($table as [$statNickName, $statName]){
|
||||||
|
$statExpName = $statName.'2';
|
||||||
|
|
||||||
|
if($this->getVar($statExpName) < 0){
|
||||||
|
$logger->pushGeneralActionLog("<R>{$statNickName}</>이 <C>1</> 떨어졌습니다!", ActionLogger::PLAIN);
|
||||||
|
$this->increaseVar($statExpName, $limit);
|
||||||
|
$this->increaseVar($statName, -1);
|
||||||
|
$result = true;
|
||||||
|
}
|
||||||
|
else if($this->getVar($statExpName) >= $limit){
|
||||||
|
$logger->pushGeneralActionLog("<R>{$statNickName}</>이 <C>1</> 올랐습니다!", ActionLogger::PLAIN);
|
||||||
|
$this->increaseVar($statExpName, -$limit);
|
||||||
|
$this->increaseVar($statName, 1);
|
||||||
|
$result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
public function onPreTurnExecute(General $general, ?array $nation):array{
|
public function onPreTurnExecute(General $general, ?array $nation):array{
|
||||||
$chain = [];
|
$chain = [];
|
||||||
if($this->nationType){
|
if($this->nationType){
|
||||||
|
|||||||
Reference in New Issue
Block a user