fix: 권한 없는 유저가 수락 버튼을 누를 시, 아예 메시지가 사라지는 버그 수정

This commit is contained in:
2021-11-20 14:00:01 +09:00
parent 6a9a57e2bc
commit 527c8370f1
+25 -25
View File
@@ -7,7 +7,7 @@ class DiplomaticMessage extends Message{
const DECLINED = -1; const DECLINED = -1;
const INVALID = 0; const INVALID = 0;
const TYPE_NO_AGGRESSION = 'noAggression'; //불가침 const TYPE_NO_AGGRESSION = 'noAggression'; //불가침
const TYPE_CANCEL_NA = 'cancelNA'; //불가침 파기 const TYPE_CANCEL_NA = 'cancelNA'; //불가침 파기
const TYPE_STOP_WAR = 'stopWar'; //종전 const TYPE_STOP_WAR = 'stopWar'; //종전
@@ -74,7 +74,7 @@ class DiplomaticMessage extends Message{
$gameStor = KVStorage::getStorage(DB::db(), 'game_env'); $gameStor = KVStorage::getStorage(DB::db(), 'game_env');
$destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], 1); $destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], 1);
$commandObj = buildNationCommandClass('che_불가침수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [ $commandObj = buildNationCommandClass('che_불가침수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [
'destNationID'=>$this->src->nationID, 'destNationID'=>$this->src->nationID,
'destGeneralID'=>$this->src->generalID, 'destGeneralID'=>$this->src->generalID,
@@ -85,7 +85,7 @@ class DiplomaticMessage extends Message{
$this->diplomacyDetail = $commandObj->getBrief(); $this->diplomacyDetail = $commandObj->getBrief();
if(!$commandObj->hasFullConditionMet()){ if(!$commandObj->hasFullConditionMet()){
return [self::DECLINED, $commandObj->getFailString()]; return [self::INVALID, $commandObj->getFailString()];
} }
$commandObj->run(); $commandObj->run();
@@ -98,7 +98,7 @@ class DiplomaticMessage extends Message{
$gameStor = KVStorage::getStorage(DB::db(), 'game_env'); $gameStor = KVStorage::getStorage(DB::db(), 'game_env');
$destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], 1); $destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], 1);
$commandObj = buildNationCommandClass('che_불가침파기수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [ $commandObj = buildNationCommandClass('che_불가침파기수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [
'destNationID'=>$this->src->nationID, 'destNationID'=>$this->src->nationID,
'destGeneralID'=>$this->src->generalID, 'destGeneralID'=>$this->src->generalID,
@@ -107,7 +107,7 @@ class DiplomaticMessage extends Message{
$this->diplomacyDetail = $commandObj->getBrief(); $this->diplomacyDetail = $commandObj->getBrief();
if(!$commandObj->hasFullConditionMet()){ if(!$commandObj->hasFullConditionMet()){
return [self::DECLINED, $commandObj->getFailString()]; return [self::INVALID, $commandObj->getFailString()];
} }
$commandObj->run(); $commandObj->run();
@@ -120,7 +120,7 @@ class DiplomaticMessage extends Message{
$gameStor = KVStorage::getStorage(DB::db(), 'game_env'); $gameStor = KVStorage::getStorage(DB::db(), 'game_env');
$destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], 1); $destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], 1);
$commandObj = buildNationCommandClass('che_종전수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [ $commandObj = buildNationCommandClass('che_종전수락', $destGeneralObj, $gameStor->getAll(true), new LastTurn(), [
'destNationID'=>$this->src->nationID, 'destNationID'=>$this->src->nationID,
'destGeneralID'=>$this->src->generalID, 'destGeneralID'=>$this->src->generalID,
@@ -129,7 +129,7 @@ class DiplomaticMessage extends Message{
$this->diplomacyDetail = $commandObj->getBrief(); $this->diplomacyDetail = $commandObj->getBrief();
if(!$commandObj->hasFullConditionMet()){ if(!$commandObj->hasFullConditionMet()){
return [self::DECLINED, $commandObj->getFailString()]; return [self::INVALID, $commandObj->getFailString()];
} }
$commandObj->run(); $commandObj->run();
@@ -148,16 +148,16 @@ class DiplomaticMessage extends Message{
throw new \RuntimeException('전송되지 않은 메시지에 수락 진행 중'); throw new \RuntimeException('전송되지 않은 메시지에 수락 진행 중');
} }
$db = DB::db(); $db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env'); $gameStor = KVStorage::getStorage($db, 'game_env');
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']); [$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
$general = $db->queryFirstRow( $general = $db->queryFirstRow(
'SELECT `name`, nation, `officer_level`, `permission`, `penalty`,belong FROM general WHERE `no`=%i AND nation=%i', 'SELECT `name`, nation, `officer_level`, `permission`, `penalty`,belong FROM general WHERE `no`=%i AND nation=%i',
$receiverID, $receiverID,
$this->dest->nationID $this->dest->nationID
); );
@@ -165,7 +165,7 @@ class DiplomaticMessage extends Message{
$this->dest->generalID = $receiverID; $this->dest->generalID = $receiverID;
$this->dest->generalName = $general['name']; $this->dest->generalName = $general['name'];
} }
list($result, $reason) = $this->checkDiplomaticMessageValidation($general); list($result, $reason) = $this->checkDiplomaticMessageValidation($general);
if($result !== self::ACCEPTED){ if($result !== self::ACCEPTED){
@@ -186,10 +186,10 @@ class DiplomaticMessage extends Message{
case self::TYPE_STOP_WAR: case self::TYPE_STOP_WAR:
list($result, $reason) = $this->stopWar(); list($result, $reason) = $this->stopWar();
break; break;
default: default:
throw new \RuntimeException('diplomaticType이 올바르지 않음'); throw new \RuntimeException('diplomaticType이 올바르지 않음');
} }
if($result !== self::ACCEPTED){ if($result !== self::ACCEPTED){
(new ActionLogger($receiverID, 0, $year, $month))->pushGeneralActionLog($reason, ActionLogger::PLAIN); (new ActionLogger($receiverID, 0, $year, $month))->pushGeneralActionLog($reason, ActionLogger::PLAIN);
if($result === self::DECLINED){ if($result === self::DECLINED){
@@ -197,8 +197,8 @@ class DiplomaticMessage extends Message{
} }
return $result; return $result;
} }
$this->dest->generalID = $receiverID; $this->dest->generalID = $receiverID;
@@ -208,9 +208,9 @@ class DiplomaticMessage extends Message{
$josaYi = JosaUtil::pick($this->src->nationName, '이'); $josaYi = JosaUtil::pick($this->src->nationName, '이');
$newMsg = new Message( $newMsg = new Message(
self::MSGTYPE_NATIONAL, self::MSGTYPE_NATIONAL,
$this->dest, $this->dest,
$this->src, $this->src,
"【외교】{$year}{$month}월: {$this->src->nationName}{$josaYi} {$this->dest->nationName}에게 제안한 {$this->diplomacyDetail}", "【외교】{$year}{$month}월: {$this->src->nationName}{$josaYi} {$this->dest->nationName}에게 제안한 {$this->diplomacyDetail}",
new \DateTime(), new \DateTime(),
new \DateTime('9999-12-31'), new \DateTime('9999-12-31'),
@@ -224,9 +224,9 @@ class DiplomaticMessage extends Message{
$newMsg->send(); $newMsg->send();
$newMsg = new Message( $newMsg = new Message(
self::MSGTYPE_DIPLOMACY, self::MSGTYPE_DIPLOMACY,
$this->dest, $this->dest,
$this->src, $this->src,
"【외교】{$year}{$month}월: {$this->src->nationName}{$josaYi} {$this->dest->nationName}에게 제안한 {$this->diplomacyDetail}", "【외교】{$year}{$month}월: {$this->src->nationName}{$josaYi} {$this->dest->nationName}에게 제안한 {$this->diplomacyDetail}",
new \DateTime(), new \DateTime(),
new \DateTime('9999-12-31'), new \DateTime('9999-12-31'),
@@ -260,8 +260,8 @@ class DiplomaticMessage extends Message{
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']); [$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
$general = $db->queryFirstRow( $general = $db->queryFirstRow(
'SELECT `name`, nation, `officer_level`, `permission`, `penalty`,belong FROM general WHERE `no`=%i AND nation=%i', 'SELECT `name`, nation, `officer_level`, `permission`, `penalty`,belong FROM general WHERE `no`=%i AND nation=%i',
$receiverID, $receiverID,
$this->dest->nationID $this->dest->nationID
); );
list($result, $reason) = $this->checkDiplomaticMessageValidation($general); list($result, $reason) = $this->checkDiplomaticMessageValidation($general);
@@ -274,7 +274,7 @@ class DiplomaticMessage extends Message{
$josaYi = JosaUtil::pick($this->dest->nationName, '이'); $josaYi = JosaUtil::pick($this->dest->nationName, '이');
(new ActionLogger($receiverID, 0, $year, $month))->pushGeneralActionLog("<D>{$this->src->nationName}</>의 {$this->diplomacyName} 제안을 거절했습니다.", ActionLogger::PLAIN); (new ActionLogger($receiverID, 0, $year, $month))->pushGeneralActionLog("<D>{$this->src->nationName}</>의 {$this->diplomacyName} 제안을 거절했습니다.", ActionLogger::PLAIN);
(new ActionLogger($this->src->generalID, 0, $year, $month))->pushGeneralActionLog("<Y>{$this->dest->nationName}</>{$josaYi} {$this->diplomacyName} 제안을 거절했습니다.", ActionLogger::PLAIN); (new ActionLogger($this->src->generalID, 0, $year, $month))->pushGeneralActionLog("<Y>{$this->dest->nationName}</>{$josaYi} {$this->diplomacyName} 제안을 거절했습니다.", ActionLogger::PLAIN);
$this->_declineMessage(); $this->_declineMessage();
return self::DECLINED; return self::DECLINED;
} }