부대 이동 관련 초기 코드
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace sammo\ActionScenarioEffect;
|
||||||
|
|
||||||
|
use \sammo\iAction;
|
||||||
|
|
||||||
|
class event_UnlimitedDefenceThresholdChange implements iAction
|
||||||
|
{
|
||||||
|
use \sammo\DefaultAction;
|
||||||
|
|
||||||
|
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux = null): float
|
||||||
|
{
|
||||||
|
if ($turnType == 'changeDefenceTrain') {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
abstract class BaseStaticEvent {
|
||||||
|
|
||||||
|
function __construct(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract function run(General $general, array $env, array $params): bool | string;
|
||||||
|
}
|
||||||
@@ -512,4 +512,8 @@ class GameConstBase
|
|||||||
["MergeInheritPointRank"],
|
["MergeInheritPointRank"],
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public static $staticEventHandlers = [
|
||||||
|
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace sammo\StaticEvent;
|
||||||
|
|
||||||
|
use sammo\ActionLogger;
|
||||||
|
use sammo\CityConst;
|
||||||
|
use sammo\DB;
|
||||||
|
use sammo\Enums\GeneralLiteQueryMode;
|
||||||
|
use sammo\General;
|
||||||
|
use sammo\GeneralLite;
|
||||||
|
use sammo\JosaUtil;
|
||||||
|
|
||||||
|
class event_부대발령즉시집합 extends \sammo\BaseStaticEvent
|
||||||
|
{
|
||||||
|
function run(General $general, array $env, array $params): bool | string
|
||||||
|
{
|
||||||
|
$destGeneralID = $params['destGeneralID'] ?? null;
|
||||||
|
if ($destGeneralID === null) {
|
||||||
|
return "destGeneralID is null";
|
||||||
|
}
|
||||||
|
if (!is_int($destGeneralID)) {
|
||||||
|
return "destGeneralID is not int";
|
||||||
|
}
|
||||||
|
|
||||||
|
$destCityID = $params['city'] ?? null;
|
||||||
|
if ($destCityID === null) {
|
||||||
|
return "destCityID is null";
|
||||||
|
}
|
||||||
|
if (!is_int($destCityID)) {
|
||||||
|
return "destCityID is not int";
|
||||||
|
}
|
||||||
|
|
||||||
|
$destGeneral = GeneralLite::createObjFromDB($destGeneralID, ['nation', 'city', 'troop'], GeneralLiteQueryMode::Core);
|
||||||
|
if ($destGeneral === null) {
|
||||||
|
return "destGeneral is null";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($destGeneral->getID() !== $destGeneral->getVar('troop')){
|
||||||
|
//부대장 발령이 아니므로 무시
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($destGeneral->getCityID() === $destCityID){
|
||||||
|
//이미 제자리이므로 무시
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($destGeneral->getNationID() !== $general->getNationID()){
|
||||||
|
return "destGeneral is not same nation";
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
|
$cityName = CityConst::byID($destCityID)->name;
|
||||||
|
$josaRo = JosaUtil::pick($cityName, '로');
|
||||||
|
|
||||||
|
$troopID = $destGeneral->getID();
|
||||||
|
$troopName = $db->queryFirstField('SELECT name FROM troop WHERE troop_leader = %i', $troopID);
|
||||||
|
|
||||||
|
|
||||||
|
$generalList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND city!=%i AND troop=%i AND no!=%i', $general->getNationID(), $destCityID, $troopID, $general->getID());
|
||||||
|
if($generalList){
|
||||||
|
$db->update('general', [
|
||||||
|
'city'=>$destCityID
|
||||||
|
], 'no IN %li', $generalList);
|
||||||
|
}
|
||||||
|
foreach($generalList as $targetGeneralID){
|
||||||
|
$targetLogger = new ActionLogger($targetGeneralID, $general->getNationID(), $env['year'], $env['month']);
|
||||||
|
$targetLogger->pushGeneralActionLog("{$troopName} 부대원들은 <G><b>{$cityName}</b></>{$josaRo} 즉시 집합되었습니다.", ActionLogger::PLAIN);
|
||||||
|
$targetLogger->flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
$general->setVar('city', $destGeneral->getCityID());
|
||||||
|
$general->applyDB(DB::db());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace sammo\StaticEvent;
|
||||||
|
|
||||||
|
use sammo\DB;
|
||||||
|
use sammo\Enums\GeneralLiteQueryMode;
|
||||||
|
use sammo\General;
|
||||||
|
use sammo\GeneralLite;
|
||||||
|
|
||||||
|
class event_부대탑승즉시이동 extends \sammo\BaseStaticEvent
|
||||||
|
{
|
||||||
|
function run(General $general, array $env, array $params): bool | string
|
||||||
|
{
|
||||||
|
|
||||||
|
$troopID = $params['troopID'] ?? null;
|
||||||
|
if ($troopID === null) {
|
||||||
|
return "troopID is null";
|
||||||
|
}
|
||||||
|
if (!is_int($troopID)) {
|
||||||
|
return "troopID is not int";
|
||||||
|
}
|
||||||
|
|
||||||
|
$destGeneral = GeneralLite::createObjFromDB($troopID, ['nation', 'city', 'troop'], GeneralLiteQueryMode::Core);
|
||||||
|
if ($destGeneral === null) {
|
||||||
|
return "destGeneral is null";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($destGeneral->getID() !== $destGeneral->getVar('troop')){
|
||||||
|
return "destGeneral is not troop";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($destGeneral->getNationID() !== $general->getNationID()){
|
||||||
|
return "destGeneral is not same nation";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($destGeneral->getCityID() === $general->getCityID()){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$general->setVar('city', $destGeneral->getCityID());
|
||||||
|
$general->applyDB(DB::db());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
class StaticEventHandler {
|
||||||
|
// This is a static class, so we don't want to instantiate it
|
||||||
|
public function __construct() {
|
||||||
|
throw new \Exception('This is a static class');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function handleEvent(General $general, string $eventType, array ...$params): void {
|
||||||
|
$handlersList = GameConst::$staticEventHandlers[ $eventType ] ?? null;
|
||||||
|
if( $handlersList === null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"title":"【이벤트】 축지",
|
||||||
|
"startYear":180,
|
||||||
|
"map":{
|
||||||
|
"mapName":"miniche"
|
||||||
|
},
|
||||||
|
"history":[
|
||||||
|
"<C>●</>180년 1월:<L><b>【이벤트】</b></>부대를 통해 빠르게 이동할 수 있습니다."
|
||||||
|
],
|
||||||
|
"const": {
|
||||||
|
"joinRuinedNPCProp":0,
|
||||||
|
"npcBanMessageProb":1,
|
||||||
|
"scenarioEffect": "event_UnlimitedDefenceThresholdChange",
|
||||||
|
"staticEventHandlers": {
|
||||||
|
"Command/General/che_부대탑승": [
|
||||||
|
"event_부대탑승즉시이동"
|
||||||
|
],
|
||||||
|
"Command/Nation/che_발령": [
|
||||||
|
"event_부대발령즉시집합"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"events":[
|
||||||
|
[
|
||||||
|
"month", 1000,
|
||||||
|
["or", ["Date", "==", null, 12], ["Date", "==", null, 6]],
|
||||||
|
["CreateManyNPC", 10, 10],
|
||||||
|
["DeleteEvent"]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"month", 1000,
|
||||||
|
["Date", "==", 181, 1],
|
||||||
|
["RaiseNPCNation"],
|
||||||
|
["DeleteEvent"]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"month", 999,
|
||||||
|
["Date", "==", 181, 1],
|
||||||
|
["OpenNationBetting", 4, 5000],
|
||||||
|
["OpenNationBetting", 1, 2000],
|
||||||
|
["DeleteEvent"]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"month", 999,
|
||||||
|
["and",
|
||||||
|
["Date", ">=", 183, 1],
|
||||||
|
["RemainNation", "<=", 8]
|
||||||
|
],
|
||||||
|
["OpenNationBetting", 1, 1000],
|
||||||
|
["DeleteEvent"]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"destroy_nation", 1000,
|
||||||
|
["and",
|
||||||
|
["Date", ">=", 183, 1],
|
||||||
|
["RemainNation", "==", 1]
|
||||||
|
],
|
||||||
|
["BlockScoutAction"],
|
||||||
|
["DeleteEvent"]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user