refac: General 클래스 관련 적용

This commit is contained in:
2023-08-01 16:28:28 +00:00
parent ed035ab75f
commit 0c53d77e61
5 changed files with 12 additions and 6 deletions
+1 -2
View File
@@ -149,7 +149,7 @@ function getRandGenName(RandUtil $rng)
function cityInfo(General $generalObj)
function cityInfo(GeneralLite $generalObj)
{
$db = DB::db();
@@ -1721,7 +1721,6 @@ function deleteNation(General $lord, bool $applyDB): array
$lordID
),
['npc', 'owner', 'gold', 'rice', 'experience', 'explevel', 'dedication', 'dedlevel', 'belong', 'aux'],
GeneralQueryMode::Lite,
);
$nationGeneralList[$lordID] = $lord;
+8 -1
View File
@@ -364,7 +364,14 @@ function disaster(RandUtil $rng) {
$logger->flush();
if (!$isGood) {
$generalListByCity = Util::arrayGroupBy($db->query('SELECT no, name, nation, city, officer_level, injury, leadership, strength, intel, horse, weapon, book, item, crew, crewtype, atmos, train, special, special2 FROM general WHERE city IN %li', Util::squeezeFromArray($targetCityList, 'city')), 'city');
[$queryColumns,,] = General::mergeQueryColumn();
$generalListByCity = Util::arrayGroupBy(
$db->query(
'SELECT %l FROM general WHERE city IN %li',
Util::formatListOfBackticks($queryColumns),
Util::squeezeFromArray($targetCityList, 'city')
),
'city');
//NOTE: 쿼리 1번이지만 복잡하기 vs 쿼리 여러번이지만 조금 더 깔끔하기
foreach ($targetCityList as $city) {
$affectRatio = Util::valueFit($city['secu'] / $city['secu_max'] / 0.8, 0, 1);
+1 -1
View File
@@ -599,7 +599,7 @@ function ConquerCity(array $admin, General $general, array $city)
Util::formatListOfBackticks(General::mergeQueryColumn(['npc', 'gold', 'rice', 'experience', 'explevel', 'belong', 'dedication', 'dedlevel', 'aux'], GeneralQueryMode::Lite)[0]),
$defenderNationID,
12
), null, null, $city, $loseNation, $year, $month, false);
), null, null, $city, $loseNation, $year, $month);
$josaUl = JosaUtil::pick($defenderNationName, '을');
$attackerLogger->pushNationalHistoryLog("<D><b>{$defenderNationName}</b></>{$josaUl} 정복");
+1 -1
View File
@@ -179,7 +179,7 @@ class AutorunNationPolicy {
'cureThreshold'=>10,
];
function __construct(General $general, $aiOptions, ?array $nationPolicy, ?array $serverPolicy, array $nation, array $env)
function __construct(GeneralLite $general, $aiOptions, ?array $nationPolicy, ?array $serverPolicy, array $nation, array $env)
{
foreach(static::$defaultPolicy as $policy=>$value){
$this->{$policy} = $value;
+1 -1
View File
@@ -43,7 +43,7 @@ $nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
$nationStor->cacheValues(['npc_nation_policy', 'npc_general_policy']);
$gameStor->cacheAll();
$general = new General($me, null, null, null, $nation, $gameStor->year, $gameStor->month, false);
$general = General::createGeneralObjFromDB($me['no']);
$rawServerPolicy = $gameStor->getValue('npc_nation_policy') ?? [];
$rawNationPolicy = $nationStor->getValue('npc_nation_policy') ?? [];