phan 처리
This commit is contained in:
+1
-1
@@ -15,7 +15,7 @@ return [
|
|||||||
// Note that the **only** effect of choosing `'5.6'` is to infer
|
// Note that the **only** effect of choosing `'5.6'` is to infer
|
||||||
// that functions removed in php 7.0 exist.
|
// that functions removed in php 7.0 exist.
|
||||||
// (See `backward_compatibility_checks` for additional options)
|
// (See `backward_compatibility_checks` for additional options)
|
||||||
"target_php_version" => '8.0',
|
"target_php_version" => '7.3',
|
||||||
'backward_compatibility_checks ' => false,
|
'backward_compatibility_checks ' => false,
|
||||||
'minimum_severity'=>\Phan\Issue::SEVERITY_NORMAL,
|
'minimum_severity'=>\Phan\Issue::SEVERITY_NORMAL,
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ if ($con >= 2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch ($admin['tnmt_type']) {
|
switch ($admin['tnmt_type']) {
|
||||||
default: throw new \RuntimeException('Invalid tnmt_type');break;
|
default: throw new \RuntimeException('Invalid tnmt_type');
|
||||||
case 0: $tnmt_type = "<font color=cyan>전력전</font>"; $tp = "total"; $tp2 = "종합"; $tp3 = "total"; break;
|
case 0: $tnmt_type = "<font color=cyan>전력전</font>"; $tp = "total"; $tp2 = "종합"; $tp3 = "total"; break;
|
||||||
case 1: $tnmt_type = "<font color=cyan>통솔전</font>"; $tp = "leadership"; $tp2 = "통솔"; $tp3 = "leadership"; break;
|
case 1: $tnmt_type = "<font color=cyan>통솔전</font>"; $tp = "leadership"; $tp2 = "통솔"; $tp3 = "leadership"; break;
|
||||||
case 2: $tnmt_type = "<font color=cyan>일기토</font>"; $tp = "strength"; $tp2 = "무력"; $tp3 = "strength"; break;
|
case 2: $tnmt_type = "<font color=cyan>일기토</font>"; $tp = "strength"; $tp2 = "무력"; $tp3 = "strength"; break;
|
||||||
|
|||||||
+2
-2
@@ -88,9 +88,9 @@ $me->applyDB($db);
|
|||||||
if($gameStor->turntime <= $gameStor->opentime){
|
if($gameStor->turntime <= $gameStor->opentime){
|
||||||
//서버 가오픈시 할 수 있는 행동
|
//서버 가오픈시 할 수 있는 행동
|
||||||
|
|
||||||
if($me['npc'] == 0){
|
if($me->getVar('npc') == 0){
|
||||||
$showDieImmediatelyBtn = true;
|
$showDieImmediatelyBtn = true;
|
||||||
if(addTurn($me['lastrefresh'], $gameStor->turnterm, 2) <= TimeUtil::DatetimeNow()){
|
if(addTurn($me->getVar('lastrefresh'), $gameStor->turnterm, 2) <= TimeUtil::now()){
|
||||||
$availableDieImmediately = true;
|
$availableDieImmediately = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ $gameStor->cacheValues(['turnterm', 'opentime', 'turntime', 'year', 'month']);
|
|||||||
|
|
||||||
if($gameStor->turntime <= $gameStor->opentime){
|
if($gameStor->turntime <= $gameStor->opentime){
|
||||||
//서버 가오픈시 할 수 있는 행동
|
//서버 가오픈시 할 수 있는 행동
|
||||||
if(addTurn($general['lastrefresh'], $gameStor->turnterm, 2) <= TimeUtil::DatetimeNow()){
|
if(addTurn($general['lastrefresh'], $gameStor->turnterm, 2) <= TimeUtil::now()){
|
||||||
$availableDieImmediately = true;
|
$availableDieImmediately = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -331,7 +331,7 @@ function checkSecretMaxPermission($penalty){
|
|||||||
return $secretMax;
|
return $secretMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkSecretPermission($me, $checkSecretLimit=true){
|
function checkSecretPermission(array $me, $checkSecretLimit=true){
|
||||||
if(!key_exists('penalty', $me) || !key_exists('permission', $me)){
|
if(!key_exists('penalty', $me) || !key_exists('permission', $me)){
|
||||||
trigger_error ('canAccessSecret() 함수에 필요한 인자가 부족');
|
trigger_error ('canAccessSecret() 함수에 필요한 인자가 부족');
|
||||||
}
|
}
|
||||||
@@ -1656,7 +1656,7 @@ function nextRuler(General $general) {
|
|||||||
|
|
||||||
|
|
||||||
if(!$candidate){
|
if(!$candidate){
|
||||||
DeleteConflict($general['nation']);
|
DeleteConflict($general->getNationID());
|
||||||
deleteNation($general);
|
deleteNation($general);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace sammo;
|
|||||||
/**
|
/**
|
||||||
* 내정 커맨드 사용시 성공 확률 계산
|
* 내정 커맨드 사용시 성공 확률 계산
|
||||||
*
|
*
|
||||||
* @param array $general 장수 정보
|
* @param General $general 장수 정보
|
||||||
* @param string $type 내정 커맨드 타입, 'leadership' = 통솔 기반, 'strength' = 무력 기반, 'intel' = 지력 기반
|
* @param string $type 내정 커맨드 타입, 'leadership' = 통솔 기반, 'strength' = 무력 기반, 'intel' = 지력 기반
|
||||||
*
|
*
|
||||||
* @return array 계산된 실패, 성공 확률 ('success' => 성공 확률, 'fail' => 실패 확률)
|
* @return array 계산된 실패, 성공 확률 ('success' => 성공 확률, 'fail' => 실패 확률)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ function processTournament() {
|
|||||||
case 5: $unit = 30; break;
|
case 5: $unit = 30; break;
|
||||||
case 6: $unit = 15; break;
|
case 6: $unit = 15; break;
|
||||||
case 7: $unit = 5; break;
|
case 7: $unit = 5; break;
|
||||||
|
default: throw new MustNotBeReachedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
//업데이트 횟수
|
//업데이트 횟수
|
||||||
@@ -617,6 +618,7 @@ function finalFight($tnmt_type, $tnmt, $phase, $type) {
|
|||||||
case 8: $offset = 30; $turn = 3; $next = 8; break;
|
case 8: $offset = 30; $turn = 3; $next = 8; break;
|
||||||
case 4: $offset = 40; $turn = 1; $next = 9; break;
|
case 4: $offset = 40; $turn = 1; $next = 9; break;
|
||||||
case 2: $offset = 50; $turn = 0; $next = 0; break;
|
case 2: $offset = 50; $turn = 0; $next = 0; break;
|
||||||
|
default: throw new MustNotBeReachedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$grp = $phase + $offset;
|
$grp = $phase + $offset;
|
||||||
@@ -662,6 +664,7 @@ function setGift($tnmt_type, $tnmt, $phase) {
|
|||||||
case 1: $tp = "통솔전"; $tp2 = "tl"; break;
|
case 1: $tp = "통솔전"; $tp2 = "tl"; break;
|
||||||
case 2: $tp = "일기토"; $tp2 = "ts"; break;
|
case 2: $tp = "일기토"; $tp2 = "ts"; break;
|
||||||
case 3: $tp = "설전"; $tp2 = "ti"; break;
|
case 3: $tp = "설전"; $tp2 = "ti"; break;
|
||||||
|
default: throw new MustNotBeReachedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
//16강자 명성 돈
|
//16강자 명성 돈
|
||||||
@@ -1120,6 +1123,7 @@ function fight($tnmt_type, $tnmt, $phs, $group, $g1, $g2, $type) {
|
|||||||
$gen1resKey = 'd';
|
$gen1resKey = 'd';
|
||||||
$gen2resKey = 'd';
|
$gen2resKey = 'd';
|
||||||
break;
|
break;
|
||||||
|
default: new MustNotBeReachedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->update('rank_data', [
|
$db->update('rank_data', [
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ if(in_array($stateOpt, ['try_destroy_src', 'try_destroy_dest'])){
|
|||||||
'aux'=>Json::encode($aux)
|
'aux'=>Json::encode($aux)
|
||||||
], 'no=%i', $letterNo);
|
], 'no=%i', $letterNo);
|
||||||
while(true){
|
while(true){
|
||||||
$deleteLetter = $db->queryFirstRow('SELECT prev_no, aux FROM ng_diplomacy WHERE no = %i AND state = \'replaced\'', $currentLetterNo);
|
$deleteLetter = $db->queryFirstRow('SELECT prev_no, aux FROM ng_diplomacy WHERE no = %i AND state = \'replaced\'', $letterNo);
|
||||||
if(!$deleteLetter){
|
if(!$deleteLetter){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace sammo\ActionNationType;
|
namespace sammo\ActionNationType;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
|
use \sammo\Util;
|
||||||
|
|
||||||
class che_덕가 extends \sammo\BaseNation{
|
class che_덕가 extends \sammo\BaseNation{
|
||||||
|
|
||||||
@@ -30,10 +31,10 @@ class che_덕가 extends \sammo\BaseNation{
|
|||||||
|
|
||||||
public function onCalcNationalIncome(string $type, int $amount):int{
|
public function onCalcNationalIncome(string $type, int $amount):int{
|
||||||
if($type == 'rice'){
|
if($type == 'rice'){
|
||||||
return $amount * 0.9;
|
return Util::toInt($amount * 0.9);
|
||||||
}
|
}
|
||||||
if($type == 'pop'){
|
if($type == 'pop'){
|
||||||
return $amount * 1.2;
|
return Util::toInt($amount * 1.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
return $amount;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace sammo\ActionNationType;
|
namespace sammo\ActionNationType;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
|
use \sammo\Util;
|
||||||
|
|
||||||
class che_도가 extends \sammo\BaseNation{
|
class che_도가 extends \sammo\BaseNation{
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ class che_도가 extends \sammo\BaseNation{
|
|||||||
|
|
||||||
public function onCalcNationalIncome(string $type, int $amount):int{
|
public function onCalcNationalIncome(string $type, int $amount):int{
|
||||||
if($type == 'pop'){
|
if($type == 'pop'){
|
||||||
return $amount * 1.2;
|
return Util::toInt($amount * 1.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
return $amount;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace sammo\ActionNationType;
|
namespace sammo\ActionNationType;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
|
use \sammo\Util;
|
||||||
|
|
||||||
class che_도적 extends \sammo\BaseNation{
|
class che_도적 extends \sammo\BaseNation{
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ class che_도적 extends \sammo\BaseNation{
|
|||||||
|
|
||||||
public function onCalcNationalIncome(string $type, int $amount):int{
|
public function onCalcNationalIncome(string $type, int $amount):int{
|
||||||
if($type == 'gold'){
|
if($type == 'gold'){
|
||||||
return $amount * 0.9;
|
return Util::toInt($amount * 0.9);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
return $amount;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace sammo\ActionNationType;
|
namespace sammo\ActionNationType;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
|
use \sammo\Util;
|
||||||
|
|
||||||
class che_명가 extends \sammo\BaseNation{
|
class che_명가 extends \sammo\BaseNation{
|
||||||
|
|
||||||
@@ -26,10 +27,10 @@ class che_명가 extends \sammo\BaseNation{
|
|||||||
|
|
||||||
public function onCalcNationalIncome(string $type, int $amount):int{
|
public function onCalcNationalIncome(string $type, int $amount):int{
|
||||||
if($type == 'rice'){
|
if($type == 'rice'){
|
||||||
return $amount * 0.9;
|
return Util::toInt($amount * 0.9);
|
||||||
}
|
}
|
||||||
if($type == 'pop'){
|
if($type == 'pop'){
|
||||||
return $amount * 1.2;
|
return Util::toInt($amount * 1.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
return $amount;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace sammo\ActionNationType;
|
namespace sammo\ActionNationType;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
|
use \sammo\Util;
|
||||||
|
|
||||||
class che_법가 extends \sammo\BaseNation{
|
class che_법가 extends \sammo\BaseNation{
|
||||||
|
|
||||||
@@ -26,10 +27,10 @@ class che_법가 extends \sammo\BaseNation{
|
|||||||
|
|
||||||
public function onCalcNationalIncome(string $type, int $amount):int{
|
public function onCalcNationalIncome(string $type, int $amount):int{
|
||||||
if($type == 'gold'){
|
if($type == 'gold'){
|
||||||
return $amount * 1.1;
|
return Util::toInt($amount * 1.1);
|
||||||
}
|
}
|
||||||
if($type == 'pop'){
|
if($type == 'pop'){
|
||||||
return $amount * 0.8;
|
return Util::toInt($amount * 0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
return $amount;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace sammo\ActionNationType;
|
namespace sammo\ActionNationType;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
|
use \sammo\Util;
|
||||||
|
|
||||||
class che_병가 extends \sammo\BaseNation{
|
class che_병가 extends \sammo\BaseNation{
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ class che_병가 extends \sammo\BaseNation{
|
|||||||
|
|
||||||
public function onCalcNationalIncome(string $type, int $amount):int{
|
public function onCalcNationalIncome(string $type, int $amount):int{
|
||||||
if($type == 'pop'){
|
if($type == 'pop'){
|
||||||
return $amount * 0.8;
|
return Util::toInt($amount * 0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
return $amount;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace sammo\ActionNationType;
|
namespace sammo\ActionNationType;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
|
use \sammo\Util;
|
||||||
|
|
||||||
class che_불가 extends \sammo\BaseNation{
|
class che_불가 extends \sammo\BaseNation{
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ class che_불가 extends \sammo\BaseNation{
|
|||||||
|
|
||||||
public function onCalcNationalIncome(string $type, int $amount):int{
|
public function onCalcNationalIncome(string $type, int $amount):int{
|
||||||
if($type == 'gold'){
|
if($type == 'gold'){
|
||||||
return $amount * 0.9;
|
return Util::toInt($amount * 0.9);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
return $amount;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace sammo\ActionNationType;
|
namespace sammo\ActionNationType;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
|
use \sammo\Util;
|
||||||
|
|
||||||
class che_오두미도 extends \sammo\BaseNation{
|
class che_오두미도 extends \sammo\BaseNation{
|
||||||
|
|
||||||
@@ -30,10 +31,10 @@ class che_오두미도 extends \sammo\BaseNation{
|
|||||||
|
|
||||||
public function onCalcNationalIncome(string $type, int $amount):int{
|
public function onCalcNationalIncome(string $type, int $amount):int{
|
||||||
if($type == 'rice'){
|
if($type == 'rice'){
|
||||||
return $amount * 1.1;
|
return Util::toInt($amount * 1.1);
|
||||||
}
|
}
|
||||||
if($type == 'pop'){
|
if($type == 'pop'){
|
||||||
return $amount * 1.2;
|
return Util::toInt($amount * 1.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
return $amount;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace sammo\ActionNationType;
|
namespace sammo\ActionNationType;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
|
use \sammo\Util;
|
||||||
|
|
||||||
class che_유가 extends \sammo\BaseNation{
|
class che_유가 extends \sammo\BaseNation{
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ class che_유가 extends \sammo\BaseNation{
|
|||||||
|
|
||||||
public function onCalcNationalIncome(string $type, int $amount):int{
|
public function onCalcNationalIncome(string $type, int $amount):int{
|
||||||
if($type == 'rice'){
|
if($type == 'rice'){
|
||||||
return $amount * 0.9;
|
return Util::toInt($amount * 0.9);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
return $amount;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace sammo\ActionNationType;
|
namespace sammo\ActionNationType;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
|
use \sammo\Util;
|
||||||
|
|
||||||
class che_음양가 extends \sammo\BaseNation{
|
class che_음양가 extends \sammo\BaseNation{
|
||||||
|
|
||||||
@@ -26,7 +27,7 @@ class che_음양가 extends \sammo\BaseNation{
|
|||||||
|
|
||||||
public function onCalcNationalIncome(string $type, int $amount):int{
|
public function onCalcNationalIncome(string $type, int $amount):int{
|
||||||
if($type == 'pop'){
|
if($type == 'pop'){
|
||||||
return $amount * 1.2;
|
return Util::toInt($amount * 1.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
return $amount;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class che_종횡가 extends \sammo\BaseNation{
|
|||||||
|
|
||||||
public function onCalcNationalIncome(string $type, int $amount):int{
|
public function onCalcNationalIncome(string $type, int $amount):int{
|
||||||
if($type == 'gold'){
|
if($type == 'gold'){
|
||||||
return $amount * 0.9;
|
return Util::toInt($amount * 0.9);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
return $amount;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace sammo\ActionNationType;
|
namespace sammo\ActionNationType;
|
||||||
use \sammo\iAction;
|
use \sammo\iAction;
|
||||||
use \sammo\General;
|
use \sammo\General;
|
||||||
|
use \sammo\Util;
|
||||||
|
|
||||||
class che_태평도 extends \sammo\BaseNation{
|
class che_태평도 extends \sammo\BaseNation{
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ class che_태평도 extends \sammo\BaseNation{
|
|||||||
|
|
||||||
public function onCalcNationalIncome(string $type, int $amount):int{
|
public function onCalcNationalIncome(string $type, int $amount):int{
|
||||||
if($type == 'pop'){
|
if($type == 'pop'){
|
||||||
return $amount * 1.2;
|
return Util::toInt($amount * 1.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
return $amount;
|
||||||
|
|||||||
@@ -14,10 +14,6 @@ use \sammo\Constraint\Constraint;
|
|||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
abstract class BaseCommand{
|
abstract class BaseCommand{
|
||||||
/**
|
|
||||||
* @var General|null $generalObj
|
|
||||||
* @var General|null $destGeneralObj
|
|
||||||
*/
|
|
||||||
static protected $actionName = 'CommandName';
|
static protected $actionName = 'CommandName';
|
||||||
static public $reqArg = false;
|
static public $reqArg = false;
|
||||||
|
|
||||||
@@ -253,7 +249,7 @@ abstract class BaseCommand{
|
|||||||
return static::$actionName;
|
return static::$actionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLogger():ActionLogger{
|
public function getLogger():?ActionLogger{
|
||||||
return $this->logger;
|
return $this->logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,7 +399,6 @@ abstract class BaseCommand{
|
|||||||
}
|
}
|
||||||
public function getForm():string{
|
public function getForm():string{
|
||||||
throw new \sammo\MustNotBeReachedException();
|
throw new \sammo\MustNotBeReachedException();
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastTurn():LastTurn{
|
public function getLastTurn():LastTurn{
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ class che_상업투자 extends Command\GeneralCommand{
|
|||||||
static protected $actionName = '상업 투자';
|
static protected $actionName = '상업 투자';
|
||||||
static protected $debuffFront = 0.5;
|
static protected $debuffFront = 0.5;
|
||||||
|
|
||||||
|
protected $reqGold;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
$this->arg = null;
|
$this->arg = null;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ class che_정착장려 extends Command\GeneralCommand{
|
|||||||
static protected $actionKey = '인구';
|
static protected $actionKey = '인구';
|
||||||
static protected $actionName = '정착 장려';
|
static protected $actionName = '정착 장려';
|
||||||
|
|
||||||
|
protected $reqRice;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
$this->arg = null;
|
$this->arg = null;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ class che_주민선정 extends Command\GeneralCommand{
|
|||||||
static protected $actionKey = '민심';
|
static protected $actionKey = '민심';
|
||||||
static protected $actionName = '주민 선정';
|
static protected $actionName = '주민 선정';
|
||||||
|
|
||||||
|
protected $reqRice;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
$this->arg = null;
|
$this->arg = null;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -24,9 +24,6 @@ use \sammo\Constraint\ConstraintHelper;
|
|||||||
|
|
||||||
|
|
||||||
class che_징병 extends Command\GeneralCommand{
|
class che_징병 extends Command\GeneralCommand{
|
||||||
/**
|
|
||||||
* @var \sammo\GameUnitDetail $reqCrewType
|
|
||||||
*/
|
|
||||||
static protected $actionName = '징병';
|
static protected $actionName = '징병';
|
||||||
static protected $costOffset = 1;
|
static protected $costOffset = 1;
|
||||||
static public $reqArg = true;
|
static public $reqArg = true;
|
||||||
|
|||||||
@@ -98,8 +98,8 @@ class che_물자원조 extends Command\NationCommand{
|
|||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::BeChief(),
|
ConstraintHelper::BeChief(),
|
||||||
ConstraintHelper::SuppliedCity(),
|
ConstraintHelper::SuppliedCity(),
|
||||||
ConstraintHelper::ReqNationGold(GameConst::$basegold+($goldAmount>0)?1:0),
|
ConstraintHelper::ReqNationGold(GameConst::$basegold+(($goldAmount>0)?1:0)),
|
||||||
ConstraintHelper::ReqNationRice(GameConst::$baserice+($riceAmount>0)?1:0),
|
ConstraintHelper::ReqNationRice(GameConst::$baserice+(($riceAmount>0)?1:0)),
|
||||||
ConstraintHelper::ReqNationValue('surlimit', '외교제한', '==', 0, '외교제한중입니다.'),
|
ConstraintHelper::ReqNationValue('surlimit', '외교제한', '==', 0, '외교제한중입니다.'),
|
||||||
ConstraintHelper::ReqDestNationValue('surlimit', '외교제한', '==', 0, '상대국이 외교제한중입니다.'),
|
ConstraintHelper::ReqDestNationValue('surlimit', '외교제한', '==', 0, '상대국이 외교제한중입니다.'),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace sammo\Constraint;
|
namespace sammo\Constraint;
|
||||||
|
|
||||||
class AllowWar extends Constraint{
|
class AllowStrategicCommand extends Constraint{
|
||||||
const REQ_VALUES = Constraint::REQ_NATION;
|
const REQ_VALUES = Constraint::REQ_NATION;
|
||||||
|
|
||||||
public function checkInputValues(bool $throwExeception=true):bool{
|
public function checkInputValues(bool $throwExeception=true):bool{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use \sammo\DB;
|
|||||||
use \sammo\GameConst;
|
use \sammo\GameConst;
|
||||||
use \sammo\Json;
|
use \sammo\Json;
|
||||||
|
|
||||||
class AllowJoinDestNation extends Constraint{
|
class ExistsAllowJoinNation extends Constraint{
|
||||||
const REQ_VALUES = Constraint::REQ_GENERAL|Constraint::REQ_ARRAY_ARG;
|
const REQ_VALUES = Constraint::REQ_GENERAL|Constraint::REQ_ARRAY_ARG;
|
||||||
|
|
||||||
protected $relYear;
|
protected $relYear;
|
||||||
|
|||||||
@@ -111,7 +111,9 @@ class ReqCityValue extends Constraint{
|
|||||||
return '부족합니다.';
|
return '부족합니다.';
|
||||||
},
|
},
|
||||||
'>'=>function($target, $src){
|
'>'=>function($target, $src){
|
||||||
return $target > $src;
|
if($target > $src){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if($src == 0){
|
if($src == 0){
|
||||||
return '없습니다';
|
return '없습니다';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,9 @@ class ReqDestCityValue extends Constraint{
|
|||||||
return '부족합니다.';
|
return '부족합니다.';
|
||||||
},
|
},
|
||||||
'>'=>function($target, $src){
|
'>'=>function($target, $src){
|
||||||
return $target > $src;
|
if($target > $src){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if($src == 0){
|
if($src == 0){
|
||||||
return '없습니다';
|
return '없습니다';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,9 @@ class ReqDestNationValue extends Constraint{
|
|||||||
return '부족합니다.';
|
return '부족합니다.';
|
||||||
},
|
},
|
||||||
'>'=>function($target, $src){
|
'>'=>function($target, $src){
|
||||||
return $target > $src;
|
if($target > $src){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if($src == 0){
|
if($src == 0){
|
||||||
return '없습니다';
|
return '없습니다';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,9 @@ class ReqGeneralValue extends Constraint{
|
|||||||
return '부족합니다.';
|
return '부족합니다.';
|
||||||
},
|
},
|
||||||
'>'=>function($target, $src){
|
'>'=>function($target, $src){
|
||||||
return $target > $src;
|
if($target > $src){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if($src == 0){
|
if($src == 0){
|
||||||
return '없습니다';
|
return '없습니다';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,9 @@ class ReqNationAuxValue extends Constraint{
|
|||||||
return '부족합니다.';
|
return '부족합니다.';
|
||||||
},
|
},
|
||||||
'>'=>function($target, $src){
|
'>'=>function($target, $src){
|
||||||
return $target > $src;
|
if($target > $src){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if($src == 0){
|
if($src == 0){
|
||||||
return '없습니다';
|
return '없습니다';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,9 @@ class ReqNationValue extends Constraint{
|
|||||||
return '부족합니다.';
|
return '부족합니다.';
|
||||||
},
|
},
|
||||||
'>'=>function($target, $src){
|
'>'=>function($target, $src){
|
||||||
return $target > $src;
|
if($target > $src){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if($src == 0){
|
if($src == 0){
|
||||||
return '없습니다';
|
return '없습니다';
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-13
@@ -8,15 +8,6 @@ use sammo\WarUnitTrigger as WarUnitTrigger;
|
|||||||
class General implements iAction{
|
class General implements iAction{
|
||||||
use LazyVarUpdater;
|
use LazyVarUpdater;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var iAction $nationType
|
|
||||||
* @var iAction $officerLevelObj
|
|
||||||
* @var iAction $specialDomesticObj
|
|
||||||
* @var iAction $specialWarObj
|
|
||||||
* @var iAction $personalityObj
|
|
||||||
* @var iAction[] $itemObjs
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected $raw = [];
|
protected $raw = [];
|
||||||
protected $rawCity = null;
|
protected $rawCity = null;
|
||||||
|
|
||||||
@@ -32,11 +23,17 @@ class General implements iAction{
|
|||||||
protected $logActivatedSkill = [];
|
protected $logActivatedSkill = [];
|
||||||
protected $isFinished = false;
|
protected $isFinished = false;
|
||||||
|
|
||||||
|
/** @var iAction */
|
||||||
protected $nationType = null;
|
protected $nationType = null;
|
||||||
|
/** @var iAction */
|
||||||
protected $officerLevelObj = null;
|
protected $officerLevelObj = null;
|
||||||
|
/** @var iAction */
|
||||||
protected $specialDomesticObj = null;
|
protected $specialDomesticObj = null;
|
||||||
|
/** @var iAction */
|
||||||
protected $specialWarObj = null;
|
protected $specialWarObj = null;
|
||||||
|
/** @var iAction */
|
||||||
protected $personalityObj = null;
|
protected $personalityObj = null;
|
||||||
|
/** @var iAction[] */
|
||||||
protected $itemObjs = [];
|
protected $itemObjs = [];
|
||||||
|
|
||||||
protected $lastTurn = null;
|
protected $lastTurn = null;
|
||||||
@@ -79,8 +76,8 @@ class General implements iAction{
|
|||||||
/**
|
/**
|
||||||
* @param array $raw DB row값.
|
* @param array $raw DB row값.
|
||||||
* @param null|array $city DB city 테이블의 row값
|
* @param null|array $city DB city 테이블의 row값
|
||||||
* @param int $year 게임 연도
|
* @param int|null $year 게임 연도
|
||||||
* @param int $month 게임 월
|
* @param int|null $month 게임 월
|
||||||
* @param bool $fullConstruct iAction, 및 ActionLogger 초기화 여부, false인 경우 no, name, city, nation, officer_level 정도로 초기화 가능
|
* @param bool $fullConstruct iAction, 및 ActionLogger 초기화 여부, false인 경우 no, name, city, nation, officer_level 정도로 초기화 가능
|
||||||
*/
|
*/
|
||||||
public function __construct(array $raw, ?array $rawRank, ?array $city, ?array $nation, ?int $year, ?int $month, bool $fullConstruct=true){
|
public function __construct(array $raw, ?array $rawRank, ?array $city, ?array $nation, ?int $year, ?int $month, bool $fullConstruct=true){
|
||||||
@@ -270,7 +267,11 @@ class General implements iAction{
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getCrewTypeObj():GameUnitDetail{
|
function getCrewTypeObj():GameUnitDetail{
|
||||||
return GameUnitConst::byID($this->getVar('crewtype'));
|
$crewType = GameUnitConst::byID($this->getVar('crewtype'));
|
||||||
|
if($crewType === null){
|
||||||
|
throw new \InvalidArgumentException('Invalid CrewType:'.$this->getVar('crewtype'));
|
||||||
|
}
|
||||||
|
return $crewType;
|
||||||
}
|
}
|
||||||
|
|
||||||
function calcRecentWarTurn(int $turnTerm):int{
|
function calcRecentWarTurn(int $turnTerm):int{
|
||||||
@@ -292,7 +293,7 @@ class General implements iAction{
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = intdiv($secDiff, 60 * $turnTerm);
|
$result = intdiv(Util::toInt($secDiff), 60 * $turnTerm);
|
||||||
$this->calcCache[$cacheKey] = $result;
|
$this->calcCache[$cacheKey] = $result;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-7
@@ -8,9 +8,7 @@ use sammo\Scenario\NPC;
|
|||||||
|
|
||||||
class GeneralAI
|
class GeneralAI
|
||||||
{
|
{
|
||||||
/**
|
/** @var General */
|
||||||
* @var General $general
|
|
||||||
*/
|
|
||||||
protected $general;
|
protected $general;
|
||||||
/** @var array */
|
/** @var array */
|
||||||
protected $city;
|
protected $city;
|
||||||
@@ -92,8 +90,12 @@ class GeneralAI
|
|||||||
if ($general->getRawCity() === null) {
|
if ($general->getRawCity() === null) {
|
||||||
$city = $db->queryFirstRow('SELECT * FROM city WHERE city = %i', $general->getCityID());
|
$city = $db->queryFirstRow('SELECT * FROM city WHERE city = %i', $general->getCityID());
|
||||||
$general->setRawCity($city);
|
$general->setRawCity($city);
|
||||||
|
$this->city = $city;
|
||||||
}
|
}
|
||||||
$this->city = $general->getRawCity();
|
else{
|
||||||
|
$this->city = $general->getRawCity();
|
||||||
|
}
|
||||||
|
|
||||||
$this->nation = $db->queryFirstRow(
|
$this->nation = $db->queryFirstRow(
|
||||||
'SELECT nation,name,color,capital,capset,gennum,gold,rice,bill,rate,rate_tmp,scout,war,strategic_cmd_limit,surlimit,tech,power,level,l12set,l11set,l10set,l9set,l8set,l7set,l6set,l5set,type,aux FROM nation WHERE nation = %i',
|
'SELECT nation,name,color,capital,capset,gennum,gold,rice,bill,rate,rate_tmp,scout,war,strategic_cmd_limit,surlimit,tech,power,level,l12set,l11set,l10set,l9set,l8set,l7set,l6set,l5set,type,aux FROM nation WHERE nation = %i',
|
||||||
$general->getNationID()
|
$general->getNationID()
|
||||||
@@ -496,7 +498,7 @@ class GeneralAI
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$turnList = General::getReservedTurnByGeneralList(array_keys($generalCadidates), 0, $this->env);
|
$turnList = General::getReservedTurnByGeneralList($generalCadidates, 0, $this->env);
|
||||||
$generalCadidates = array_filter($generalCadidates, function(General $general)use($turnList){
|
$generalCadidates = array_filter($generalCadidates, function(General $general)use($turnList){
|
||||||
$generalID = $general->getID();
|
$generalID = $general->getID();
|
||||||
if($turnList[$generalID] instanceof Command\General\che_징병){
|
if($turnList[$generalID] instanceof Command\General\che_징병){
|
||||||
@@ -2898,8 +2900,6 @@ class GeneralAI
|
|||||||
'amount' => GameConst::$maxResourceActionAmount
|
'amount' => GameConst::$maxResourceActionAmount
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function do중립(): GeneralCommand
|
protected function do중립(): GeneralCommand
|
||||||
@@ -3205,6 +3205,9 @@ class GeneralAI
|
|||||||
return $reservedCommand;
|
return $reservedCommand;
|
||||||
}
|
}
|
||||||
$result = $this->do집합();
|
$result = $this->do집합();
|
||||||
|
if(!$result){
|
||||||
|
throw new MustNotBeReachedException();
|
||||||
|
}
|
||||||
$result->reason='do집합';
|
$result->reason='do집합';
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace sammo;
|
|||||||
trait LazyVarUpdater{
|
trait LazyVarUpdater{
|
||||||
protected $raw = [];
|
protected $raw = [];
|
||||||
protected $updatedVar = [];
|
protected $updatedVar = [];
|
||||||
|
protected $auxVar = null;
|
||||||
protected $auxUpdated = false;
|
protected $auxUpdated = false;
|
||||||
|
|
||||||
function getRaw(bool $extractAux=false):array{
|
function getRaw(bool $extractAux=false):array{
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class MessageTarget extends Target {
|
|||||||
public static function buildFromArray($arr)
|
public static function buildFromArray($arr)
|
||||||
{
|
{
|
||||||
if(!$arr){
|
if(!$arr){
|
||||||
return null;
|
throw new \InvalidArgumentException();
|
||||||
}
|
}
|
||||||
if(!Util::array_get($arr['nation_id'])){
|
if(!Util::array_get($arr['nation_id'])){
|
||||||
$arr['nation'] = '재야';
|
$arr['nation'] = '재야';
|
||||||
@@ -71,7 +71,7 @@ class MessageTarget extends Target {
|
|||||||
) = $db->queryFirstList('SELECT `name`, nation, imgsvr, picture FROM general WHERE `no`=%i', $generalID);
|
) = $db->queryFirstList('SELECT `name`, nation, imgsvr, picture FROM general WHERE `no`=%i', $generalID);
|
||||||
|
|
||||||
if($generalName === null){
|
if($generalName === null){
|
||||||
return null;
|
throw new \RuntimeException('장수가 없음:'.$generalID);
|
||||||
}
|
}
|
||||||
|
|
||||||
$icon = GetImageURL($imgsvr, $picture);
|
$icon = GetImageURL($imgsvr, $picture);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use \sammo\Util;
|
|||||||
use \sammo\JosaUtil;
|
use \sammo\JosaUtil;
|
||||||
|
|
||||||
class DyingMessage{
|
class DyingMessage{
|
||||||
|
private $general;
|
||||||
private $name;
|
private $name;
|
||||||
private $realName;
|
private $realName;
|
||||||
private $npc;
|
private $npc;
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ namespace sammo;
|
|||||||
use \Symfony\Component\Lock;
|
use \Symfony\Component\Lock;
|
||||||
class TurnExecutionHelper
|
class TurnExecutionHelper
|
||||||
{
|
{
|
||||||
/**
|
/** @var General*/
|
||||||
* @var General $generalObj;
|
|
||||||
*/
|
|
||||||
protected $generalObj;
|
protected $generalObj;
|
||||||
|
|
||||||
public function __construct(General $general)
|
public function __construct(General $general)
|
||||||
@@ -267,17 +265,16 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
|
|||||||
}
|
}
|
||||||
|
|
||||||
$autorunMode = false;
|
$autorunMode = false;
|
||||||
$tryAutorun = false;
|
$ai = null;
|
||||||
|
|
||||||
if($general->getVar('npc') >= 2 || ($autorun_user['limit_minutes']??false)){
|
if($general->getVar('npc') >= 2 || ($autorun_user['limit_minutes']??false)){
|
||||||
$tryAutorun = true;
|
|
||||||
$ai = new GeneralAI($turnObj->getGeneral());
|
$ai = new GeneralAI($turnObj->getGeneral());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$turnObj->processBlocked()){
|
if(!$turnObj->processBlocked()){
|
||||||
$turnObj->preprocessCommand();
|
$turnObj->preprocessCommand();
|
||||||
if($hasNationTurn){
|
if($hasNationTurn){
|
||||||
if($tryAutorun){
|
if($ai){
|
||||||
$nationCommandObj = $ai->chooseNationTurn($nationCommandObj);
|
$nationCommandObj = $ai->chooseNationTurn($nationCommandObj);
|
||||||
LogText("NationTurn", "General, {$general->getName()}, {$general->getID()}, {$general->getStaticNation()['name']}, {$nationCommandObj->getBrief()}, {$nationCommandObj->reason}, ");
|
LogText("NationTurn", "General, {$general->getName()}, {$general->getID()}, {$general->getStaticNation()['name']}, {$nationCommandObj->getBrief()}, {$nationCommandObj->reason}, ");
|
||||||
}
|
}
|
||||||
@@ -287,7 +284,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
|
|||||||
$nationStor->setValue($lastNationTurnKey, $resultNationTurn->toJson());
|
$nationStor->setValue($lastNationTurnKey, $resultNationTurn->toJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
if($tryAutorun){
|
if($ai){
|
||||||
$newGeneralCommandObj = $ai->chooseGeneralTurn($generalCommandObj); // npc AI 처리
|
$newGeneralCommandObj = $ai->chooseGeneralTurn($generalCommandObj); // npc AI 처리
|
||||||
if($generalCommandObj !== $newGeneralCommandObj){
|
if($generalCommandObj !== $newGeneralCommandObj){
|
||||||
$autorunMode = true;
|
$autorunMode = true;
|
||||||
@@ -347,7 +344,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
|
|||||||
$prevTurn = cutTurn($gameStor->turntime, $gameStor->turnterm);
|
$prevTurn = cutTurn($gameStor->turntime, $gameStor->turnterm);
|
||||||
$nextTurn = addTurn($prevTurn, $gameStor->turnterm);
|
$nextTurn = addTurn($prevTurn, $gameStor->turnterm);
|
||||||
|
|
||||||
$maxActionTime = ini_get('max_execution_time');
|
$maxActionTime = Util::toInt(ini_get('max_execution_time'));
|
||||||
if($maxActionTime == 0){
|
if($maxActionTime == 0){
|
||||||
$maxActionTime = 60;
|
$maxActionTime = 60;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,11 @@ class WarUnit{
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getLogger():ActionLogger{
|
function getLogger():ActionLogger{
|
||||||
return $this->getGeneral()->getLogger();
|
$logger = $this->getGeneral()->getLogger();
|
||||||
|
if($logger === null){
|
||||||
|
throw new \RuntimeException();
|
||||||
|
}
|
||||||
|
return $logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getKilled():int{
|
function getKilled():int{
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class WarUnitCity extends WarUnit{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function applyDB($db):bool{
|
function applyDB(\MeekroDB $db):bool{
|
||||||
$updateVals = $this->getUpdatedValues();
|
$updateVals = $this->getUpdatedValues();
|
||||||
$this->getLogger()->rollback(); //수비 도시의 로그는 기록하지 않음
|
$this->getLogger()->rollback(); //수비 도시의 로그는 기록하지 않음
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
class WarUnitGeneral extends WarUnit{
|
class WarUnitGeneral extends WarUnit{
|
||||||
|
protected $raw;
|
||||||
|
|
||||||
function __construct(General $general, array $rawNation, bool $isAttacker){
|
function __construct(General $general, array $rawNation, bool $isAttacker){
|
||||||
$this->general = $general;
|
$this->general = $general;
|
||||||
$this->raw = $general->getRaw();
|
$this->raw = $general->getRaw();
|
||||||
@@ -301,10 +303,7 @@ class WarUnitGeneral extends WarUnit{
|
|||||||
$this->checkStatChange();
|
$this->checkStatChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
function applyDB(\MeekroDB $db):bool{
|
||||||
* @param \MeekroDB $db
|
|
||||||
*/
|
|
||||||
function applyDB($db):bool{
|
|
||||||
$affected = $this->getGeneral()->applyDB($db);
|
$affected = $this->getGeneral()->applyDB($db);
|
||||||
$this->getLogger()->flush();
|
$this->getLogger()->flush();
|
||||||
return $affected;
|
return $affected;
|
||||||
|
|||||||
+34
-5
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
|
use MeekroDBException;
|
||||||
|
|
||||||
class KVStorage{
|
class KVStorage{
|
||||||
private $db;
|
private $db;
|
||||||
private $tableName;
|
private $tableName;
|
||||||
@@ -31,7 +33,7 @@ class KVStorage{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function __set($key, $value) {
|
public function __set($key, $value) {
|
||||||
return $this->setValue($key, $value);
|
$this->setValue($key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __unset($key){
|
public function __unset($key){
|
||||||
@@ -63,7 +65,9 @@ class KVStorage{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function invalidateCacheValue($key):self{
|
public function invalidateCacheValue($key):self{
|
||||||
$key = mb_strtolower($key);
|
if(is_string($key)){
|
||||||
|
$key = mb_strtolower($key);
|
||||||
|
}
|
||||||
if($this->cacheData === null){
|
if($this->cacheData === null){
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -192,8 +196,15 @@ class KVStorage{
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string|int $key
|
||||||
|
* @param bool $onlyCache
|
||||||
|
* @return mixed|null
|
||||||
|
*/
|
||||||
public function getValue($key, bool $onlyCache=false){
|
public function getValue($key, bool $onlyCache=false){
|
||||||
$key = mb_strtolower($key);
|
if(is_string($key)){
|
||||||
|
$key = mb_strtolower($key);
|
||||||
|
}
|
||||||
if($this->cacheData !== null && ($onlyCache || key_exists($key, $this->cacheData))){
|
if($this->cacheData !== null && ($onlyCache || key_exists($key, $this->cacheData))){
|
||||||
return $this->cacheData[$key] ?? null;
|
return $this->cacheData[$key] ?? null;
|
||||||
}
|
}
|
||||||
@@ -205,8 +216,17 @@ class KVStorage{
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string|int $key
|
||||||
|
* @param mixed $value
|
||||||
|
* @return KVStorage
|
||||||
|
* @throws MeekroDBException
|
||||||
|
*/
|
||||||
public function setValue($key, $value):self{
|
public function setValue($key, $value):self{
|
||||||
$key = mb_strtolower($key);
|
if(is_string($key)){
|
||||||
|
$key = mb_strtolower($key);
|
||||||
|
}
|
||||||
if($value === null){
|
if($value === null){
|
||||||
return $this->deleteValue($key);
|
return $this->deleteValue($key);
|
||||||
}
|
}
|
||||||
@@ -217,8 +237,17 @@ class KVStorage{
|
|||||||
return $this->setDBValue($key, $value);
|
return $this->setDBValue($key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string|int $key
|
||||||
|
* @param mixed $value
|
||||||
|
* @return KVStorage
|
||||||
|
* @throws MeekroDBException
|
||||||
|
*/
|
||||||
public function deleteValue($key):self{
|
public function deleteValue($key):self{
|
||||||
$key = mb_strtolower($key);
|
if(is_string($key)){
|
||||||
|
$key = mb_strtolower($key);
|
||||||
|
}
|
||||||
if(isset($this->cacheData[$key])){
|
if(isset($this->cacheData[$key])){
|
||||||
unset($this->cacheData[$key]);
|
unset($this->cacheData[$key]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ class Session
|
|||||||
public function restart(): Session
|
public function restart(): Session
|
||||||
{
|
{
|
||||||
//NOTE: logout 프로세스는 아예 세션을 날려버리기도 하므로, 항상 안전하게 session_restart가 가능함을 보장하지 않음.
|
//NOTE: logout 프로세스는 아예 세션을 날려버리기도 하므로, 항상 안전하게 session_restart가 가능함을 보장하지 않음.
|
||||||
ini_set('session.use_only_cookies', false);
|
ini_set('session.use_only_cookies', 'false');
|
||||||
ini_set('session.use_cookies', false);
|
ini_set('session.use_cookies', 'false');
|
||||||
ini_set('session.use_trans_sid', false);
|
ini_set('session.use_trans_sid', 'false');
|
||||||
ini_set('session.cache_limiter', "none");
|
ini_set('session.cache_limiter', "none");
|
||||||
session_id($this->sessionID);
|
session_id($this->sessionID);
|
||||||
session_start(); // second session_start
|
session_start(); // second session_start
|
||||||
|
|||||||
@@ -76,13 +76,13 @@ class TimeUtil
|
|||||||
return date('H:i:s', strtotime('00:00:00') + $second);
|
return date('H:i:s', strtotime('00:00:00') + $second);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function today()
|
public static function today():string
|
||||||
{
|
{
|
||||||
$obj = new \DateTime();
|
$obj = new \DateTime();
|
||||||
return $obj->format('Y-m-d');
|
return $obj->format('Y-m-d');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function now(bool $withFraction=false)
|
public static function now(bool $withFraction=false):string
|
||||||
{
|
{
|
||||||
$obj = new \DateTime();
|
$obj = new \DateTime();
|
||||||
if(!$withFraction){
|
if(!$withFraction){
|
||||||
@@ -91,7 +91,7 @@ class TimeUtil
|
|||||||
return $obj->format('Y-m-d H:i:s.u');
|
return $obj->format('Y-m-d H:i:s.u');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function nowAddDays($day, bool $withFraction=false)
|
public static function nowAddDays($day, bool $withFraction=false):string
|
||||||
{
|
{
|
||||||
$obj = new \DateTime();
|
$obj = new \DateTime();
|
||||||
$obj->add(static::secondsToDateInterval($day * 3600 * 24));
|
$obj->add(static::secondsToDateInterval($day * 3600 * 24));
|
||||||
@@ -101,7 +101,7 @@ class TimeUtil
|
|||||||
return $obj->format('Y-m-d H:i:s.u');
|
return $obj->format('Y-m-d H:i:s.u');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function nowAddHours($hour, bool $withFraction=false)
|
public static function nowAddHours($hour, bool $withFraction=false):string
|
||||||
{
|
{
|
||||||
$obj = new \DateTime();
|
$obj = new \DateTime();
|
||||||
$obj->add(static::secondsToDateInterval($hour * 3600));
|
$obj->add(static::secondsToDateInterval($hour * 3600));
|
||||||
@@ -111,7 +111,7 @@ class TimeUtil
|
|||||||
return $obj->format('Y-m-d H:i:s.u');
|
return $obj->format('Y-m-d H:i:s.u');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function nowAddMinutes($minute, bool $withFraction=false)
|
public static function nowAddMinutes($minute, bool $withFraction=false):string
|
||||||
{
|
{
|
||||||
$obj = new \DateTime();
|
$obj = new \DateTime();
|
||||||
$obj->add(static::secondsToDateInterval($minute * 60));
|
$obj->add(static::secondsToDateInterval($minute * 60));
|
||||||
@@ -121,7 +121,7 @@ class TimeUtil
|
|||||||
return $obj->format('Y-m-d H:i:s.u');
|
return $obj->format('Y-m-d H:i:s.u');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function nowAddSeconds($second, bool $withFraction=false)
|
public static function nowAddSeconds($second, bool $withFraction=false):string
|
||||||
{
|
{
|
||||||
$obj = new \DateTime();
|
$obj = new \DateTime();
|
||||||
$obj->add(static::secondsToDateInterval($second));
|
$obj->add(static::secondsToDateInterval($second));
|
||||||
|
|||||||
+1
-1
@@ -567,7 +567,7 @@ class Util extends \utilphp\util
|
|||||||
*
|
*
|
||||||
* @param array $array 배열. 1차원 배열 또는 2차원 배열
|
* @param array $array 배열. 1차원 배열 또는 2차원 배열
|
||||||
* @param int|string|null $key 2차원 배열에서 참조할 키.
|
* @param int|string|null $key 2차원 배열에서 참조할 키.
|
||||||
* @return int|float 합계
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function arrayGroupBy(array $array, $key, bool $preserveRowKey=false) {
|
public static function arrayGroupBy(array $array, $key, bool $preserveRowKey=false) {
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|||||||
Reference in New Issue
Block a user