forked from devsam/core
Command 구조 일부 수정
This commit is contained in:
@@ -615,6 +615,98 @@ function processCommand($no) {
|
||||
}
|
||||
}
|
||||
|
||||
function pushGeneralCommand(int $generalID, int $turnCnt=1){
|
||||
if($turnCnt == 0){
|
||||
return;
|
||||
}
|
||||
if($turnCnt < 0){
|
||||
pullGeneralCommand($generalID, -$turnCnt);
|
||||
}
|
||||
if($turnCnt >= GameConst::$maxTurn){
|
||||
return;
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$db->update('general_turn', [
|
||||
'turn_idx'=>$db->sqleval('turn_idx + %i', $turnCnt)
|
||||
], 'general_id=%i', $generalID);
|
||||
$db->update('general_turn', [
|
||||
'turn_idx'=>$db->sqleval('turn_idx - %i', GameConst::$maxTurn),
|
||||
'action'=>'휴식',
|
||||
'arg'=>'{}'
|
||||
], 'general_id=%i AND turn_idx >= %i', $generalID, GameConst::$maxTurn);
|
||||
}
|
||||
|
||||
function pullGeneralCommand(int $generalID, int $turnCnt=1){
|
||||
if($turnCnt == 0){
|
||||
return;
|
||||
}
|
||||
if($turnCnt < 0){
|
||||
pushGeneralCommand($generalID, -$turnCnt);
|
||||
}
|
||||
if($turnCnt >= GameConst::$maxTurn){
|
||||
return;
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$db->update('general_turn', [
|
||||
'turn_idx'=>$db->sqleval('turn_idx + %i', GameConst::$maxTurn),
|
||||
'action'=>'휴식',
|
||||
'arg'=>'{}'
|
||||
], 'general_id=%i AND turn_idx < %i', $generalID, $turnCnt);
|
||||
$db->update('general_turn', [
|
||||
'turn_idx'=>$db->sqleval('turn_idx - %i', $turnCnt)
|
||||
], 'general_id=%i', $generalID);
|
||||
}
|
||||
|
||||
function pushNationCommand(int $nationID, int $level, int $turnCnt=1){
|
||||
if($turnCnt == 0){
|
||||
return;
|
||||
}
|
||||
if($turnCnt < 0){
|
||||
pullNationCommand($nationID, $level, -$turnCnt);
|
||||
}
|
||||
if($turnCnt >= GameConst::$maxNationTurn){
|
||||
return;
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$db->update('general_turn', [
|
||||
'turn_idx'=>$db->sqleval('turn_idx + %i', $turnCnt)
|
||||
], 'general_id=%i', $generalID);
|
||||
$db->update('general_turn', [
|
||||
'turn_idx'=>$db->sqleval('turn_idx - %i', GameConst::$maxNationTurn),
|
||||
'action'=>'휴식',
|
||||
'arg'=>'{}'
|
||||
], 'general_id=%i AND turn_idx >= %i', $generalID, GameConst::$maxNationTurn);
|
||||
}
|
||||
|
||||
function pullNationCommand(int $nationID, int $level, int $turnCnt=1){
|
||||
if($turnCnt == 0){
|
||||
return;
|
||||
}
|
||||
if($turnCnt < 0){
|
||||
pushNationCommand($nationID, $level, -$turnCnt);
|
||||
}
|
||||
if($turnCnt >= GameConst::$maxNationTurn){
|
||||
return;
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$db->update('general_turn', [
|
||||
'turn_idx'=>$db->sqleval('turn_idx + %i', GameConst::$maxNationTurn),
|
||||
'action'=>'휴식',
|
||||
'arg'=>'{}'
|
||||
], 'nation_id=%i AND turn_idx < %i', $generalID, $turnCnt);
|
||||
$db->update('general_turn', [
|
||||
'turn_idx'=>$db->sqleval('turn_idx - %i', $turnCnt)
|
||||
], 'nation_id=%i', $generalID);
|
||||
}
|
||||
|
||||
function updateCommand($no, $type=0) {
|
||||
$db = DB::db();
|
||||
$connect=$db->get();
|
||||
|
||||
@@ -63,10 +63,10 @@ abstract class BaseCommand{
|
||||
$this->reasonNotReservable = null;
|
||||
}
|
||||
|
||||
protected function setCity(array $args=null){
|
||||
protected function setCity(?array $args=null){
|
||||
$this->resetTestCache();
|
||||
$db = DB::db();
|
||||
if($args == null){
|
||||
if($args === null){
|
||||
$this->city = $this->generalObj->getRawCity();
|
||||
if($this->city){
|
||||
return;
|
||||
@@ -83,7 +83,7 @@ abstract class BaseCommand{
|
||||
|
||||
protected function setNation(?array $args = null){
|
||||
$this->resetTestCache();
|
||||
if($args == null){
|
||||
if($args === null){
|
||||
$this->nation = $this->generalObj->getStaticNation();
|
||||
return;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ abstract class BaseCommand{
|
||||
$constraintInput = [
|
||||
'general'=>$this->generalObj->getRaw(),
|
||||
'city'=>$this->city,
|
||||
'nation'=>$this->city,
|
||||
'nation'=>$this->nation,
|
||||
'arg'=>$this->arg,
|
||||
|
||||
'destGeneral'=>$this->destGeneral,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace sammo\Command;
|
||||
namespace sammo\GeneralCommand;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
@@ -11,6 +11,7 @@ use \sammo\{
|
||||
uniqueItemEx
|
||||
};
|
||||
|
||||
use \sammo\Command;
|
||||
use \sammo\Constraint\Constraint;
|
||||
use function sammo\CriticalScore;
|
||||
use function sammo\uniqueItemEx;
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace sammo\Command;
|
||||
namespace sammo\GeneralCommand;
|
||||
|
||||
use \sammo\Util;
|
||||
use \sammo\JosaUtil;
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace sammo\Command;
|
||||
namespace sammo\GeneralCommand;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
@@ -11,13 +11,14 @@ use \sammo\{
|
||||
uniqueItemEx
|
||||
};
|
||||
|
||||
use \sammo\Command;
|
||||
use \sammo\Constraint\Constraint;
|
||||
use function sammo\CriticalScore;
|
||||
use function sammo\uniqueItemEx;
|
||||
use function sammo\getGeneralLeadership;
|
||||
|
||||
|
||||
class che_상업투자 extends BaseCommand{
|
||||
class che_상업투자 extends GeneralCommand{
|
||||
static $cityKey = 'comm';
|
||||
static $statKey = 'intel';
|
||||
static $actionKey = '상업';
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace sammo\Command;
|
||||
namespace sammo\GeneralCommand;
|
||||
|
||||
use \sammo\Util;
|
||||
use \sammo\JosaUtil;
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace sammo\Command;
|
||||
namespace sammo\GeneralCommand;
|
||||
|
||||
use \sammo\Util;
|
||||
use \sammo\JosaUtil;
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace sammo\Command;
|
||||
namespace sammo\GeneralCommand;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
@@ -11,13 +11,14 @@ use \sammo\{
|
||||
uniqueItemEx
|
||||
};
|
||||
|
||||
use \sammo\Command;
|
||||
use \sammo\Constraint\Constraint;
|
||||
use function sammo\CriticalScore;
|
||||
use function sammo\uniqueItemEx;
|
||||
use function sammo\getGeneralLeadership;
|
||||
|
||||
|
||||
class che_상업투자 extends BaseCommand{
|
||||
class che_상업투자 extends GeneralCommand{
|
||||
static $cityKey = 'pop';
|
||||
static $statKey = 'leader';
|
||||
static $actionKey = '인구';
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace sammo\Command;
|
||||
namespace sammo\GeneralCommand;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
@@ -11,13 +11,14 @@ use \sammo\{
|
||||
uniqueItemEx
|
||||
};
|
||||
|
||||
use \sammo\Command;
|
||||
use \sammo\Constraint\Constraint;
|
||||
use function sammo\CriticalScore;
|
||||
use function sammo\uniqueItemEx;
|
||||
use function sammo\getGeneralLeadership;
|
||||
|
||||
|
||||
class che_주민선정 extends BaseCommand{
|
||||
class che_주민선정 extends GeneralCommand{
|
||||
static $cityKey = 'trust';
|
||||
static $statKey = 'leader';
|
||||
static $actionKey = '민심';
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace sammo\Command;
|
||||
namespace sammo\GeneralCommand;
|
||||
|
||||
use \sammo\Util;
|
||||
use \sammo\JosaUtil;
|
||||
@@ -1,10 +1,11 @@
|
||||
<?php
|
||||
namespace sammo\Command;
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use \sammo\Command;
|
||||
use \sammo\Util;
|
||||
use \sammo\JosaUtil;
|
||||
|
||||
class 휴식 extends BaseCommand{
|
||||
class 휴식 extends GeneralCommand{
|
||||
protected function init(){
|
||||
//아무것도 하지 않음
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
namespace sammo\Command;
|
||||
|
||||
abstract class GeneralCommand extends BaseCommand{
|
||||
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace sammo\Command\Nation;
|
||||
|
||||
use \sammo\Command;
|
||||
use \sammo\Util;
|
||||
use \sammo\JosaUtil;
|
||||
|
||||
class 휴식 extends NationCommand{
|
||||
protected function init(){
|
||||
//아무것도 하지 않음
|
||||
}
|
||||
|
||||
protected function argTest():bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
namespace sammo\Command;
|
||||
|
||||
abstract class NationCommand extends BaseCommand{
|
||||
|
||||
};
|
||||
@@ -3,13 +3,13 @@ namespace sammo;
|
||||
|
||||
class GameConstBase
|
||||
{
|
||||
/** @var string 버전 */
|
||||
/** @var string 게임명 */
|
||||
public static $title = "삼국지 모의전투 PHP HiDCHe";
|
||||
/** @var string 코드 아래에 붙는 설명 코드 */
|
||||
public static $banner = "KOEI의 이미지를 사용, 응용하였습니다 / 제작 : HideD(hided62@gmail.com) / <a href='https://sam.hided.net/wiki/hidche/credit' target='_blank' style='color:white;text-decoration: underline;'>Credit</a>";
|
||||
/** @var string mapName 사용중인 지도명 */
|
||||
/** @var string 사용중인 지도명 */
|
||||
public static $mapName = 'che';
|
||||
/** @var string unitSet 사용중인 유닛셋 */
|
||||
/** @var string 사용중인 유닛셋 */
|
||||
public static $unitSet = 'che';
|
||||
/** @var int 내정시 최하 민심 설정*/
|
||||
public static $develrate = 50;
|
||||
@@ -86,8 +86,9 @@ class GameConstBase
|
||||
/** @var int 초기 시작 년도. 실제 값은 시나리오에서 정해지므로 딱히 의미는 없음. */
|
||||
public static $defaultStartYear = 180;
|
||||
|
||||
/** @var int 최대 턴(현재는 DB상 24턴으로 고정) */
|
||||
public static $maxTurn = 24;
|
||||
/** @var int 최대 턴 */
|
||||
public static $maxTurn = 30;
|
||||
public static $maxNationTurn = 12;
|
||||
|
||||
public static $statGradeLevel = 5;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user