From ed75f390947422c6f88cbcd0a10e92b6bcb5f81b Mon Sep 17 00:00:00 2001 From: hide_d Date: Sat, 14 Jul 2018 18:17:18 +0900 Subject: [PATCH] =?UTF-8?q?ActionLogger=20=EB=B3=B4=EA=B0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/ActionLogger.php | 87 +++++++++++++++++++++++++++++++++----- 1 file changed, 77 insertions(+), 10 deletions(-) diff --git a/hwe/sammo/ActionLogger.php b/hwe/sammo/ActionLogger.php index 49b67fff..df15bf2b 100644 --- a/hwe/sammo/ActionLogger.php +++ b/hwe/sammo/ActionLogger.php @@ -6,6 +6,9 @@ class ActionLogger{ protected $generalId; protected $nationId; protected $autoFlush; + + protected $year = null; + protected $month = null; protected $generalHistoryLog = []; protected $generalActionLog = []; @@ -15,9 +18,21 @@ class ActionLogger{ protected $globalHistoryLog = []; protected $globalActionLog = []; - public function __construct(int $generalId, int $nationId, bool $autoFlush = true){ + const RAWTEXT = 0; + const PLAIN = 1; + const YEAR_MONTH = 2; + const YEAR = 3; + const MONTH = 4; + const EVENT_PLAIN = 5; + const EVENT_YEAR_MONTH = 6; + const NOTICE = 7; + 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; + $this->year = $year; + $this->month = $month; $this->autoFlush = $autoFlush; } @@ -62,18 +77,18 @@ class ActionLogger{ } if($this->globalHistoryLog){ - pushWorldHistory($this->globalHistoryLog); + pushWorldHistory($this->globalHistoryLog, $this->year, $this->month); $this->globalHistoryLog = []; } if($this->globalActionLog){ - pushGeneralPublicRecord($this->globalActionLog); + pushGeneralPublicRecord($this->globalActionLog, $this->year, $this->month); $this->globalActionLog = []; } } - public function pushGeneralHistoryLog($text){ + public function pushGeneralHistoryLog($text, int $formatType = self::YEAR_MONTH){ if(!$text){ return; } @@ -83,10 +98,12 @@ class ActionLogger{ } return; } + + $text = $this->formatText($formatType); $this->generalHistoryLog[] = $text; } - public function pushGeneralActionLog($text){ + public function pushGeneralActionLog($text, int $formatType = self::MONTH){ if(!$text){ return; } @@ -96,10 +113,12 @@ class ActionLogger{ } return; } + + $text = $this->formatText($formatType); $this->generalActionLog[] = $text; } - public function pushGeneralBattleResultLog($text){ + public function pushGeneralBattleResultLog($text, int $formatType = self::RAWTEXT){ if(!$text){ return; } @@ -109,10 +128,12 @@ class ActionLogger{ } return; } + + $text = $this->formatText($formatType); $this->generalBattleResultLog[] = $text; } - public function pushGeneralBattleDetailLog($text){ + public function pushGeneralBattleDetailLog($text, int $formatType = self::RAWTEXT){ if(!$text){ return; } @@ -122,10 +143,12 @@ class ActionLogger{ } return; } + + $text = $this->formatText($formatType); $this->generalBattleDetailLog[] = $text; } - public function pushNationalHistoryLog($text){ + public function pushNationalHistoryLog($text, int $formatType = self::RAWTEXT){ if(!$text){ return; } @@ -135,10 +158,12 @@ class ActionLogger{ } return; } + + $text = $this->formatText($formatType); $this->nationalHistoryLog[] = $text; } - public function pushGlobalActionLog($text){ + public function pushGlobalActionLog($text, int $formatType = self::MONTH){ if(!$text){ return; } @@ -148,10 +173,12 @@ class ActionLogger{ } return; } + + $text = $this->formatText($formatType); $this->globalActionLog[] = $text; } - public function pushGlobalHistoryLog($text){ + public function pushGlobalHistoryLog($text, int $formatType = self::YEAR_MONTH){ if(!$text){ return; } @@ -161,9 +188,49 @@ class ActionLogger{ } return; } + + $text = $this->formatText($formatType); $this->globalHistoryLog[] = $text; } + public function formatText(string $text, int $formatType):string{ + if($formatType === self::RAWTEXT){ + return $text; + } + if($formatType === self::PLAIN){ + return "●{$text}"; + } + + if($formatType === self::YEAR_MONTH){ + return "●{$this->year}년 {$this->month}월:{$text}"; + } + + if($formatType === self::YEAR){ + return "●{$this->year}년:{$text}"; + } + + if($formatType === self::MONTH){ + return "●{$this->month}월:{$text}"; + } + + if($formatType === self::EVENT_PLAIN){ + return "◆{$text}"; + } + + if($formatType === self::EVENT_YEAR_MONTH){ + return "◆{$this->year}년 {$this->month}월:{$text}"; + } + + if($formatType === self::NOTICE){ + return "★{$text}"; + } + + if($formatType === self::NOTICE_YEAR_MONTH){ + return "★{$this->year}년 {$this->month}월:{$text}"; + } + + return $text; + } } \ No newline at end of file