불가침, 종전 메시지

This commit is contained in:
2020-05-03 00:31:04 +09:00
parent 83e8cfc2cc
commit ce5ad89d5e
16 changed files with 477 additions and 98 deletions
+22 -34
View File
@@ -77,7 +77,7 @@ class DiplomaticMessage extends Message{
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
$destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr'], 1);
$destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], 1);
$commandObj = buildNationCommandClass('che_불가침수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [
'destNationID'=>$this->src->nationID,
@@ -133,38 +133,24 @@ class DiplomaticMessage extends Message{
}
protected function stopWar(){
$helper = new Engine\Diplomacy($this->src->nationID, $this->dest->nationID);
$chk = $helper->stopWar();
if($chk[0] !== self::ACCEPTED){
return $chk;
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
$destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], 1);
$commandObj = buildNationCommandClass('che_종전수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [
'destNationID'=>$this->src->nationID,
'destGeneralID'=>$this->src->generalID,
]);
$this->diplomacyDetail = $commandObj->getBrief();
if(!$commandObj->isRunnable()){
return [self::DECLINED, $commandObj->getFailString()];
}
$josaYi = JosaUtil::pick($this->dest->generalName, '이');
$josaWa = JosaUtil::pick($this->src->nationName, '와');
$alllog[] = "<C>●</>{$helper->month}월:<Y>{$this->dest->generalName}</>{$josaYi} <D><b>{$this->src->nationName}</b></>{$josaWa} <M>종전 합의</> 하였습니다.";
$commandObj->run();
$josaYi = JosaUtil::pick($this->dest->nationName, '');
$josaWa = JosaUtil::pick($this->src->nationName, '와');
$history[] = "<C>●</>{$helper->year}{$helper->month}월:<Y><b>【종전】</b></><D><b>{$this->dest->nationName}</b></>{$josaYi} <D><b>{$this->src->nationName}</b></>{$josaWa} <M>종전 합의</> 하였습니다.";
$josaWa = JosaUtil::pick($this->dest->nationName, '와');
$youlog[] = "<C>●</><D><b>{$this->dest->nationName}</b></>{$josaWa} 종전에 성공했습니다.";
$josaWa = JosaUtil::pick($this->src->nationName, '와');
$mylog[] = "<C>●</><D><b>{$this->src->nationName}</b></>{$josaWa} 종전에 합의했습니다.";
$josaWa = JosaUtil::pick($this->dest->nationName, '와');
pushGeneralHistory($this->src->generalID, ["<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->dest->nationName}</b></>{$josaWa} 종전 성공"]);
$josaWa = JosaUtil::pick($this->src->nationName, '와');
pushGeneralHistory($this->dest->generalID, ["<C>●</>{$helper->year}{$helper->month}월:<D><b>{$this->src->nationName}</b></>{$josaWa} 종전 수락"]);
pushGenLog($this->dest->generalID, $mylog);
pushGenLog($this->src->generalID, $youlog);
pushGeneralPublicRecord($alllog, $helper->year, $helper->month);
pushWorldHistory($history, $helper->year, $helper->month);
return $chk;
return [self::ACCEPTED, ''];
}
protected function acceptMerge(){
@@ -307,9 +293,9 @@ class DiplomaticMessage extends Message{
default:
throw new \RuntimeException('diplomaticType이 올바르지 않음');
}
if($result !== self::ACCEPTED){
pushGenLog($receiverID, ["<C>●</>{$reason} {$this->diplomacyName} 실패."]);
pushGenLog($receiverID, ["<C>●</>{$reason}"]);
if($result === self::DECLINED){
$this->_declineMessage();
}
@@ -329,12 +315,13 @@ class DiplomaticMessage extends Message{
self::MSGTYPE_NATIONAL,
$this->dest,
$this->src,
"【외교】{$year}{$month}월: {$this->src->nationName}{$josaYi} {$this->dest->nationName}에게 제안한 {$this->diplomacyDetail}{$this->diplomacyName} 동의.",
"【외교】{$year}{$month}월: {$this->src->nationName}{$josaYi} {$this->dest->nationName}에게 제안한 {$this->diplomacyDetail}",
new \DateTime(),
new \DateTime('9999-12-31'),
[
'delete'=>$this->id,
'silence'=>true,
'deletable' => false
]
);
$this->invalidate();
@@ -344,12 +331,13 @@ class DiplomaticMessage extends Message{
self::MSGTYPE_DIPLOMACY,
$this->dest,
$this->src,
"【외교】{$year}{$month}월: {$this->src->nationName}{$josaYi} {$this->dest->nationName}에게 제안한 {$this->diplomacyDetail}{$this->diplomacyName} 동의.",
"【외교】{$year}{$month}월: {$this->src->nationName}{$josaYi} {$this->dest->nationName}에게 제안한 {$this->diplomacyDetail}",
new \DateTime(),
new \DateTime('9999-12-31'),
[
'delete'=>$this->id,
'silence'=>true,
'deletable' => false
]
);
$newMsg->send();