From 432318226e219048c4ecc64d502fffba3efc32d8 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 30 Sep 2018 02:05:12 +0900 Subject: [PATCH] =?UTF-8?q?=EC=82=AC=EB=A7=9D=20=EB=A9=94=EC=8B=9C?= =?UTF-8?q?=EC=A7=80=EB=A5=BC=20=EB=B3=84=EB=8F=84=EB=A1=9C=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/TextDecoration/DyingMessage.php | 135 ++++++++++++++++++++++ src/sammo/JosaUtil.php | 17 +++ 2 files changed, 152 insertions(+) create mode 100644 hwe/sammo/TextDecoration/DyingMessage.php diff --git a/hwe/sammo/TextDecoration/DyingMessage.php b/hwe/sammo/TextDecoration/DyingMessage.php new file mode 100644 index 00000000..592c27fa --- /dev/null +++ b/hwe/sammo/TextDecoration/DyingMessage.php @@ -0,0 +1,135 @@ +:name::이: 사망했습니다.'; + static protected $messages = null; + static protected $scenarioNPCMessages = null; + static protected $utilNPCMessages = null; + + protected static function getMessageList():array{ + return [ + ':name::이: 역병에 걸려 죽고 말았습니다.', + ':name::이: 요절하고 말았습니다.', + ':name::이: 거리에서 갑자기 객사하고 말았습니다.', + ':name::이: 안타깝게도 번개에 맞아 죽고 말았습니다.', + ':name::이: 고리대금에 시달리다가 자살하고 말았습니다.', + ':name::이: 일확천금에 놀라 심장마비로 죽고 말았습니다.', + ':name::이: 산속에서 호랑이에게 물려 죽고 말았습니다.', + ':name::이: 산책중 곰에게 할퀴어 죽고 말았습니다.', + ':name::이: 수영을 하다 익사하고 말았습니다.', + ':name::이: 황제를 모독하다가 처형당하고 말았습니다.', + ':name::이: 이튿날 침실에서 죽은채로발견되었습니다.', + ':name::이: 색에 빠져 기력이 쇠진해 죽고말았습니다.', + ':name::이: 미녀를 보고 심장마비로 죽고말았습니다.', + ':name::이: 우울증에 걸려 자살하고 말았습니다.', + ':name::이: 천하 정세를 비관하며 분신하고 말았습니다.', + ':name::이: 어떤 관심도 못받고 쓸쓸히 죽고말았습니다.', + ':name::이: 유산 상속 문제로 다투다가 살해당했습니다.', + ':name::이: 누군가의 사주로 자객에게 암살당했습니다.', + ':name::이: 바람난 배우자에게 독살당하고 말았습니다.', + ':name::이: 농약을 술인줄 알고 마셔 죽고말았습니다.', + ':name::이: 아무 이유 없이 죽고말았습니다.', + ':name::이: 전재산을 잃고 화병으로 죽고말았습니다.', + ':name::이: 단식운동을 하다가 굶어 죽고말았습니다.', + ':name::이: 귀신에게 홀려 시름 앓다가 죽고말았습니다.', + ':name::이: 사람들에게 집단으로 맞아서 죽고말았습니다.', + ':name::이: 갑자기 성벽에서 뛰어내려 죽고말았습니다.', + ':name::이: 농사중 호미에 머리를 맞아 죽고말았습니다.', + ':name::이: 저세상이 궁금하다며 자살하고 말았습니다.', + '운좋기로 소문난 :name::이: 불운하게도 죽고말았습니다.', + ':name::이: 무리하게 단련을 하다가 죽고말았습니다.', + ':name::이: 생활고를 비관하며 자살하고 말았습니다.', + ':name::이: 평생 결혼도 못해보고 죽고 말았습니다.', + ':name::이: 과식하다 배가 터져 죽고 말았습니다.', + ':name::이: 웃다가 숨이 넘어가 죽고 말았습니다.', + ':name::이: 추녀를 보고 놀라서 죽고 말았습니다.', + ':name::이: 물에 빠진 사람을 구하려다 같이 죽고 말았습니다.', + ':name::이: 독살을 준비하다 독에 걸려 죽고 말았습니다.', + ':name::이: 뒷간에서 너무 힘을 주다가 죽고 말았습니다.', + ':name::이: 돌팔이 의사에게 치료받다가 죽고 말았습니다.', + ':name::이: 남의 보약을 훔쳐먹다 부작용으로 죽고 말았습니다.', + '희대의 사기꾼 :name::이: 사망했습니다.', + '희대의 호색한 :name::이: 사망했습니다.', + ]; + } + + protected static function getScenarioNPCMessageList():array{ + return [ + static::$defaultMessage, + ]; + } + + protected static function getUtilNPCMessageList():array{ + return [ + ':name::이: 푸대접에 실망하여 떠났습니다.', + ':name::이: 갑자기 화를 내며 떠났습니다.', + ':name::이: 의견차이를 좁히지 못하고 떠났습니다.', + ':name::이: 판단 착오였다며 떠났습니다.', + ':name::이: 생활고가 나아지지 않는다며 떠났습니다.', + ':name::이: 기대가 너무 컸다며 떠났습니다.', + ':name::이: 아무 이유 없이 떠났습니다.', + ':name::이: 자기 목적은 달성했다며 떠났습니다.', + ':name::이: 자기가 없어도 될것 같다며 떠났습니다.', + ':name::이: 처자식이 그립다며 떠났습니다.', + ]; + } + + protected static function initMessageList():void{ + static::$messages = static::getMessageList(); + static::$scenarioNPCMessages = static::getScenarioNPCMessageList(); + static::$utilNPCMessages = static::getUtilNPCMessageList(); + } + + protected function _constructWithObj(General $general){ + $this->name = $general->getName(); + $this->npc = $general->getVar('npc'); + } + + protected function _constructWithRawValue(string $name, int $npc){ + $this->name = $name; + $this->npc = $npc; + } + + function __construct($name, ?int $npc = null) + { + if(static::$messages === null){ + static::buildMessageList(); + } + if($name instanceof General){ + $this->_constructWithObj($name); + } + else{ + $this->_constructWithRawValue($name, $npc); + } + } + + public function getText():string{ + $name = $this->general->getName(); + $npc = $this->general->getVar('npc'); + + if($npc == 0){ + $text = Util::choiceRandom(static::$messages); + } + else if($npc == 2 || $npc == 6){ + $text = Util::choiceRandom(static::$scenarioNPCMessages); + } + else if($npc == 3 || $npc == 4){ + $text = Util::choiceRandom(static::$utilNPCMessages); + } + else{ + $text = static::$defaultMessage; + } + + $text = str_replace(':name:', $name, $text); + + JosaUtil::batch($text, $name); + } +} \ No newline at end of file diff --git a/src/sammo/JosaUtil.php b/src/sammo/JosaUtil.php index f278e7bd..91f9d612 100644 --- a/src/sammo/JosaUtil.php +++ b/src/sammo/JosaUtil.php @@ -603,4 +603,21 @@ class JosaUtil{ return JosaUtil::put($text, $wJongsung, $woJongsung); }; } + + public static function batch(string $text, string $key, array $decorator =[':',':']){ + JosaUtil::init(); + + $search = []; + $replace = []; + + foreach(static::DEFAULT_POSTPOSITION as [$wJong, $woJong]){ + $value = JosaUtil::pick($key, $wJong); + $search[] = "{$prefix}{$wJong}{$postfix}"; + $replace[] = $value; + $search[] = "{$prefix}{$woJong}{$postfix}"; + $replace[] = $value; + } + + return str_replace($search, $replace, $text); + } } \ No newline at end of file