arg 경고 회피, 사령부 버그 수정, 턴반복 추가
This commit is contained in:
@@ -74,6 +74,40 @@ function pullGeneralCommand(int $generalID, int $turnCnt=1){
|
|||||||
], 'general_id=%i ORDER BY turn_idx ASC', $generalID);
|
], 'general_id=%i ORDER BY turn_idx ASC', $generalID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function repeatGeneralCommand(int $generalId, int $turnCnt){
|
||||||
|
if($turnCnt <= 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if($turnCnt >= GameConst::$maxTurn){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = DB::db();
|
||||||
|
|
||||||
|
$reqTurn = $turnCnt;
|
||||||
|
if($turnCnt * 2 > GameConst::$maxTurn){
|
||||||
|
$reqTurn = GameConst::$maxTurn - $turnCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
$turnList = $db->query('SELECT turn_idx, `action`, arg, brief FROM general_turn WHERE general_id=%i AND turn_idx < %i', $generalId, $reqTurn);
|
||||||
|
foreach($turnList as $turnItem){
|
||||||
|
$turnIdx = $turnItem['turn_idx'];
|
||||||
|
$nextTurnIdx = $turnIdx+$turnCnt;
|
||||||
|
$turnTarget = [];
|
||||||
|
while($nextTurnIdx < GameConst::$maxTurn){
|
||||||
|
//NOTE: range(15, 24, 12) 가 PHP에선 에러다. 그러니 직접 짠다.
|
||||||
|
$turnTarget[] = $nextTurnIdx;
|
||||||
|
$nextTurnIdx += $turnCnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->update('general_turn', [
|
||||||
|
'action'=>$turnItem['action'],
|
||||||
|
'arg'=>$turnItem['arg'],
|
||||||
|
'brief'=>$turnItem['brief']
|
||||||
|
], 'general_id=%i AND turn_idx IN %li', $generalId, $turnTarget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function pushNationCommand(int $nationID, int $level, int $turnCnt=1){
|
function pushNationCommand(int $nationID, int $level, int $turnCnt=1){
|
||||||
if($nationID == 0){
|
if($nationID == 0){
|
||||||
return;
|
return;
|
||||||
|
|||||||
+8
-1
@@ -11,6 +11,7 @@ $session = Session::requireGameLogin([])->setReadOnly();
|
|||||||
$generalID = $session->generalID;
|
$generalID = $session->generalID;
|
||||||
|
|
||||||
$turnAmount = Util::getReq('amount', 'int');
|
$turnAmount = Util::getReq('amount', 'int');
|
||||||
|
$isRepeat = Util::getReq('is_repeat', 'bool', false);
|
||||||
|
|
||||||
if($turnAmount == null){
|
if($turnAmount == null){
|
||||||
Json::die([
|
Json::die([
|
||||||
@@ -26,7 +27,13 @@ if(abs($turnAmount) >= GameConst::$maxTurn){
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
pushGeneralCommand($generalID, $turnAmount);
|
if($isRepeat){
|
||||||
|
repeatGeneralCommand($generalID, $turnAmount);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
pushGeneralCommand($generalID, $turnAmount);
|
||||||
|
}
|
||||||
|
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'reason'=>'success',
|
'reason'=>'success',
|
||||||
|
|||||||
@@ -75,10 +75,9 @@ function reloadTable(){
|
|||||||
var turnTimeObj = moment(chiefInfo.turnTime);
|
var turnTimeObj = moment(chiefInfo.turnTime);
|
||||||
var turnList = plateObj.turn;
|
var turnList = plateObj.turn;
|
||||||
$.each(chiefInfo.turn, function(turnIdx, turnText){
|
$.each(chiefInfo.turn, function(turnIdx, turnText){
|
||||||
turnTimeObj = turnTimeObj.add(turnTerm, 'minute');
|
|
||||||
turnList[turnIdx].turnTime.text(turnTimeObj.format('hh:mm'));
|
turnList[turnIdx].turnTime.text(turnTimeObj.format('hh:mm'));
|
||||||
turnList[turnIdx].turnText.text(turnText);
|
turnList[turnIdx].turnText.text(turnText);
|
||||||
|
turnTimeObj = turnTimeObj.add(turnTerm, 'minute');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,22 @@ function pushTurn(pushAmount){
|
|||||||
}, errUnknown);
|
}, errUnknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function repeatTurn(repeatAmount){
|
||||||
|
$.post({
|
||||||
|
url:'j_turn.php',
|
||||||
|
dataType:'json',
|
||||||
|
data:{
|
||||||
|
amount:repeatAmount,
|
||||||
|
is_repeat:true
|
||||||
|
}
|
||||||
|
}).then(function(data){
|
||||||
|
if(!data.result){
|
||||||
|
alert(data.reason);
|
||||||
|
}
|
||||||
|
reloadCommandList();
|
||||||
|
}, errUnknown);
|
||||||
|
}
|
||||||
|
|
||||||
$('#pullTurn').click(function(){
|
$('#pullTurn').click(function(){
|
||||||
pushTurn(-parseInt($('#repeatAmount').val()));
|
pushTurn(-parseInt($('#repeatAmount').val()));
|
||||||
});
|
});
|
||||||
@@ -84,6 +100,10 @@ $('#pushTurn').click(function(){
|
|||||||
pushTurn(parseInt($('#repeatAmount').val()));
|
pushTurn(parseInt($('#repeatAmount').val()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#repeatTurn').click(function(){
|
||||||
|
repeatTurn(parseInt($('#repeatAmount').val()));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
function reserveTurn(turnList, command){
|
function reserveTurn(turnList, command){
|
||||||
console.log(turnList, command);
|
console.log(turnList, command);
|
||||||
|
|||||||
@@ -184,28 +184,28 @@ class che_증여 extends Command\GeneralCommand{
|
|||||||
<option value="false">쌀</option>
|
<option value="false">쌀</option>
|
||||||
</select>
|
</select>
|
||||||
<select class='formInput' name="amount" id="amount" size='1' style='color:white;background-color:black;'>
|
<select class='formInput' name="amount" id="amount" size='1' style='color:white;background-color:black;'>
|
||||||
<option value=1>100</option>
|
<option value=100>100</option>
|
||||||
<option value=2>200</option>
|
<option value=200>200</option>
|
||||||
<option value=3>300</option>
|
<option value=300>300</option>
|
||||||
<option value=4>400</option>
|
<option value=400>400</option>
|
||||||
<option value=5>500</option>
|
<option value=500>500</option>
|
||||||
<option value=6>600</option>
|
<option value=600>600</option>
|
||||||
<option value=7>700</option>
|
<option value=700>700</option>
|
||||||
<option value=8>800</option>
|
<option value=800>800</option>
|
||||||
<option value=9>900</option>
|
<option value=900>900</option>
|
||||||
<option value=10>1000</option>
|
<option value=1000>1000</option>
|
||||||
<option value=12>1200</option>
|
<option value=1200>1200</option>
|
||||||
<option value=15>1500</option>
|
<option value=1500>1500</option>
|
||||||
<option value=20>2000</option>
|
<option value=2000>2000</option>
|
||||||
<option value=25>2500</option>
|
<option value=2500>2500</option>
|
||||||
<option value=30>3000</option>
|
<option value=3000>3000</option>
|
||||||
<option value=40>4000</option>
|
<option value=4000>4000</option>
|
||||||
<option value=50>5000</option>
|
<option value=5000>5000</option>
|
||||||
<option value=60>6000</option>
|
<option value=6000>6000</option>
|
||||||
<option value=70>7000</option>
|
<option value=7000>7000</option>
|
||||||
<option value=80>8000</option>
|
<option value=8000>8000</option>
|
||||||
<option value=90>9000</option>
|
<option value=9000>9000</option>
|
||||||
<option value=100>10000</option>
|
<option value=10000>10000</option>
|
||||||
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
|
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
|
||||||
<?php
|
<?php
|
||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ class che_몰수 extends Command\NationCommand{
|
|||||||
static public $reqArg = true;
|
static public $reqArg = true;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
|
if($this->arg === null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//NOTE: 사망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
|
//NOTE: 사망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
|
||||||
if(!key_exists('isGold', $this->arg)){
|
if(!key_exists('isGold', $this->arg)){
|
||||||
return false;
|
return false;
|
||||||
@@ -73,7 +76,7 @@ class che_몰수 extends Command\NationCommand{
|
|||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation(['gold', 'rice']);
|
$this->setNation(['gold', 'rice']);
|
||||||
|
|
||||||
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'npc', 'nation'], 1);
|
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'npc', 'nation', 'imgsvr', 'picture'], 1);
|
||||||
$this->setDestGeneral($destGeneral);
|
$this->setDestGeneral($destGeneral);
|
||||||
|
|
||||||
$relYear = $env['year'] - $env['startyear'];
|
$relYear = $env['year'] - $env['startyear'];
|
||||||
@@ -131,7 +134,12 @@ class che_몰수 extends Command\NationCommand{
|
|||||||
$resName = $isGold?'금':'쌀';
|
$resName = $isGold?'금':'쌀';
|
||||||
$destGeneral = $this->destGeneralObj;
|
$destGeneral = $this->destGeneralObj;
|
||||||
|
|
||||||
$amount = Util::valueFit($amount, 0, ($general->getVar($resKey)- $isGold?GameConst::$generalMinimumGold:GameConst::$generalMinimumRice));
|
$amount = Util::valueFit(
|
||||||
|
$amount,
|
||||||
|
0,
|
||||||
|
($destGeneral->getVar($resKey) -
|
||||||
|
($isGold?GameConst::$generalMinimumGold:GameConst::$generalMinimumRice))
|
||||||
|
);
|
||||||
$amountText = number_format($amount, 0);
|
$amountText = number_format($amount, 0);
|
||||||
|
|
||||||
if($destGeneral->getVar('npc') >= 2 && Util::randBool(0.01)){
|
if($destGeneral->getVar('npc') >= 2 && Util::randBool(0.01)){
|
||||||
@@ -144,12 +152,12 @@ class che_몰수 extends Command\NationCommand{
|
|||||||
];
|
];
|
||||||
$text = Util::choiceRandom($npcTexts);
|
$text = Util::choiceRandom($npcTexts);
|
||||||
$src = new MessageTarget(
|
$src = new MessageTarget(
|
||||||
$general->getID(),
|
$destGeneral->getID(),
|
||||||
$general->getName(),
|
$destGeneral->getName(),
|
||||||
$nationID,
|
$nationID,
|
||||||
$nation['name'],
|
$nation['name'],
|
||||||
$nation['color'],
|
$nation['color'],
|
||||||
GetImageURL($general->getVar('imgsvr'), $general->getVar('picture'))
|
GetImageURL($destGeneral->getVar('imgsvr'), $destGeneral->getVar('picture'))
|
||||||
);
|
);
|
||||||
$msg = new Message(
|
$msg = new Message(
|
||||||
Message::MSGTYPE_PUBLIC,
|
Message::MSGTYPE_PUBLIC,
|
||||||
@@ -165,7 +173,7 @@ class che_몰수 extends Command\NationCommand{
|
|||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
|
|
||||||
$destGeneral->increaseVarWithLimit($resKey, -$amount);
|
$destGeneral->increaseVarWithLimit($resKey, -$amount, 0);
|
||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
$resKey=>$db->sqleval('%b + %i', $resKey, $amount)
|
$resKey=>$db->sqleval('%b + %i', $resKey, $amount)
|
||||||
], 'nation=%i', $nationID);
|
], 'nation=%i', $nationID);
|
||||||
@@ -228,7 +236,7 @@ class che_몰수 extends Command\NationCommand{
|
|||||||
</select>
|
</select>
|
||||||
<select class='formInput' name="amount" id="amount" size='1' style='color:white;background-color:black;'>
|
<select class='formInput' name="amount" id="amount" size='1' style='color:white;background-color:black;'>
|
||||||
<?php foreach($amountList as $amount): ?>
|
<?php foreach($amountList as $amount): ?>
|
||||||
<option value='<?=$amount?>'><?=$amount?>00</option>
|
<option value='<?=$amount?>00'><?=$amount?>00</option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
|
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ class che_발령 extends Command\NationCommand{
|
|||||||
static public $reqArg = true;
|
static public $reqArg = true;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
|
if($this->arg === null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//NOTE: 사망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
|
//NOTE: 사망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
|
||||||
if(!key_exists('destGeneralID', $this->arg)){
|
if(!key_exists('destGeneralID', $this->arg)){
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -8,13 +8,17 @@ use \sammo\{
|
|||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command
|
Command,
|
||||||
|
MessageTarget,
|
||||||
|
DiplomaticMessage,
|
||||||
|
Message,
|
||||||
};
|
};
|
||||||
|
|
||||||
use function \sammo\{
|
use function \sammo\{
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx
|
CriticalScoreEx,
|
||||||
|
GetImageURL
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
@@ -25,6 +29,9 @@ class che_불가침제의 extends Command\NationCommand{
|
|||||||
static public $reqArg = true;
|
static public $reqArg = true;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
|
if($this->arg === null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음
|
//NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음
|
||||||
if(!key_exists('destNationID', $this->arg)){
|
if(!key_exists('destNationID', $this->arg)){
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ class che_선전포고 extends Command\NationCommand{
|
|||||||
static public $reqArg = true;
|
static public $reqArg = true;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
|
if($this->arg === null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음
|
//NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음
|
||||||
if(!key_exists('destNationID', $this->arg)){
|
if(!key_exists('destNationID', $this->arg)){
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ class che_포상 extends Command\NationCommand{
|
|||||||
static public $reqArg = true;
|
static public $reqArg = true;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
|
if($this->arg === null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//NOTE: 사망 직전에 '포상' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
|
//NOTE: 사망 직전에 '포상' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
|
||||||
if(!key_exists('isGold', $this->arg)){
|
if(!key_exists('isGold', $this->arg)){
|
||||||
return false;
|
return false;
|
||||||
@@ -201,7 +204,7 @@ class che_포상 extends Command\NationCommand{
|
|||||||
</select>
|
</select>
|
||||||
<select class='formInput' name="amount" id="amount" size='1' style='color:white;background-color:black;'>
|
<select class='formInput' name="amount" id="amount" size='1' style='color:white;background-color:black;'>
|
||||||
<?php foreach($amountList as $amount): ?>
|
<?php foreach($amountList as $amount): ?>
|
||||||
<option value='<?=$amount?>'><?=$amount?>00</option>
|
<option value='<?=$amount?>00'><?=$amount?>00</option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
|
</select> <input type=button id="commonSubmit" value="<?=$this->getName()?>"><br>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@@ -765,7 +765,7 @@ class GeneralAI{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($compNpcWar && $compNpcWar->$resName < 21000){
|
if($compNpcWar && $compNpcWar->$resName < 21000){
|
||||||
$amount = min(100, intdiv(($nation[$resName]-($resName=='rice'?(GameConst::$baserice):(GameConst::$basegold))), 5000)*10 + 10);
|
$amount = min(100, intdiv(($nation[$resName]-($resName=='rice'?(GameConst::$baserice):(GameConst::$basegold))), 5000)*10 + 10)*100;
|
||||||
$commandList[] = [['che_몰수', [
|
$commandList[] = [['che_몰수', [
|
||||||
'destGeneralID'=>$compNpcWar->no,
|
'destGeneralID'=>$compNpcWar->no,
|
||||||
'isGold'=>$resName=='gold',
|
'isGold'=>$resName=='gold',
|
||||||
|
|||||||
Reference in New Issue
Block a user