사령턴 수행용 '지난턴' 추가
This commit is contained in:
@@ -2,5 +2,13 @@
|
|||||||
namespace sammo\Command;
|
namespace sammo\Command;
|
||||||
|
|
||||||
abstract class NationCommand extends BaseCommand{
|
abstract class NationCommand extends BaseCommand{
|
||||||
|
protected $lastTurn;
|
||||||
|
|
||||||
|
public function setLast($lastTurn){
|
||||||
|
$this->lastTurn = $lastTurn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLast():array{
|
||||||
|
return $this->lastTurn;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
@@ -7,7 +7,7 @@ use sammo\DB;
|
|||||||
use sammo\Util;
|
use sammo\Util;
|
||||||
use sammo\JosaUtil;
|
use sammo\JosaUtil;
|
||||||
|
|
||||||
class che_강제소집해제 extends BaseGeneralTrigger{
|
class che_병력군량소모 extends BaseGeneralTrigger{
|
||||||
static protected $priority = 50000;
|
static protected $priority = 50000;
|
||||||
|
|
||||||
public function action(?array $env=null, $arg=null):?array{
|
public function action(?array $env=null, $arg=null):?array{
|
||||||
@@ -26,8 +26,9 @@ class che_강제소집해제 extends BaseGeneralTrigger{
|
|||||||
$general->getLogger()->pushGeneralActionLog(
|
$general->getLogger()->pushGeneralActionLog(
|
||||||
'군량이 모자라 병사들이 <R>소집해제</>되었습니다!', ActionLogger::PLAIN
|
'군량이 모자라 병사들이 <R>소집해제</>되었습니다!', ActionLogger::PLAIN
|
||||||
);
|
);
|
||||||
|
$general->activateSkill('pre.소집해제');
|
||||||
}
|
}
|
||||||
$general->activateSkill('pre.소집해제');
|
$general->activateSkill('pre.병력군량소모');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $env;
|
return $env;
|
||||||
@@ -8,7 +8,7 @@ use sammo\Util;
|
|||||||
use sammo\JosaUtil;
|
use sammo\JosaUtil;
|
||||||
|
|
||||||
class che_부상경감 extends BaseGeneralTrigger{
|
class che_부상경감 extends BaseGeneralTrigger{
|
||||||
static protected $priority = 30000;
|
static protected $priority = 30010;
|
||||||
|
|
||||||
public function action(?array $env=null, $arg=null):?array{
|
public function action(?array $env=null, $arg=null):?array{
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class TurnExecutionHelper
|
|||||||
protected $generalObj;
|
protected $generalObj;
|
||||||
protected $turn = null;
|
protected $turn = null;
|
||||||
protected $nationTurn = null;
|
protected $nationTurn = null;
|
||||||
|
protected $lastNationTurn = null;
|
||||||
|
|
||||||
public function __construct(array $rawGeneral, array $turn, ?array $nationTurn, int $year, int $month)
|
public function __construct(array $rawGeneral, array $turn, ?array $nationTurn, int $year, int $month)
|
||||||
{
|
{
|
||||||
@@ -37,22 +38,59 @@ class TurnExecutionHelper
|
|||||||
$caller = $general->getPreTurnExecuteTriggerList($general);
|
$caller = $general->getPreTurnExecuteTriggerList($general);
|
||||||
$caller->merge(new GeneralTriggerCaller([
|
$caller->merge(new GeneralTriggerCaller([
|
||||||
new GeneralTrigger\che_부상경감($general),
|
new GeneralTrigger\che_부상경감($general),
|
||||||
new GeneralTrigger\che_강제소집해제($general),
|
new GeneralTrigger\che_병력군량소모($general),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$caller->fire();
|
$caller->fire();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processNationCommand(){
|
public function processBlocked():bool{
|
||||||
|
$general = $this->getGeneral();
|
||||||
|
|
||||||
|
$blocked = $general->getVar('block');
|
||||||
|
if($blocked < 2){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$date = substr($general->getVar('turntime'),11,5);
|
||||||
|
$logger = $general->getLogger();
|
||||||
|
if($blocked == 2){
|
||||||
|
$general->increaseVarWithLimit('killturn', -1, 0);
|
||||||
|
$logger->pushGeneralActionLog("현재 멀티, 또는 비매너로 인한<R>블럭</> 대상자입니다. <1>$date</>");
|
||||||
|
}
|
||||||
|
else if($blocked == 3){
|
||||||
|
$general->increaseVarWithLimit('killturn', -1, 0);
|
||||||
|
$logger->pushGeneralActionLog("현재 악성유저로 분류되어 <R>블럭</> 대상자입니다. <1>$date</>");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//Hmm?
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processNationCommand():array{
|
||||||
if(!$this->nationTurn){
|
if(!$this->nationTurn){
|
||||||
return;
|
throw new \InvalidArgumentException('nationTurn이 없음');
|
||||||
}
|
}
|
||||||
$general = $this->getGeneral();
|
$general = $this->getGeneral();
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
[$commandClassName, $commandArg] = $this->nationTurn;
|
[$commandClassName, $commandArg, $commandLast] = $this->nationTurn;
|
||||||
|
|
||||||
|
if(!$commandLast){
|
||||||
|
//doNothing
|
||||||
|
}
|
||||||
|
else if($commandLast['command'] != $commandClassName){
|
||||||
|
$commandLast = [];
|
||||||
|
}
|
||||||
|
else if($commandLast['arg'] != $commandArg){
|
||||||
|
$commandLast = [];
|
||||||
|
}
|
||||||
|
|
||||||
$commandClass = getNationCommandClass($commandClassName);
|
$commandClass = getNationCommandClass($commandClassName);
|
||||||
/** @var \sammo\Command\NationCommand $commandObj */
|
/** @var \sammo\Command\NationCommand $commandObj */
|
||||||
$commandObj = new $commandClass($general, $gameStor->getAll(true), $commandArg);
|
$commandObj = new $commandClass($general, $gameStor->getAll(true), $commandArg);
|
||||||
@@ -63,10 +101,15 @@ class TurnExecutionHelper
|
|||||||
$commandName = $commandObj->getName();
|
$commandName = $commandObj->getName();
|
||||||
$text = "{$failReason} {$commandName} 실패. <1>{$date}</>";
|
$text = "{$failReason} {$commandName} 실패. <1>{$date}</>";
|
||||||
$general->getLogger()->pushGeneralActionLog($text);
|
$general->getLogger()->pushGeneralActionLog($text);
|
||||||
|
|
||||||
|
$commandLast = [];
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$commandObj->run();
|
$commandObj->run();
|
||||||
|
$commandLast = $commandObj->getLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $commandLast;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processCommand(){
|
public function processCommand(){
|
||||||
@@ -178,19 +221,27 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
|
|||||||
|
|
||||||
$nationTurn = null;
|
$nationTurn = null;
|
||||||
if($generalWork['nation'] != 0 && $generalWork['level'] >= 5){
|
if($generalWork['nation'] != 0 && $generalWork['level'] >= 5){
|
||||||
|
$nationStor = KVStorage::getStorage($db, 'nation_env');
|
||||||
|
$lastNationTurnKey = "turn_last_{$generalWork['nation']}_{$generalWork['level']}";
|
||||||
|
$lastNationTurn = $nationStor->getDBValue($lastNationTurnKey)??[];
|
||||||
//수뇌 몇 없는데 매번 left join 하는건 낭비인것 같다.
|
//수뇌 몇 없는데 매번 left join 하는건 낭비인것 같다.
|
||||||
$rawNationTurn = $db->queryFirstRow(
|
$rawNationTurn = $db->queryFirstRow(
|
||||||
'SELECT action, arg FROM nation_turn WHERE nation_id = %i AND level = %i AND turn_idx =0',
|
'SELECT action, arg FROM nation_turn WHERE nation_id = %i AND level = %i AND turn_idx =0',
|
||||||
$generalWork['nation'],
|
$generalWork['nation'],
|
||||||
$generalWork['level']
|
$generalWork['level']
|
||||||
);
|
);
|
||||||
$nationTurn = [$rawNationTurn['action'], Json::decode($rawNationTurn['arg'])];
|
$nationTurn = [$rawNationTurn['action'], Json::decode($rawNationTurn['arg']), $lastNationTurn];
|
||||||
}
|
}
|
||||||
|
|
||||||
$turnObj = new static($generalWork, $turn, $nationTurn, $year, $month);
|
$turnObj = new static($generalWork, $turn, $nationTurn, $year, $month);
|
||||||
$turnObj->preprocessCommand();
|
if(!$turnObj->processBlocked()){
|
||||||
$turnObj->processNationCommand();
|
$turnObj->preprocessCommand();
|
||||||
$turnObj->processCommand();
|
if($nationTurn){
|
||||||
|
$lastNationTurn = $turnObj->processNationCommand();
|
||||||
|
$nationStor->setValue($lastNationTurnKey, $lastNationTurn);
|
||||||
|
}
|
||||||
|
$turnObj->processCommand();
|
||||||
|
}
|
||||||
pullNationCommand($generalWork['nation'], $generalWork['level']);
|
pullNationCommand($generalWork['nation'], $generalWork['level']);
|
||||||
pullGeneralCommand($generalWork['no']);
|
pullGeneralCommand($generalWork['no']);
|
||||||
$turnObj->updateTurntime();
|
$turnObj->updateTurntime();
|
||||||
@@ -209,8 +260,6 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
|
|||||||
|
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
|
|
||||||
DB::db();
|
|
||||||
|
|
||||||
if(!tryLock()){
|
if(!tryLock()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -262,7 +311,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
|
|||||||
throw new \RuntimeException('preUpdateMonthly() 처리 에러');
|
throw new \RuntimeException('preUpdateMonthly() 처리 에러');
|
||||||
}
|
}
|
||||||
|
|
||||||
[$gameStor->year, $gameStor->month] = turnDate($nextTurn);
|
turnDate($nextTurn);
|
||||||
|
|
||||||
// 이벤트 핸들러 동작
|
// 이벤트 핸들러 동작
|
||||||
foreach (DB::db()->query('SELECT * from event') as $rawEvent) {
|
foreach (DB::db()->query('SELECT * from event') as $rawEvent) {
|
||||||
@@ -312,13 +361,18 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
|
|||||||
// 이시각까지는 업데이트 완료했음
|
// 이시각까지는 업데이트 완료했음
|
||||||
$gameStor->turntime = $prevTurn;
|
$gameStor->turntime = $prevTurn;
|
||||||
// 그 시각 년도,월 저장
|
// 그 시각 년도,월 저장
|
||||||
[$gameStor->year, $gameStor->month] = turnDate($prevTurn);
|
turnDate($prevTurn);
|
||||||
// 현재시간의 월턴시간 이후 분단위 장수 처리
|
// 현재시간의 월턴시간 이후 분단위 장수 처리
|
||||||
|
|
||||||
[$executionOver, $currentTurn] = static::executeGeneralCommandUntil(
|
[$executionOver, $currentTurn] = static::executeGeneralCommandUntil(
|
||||||
$nextTurn, $limitActionTime, $gameStor->year, $gameStor->month
|
$nextTurn, $limitActionTime, $gameStor->year, $gameStor->month
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if($currentTurn !== null){
|
||||||
|
$gameStor->turntime = $currentTurn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 부상 과도 제한
|
// 부상 과도 제한
|
||||||
//TODO: 없애고, 부상 자체가 80 이상 넘지 않도록 처리
|
//TODO: 없애고, 부상 자체가 80 이상 넘지 않도록 처리
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
|
|||||||
Reference in New Issue
Block a user