diff --git a/hwe/sammo/Command/General/cr_건국.php b/hwe/sammo/Command/General/cr_건국.php new file mode 100644 index 00000000..aff4d3a5 --- /dev/null +++ b/hwe/sammo/Command/General/cr_건국.php @@ -0,0 +1,231 @@ +arg === null) { + return false; + } + $nationName = $this->arg['nationName'] ?? null; + $nationType = $this->arg['nationType'] ?? null; + $colorType = $this->arg['colorType'] ?? null; + + if ($nationName === null || $nationType === null || $colorType === null) { + return false; + } + + if (!is_string($nationName) || !is_string($nationType) || !is_int($colorType)) { + return false; + } + + if (mb_strwidth($nationName) > 18 || $nationName == '') { + return false; + } + + if (!key_exists($colorType, GetNationColors())) { + return false; + } + + try { + $nationTypeClass = buildNationTypeClass($nationType); + } catch (\InvalidArgumentException $e) { + return false; + } + + $this->arg = [ + 'nationName' => $nationName, + 'nationType' => $nationType, + 'colorType' => $colorType + ]; + + return true; + } + + protected function init() + { + $env = $this->env; + + $this->setCity(); + $this->setNation(['gennum', 'aux']); + + $relYear = $env['year'] - $env['startyear']; + + $this->minConditionConstraints = [ + ConstraintHelper::BeOpeningPart($relYear + 1), + ConstraintHelper::ReqNationValue('level', '국가규모', '==', 0, '정식 국가가 아니어야합니다.') + ]; + } + + protected function initWithArg() + { + $env = $this->env; + $relYear = $env['year'] - $env['startyear']; + + $nationName = $this->arg['nationName']; + $nationType = $this->arg['nationType']; + $colorType = $this->arg['colorType']; + + $this->fullConditionConstraints = [ + ConstraintHelper::BeLord(), + ConstraintHelper::WanderingNation(), + ConstraintHelper::ReqNationValue('gennum', '수하 장수', '>=', 2), + ConstraintHelper::BeOpeningPart($relYear + 1), + ConstraintHelper::CheckNationNameDuplicate($nationName), + ConstraintHelper::AllowJoinAction(), + ConstraintHelper::NeutralCity(), + ]; + } + + public function getBrief(): string + { + $nationName = $this->arg['nationName']; + $josaUl = JosaUtil::pick($nationName, '을'); + return "【{$nationName}】{$josaUl} 건국"; + } + + public function getCost(): array + { + return [0, 0]; + } + + public function getPreReqTurn(): int + { + return 0; + } + + public function getPostReqTurn(): int + { + return 0; + } + + public function run(\Sammo\RandUtil $rng): bool + { + if (!$this->hasFullConditionMet()) { + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + + $db = DB::db(); + $env = $this->env; + + $general = $this->generalObj; + $date = $general->getTurnTime($general::TURNTIME_HM); + $generalName = $general->getName(); + $logger = $general->getLogger(); + + $initYearMonth = Util::joinYearMonth($env['init_year'], $env['init_month']); + $yearMonth = Util::joinYearMonth($env['year'], $env['month']); + if($yearMonth <= $initYearMonth){ + $logger->pushGeneralActionLog("다음 턴부터 건국할 수 있습니다. <1>$date"); + $this->alternative = new che_인재탐색($general, $this->env, null); + return false; + } + + $josaYi = JosaUtil::pick($generalName, '이'); + + $nationName = $this->arg['nationName']; + $nationType = $this->arg['nationType']; + $colorType = GetNationColors()[$this->arg['colorType']]; + + $cityName = $this->city['name']; + + $josaUl = JosaUtil::pick($nationName, '을'); + + + + $nationTypeClass = buildNationTypeClass($nationType); + $nationTypeName = $nationTypeClass->getName(); + + + $logger->pushGeneralActionLog("{$nationName}{$josaUl} 건국하였습니다. <1>$date"); + $logger->pushGlobalActionLog("{$generalName}{$josaYi} {$cityName}에 국가를 건설하였습니다."); + + $josaNationYi = JosaUtil::pick($nationName, '이'); + $logger->pushGlobalHistoryLog("【건국】{$nationTypeName} {$nationName}{$josaNationYi} 새로이 등장하였습니다."); + $logger->pushGeneralHistoryLog("{$nationName}{$josaUl} 건국"); + $logger->pushNationalHistoryLog("{$generalName}{$josaYi} {$nationName}{$josaUl} 건국"); + + $exp = 1000; + $ded = 1000; + + $general->addExperience($exp); + $general->addDedication($ded); + + $aux = Json::decode($this->nation['aux']) ?? []; + $aux['can_국기변경'] = 1; + + $db->update('city', [ + 'nation' => $general->getNationID(), + 'conflict' => '{}' + ], 'city=%i', $general->getCityID()); + + $db->update('nation', [ + 'name' => $nationName, + 'color' => $colorType, + 'level' => 1, + 'type' => $nationType, + 'capital' => $general->getCityID(), + 'aux' => Json::encode($aux) + ], 'nation=%i', $general->getNationID()); + + refreshNationStaticInfo(); + + $general->increaseInheritancePoint(InheritanceKey::active_action, 1); + $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); + $general->checkStatChange(); + tryUniqueItemLottery(genGenericUniqueRNGFromGeneral($general), $general, '건국'); + $general->applyDB($db); + + return true; + } + + public function exportJSVars(): array + { + $nationTypes = []; + foreach (GameConst::$availableNationType as $nationType) { + $nationClass = buildNationTypeClass($nationType); + $nationTypes[$nationType] = [ + 'type' => $nationType, + 'name' => $nationClass->getName(), + 'pros' => $nationClass::$pros, + 'cons' => $nationClass::$cons + ]; + } + return [ + 'procRes' => [ + 'available건국' => count(getAllNationStaticInfo()) < $this->env['maxnation'], + 'nationTypes' => $nationTypes, + 'colors' => GetNationColors(), + + ] + ]; + } +} diff --git a/hwe/sammo/Command/General/cr_맹훈련.php b/hwe/sammo/Command/General/cr_맹훈련.php new file mode 100644 index 00000000..58d5ed60 --- /dev/null +++ b/hwe/sammo/Command/General/cr_맹훈련.php @@ -0,0 +1,115 @@ +arg = null; + return true; + } + + protected function init(){ + + $general = $this->generalObj; + + $this->setCity(); + $this->setNation(); + + $this->minConditionConstraints=[ + ConstraintHelper::NotBeNeutral(), + ConstraintHelper::NotWanderingNation(), + ConstraintHelper::OccupiedCity(), + ]; + + $this->fullConditionConstraints=[ + ConstraintHelper::NotBeNeutral(), + ConstraintHelper::NotWanderingNation(), + ConstraintHelper::OccupiedCity(), + ConstraintHelper::ReqGeneralCrew(), + ConstraintHelper::ReqGeneralTrainMargin(GameConst::$maxTrainByCommand), + ]; + + } + + public function getCommandDetailTitle():string{ + $name = $this->getName(); + [$reqGold, $reqRice] = $this->getCost(); + + $title = "{$name}(통솔경험"; + if($reqGold > 0){ + $title .= ", 자금{$reqGold}"; + } + if($reqRice > 0){ + $title .= ", 군량{$reqRice}"; + } + $title .= ')'; + return $title; + } + + public function getCost():array{ + return [0, 500]; + } + + public function getPreReqTurn():int{ + return 0; + } + + public function getPostReqTurn():int{ + return 0; + } + + public function run(\Sammo\RandUtil $rng):bool{ + if(!$this->hasFullConditionMet()){ + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + + $db = DB::db(); + + $general = $this->generalObj; + $date = $general->getTurnTime($general::TURNTIME_HM); + + $score = Util::round($general->getLeadership() * 100 / $general->getVar('crew') * GameConst::$trainDelta * 2 / 3); + $scoreText = number_format($score, 0); + + $logger = $general->getLogger(); + + $logger->pushGeneralActionLog("훈련, 사기치가 $scoreText 상승했습니다. <1>$date"); + + $exp = 150; + $ded = 100; + + $general->increaseVarWithLimit('train', $score, 0, GameConst::$maxTrainByCommand); + $general->increaseVarWithLimit('atmos', $score, 0, GameConst::$maxAtmosByCommand); + + $general->addDex($general->getCrewTypeObj(), $score * 2, false); + + $general->addExperience($exp); + $general->addDedication($ded); + $general->increaseVar('leadership_exp', 1); + $this->setResultTurn(new LastTurn(static::getName(), $this->arg)); + $general->checkStatChange(); + tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general); + $general->applyDB($db); + + return true; + } + + +} \ No newline at end of file diff --git a/hwe/sammo/Command/Nation/cr_인구이동.php b/hwe/sammo/Command/Nation/cr_인구이동.php new file mode 100644 index 00000000..52be4a72 --- /dev/null +++ b/hwe/sammo/Command/Nation/cr_인구이동.php @@ -0,0 +1,195 @@ +arg === null) { + return false; + } + + if (!key_exists('destCityID', $this->arg)) { + return false; + } + if (CityConst::byID($this->arg['destCityID']) === null) { + return false; + } + $destCityID = $this->arg['destCityID']; + + + if (!key_exists('amount', $this->arg)) { + return false; + } + $amount = $this->arg['amount']; + if (!is_numeric($amount)) { + return false; + } + $amount = (int) $amount; + if ($amount > static::AMOUNT_LIMIT){ + $amount = static::AMOUNT_LIMIT; + } + if ($amount < 0) { + return false; + } + + $this->arg = [ + 'destCityID' => $destCityID, + 'amount' => $amount, + ]; + return true; + } + + protected function init() + { + $general = $this->generalObj; + + $env = $this->env; + + $this->setCity(); + $this->setNation(['gold', 'rice']); + + $this->minConditionConstraints = [ + ConstraintHelper::OccupiedCity(), + ConstraintHelper::BeChief(), + ConstraintHelper::SuppliedCity(), + ConstraintHelper::ReqCityCapacity('pop', '주민', GameConst::$minAvailableRecruitPop + 100), + ]; + } + + protected function initWithArg() + { + $this->setDestCity($this->arg['destCityID']); + + [$reqGold, $reqRice] = $this->getCost(); + $this->fullConditionConstraints = [ + ConstraintHelper::NotSameDestCity(), + ConstraintHelper::OccupiedCity(), + ConstraintHelper::ReqCityCapacity('pop', '주민', GameConst::$minAvailableRecruitPop + 100), + ConstraintHelper::OccupiedDestCity(), + ConstraintHelper::NearCity(1), + ConstraintHelper::BeChief(), + ConstraintHelper::SuppliedCity(), + ConstraintHelper::SuppliedDestCity(), + ConstraintHelper::ReqNationGold(GameConst::$basegold + $reqGold), + ConstraintHelper::ReqNationRice(GameConst::$baserice + $reqRice), + ]; + } + + public function getCommandDetailTitle(): string + { + $name = $this->getName(); + + $amount = number_format($this->env['develcost']); + + return "{$name}(금쌀 {$amount}×인구[만])"; + } + + public function getCost(): array + { + $amount = Util::round($this->env['develcost'] * $this->arg['amount'] / 10000); + + return [$amount, $amount]; + } + + public function getPreReqTurn(): int + { + return 0; + } + + public function getPostReqTurn(): int + { + return 0; + } + + public function getBrief(): string + { + $commandName = $this->getName(); + $destCityName = CityConst::byID($this->arg['destCityID'])->name; + $josaRo = JosaUtil::pick($destCityName, '로'); + $amount = number_format($this->arg['amount']); + return "【{$destCityName}】{$josaRo} {$amount}명 {$commandName}"; + } + + public function run(\Sammo\RandUtil $rng): bool + { + if (!$this->hasFullConditionMet()) { + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + + $db = DB::db(); + + $general = $this->generalObj; + $date = $general->getTurnTime($general::TURNTIME_HM); + + $srcCity = $this->city; + $srcCityID = $srcCity['city']; + + $destCity = $this->destCity; + $destCityID = $destCity['city']; + $destCityName = $destCity['name']; + + $amount = $this->arg['amount']; + $amount = Util::clamp($amount, null, $this->city['pop'] - GameConst::$minAvailableRecruitPop); + + $josaRo = JosaUtil::pick($destCityName, '로'); + + $logger = $general->getLogger(); + + $general->addExperience(5); + $general->addDedication(5); + + $db->update('city', [ + 'pop' => $db->sqleval('pop + %i', $amount), + ], 'city=%i', $destCityID); + $db->update('city', [ + 'pop' => $db->sqleval('pop - %i', $amount), + ], 'city=%i', $srcCityID); + + [$reqGold, $reqRice] = $this->getCost(); + $db->update('nation', [ + 'gold' => $db->sqleval('gold - %i', $reqGold), + 'rice' => $db->sqleval('rice - %i', $reqRice), + ], 'nation=%i', $this->nation['nation']); + + $logger->pushGeneralActionLog("{$destCityName}{$josaRo} 인구 {$amount}명을 옮겼습니다. <1>$date"); + + $this->setResultTurn(new LastTurn($this->getName(), $this->arg, 0)); + $general->applyDB($db); + return true; + } + + public function exportJSVars(): array + { + return [ + 'procRes' => [ + 'cities' => \sammo\JSOptionsForCities(), + 'distanceList' => \sammo\JSCitiesBasedOnDistance($this->generalObj->getCityID(), 1), + ], + ]; + } +} diff --git a/hwe/ts/processing/General/cr_건국.vue b/hwe/ts/processing/General/cr_건국.vue new file mode 100644 index 00000000..e54c8697 --- /dev/null +++ b/hwe/ts/processing/General/cr_건국.vue @@ -0,0 +1,82 @@ + + + + diff --git a/hwe/ts/processing/General/index.ts b/hwe/ts/processing/General/index.ts index f8710642..30175a1a 100644 --- a/hwe/ts/processing/General/index.ts +++ b/hwe/ts/processing/General/index.ts @@ -9,6 +9,7 @@ import { default as che_장비매매 } from "./che_장비매매.vue"; import { default as che_장수대상임관 } from "./che_장수대상임관.vue"; import { default as che_징병 } from "./che_징병.vue"; import { default as che_헌납 } from "./che_헌납.vue"; +import { default as cr_건국 } from "./cr_건국.vue"; import { default as ProcessCity } from "../ProcessCity.vue"; import { default as ProcessGeneralAmount } from "../ProcessGeneralAmount.vue"; @@ -38,6 +39,7 @@ export const commandMap: Record = { che_파괴: ProcessCity, che_화계: ProcessCity, che_헌납, + cr_건국, } /* diff --git a/hwe/ts/processing/Nation/cr_인구이동.vue b/hwe/ts/processing/Nation/cr_인구이동.vue new file mode 100644 index 00000000..31f2cbf7 --- /dev/null +++ b/hwe/ts/processing/Nation/cr_인구이동.vue @@ -0,0 +1,166 @@ + + + + + diff --git a/hwe/ts/processing/Nation/index.ts b/hwe/ts/processing/Nation/index.ts index 5ebda428..68aaa9e3 100644 --- a/hwe/ts/processing/Nation/index.ts +++ b/hwe/ts/processing/Nation/index.ts @@ -4,6 +4,8 @@ import { default as che_물자원조 } from "./che_물자원조.vue"; import { default as che_불가침제의 } from "./che_불가침제의.vue"; import { default as che_피장파장 } from "./che_피장파장.vue"; +import { default as cr_인구이동 } from "./cr_인구이동.vue"; + import { default as ProcessNation } from "../ProcessNation.vue"; import { default as ProcessGeneralAmount } from "../ProcessGeneralAmount.vue"; import { default as ProcessGeneralCity } from "./che_발령.vue"; @@ -28,6 +30,7 @@ export const commandMap: Record