history column을 테이블로 분리

This commit is contained in:
2020-04-18 14:07:07 +09:00
parent 57ba12834a
commit c1bf3a773f
14 changed files with 323 additions and 184 deletions
+19 -19
View File
@@ -4,8 +4,8 @@ namespace sammo;
class ActionLogger{
//TODO: global을 따로 뗴어내고, 장수 Logger를 상속해서 받는 형식으로.
protected $generalId;
protected $nationId;
protected $generalID;
protected $nationID;
protected $autoFlush;
protected $year = null;
@@ -20,18 +20,26 @@ class ActionLogger{
protected $globalActionLog = [];
const RAWTEXT = 0;
/** <C>●</> */
const PLAIN = 1;
/** <C>●</>{$year}년 {$month}월: */
const YEAR_MONTH = 2;
/** <C>●</>{$year}년: */
const YEAR = 3;
/** <C>●</>{$month}월: */
const MONTH = 4;
/** <S>◆</> */
const EVENT_PLAIN = 5;
/** <S>◆</>{$year}년 {$month}월: */
const EVENT_YEAR_MONTH = 6;
/** <R>★</> */
const NOTICE = 7;
/** <R>★</>{$year}년 {$month}월: */
const NOTICE_YEAR_MONTH = 8;
public function __construct(int $generalId, int $nationId, int $year, int $month, bool $autoFlush = true){
$this->generalId = $generalId;
$this->nationId = $nationId;
public function __construct(int $generalID, int $nationID, int $year, int $month, bool $autoFlush = true){
$this->generalID = $generalID;
$this->nationID = $nationID;
$this->year = $year;
$this->month = $month;
$this->autoFlush = $autoFlush;
@@ -66,36 +74,28 @@ class ActionLogger{
}
public function flush(){
$db = DB::db();
if($this->generalHistoryLog){
$rawText = join('<br>', $this->generalHistoryLog).'<br>';
$db->update('general', [
'history'=>$db->sqleval('concat(%s, history)', $rawText)
], 'no=%i', $this->generalId);
pushGeneralHistory($this->generalID, $this->generalHistoryLog, $this->year, $this->month);
$this->generalHistoryLog = [];
}
if($this->generalActionLog){
pushGenLog(['no'=>$this->generalId], $this->generalActionLog);
pushGenLog($this->generalID, $this->generalActionLog, $this->year, $this->month);
$this->generalActionLog = [];
}
if($this->generalBattleResultLog){
pushBatRes(['no'=>$this->generalId], $this->generalBattleResultLog);
pushBatRes($this->generalID, $this->generalBattleResultLog, $this->year, $this->month);
$this->generalBattleResultLog = [];
}
if($this->generalBattleDetailLog){
pushBatLog(['no'=>$this->generalId], $this->generalBattleDetailLog);
pushBatLog($this->generalID, $this->generalBattleDetailLog, $this->year, $this->month);
$this->generalBattleDetailLog = [];
}
if($this->nationId && $this->nationalHistoryLog){
$rawText = join('<br>', $this->nationalHistoryLog).'<br>';
$db->update('nation', [
'history'=>$db->sqleval('concat(%s, history)', $rawText)
], 'nation=%i', $this->nationId);
if($this->nationID && $this->nationalHistoryLog){
pushNationHistory($this->nationID, $this->nationalHistoryLog, $this->year, $this->month);
$this->nationalHistoryLog = [];
}
+25 -25
View File
@@ -119,13 +119,13 @@ class DiplomaticMessage extends Message{
$mylog[] = "<C>●</><D><b>{$this->src->nationName}</b></>{$josaWa} 파기에 합의했습니다.";
$josaWa = JosaUtil::pick($this->dest->nationName, '와');
pushGeneralHistory(['no'=>$this->src->generalID], "<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->dest->nationName}</b></>{$josaWa} 파기 성공");
pushGeneralHistory($this->src->generalID, ["<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->dest->nationName}</b></>{$josaWa} 파기 성공"]);
$josaWa = JosaUtil::pick($this->src->nationName, '와');
pushGeneralHistory(['no'=>$this->dest->generalID], "<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->src->nationName}</b></>{$josaWa} 파기 수락");
pushGeneralHistory($this->dest->generalID, ["<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->src->nationName}</b></>{$josaWa} 파기 수락"]);
pushGenLog(['no'=>$this->dest->generalID], $mylog);
pushGenLog(['no'=>$this->src->generalID], $youlog);
pushGenLog($this->dest->generalID, $mylog);
pushGenLog($this->src->generalID, $youlog);
pushGeneralPublicRecord($alllog, $helper->year, $helper->month);
pushWorldHistory($history, $helper->year, $helper->month);
@@ -154,13 +154,13 @@ class DiplomaticMessage extends Message{
$mylog[] = "<C>●</><D><b>{$this->src->nationName}</b></>{$josaWa} 종전에 합의했습니다.";
$josaWa = JosaUtil::pick($this->dest->nationName, '와');
pushGeneralHistory(['no'=>$this->src->generalID], "<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->dest->nationName}</b></>{$josaWa} 종전 성공");
pushGeneralHistory($this->src->generalID, ["<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->dest->nationName}</b></>{$josaWa} 종전 성공"]);
$josaWa = JosaUtil::pick($this->src->nationName, '와');
pushGeneralHistory(['no'=>$this->dest->generalID], "<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->src->nationName}</b></>{$josaWa} 종전 수락");
pushGeneralHistory($this->dest->generalID, ["<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->src->nationName}</b></>{$josaWa} 종전 수락"]);
pushGenLog(['no'=>$this->dest->generalID], $mylog);
pushGenLog(['no'=>$this->src->generalID], $youlog);
pushGenLog($this->dest->generalID, $mylog);
pushGenLog($this->src->generalID, $youlog);
pushGeneralPublicRecord($alllog, $helper->year, $helper->month);
pushWorldHistory($history, $helper->year, $helper->month);
@@ -176,11 +176,11 @@ class DiplomaticMessage extends Message{
$josaWa = JosaUtil::pick($this->src->nationName, '와');
pushGeneralHistory(
['no'=>$this->dest->generalID],
"<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->src->nationName}</b></>{$josaWa} 통합 시도"
$this->dest->generalID,
["<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->src->nationName}</b></>{$josaWa} 통합 시도"]
);
pushGenLog(
['no'=>$this->dest->generalID],
$this->dest->generalID,
["<C>●</><D><b>{$this->src->nationName}</b></>{$josaWa} 통합에 동의했습니다."]
);
@@ -195,12 +195,12 @@ class DiplomaticMessage extends Message{
$josaWa = JosaUtil::pick($this->dest->nationName, '와');
pushGeneralHistory(
['no'=>$this->src->generalID],
"<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->dest->nationName}</b></>{$josaWa} 통합 시도"
$this->src->generalID,
["<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->dest->nationName}</b></>{$josaWa} 통합 시도"]
);
$josaYi = JosaUtil::pick($this->dest->nationName, '이');
pushGenLog(
['no'=>$this->src->generalID],
$this->src->generalID,
["<C>●</><D><b>{$this->dest->nationName}</b></>{$josaYi} 통합에 동의했습니다."]
);
pushWorldHistory(
@@ -221,20 +221,20 @@ class DiplomaticMessage extends Message{
$josaRo = JosaUtil::pick($this->src->nationName, '로');
pushGeneralHistory(
['no'=>$this->src->generalID],
"<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->dest->nationName}</b></>에게 투항 제의"
$this->src->generalID,
["<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->dest->nationName}</b></>에게 투항 제의"]
);
pushGeneralHistory(
['no'=>$this->dest->generalID],
"<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->src->nationName}</b></>{$josaRo} 투항 동의"
$this->dest->generalID,
["<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->src->nationName}</b></>{$josaRo} 투항 동의"]
);
pushGenLog(
['no'=>$this->dest->generalID],
$this->dest->generalID,
["<C>●</><D><b>{$this->src->nationName}</b></>{$josaRo} 투항에 동의했습니다."]
);
$josaYi = JosaUtil::pick($this->dest->nationName, '이');
pushGenLog(
['no'=>$this->src->generalID],
$this->src->generalID,
["<C>●</><D><b>{$this->dest->nationName}</b></>{$josaYi} 투항에 동의했습니다."]
);
$josaYi = JosaUtil::pick($this->dest->generalName, '이');
@@ -281,7 +281,7 @@ class DiplomaticMessage extends Message{
list($result, $reason) = $this->checkDiplomaticMessageValidation($general);
if($result !== self::ACCEPTED){
pushGenLog(['no'=>$receiverID], ["<C>●</>{$reason} {$this->diplomacyName} 실패."]);
pushGenLog($receiverID, ["<C>●</>{$reason} {$this->diplomacyName} 실패."]);
if($result === self::DECLINED){
$this->_declineMessage();
}
@@ -309,7 +309,7 @@ class DiplomaticMessage extends Message{
}
if($result !== self::ACCEPTED){
pushGenLog(['no'=>$receiverID], ["<C>●</>{$reason} {$this->diplomacyName} 실패."]);
pushGenLog($receiverID, ["<C>●</>{$reason} {$this->diplomacyName} 실패."]);
if($result === self::DECLINED){
$this->_declineMessage();
}
@@ -380,13 +380,13 @@ class DiplomaticMessage extends Message{
list($result, $reason) = $this->checkDiplomaticMessageValidation($general);
if($result === self::INVALID){
pushGenLog(['no'=>$receiverID], ["<C>●</>{$reason} {$this->diplomacyName} 거절 불가."]);
pushGenLog($receiverID, ["<C>●</>{$reason} {$this->diplomacyName} 거절 불가."]);
return $result;
}
$josaYi = JosaUtil::pick($this->dest->nationName, '이');
pushGenLog(['no'=>$receiverID], "<C>●</><D>{$this->src->nationName}</>의 {$this->diplomacyName} 제안을 거절했습니다.");
pushGenLog(['no'=>$this->src->generalID], "<C>●</><Y>{$this->dest->nationName}</>{$josaYi} {$this->diplomacyName} 제안을 거절했습니다.");
pushGenLog($receiverID, ["<C>●</><D>{$this->src->nationName}</>의 {$this->diplomacyName} 제안을 거절했습니다."]);
pushGenLog($this->src->generalID, ["<C>●</><Y>{$this->dest->nationName}</>{$josaYi} {$this->diplomacyName} 제안을 거절했습니다."]);
$this->_declineMessage();
return self::DECLINED;
}
+3 -3
View File
@@ -143,14 +143,14 @@ class ScoutMessage extends Message{
list($result, $reason) = $this->checkScoutMessageValidation($receiverID);
if($result === self::INVALID){
pushGenLog(['no'=>$receiverID], ["<C>●</>{$reason} 등용 취소 불가."]);
pushGenLog($receiverID, ["<C>●</>{$reason} 등용 취소 불가."]);
return $result;
}
$josaRo = JosaUtil::pick($this->src->nationName, '로');
$josaYi = JosaUtil::pick($this->dest->generalName, '이');
pushGenLog(['no'=>$receiverID], "<C>●</><D>{$this->src->nationName}</>{$josaRo} 망명을 거부했습니다.");
pushGenLog(['no'=>$this->src->generalID], "<C>●</><Y>{$this->dest->generalName}</>{$josaYi} 등용을 거부했습니다.");
pushGenLog($receiverID, ["<C>●</><D>{$this->src->nationName}</>{$josaRo} 망명을 거부했습니다."]);
pushGenLog($this->src->generalID, ["<C>●</><Y>{$this->dest->generalName}</>{$josaYi} 등용을 거부했습니다."]);
$this->_declineMessage();
return self::DECLINED;