diff --git a/hwe/b_currentCity.php b/hwe/b_currentCity.php
index 29c513c5..f09fce83 100644
--- a/hwe/b_currentCity.php
+++ b/hwe/b_currentCity.php
@@ -199,7 +199,7 @@ $generalTurnList = [];
foreach($db->queryAllLists(
'SELECT general_id, turn_idx, action, arg FROM general_turn WHERE general_id IN %li AND turn_idx < 5 ORDER BY general_id ASC, turn_idx ASC',
- Util::pickArrayFromArrayOfDictWithKey($generals, 'no')
+ array_column($generals, 'no')
) as [$generalID, $turnIdx, $action, $arg]
){
if(!key_exists($generalID, $generalTurnList)){
diff --git a/hwe/b_genList.php b/hwe/b_genList.php
index 555499bc..96ab0b03 100644
--- a/hwe/b_genList.php
+++ b/hwe/b_genList.php
@@ -107,7 +107,7 @@ $generalTurnList = [];
foreach($db->queryAllLists(
'SELECT general_id, turn_idx, action, arg FROM general_turn WHERE general_id IN %li AND turn_idx < 5 ORDER BY general_id ASC, turn_idx ASC',
- Util::pickArrayFromArrayOfDictWithKey($generals, 'no')
+ array_column($generals, 'no')
) as [$generalID, $turnIdx, $action, $arg]
){
if(!key_exists($generalID, $generalTurnList)){
diff --git a/hwe/b_troop.php b/hwe/b_troop.php
index be02541c..095a90c4 100644
--- a/hwe/b_troop.php
+++ b/hwe/b_troop.php
@@ -40,23 +40,38 @@ foreach($db->query(
}
if($troops){
- foreach($db->query(
- 'SELECT no,name,picture,imgsvr,turntime,city,turn0,turn1,turn2,turn3,turn4,turn5,troop FROM general WHERE no IN %li',
+ $troopLeaders = $db->query(
+ 'SELECT no,name,picture,imgsvr,turntime,city,troop FROM general WHERE no IN %li',
array_column($troops, 'no')
- ) as $troopLeader
+ );
+
+ foreach($db->queryAllLists(
+ 'SELECT general_id, turn_idx, action, arg FROM general_turn WHERE general_id IN %li AND turn_idx < 5 ORDER BY general_id ASC, turn_idx ASC',
+ array_column($troopLeaders, 'no')
+ ) as [$generalID, $turnIdx, $action, $arg]
){
+ if(!key_exists($generalID, $generalTurnList)){
+ $generalTurnList[$generalID] = [];
+ }
+ $generalTurnList[$generalID][$turnIdx] = [$action, Json::decode($arg)];
+ }
+
+ foreach($troopLeaders as $troopLeader){
$imageTemp = GetImageURL($troopLeader['imgsvr']);
$troopLeader['pictureFullPath'] = "$imageTemp/{$troopLeader['picture']}";
$troopLeader['cityText'] = CityConst::byID($troopLeader['city'])->name;
- $troopLeader['turnText'] = join('
', [
- '1 : '.((DecodeCommand($troopLeader['turn0'])[0] == 26)?'집합':'~'),
- '2 : '.((DecodeCommand($troopLeader['turn1'])[0] == 26)?'집합':'~'),
- '3 : '.((DecodeCommand($troopLeader['turn2'])[0] == 26)?'집합':'~'),
- '4 : '.((DecodeCommand($troopLeader['turn3'])[0] == 26)?'집합':'~'),
- '5 : '.((DecodeCommand($troopLeader['turn4'])[0] == 26)?'집합':'~'),
- ]);
+ $turnText = [];
+ foreach($generalTurnList[$troopLeader['no']] as $rawTurnIdx => [$action, $arg]){
+ $actionName = getGeneralCommandClass($action)::getName();
+ if($actionName != '집합'){
+ $actionName = '~';
+ }
+ $turnIdx = $rawTurnIdx + 1;
+ $turnText[] = "{$turnIdx} : {$actionName}";
+ }
+ $troopLeader['turnText'] = join('
', $turnText);
$troops[$troopLeader['troop']]['leader'] = $troopLeader;
}
}
diff --git a/hwe/commandlist.php b/hwe/commandlist.php
index 666cccab..ee1c8768 100644
--- a/hwe/commandlist.php
+++ b/hwe/commandlist.php
@@ -78,12 +78,12 @@ function myCommandList() {
// 명령 목록
$admin = $gameStor->getValues(['year','month','turnterm','turntime']);
- $me = $db->queryFirstRow("SELECT `no`,turntime,last_turn,turn0,turn1,turn2,turn3,turn4,turn5,turn6,turn7,turn8,turn9,turn10,turn11,turn12,turn13,turn14,turn15,turn16,turn17,turn18,turn19,turn20,turn21,turn22,turn23 FROM general WHERE `owner`=%s", $userID);
+ $me = $db->queryFirstRow("SELECT `no`,name,city,nation,level,turntime,last_turn FROM general WHERE `owner`=%s", $userID);
if(!$me){
echo "로그인 되어있지 않습니다.";
return;
}
- $generalObj = new General($me, null, 1, 1, false);
+ $generalObj = new General($me, null, 0, 0, false);
$turnList = $db->query('SELECT turn_idx, action, arg FROM general_turn WHERE general_id = %i ORDER BY turn_idx ASC', $generalObj->getID());
$turnBrief = getGeneralTurnBrief($generalObj, $turnList);
diff --git a/hwe/func.php b/hwe/func.php
index 8663bfbe..2d0e8f32 100644
--- a/hwe/func.php
+++ b/hwe/func.php
@@ -1594,109 +1594,6 @@ function triggerTournament() {
}
}
-function PreprocessCommand($no) {
- $db = DB::db();
- $connect=$db->get();
- $log = [];
-
- $query = "select no,name,city,injury,special2,item,turn0,rice,crew from general where no='$no'";
- $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
- $general = MYDB_fetch_array($result);
-
- if($general['special2'] == 73 || $general['item'] == 23 || $general['item'] == 24) {
- //특기보정 : 의술
- //의서 사용
- if($general['injury'] > 0) {
- $general['injury'] = 0;
- $query = "update general set injury=0 where no='$no'";
- MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
-
- pushGenLog($general, "●>의술>을 펼쳐 스스로 치료합니다!");
- }
-
- $query = "select no,name,injury from general where city='{$general['city']}' and injury>10 order by rand()";
- $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
- $patientCount = MYDB_num_rows($result);
-
- if($patientCount > 0) {
- // 50% 확률로 치료
- $patientCount = Util::round($patientCount * 0.5);
-
- $patientName = "";
- for($i=0; $i < $patientCount; $i++) {
- $patient = MYDB_fetch_array($result);
-
- //부상 치료
- $query = "update general set injury=0 where no='{$patient['no']}'";
- MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
-
- $josaYi = JosaUtil::pick($general['name'], '이');
- pushGenLog($patient, "●>{$general['name']}>{$josaYi} 의술>로써 치료해줍니다!");
-
- if($patientName == "") {
- $patientName = $patient['name'];
- }
- }
-
- if($patientCount == 1) {
- $josaUl = JosaUtil::pick($patientName, '을');
- pushGenLog($general, "●>의술>을 펼쳐 도시의 장수 {$patientName}>{$josaUl} 치료합니다!");
- } else {
- $patientCount -= 1;
- pushGenLog($general, "●>의술>을 펼쳐 도시의 장수들 {$patientName}> 외 {$patientCount}>명을 치료합니다!");
- }
- }
- }
-
- if($general['injury'] > 0) {
- if($general['item'] >=7 && $general['item'] <= 11) {
- //영구약 사용
- $query = "update general set injury=0 where no='$no'";
- MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
-
- $josaUl = JosaUtil::pick($general['item'], '을');
- $log[0] = "●>".getItemName($general['item']).">{$josaUl} 사용하여 치료합니다!";
- pushGenLog($general, $log);
- } elseif($general['injury'] > 10 && $general['item'] == 1 && DecodeCommand($general['turn0'])[0] != 50) {
- //환약 사용
- $query = "update general set injury=0,item=0 where no='$no'";
- MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
-
- $log[0] = "●>환약>을 사용하여 치료합니다!";
- pushGenLog($general, $log);
- } elseif($general['injury'] > 10) {
- //부상 감소
- $query = "update general set injury=injury-10 where no='$no'";
- MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
- } else {
- //부상 감소
- $query = "update general set injury=0 where no='$no'";
- MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
- }
- }
-
-
- if($general['crew'] >= 100){
- $newRice = $general['rice'] - $general['crew'] / 100;
- if($newRice >= 0){
- $db->update('general', [
- 'rice'=>Util::round($newRice)
- ], 'no=%i',$general['no']);
- }
- else{
- $db->update('city', [
- 'pop'=>$db->sqleval('pop + %i', $general['crew'])
- ], 'city=%i', $general['city']);
- $db->update('general', [
- 'crew'=>0,
- 'rice'=>0
- ], 'no=%i',$general['no']);
- pushGenLog($general, ["●>군량이 모자라 병사들이 소집해제>되었습니다!"]);
- }
- }
-
-}
-
function CheckHall($no) {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
diff --git a/hwe/sammo/Command/BaseCommand.php b/hwe/sammo/Command/BaseCommand.php
index aa37546b..79577b79 100644
--- a/hwe/sammo/Command/BaseCommand.php
+++ b/hwe/sammo/Command/BaseCommand.php
@@ -127,10 +127,10 @@ abstract class BaseCommand{
abstract protected function argTest():bool;
public function getBrief():string{
- return $this->getName();
+ return static::getName();
}
- public function getName():string {
+ static public function getName():string {
return static::$actionName;
}
diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php
index c9fcfd4c..855500ea 100644
--- a/hwe/sammo/General.php
+++ b/hwe/sammo/General.php
@@ -31,6 +31,13 @@ class General implements iAction{
protected $lastTurn = null;
protected $resultTurn = null;
+ /**
+ * @param array $raw DB row값.
+ * @param null|array $city DB city 테이블의 row값
+ * @param int $year 게임 연도
+ * @param int $month 게임 월
+ * @param bool $fullConstruct iAction, 및 ActionLogger 초기화 여부, false인 경우 no, name, city, nation, level 정도로 초기화 가능
+ */
public function __construct(array $raw, ?array $city, int $year, int $month, bool $fullConstruct=true){
//TODO: 밖에서 가져오도록 하면 버그 확률이 높아짐. 필요한 raw 값을 직접 구해야함.
@@ -39,15 +46,14 @@ class General implements iAction{
$this->raw = $raw;
$this->rawCity = $city;
- if(!$fullConstruct){
- return;
- }
-
if(key_exists('last_turn', $this->raw)){
$this->lastTurn = LastTurn::fromJson($this->raw['last_turn']);
}
$this->resultTurn = new LastTurn();
+ if(!$fullConstruct){
+ return;
+ }
$this->logger = new ActionLogger(
$this->getVar('no'),
diff --git a/src/sammo/Util.php b/src/sammo/Util.php
index afcf2398..42c73fc7 100644
--- a/src/sammo/Util.php
+++ b/src/sammo/Util.php
@@ -269,17 +269,6 @@ class Util extends \utilphp\util
return $result;
}
- public static function pickArrayFromArrayOfDictWithKey(array $arrayOfDict, string $key):array{
- $result = [];
- foreach($arrayOfDict as $array){
- if(!key_exist($key, $array)){
- continue;
- }
- $result[] = $array[$key];
- }
- return $result;
- }
-
public static function convertArrayToDict($arr, $keyName)
{
$result = [];