불가침, 종전 메시지
This commit is contained in:
@@ -123,7 +123,7 @@ $msg = new Message(
|
|||||||
$msgText,
|
$msgText,
|
||||||
$now,
|
$now,
|
||||||
$unlimited,
|
$unlimited,
|
||||||
['invalid' => true]
|
['deletable' => false]
|
||||||
);
|
);
|
||||||
$msgID = $msg->send();
|
$msgID = $msg->send();
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ $msg = new Message(
|
|||||||
$msgText,
|
$msgText,
|
||||||
$now,
|
$now,
|
||||||
$unlimited,
|
$unlimited,
|
||||||
['invalid' => true]
|
['deletable' => false]
|
||||||
);
|
);
|
||||||
$msgID = $msg->send();
|
$msgID = $msg->send();
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ $msg = new Message(
|
|||||||
$msgText,
|
$msgText,
|
||||||
$now,
|
$now,
|
||||||
$unlimited,
|
$unlimited,
|
||||||
['invalid' => true]
|
['deletable' => false]
|
||||||
);
|
);
|
||||||
$msgID = $msg->send();
|
$msgID = $msg->send();
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ $msg = new Message(
|
|||||||
$msgText,
|
$msgText,
|
||||||
$now,
|
$now,
|
||||||
$unlimited,
|
$unlimited,
|
||||||
['invalid' => true]
|
['deletable' => false]
|
||||||
);
|
);
|
||||||
$msgID = $msg->send();
|
$msgID = $msg->send();
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ $msg = new Message(
|
|||||||
$msgText,
|
$msgText,
|
||||||
$now,
|
$now,
|
||||||
$unlimited,
|
$unlimited,
|
||||||
['invalid' => true]
|
['deletable' => false]
|
||||||
);
|
);
|
||||||
$msgID = $msg->send();
|
$msgID = $msg->send();
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ if ($msgID === null || !is_bool($msgResponse)) {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$general = DB::db()->queryFirstRow('select `no`, `name`, `nation`, `nations`, `officer_level`, `npc`, `gold`, `rice`, `troop` from `general` where `no` = %i', $generalID);
|
$general = DB::db()->queryFirstRow('SELECT `no`, `name`, `nation`, `officer_level`, `npc`, `gold`, `rice`, `troop`, `aux` from `general` where `no` = %i', $generalID);
|
||||||
if(!$general){
|
if(!$general){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
|
|||||||
+9
-1
@@ -208,6 +208,14 @@ function redrawMsg(deferred, addFront){
|
|||||||
else{
|
else{
|
||||||
msg.invalidType = 'msg_valid';
|
msg.invalidType = 'msg_valid';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(msg.option && !msg.option.deletable){
|
||||||
|
msg.deletable = false;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
msg.deletable = true;
|
||||||
|
}
|
||||||
|
|
||||||
var msgHtml = TemplateEngine(messageTemplate, msg);
|
var msgHtml = TemplateEngine(messageTemplate, msg);
|
||||||
|
|
||||||
|
|
||||||
@@ -504,7 +512,7 @@ function activateMessageForm(){
|
|||||||
jQuery(function($){
|
jQuery(function($){
|
||||||
|
|
||||||
//tmp_template.html은 추후 msg.js에 통합될 수 있음
|
//tmp_template.html은 추후 msg.js에 통합될 수 있음
|
||||||
var getTemplate = $.get('js/templates/message.html?11',function(obj){
|
var getTemplate = $.get('js/templates/message.html?12',function(obj){
|
||||||
messageTemplate = obj;
|
messageTemplate = obj;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="msg_body">
|
<div class="msg_body">
|
||||||
<div class="msg_header">
|
<div class="msg_header">
|
||||||
<%if(!this.option.action && src.id == myGeneralID && now <= last5min && invalidType == 'msg_valid'){%>
|
<%if(!this.option.action && src.id == myGeneralID && now <= last5min && invalidType == 'msg_valid' && !deletable){%>
|
||||||
<button type="button" data-erase_until="<%last5min%>" class="btn btn btn-outline-warning btn-sm btn-delete-msg" style='float:right'>❌</button>
|
<button type="button" data-erase_until="<%last5min%>" class="btn btn btn-outline-warning btn-sm btn-delete-msg" style='float:right'>❌</button>
|
||||||
<%}%>
|
<%}%>
|
||||||
<%if(msgType == 'private') {%>
|
<%if(msgType == 'private') {%>
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ use \sammo\Constraint\Constraint;
|
|||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
class che_불가침수락 extends Command\NationCommand{
|
class che_불가침수락 extends Command\NationCommand{
|
||||||
static protected $actionName = '불가침';
|
static protected $actionName = '불가침 수락';
|
||||||
static public $reqArg = true;
|
static public $reqArg = true;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
@@ -95,7 +95,7 @@ class che_불가침수락 extends Command\NationCommand{
|
|||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation();
|
$this->setNation();
|
||||||
|
|
||||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['imgsvr', 'picture'], 1);
|
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], [], 1);
|
||||||
$this->setDestGeneral($destGeneral);
|
$this->setDestGeneral($destGeneral);
|
||||||
$this->setDestNation($this->arg['destNationID']);
|
$this->setDestNation($this->arg['destNationID']);
|
||||||
|
|
||||||
@@ -126,6 +126,7 @@ class che_불가침수락 extends Command\NationCommand{
|
|||||||
ConstraintHelper::SuppliedCity(),
|
ConstraintHelper::SuppliedCity(),
|
||||||
ConstraintHelper::ExistsDestNation(),
|
ConstraintHelper::ExistsDestNation(),
|
||||||
ConstraintHelper::ExistsDestGeneral(),
|
ConstraintHelper::ExistsDestGeneral(),
|
||||||
|
ConstraintHelper::ReqDestNationValue('nation', '소속', '==', $this->destGeneralObj->getNationID(), '제의 장수가 국가 소속이 아닙니다'),
|
||||||
ConstraintHelper::DisallowDiplomacyBetweenStatus([
|
ConstraintHelper::DisallowDiplomacyBetweenStatus([
|
||||||
0 => '아국과 이미 교전중입니다.',
|
0 => '아국과 이미 교전중입니다.',
|
||||||
1 => '아국과 이미 선포중입니다.',
|
1 => '아국과 이미 선포중입니다.',
|
||||||
@@ -155,7 +156,7 @@ class che_불가침수락 extends Command\NationCommand{
|
|||||||
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
||||||
$year = $this->arg['year'];
|
$year = $this->arg['year'];
|
||||||
$month = $this->arg['month'];
|
$month = $this->arg['month'];
|
||||||
return "{$year}년 {$month}월 전까지 ";
|
return "{$year}년 {$month}월까지 불가침 합의";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run():bool{
|
public function run():bool{
|
||||||
@@ -180,7 +181,7 @@ class che_불가침수락 extends Command\NationCommand{
|
|||||||
$month = $this->arg['month'];
|
$month = $this->arg['month'];
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
$destLogger = new ActionLogger(0, $destNationID, $env['year'], $env['month']);
|
$destLogger = $this->destGeneralObj->getLogger();
|
||||||
|
|
||||||
$currentMonth = $env['year'] * 12 + $env['month'] - 1;
|
$currentMonth = $env['year'] * 12 + $env['month'] - 1;
|
||||||
$reqMonth = $year *12 + $month - 1;
|
$reqMonth = $year *12 + $month - 1;
|
||||||
@@ -194,13 +195,13 @@ class che_불가침수락 extends Command\NationCommand{
|
|||||||
$nationID, $destNationID);
|
$nationID, $destNationID);
|
||||||
|
|
||||||
$josaWa = JosaUtil::pick($destNationName, '와');
|
$josaWa = JosaUtil::pick($destNationName, '와');
|
||||||
$logger->pushGeneralActionLog("<D><b>{$destNationName}</b></>{$josaWa} <C>$year</>년 불가침에 성공했습니다.", ActionLogger::PLAIN);
|
$logger->pushGeneralActionLog("<D><b>{$destNationName}</b></>{$josaWa} <C>$year</>년 <C>{$month}</>월까지 불가침에 성공했습니다.", ActionLogger::PLAIN);
|
||||||
$logger->pushGeneralHistoryLog("<D><b>{$destNationName}</b></>{$josaWa} {$year}년 {$month}월 전까지 불가침 성공");
|
$logger->pushGeneralHistoryLog("<D><b>{$destNationName}</b></>{$josaWa} {$year}년 {$month}월까지 불가침 성공");
|
||||||
|
|
||||||
|
|
||||||
$josaWa = JosaUtil::pick($nationName, '와');
|
$josaWa = JosaUtil::pick($nationName, '와');
|
||||||
$destLogger->pushGeneralActionLog("<D><b>{$nationName}</b></>{$josaWa} <C>$year</>년 불가침에 성공했습니다.", ActionLogger::PLAIN);
|
$destLogger->pushGeneralActionLog("<D><b>{$nationName}</b></>{$josaWa} <C>$year</>년 <C>{$month}</>월까지 불가침에 성공했습니다.", ActionLogger::PLAIN);
|
||||||
$destLogger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>{$josaWa} {$year}년 {$month}월 전까지 불가침 성공");
|
$destLogger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>{$josaWa} {$year}년 {$month}월까지 불가침 성공");
|
||||||
|
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
$destLogger->flush();
|
$destLogger->flush();
|
||||||
|
|||||||
@@ -105,8 +105,6 @@ class che_불가침제의 extends Command\NationCommand{
|
|||||||
$this->runnableConstraints=[
|
$this->runnableConstraints=[
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::NotBeNeutral(),
|
ConstraintHelper::NotBeNeutral(),
|
||||||
ConstraintHelper::OccupiedCity(),
|
|
||||||
ConstraintHelper::SuppliedCity(),
|
|
||||||
ConstraintHelper::ExistsDestNation(),
|
ConstraintHelper::ExistsDestNation(),
|
||||||
ConstraintHelper::DisallowDiplomacyBetweenStatus([
|
ConstraintHelper::DisallowDiplomacyBetweenStatus([
|
||||||
0 => '아국과 이미 교전중입니다.',
|
0 => '아국과 이미 교전중입니다.',
|
||||||
@@ -137,7 +135,7 @@ class che_불가침제의 extends Command\NationCommand{
|
|||||||
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
||||||
$year = $this->arg['year'];
|
$year = $this->arg['year'];
|
||||||
$month = $this->arg['month'];
|
$month = $this->arg['month'];
|
||||||
return "【{$destNationName}】에게 {$year}년 {$month}월 전까지 {$commandName}";
|
return "【{$destNationName}】에게 {$year}년 {$month}월까지 {$commandName}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -191,11 +189,13 @@ class che_불가침제의 extends Command\NationCommand{
|
|||||||
$validMinutes = max(30, $env['turnterm']*3);
|
$validMinutes = max(30, $env['turnterm']*3);
|
||||||
$validUntil->add(new \DateInterval("PT{$validMinutes}M"));
|
$validUntil->add(new \DateInterval("PT{$validMinutes}M"));
|
||||||
|
|
||||||
|
$josaWa = JosaUtil::pick($nationName, '와');
|
||||||
|
|
||||||
$msg = new DiplomaticMessage(
|
$msg = new DiplomaticMessage(
|
||||||
Message::MSGTYPE_DIPLOMACY,
|
Message::MSGTYPE_DIPLOMACY,
|
||||||
$src,
|
$src,
|
||||||
$dest,
|
$dest,
|
||||||
"{$nationName}와 {$year}년 {$month}월 전까지 불가침 제의 서신",
|
"{$nationName}{$josaWa} {$year}년 {$month}월까지 불가침 제의 서신",
|
||||||
$now,
|
$now,
|
||||||
$validUntil,
|
$validUntil,
|
||||||
[
|
[
|
||||||
@@ -283,7 +283,7 @@ class che_불가침제의 extends Command\NationCommand{
|
|||||||
<?php foreach(Util::range(1, 12+1) as $formMonth): ?>
|
<?php foreach(Util::range(1, 12+1) as $formMonth): ?>
|
||||||
<option value='<?=$formMonth?>'><?=$formMonth?></option>
|
<option value='<?=$formMonth?>'><?=$formMonth?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>월 전까지
|
</select>월까지
|
||||||
<input type=button id="commonSubmit" value="<?=$this->getName()?>">
|
<input type=button id="commonSubmit" value="<?=$this->getName()?>">
|
||||||
<?php
|
<?php
|
||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
|
|||||||
@@ -0,0 +1,171 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo\Command\Nation;
|
||||||
|
|
||||||
|
use \sammo\{
|
||||||
|
DB, Util, JosaUtil,
|
||||||
|
General, DummyGeneral,
|
||||||
|
ActionLogger,
|
||||||
|
GameConst,
|
||||||
|
LastTurn,
|
||||||
|
GameUnitConst,
|
||||||
|
Command,
|
||||||
|
MessageTarget,
|
||||||
|
DiplomaticMessage,
|
||||||
|
Message,
|
||||||
|
};
|
||||||
|
|
||||||
|
use function \sammo\{
|
||||||
|
getDomesticExpLevelBonus,
|
||||||
|
CriticalRatioDomestic,
|
||||||
|
CriticalScoreEx,
|
||||||
|
getAllNationStaticInfo,
|
||||||
|
getNationStaticInfo,
|
||||||
|
GetImageURL
|
||||||
|
};
|
||||||
|
|
||||||
|
use \sammo\Constraint\Constraint;
|
||||||
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
|
class che_종전수락 extends Command\NationCommand{
|
||||||
|
static protected $actionName = '종전 수락';
|
||||||
|
static public $reqArg = true;
|
||||||
|
|
||||||
|
protected function argTest():bool{
|
||||||
|
if($this->arg === null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!key_exists('destNationID', $this->arg)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$destNationID = $this->arg['destNationID'];
|
||||||
|
if(!is_int($destNationID)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if($destNationID < 1){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!key_exists('destGeneralID', $this->arg)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$destGeneralID = $this->arg['destGeneralID'];
|
||||||
|
if(!is_int($destGeneralID)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if($destGeneralID <= 0){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if($destGeneralID == $this->generalObj->getID()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->arg = [
|
||||||
|
'destNationID'=>$destNationID,
|
||||||
|
'destGeneralID'=>$destGeneralID,
|
||||||
|
];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function init(){
|
||||||
|
$general = $this->generalObj;
|
||||||
|
|
||||||
|
$env = $this->env;
|
||||||
|
$relYear = $env['year'] - $env['startyear'];
|
||||||
|
|
||||||
|
$this->setCity();
|
||||||
|
$this->setNation();
|
||||||
|
|
||||||
|
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], [], 1);
|
||||||
|
$this->setDestGeneral($destGeneral);
|
||||||
|
$this->setDestNation($this->arg['destNationID']);
|
||||||
|
|
||||||
|
$nationID = $this->nation['nation'];
|
||||||
|
|
||||||
|
$this->reservableConstraints = [
|
||||||
|
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->runnableConstraints=[
|
||||||
|
ConstraintHelper::BeChief(),
|
||||||
|
ConstraintHelper::NotBeNeutral(),
|
||||||
|
ConstraintHelper::ExistsDestNation(),
|
||||||
|
ConstraintHelper::ExistsDestGeneral(),
|
||||||
|
ConstraintHelper::ReqDestNationValue('nation', '소속', '==', $this->destGeneralObj->getNationID(), '제의 장수가 국가 소속이 아닙니다'),
|
||||||
|
ConstraintHelper::AllowDiplomacyBetweenStatus(
|
||||||
|
[0, 1],
|
||||||
|
'상대국과 선포, 전쟁중이지 않습니다.'
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCost():array{
|
||||||
|
return [0, 0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPreReqTurn():int{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPostReqTurn():int{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBrief():string{
|
||||||
|
$commandName = $this->getName();
|
||||||
|
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
||||||
|
return "{$destNationName}국과 종전 합의";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function run():bool{
|
||||||
|
if(!$this->isRunnable()){
|
||||||
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
|
$env = $this->env;
|
||||||
|
|
||||||
|
$general = $this->generalObj;
|
||||||
|
$generalName = $general->getName();
|
||||||
|
|
||||||
|
$nation = $this->nation;
|
||||||
|
$nationID = $nation['nation'];
|
||||||
|
$nationName = $nation['name'];
|
||||||
|
|
||||||
|
$destNation = $this->destNation;
|
||||||
|
$destNationID = $destNation['nation'];
|
||||||
|
$destNationName = $destNation['name'];
|
||||||
|
|
||||||
|
$logger = $general->getLogger();
|
||||||
|
$destLogger = $this->destGeneralObj->getLogger();
|
||||||
|
|
||||||
|
$db->update('diplomacy',[
|
||||||
|
'state'=>2,
|
||||||
|
'term'=>0
|
||||||
|
],
|
||||||
|
'(me=%i AND you=%i) OR (you=%i AND me=%i)',
|
||||||
|
$nationID, $destNationID,
|
||||||
|
$nationID, $destNationID);
|
||||||
|
|
||||||
|
$josaYiGeneral = JosaUtil::pick($generalName, '이');
|
||||||
|
$josaYiNation = JosaUtil::pick($nationName, '이');
|
||||||
|
|
||||||
|
$josaWa = JosaUtil::pick($destNationName, '와');
|
||||||
|
$logger->pushGeneralActionLog("<D><b>{$destNationName}</b></>{$josaWa} 종전에 합의했습니다.", ActionLogger::PLAIN);
|
||||||
|
$logger->pushGeneralHistoryLog("<D><b>{$destNationName}</b></>{$josaWa} 종전 수락");
|
||||||
|
|
||||||
|
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYiGeneral} <D><b>{$destNationName}</b></>{$josaWa} <M>종전 합의</> 하였습니다.");
|
||||||
|
$logger->pushGlobalHistoryLog("<Y><b>【종전】</b></><D><b>{$nationName}</b></>{$josaYiNation} <D><b>{$destNationName}</b></>{$josaWa} <M>종전 합의</> 하였습니다.");
|
||||||
|
|
||||||
|
|
||||||
|
$josaWa = JosaUtil::pick($nationName, '와');
|
||||||
|
$destLogger->pushGeneralActionLog("<D><b>{$nationName}</b></>{$josaWa} 종전에 성공했습니다.", ActionLogger::PLAIN);
|
||||||
|
$destLogger->pushGeneralHistoryLog("<D><b>{$nationName}</b></>{$josaWa} 종전 성공");
|
||||||
|
|
||||||
|
$general->applyDB($db);
|
||||||
|
$destLogger->flush();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,219 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo\Command\Nation;
|
||||||
|
|
||||||
|
use \sammo\{
|
||||||
|
DB, Util, JosaUtil,
|
||||||
|
General, DummyGeneral,
|
||||||
|
ActionLogger,
|
||||||
|
GameConst,
|
||||||
|
LastTurn,
|
||||||
|
GameUnitConst,
|
||||||
|
Command,
|
||||||
|
MessageTarget,
|
||||||
|
DiplomaticMessage,
|
||||||
|
Message,
|
||||||
|
};
|
||||||
|
|
||||||
|
use function \sammo\{
|
||||||
|
getDomesticExpLevelBonus,
|
||||||
|
CriticalRatioDomestic,
|
||||||
|
CriticalScoreEx,
|
||||||
|
getAllNationStaticInfo,
|
||||||
|
getNationStaticInfo,
|
||||||
|
GetImageURL
|
||||||
|
};
|
||||||
|
|
||||||
|
use \sammo\Constraint\Constraint;
|
||||||
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
|
class che_종전제의 extends Command\NationCommand{
|
||||||
|
static protected $actionName = '종전 제의';
|
||||||
|
static public $reqArg = true;
|
||||||
|
|
||||||
|
protected function argTest():bool{
|
||||||
|
if($this->arg === null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음
|
||||||
|
if(!key_exists('destNationID', $this->arg)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$destNationID = $this->arg['destNationID'];
|
||||||
|
if(!is_int($destNationID)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if($destNationID < 1){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->arg = [
|
||||||
|
'destNationID'=>$destNationID,
|
||||||
|
];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function init(){
|
||||||
|
$general = $this->generalObj;
|
||||||
|
|
||||||
|
$env = $this->env;
|
||||||
|
|
||||||
|
$this->setCity();
|
||||||
|
$this->setNation();
|
||||||
|
|
||||||
|
$this->setDestNation($this->arg['destNationID'], null);
|
||||||
|
|
||||||
|
$this->runnableConstraints=[
|
||||||
|
ConstraintHelper::BeChief(),
|
||||||
|
ConstraintHelper::NotBeNeutral(),
|
||||||
|
ConstraintHelper::OccupiedCity(),
|
||||||
|
ConstraintHelper::SuppliedCity(),
|
||||||
|
ConstraintHelper::ExistsDestNation(),
|
||||||
|
ConstraintHelper::AllowDiplomacyBetweenStatus(
|
||||||
|
[0, 1],
|
||||||
|
'선포, 전쟁중인 상대국에게만 가능합니다.'
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCost():array{
|
||||||
|
return [0, 0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPreReqTurn():int{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPostReqTurn():int{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBrief():string{
|
||||||
|
$commandName = $this->getName();
|
||||||
|
$destNationName = getNationStaticInfo($this->arg['destNationID'])['name'];
|
||||||
|
return "【{$destNationName}】에게 {$commandName}";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function run():bool{
|
||||||
|
if(!$this->isRunnable()){
|
||||||
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
|
$env = $this->env;
|
||||||
|
|
||||||
|
$general = $this->generalObj;
|
||||||
|
$generalName = $general->getName();
|
||||||
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
|
|
||||||
|
$nation = $this->nation;
|
||||||
|
$nationID = $nation['nation'];
|
||||||
|
$nationName = $nation['name'];
|
||||||
|
|
||||||
|
$destNation = $this->destNation;
|
||||||
|
$destNationID = $destNation['nation'];
|
||||||
|
$destNationName = $destNation['name'];
|
||||||
|
|
||||||
|
$logger = $general->getLogger();
|
||||||
|
$destLogger = new ActionLogger(0, $destNationID, $env['year'], $env['month']);
|
||||||
|
|
||||||
|
$logger->pushGeneralActionLog("<D><b>{$destNationName}</b></>으로 종전 제의 서신을 보냈습니다.<1>$date</>");
|
||||||
|
|
||||||
|
// 상대에게 발송
|
||||||
|
$src = new MessageTarget(
|
||||||
|
$general->getID(),
|
||||||
|
$general->getName(),
|
||||||
|
$nationID,
|
||||||
|
$nationName,
|
||||||
|
$nation['color'],
|
||||||
|
GetImageURL($general->getVar('imgsvr'), $general->getVar('picture'))
|
||||||
|
);
|
||||||
|
$dest = new MessageTarget(
|
||||||
|
0,
|
||||||
|
'',
|
||||||
|
$destNationID,
|
||||||
|
$destNationName,
|
||||||
|
$destNation['color']
|
||||||
|
);
|
||||||
|
|
||||||
|
$now = new \DateTime($date);
|
||||||
|
$validUntil = new \DateTime($date);
|
||||||
|
$validMinutes = max(30, $env['turnterm']*3);
|
||||||
|
$validUntil->add(new \DateInterval("PT{$validMinutes}M"));
|
||||||
|
|
||||||
|
$msg = new DiplomaticMessage(
|
||||||
|
Message::MSGTYPE_DIPLOMACY,
|
||||||
|
$src,
|
||||||
|
$dest,
|
||||||
|
"{$nationName}의 종전 제의 서신",
|
||||||
|
$now,
|
||||||
|
$validUntil,
|
||||||
|
[
|
||||||
|
'action'=>DiplomaticMessage::TYPE_STOP_WAR,
|
||||||
|
'deletable'=>false,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$msg->send();
|
||||||
|
|
||||||
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
|
$general->applyDB($db);
|
||||||
|
$destLogger->flush();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getJSFiles(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'js/defaultSelectNationByMap.js'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getForm(): string
|
||||||
|
{
|
||||||
|
$generalObj = $this->generalObj;
|
||||||
|
$nationID = $generalObj->getNationID();
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
|
$diplomacyStatus = Util::convertArrayToDict(
|
||||||
|
$db->query('SELECT * FROM diplomacy WHERE me = %i', $nationID),
|
||||||
|
'you'
|
||||||
|
);
|
||||||
|
|
||||||
|
$nationList = [];
|
||||||
|
foreach(getAllNationStaticInfo() as $destNation){
|
||||||
|
if($destNation['nation'] == $nationID){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!in_array($diplomacyStatus[$destNation['nation']]['state'], [0, 1])){
|
||||||
|
$destNation['cssBgColor'] = 'background-color:red;';
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$destNation['cssBgColor'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$nationList[] = $destNation;
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
?>
|
||||||
|
<?=\sammo\getMapHtml()?><br>
|
||||||
|
전쟁중인 국가에 종전을 제의합니다.<br>
|
||||||
|
제의할 국가를 목록에서 선택하세요.<br>
|
||||||
|
배경색은 현재 제의가 불가능한 국가는 <font color=red>붉은색</font>으로 표시됩니다.<br>
|
||||||
|
<br>
|
||||||
|
<select class='formInput' name="destNationID" id="destNationID" size='1' style='color:white;background-color:black;'>
|
||||||
|
<?php foreach($nationList as $nation): ?>
|
||||||
|
<option
|
||||||
|
value='<?=$nation['nation']?>'
|
||||||
|
style='color:<?=$nation['color']?>;<?=$nation['cssBgColor']?>'
|
||||||
|
>【<?=$nation['name']?> 】</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>에게
|
||||||
|
<input type=button id="commonSubmit" value="<?=$this->getName()?>">
|
||||||
|
<?php
|
||||||
|
return ob_get_clean();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -77,7 +77,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'], 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,
|
||||||
@@ -133,38 +133,24 @@ class DiplomaticMessage extends Message{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function stopWar(){
|
protected function stopWar(){
|
||||||
$helper = new Engine\Diplomacy($this->src->nationID, $this->dest->nationID);
|
$gameStor = KVStorage::getStorage(DB::db(), 'game_env');
|
||||||
$chk = $helper->stopWar();
|
|
||||||
if($chk[0] !== self::ACCEPTED){
|
$destGeneralObj = General::createGeneralObjFromDB($this->dest->generalID, ['picture', 'imgsvr', 'aux'], 1);
|
||||||
return $chk;
|
|
||||||
|
$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, '이');
|
$commandObj->run();
|
||||||
$josaWa = JosaUtil::pick($this->src->nationName, '와');
|
|
||||||
$alllog[] = "<C>●</>{$helper->month}월:<Y>{$this->dest->generalName}</>{$josaYi} <D><b>{$this->src->nationName}</b></>{$josaWa} <M>종전 합의</> 하였습니다.";
|
|
||||||
|
|
||||||
$josaYi = JosaUtil::pick($this->dest->nationName, '이');
|
return [self::ACCEPTED, ''];
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function acceptMerge(){
|
protected function acceptMerge(){
|
||||||
@@ -309,7 +295,7 @@ class DiplomaticMessage extends Message{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($result !== self::ACCEPTED){
|
if($result !== self::ACCEPTED){
|
||||||
pushGenLog($receiverID, ["<C>●</>{$reason} {$this->diplomacyName} 실패."]);
|
pushGenLog($receiverID, ["<C>●</>{$reason}"]);
|
||||||
if($result === self::DECLINED){
|
if($result === self::DECLINED){
|
||||||
$this->_declineMessage();
|
$this->_declineMessage();
|
||||||
}
|
}
|
||||||
@@ -329,12 +315,13 @@ class DiplomaticMessage extends 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}{$this->diplomacyName} 동의.",
|
"【외교】{$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'),
|
||||||
[
|
[
|
||||||
'delete'=>$this->id,
|
'delete'=>$this->id,
|
||||||
'silence'=>true,
|
'silence'=>true,
|
||||||
|
'deletable' => false
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->invalidate();
|
$this->invalidate();
|
||||||
@@ -344,12 +331,13 @@ class DiplomaticMessage extends 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}{$this->diplomacyName} 동의.",
|
"【외교】{$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'),
|
||||||
[
|
[
|
||||||
'delete'=>$this->id,
|
'delete'=>$this->id,
|
||||||
'silence'=>true,
|
'silence'=>true,
|
||||||
|
'deletable' => false
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$newMsg->send();
|
$newMsg->send();
|
||||||
|
|||||||
@@ -294,27 +294,6 @@ class Diplomacy{
|
|||||||
return $chk;
|
return $chk;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stopWar(){
|
|
||||||
$chk = $this->checkValidNation();
|
|
||||||
$chk = $this->checkInWar($chk);
|
|
||||||
|
|
||||||
[$result, $reason] = $chk;
|
|
||||||
if($result !== DiplomaticMessage::ACCEPTED){
|
|
||||||
return $chk;
|
|
||||||
}
|
|
||||||
|
|
||||||
$db = DB::db();
|
|
||||||
$db->update('diplomacy',[
|
|
||||||
'state'=>2,
|
|
||||||
'term'=>0
|
|
||||||
],
|
|
||||||
'(me=%i AND you=%i) OR (you=%i AND me=%i)',
|
|
||||||
$this->srcNation['nation'], $this->destNation['nation'],
|
|
||||||
$this->srcNation['nation'], $this->destNation['nation']);
|
|
||||||
|
|
||||||
return $chk;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function acceptMerge(int $srcGeneral, int $destGeneral){
|
public function acceptMerge(int $srcGeneral, int $destGeneral){
|
||||||
$chk = $this->checkValidNation();
|
$chk = $this->checkValidNation();
|
||||||
$chk = $this->checkDiplomacyLimit($chk);
|
$chk = $this->checkDiplomacyLimit($chk);
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ class GameConstBase
|
|||||||
'che_물자원조',
|
'che_물자원조',
|
||||||
'che_불가침제의',
|
'che_불가침제의',
|
||||||
'che_선전포고',
|
'che_선전포고',
|
||||||
//'che_종전제의',
|
'che_종전제의',
|
||||||
//'che_파기제의',
|
//'che_파기제의',
|
||||||
],
|
],
|
||||||
'특수'=>[
|
'특수'=>[
|
||||||
|
|||||||
+29
-19
@@ -667,36 +667,46 @@ class General implements iAction{
|
|||||||
}
|
}
|
||||||
$updateVals = $this->getUpdatedValues();
|
$updateVals = $this->getUpdatedValues();
|
||||||
|
|
||||||
if(!$updateVals){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$generalID = $this->getID();
|
$generalID = $this->getID();
|
||||||
|
$result = false;
|
||||||
|
|
||||||
$db->update('general', $updateVals, 'no=%i', $generalID);
|
if($updateVals){
|
||||||
if(key_exists('nation', $updateVals)){
|
$db->update('general', $updateVals, 'no=%i', $generalID);
|
||||||
$db->update('rank_data', [
|
$result |= $db->affectedRows() > 0;
|
||||||
'nation_id'=>$updateVals['nation']
|
if(key_exists('nation', $updateVals)){
|
||||||
], 'general_id = %i', $generalID);
|
$db->update('rank_data', [
|
||||||
|
'nation_id'=>$updateVals['nation']
|
||||||
|
], 'general_id = %i', $generalID);
|
||||||
|
$result = true;
|
||||||
|
}
|
||||||
|
$this->flushUpdateValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->rankVarIncrease as $rankKey => $rankVal){
|
if($this->rankVarIncrease){
|
||||||
$db->update('rank_data', [
|
foreach($this->rankVarIncrease as $rankKey => $rankVal){
|
||||||
'value'=>$db->sqleval('value + %i', $rankVal)
|
$db->update('rank_data', [
|
||||||
], 'general_id = %i AND type = %s', $generalID, $rankKey);
|
'value'=>$db->sqleval('value + %i', $rankVal)
|
||||||
|
], 'general_id = %i AND type = %s', $generalID, $rankKey);
|
||||||
|
}
|
||||||
|
$result = true;
|
||||||
}
|
}
|
||||||
foreach($this->rankVarSet as $rankKey => $rankVal){
|
|
||||||
$db->update('rank_data', [
|
if($this->rankVarSet){
|
||||||
'value'=>$rankVal
|
foreach($this->rankVarSet as $rankKey => $rankVal){
|
||||||
], 'general_id = %i AND type = %s', $generalID, $rankKey);
|
$db->update('rank_data', [
|
||||||
$this->rankVarRead[$rankKey] = $rankVal;
|
'value'=>$rankVal
|
||||||
|
], 'general_id = %i AND type = %s', $generalID, $rankKey);
|
||||||
|
$this->rankVarRead[$rankKey] = $rankVal;
|
||||||
|
}
|
||||||
|
$result = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->rankVarIncrease = [];
|
$this->rankVarIncrease = [];
|
||||||
$this->rankVarSet = [];
|
$this->rankVarSet = [];
|
||||||
|
|
||||||
$this->getLogger()->flush();
|
$this->getLogger()->flush();
|
||||||
$this->flushUpdateValues();
|
return $result;
|
||||||
return $db->affectedRows() > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkStatChange():bool{
|
function checkStatChange():bool{
|
||||||
|
|||||||
@@ -2923,6 +2923,9 @@ class GeneralAI
|
|||||||
|
|
||||||
|
|
||||||
$cmd = buildGeneralCommandClass(Util::choiceRandom($candidate), $this->general, $this->env);
|
$cmd = buildGeneralCommandClass(Util::choiceRandom($candidate), $this->general, $this->env);
|
||||||
|
if(!$cmd->isRunnable()){
|
||||||
|
return buildGeneralCommandClass('che_물자조달', $this->general, $this->env);
|
||||||
|
}
|
||||||
return $cmd;
|
return $cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user