General 클래스를 General, GeneralLite로 분리 (#236)
내부 코드 사용례에서 General 테이블의 column을 일부만 가져오는 경우가 다수 있습니다. 다만 General 클래스에서 각종 iAction에 해당하는 트리거 함수 호출을 위해서는 모든 column을 다 가져와야 정상 동작이 가능한 만큼, iAction interface를 구현한 General 클래스와, 구현하지 않은 GeneralLite 클래스 둘로 나눕니다. 또한 General 클래스에서는 필요한 column을 다 가져오도록 변경합니다. Reviewed-on: https://storage.hided.net/gitea/devsam/core/pulls/236
This commit was merged in pull request #236.
This commit is contained in:
@@ -28,7 +28,7 @@ class LostUniqueItem extends \sammo\Event\Action
|
||||
if (!$generalIDList) {
|
||||
return;
|
||||
}
|
||||
$generals = General::createGeneralObjListFromDB($generalIDList);
|
||||
$generals = General::createObjListFromDB($generalIDList);
|
||||
|
||||
$lostItems = [];
|
||||
$totalLostCnt = 0;
|
||||
|
||||
@@ -18,7 +18,7 @@ class MergeInheritPointRank extends \sammo\Event\Action
|
||||
{
|
||||
$db = DB::db();
|
||||
|
||||
$generals = General::createGeneralObjListFromDB(null, null);
|
||||
$generals = General::createObjListFromDB(null, null);
|
||||
|
||||
$points = new Map();
|
||||
$points->allocate(count($generals));
|
||||
|
||||
@@ -39,7 +39,11 @@ class ProcessIncome extends \sammo\Event\Action
|
||||
|
||||
$nationList = $db->query('SELECT name,nation,capital,gold,level,rate_tmp,bill,type from nation');
|
||||
$cityListByNation = Util::arrayGroupBy($db->query('SELECT * FROM city'), 'nation');
|
||||
$generalRawListByNation = Util::arrayGroupBy($db->query('SELECT no,name,nation,gold,officer_level,dedication,city FROM general WHERE npc != 5'), 'nation');
|
||||
//FIXME: factory 형태로 바꿔야함
|
||||
$generalRawListByNation = Util::arrayGroupBy($db->query(
|
||||
'SELECT %l FROM general WHERE npc != 5',
|
||||
Util::formatListOfBackticks(General::mergeQueryColumn()[0])
|
||||
), 'nation');
|
||||
|
||||
//국가별 처리
|
||||
foreach ($nationList as $nation) {
|
||||
@@ -119,7 +123,11 @@ class ProcessIncome extends \sammo\Event\Action
|
||||
|
||||
$nationList = $db->query('SELECT name,level,nation,capital,rice,rate_tmp,bill,type from nation');
|
||||
$cityListByNation = Util::arrayGroupBy($db->query('SELECT * FROM city'), 'nation');
|
||||
$generalRawListByNation = Util::arrayGroupBy($db->query('SELECT no,name,nation,rice,officer_level,dedication,city FROM general WHERE npc != 5'), 'nation');
|
||||
//FIXME: factory 형태로 바꿔야함
|
||||
$generalRawListByNation = Util::arrayGroupBy($db->query(
|
||||
'SELECT %l FROM general WHERE npc != 5',
|
||||
Util::formatListOfBackticks(General::mergeQueryColumn()[0])
|
||||
), 'nation');
|
||||
|
||||
//국가별 처리
|
||||
foreach ($nationList as $nation) {
|
||||
|
||||
@@ -84,7 +84,7 @@ class ProvideNPCTroopLeader extends \sammo\Event\Action
|
||||
'troop' => $npcID
|
||||
], 'no=%i', $npcID);
|
||||
|
||||
$cmd = buildGeneralCommandClass('che_집합', General::createGeneralObjFromDB($npcID), $env);
|
||||
$cmd = buildGeneralCommandClass('che_집합', General::createObjFromDB($npcID), $env);
|
||||
_setGeneralCommand($cmd, iterator_to_array(Util::range(GameConst::$maxTurn)));
|
||||
$NPCTroopLeaderCnt += 1;
|
||||
$gameStor->lastNPCTroopLeaderID = $lastNPCTroopLeaderID;
|
||||
|
||||
@@ -112,7 +112,12 @@ class RaiseDisaster extends \sammo\Event\Action
|
||||
$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');
|
||||
//FIXME: factory 형태로 바꿔야함
|
||||
$generalListByCity = Util::arrayGroupBy($db->query(
|
||||
'SELECT %l FROM general WHERE city IN %li',
|
||||
Util::formatListOfBackticks(General::mergeQueryColumn()[0]),
|
||||
Util::squeezeFromArray($targetCityList, 'city')),
|
||||
'city');
|
||||
//NOTE: 쿼리 1번이지만 복잡하기 vs 쿼리 여러번이지만 조금 더 깔끔하기
|
||||
foreach ($targetCityList as $city) {
|
||||
$affectRatio = Util::valueFit($city['secu'] / $city['secu_max'] / 0.8, 0, 1);
|
||||
|
||||
@@ -140,7 +140,7 @@ class UpdateNationLevel extends \sammo\Event\Action
|
||||
$nation['nation'],
|
||||
$targetKillTurn
|
||||
);
|
||||
$nationGenList = General::createGeneralObjListFromDB($nationGenIDList, ['belong', 'npc', 'aux']);
|
||||
$nationGenList = General::createObjListFromDB($nationGenIDList, ['belong', 'npc', 'aux']);
|
||||
$chiefID = null;
|
||||
|
||||
$uniqueLotteryWeightList = [];
|
||||
@@ -215,7 +215,7 @@ class UpdateNationLevel extends \sammo\Event\Action
|
||||
}
|
||||
|
||||
if ($chiefID) {
|
||||
$chiefObj = General::createGeneralObjFromDB($chiefID, ['belong', 'npc', 'aux'], GeneralQueryMode::Lite);
|
||||
$chiefObj = General::createObjFromDB($chiefID);
|
||||
$chiefObj->increaseInheritancePoint(InheritanceKey::unifier, 250 * $levelDiff);
|
||||
$chiefObj->applyDB($db);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user