첫 화면 띄우기 성공

This commit is contained in:
2018-11-26 04:05:34 +09:00
parent 8bb9ed8a18
commit af9cbb47ef
73 changed files with 350 additions and 289 deletions
+29 -29
View File
@@ -137,17 +137,11 @@ function getRandGenName() {
function cityInfo() { function cityInfo(General $generalObj) {
$db = DB::db(); $db = DB::db();
$connect=$db->get();
$userID = Session::getUserID();
$query = "select no,city from general where owner='{$userID}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$me = MYDB_fetch_array($result);
// 도시 정보 // 도시 정보
$city = getCity($me['city']); $city = $generalObj->getRawCity();
$nation = getNationStaticInfo($city['nation']); $nation = getNationStaticInfo($city['nation']);
@@ -181,29 +175,35 @@ function cityInfo() {
echo "지배 국가 【 {$nation['name']}"; echo "지배 국가 【 {$nation['name']}";
} }
if($city['gen1'] > 0) { $officers = [];
$query = "select name from general where no='{$city['gen1']}'"; $reqOfficersID = [];
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gen1 = MYDB_fetch_array($result); if ($city['gen1'] > 0) {
} else { $reqOfficersID[] = $city['gen1'];
$gen1 = ['name'=>'-']; }
else{
$officers[1] = '-';
} }
if($city['gen2'] > 0) { if ($city['gen2'] > 0) {
$query = "select name from general where no='{$city['gen2']}'"; $reqOfficersID[] = $city['gen2'];
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); }
$gen2 = MYDB_fetch_array($result); else{
} else { $officers[2] = '-';
$gen2 = ['name'=>'-'];
} }
if($city['gen3'] > 0) { if ($city['gen3'] > 0) {
$query = "select name from general where no='{$city['gen3']}'"; $reqOfficersID[] = $city['gen3'];
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gen3 = MYDB_fetch_array($result);
} else {
$gen3 = ['name'=>'-'];
} }
else{
$officers[3] = '-';
}
foreach($db->queryAllLists('SELECT level, name FROM general WHERE no IN %li', $reqOfficersID) as [$level, $name]){
$officers[$level] = $name;
}
echo " echo "
</b></td> </b></td>
@@ -214,7 +214,7 @@ function cityInfo() {
<td rowspan=2 style='text-align:center;' class='bg1'><b>민심</b></td> <td rowspan=2 style='text-align:center;' class='bg1'><b>민심</b></td>
<td height=7>".bar($trust)."</td> <td height=7>".bar($trust)."</td>
<td rowspan=2 style='text-align:center;' class='bg1'><b>태수</b></td> <td rowspan=2 style='text-align:center;' class='bg1'><b>태수</b></td>
<td rowspan=2 style='text-align:center;'>{$gen1['name']}</td> <td rowspan=2 style='text-align:center;'>{$officers[1]}</td>
</tr> </tr>
<tr> <tr>
<td colspan=3 style='text-align:center;'>{$city['pop']}/{$city['pop2']}</td> <td colspan=3 style='text-align:center;'>{$city['pop']}/{$city['pop2']}</td>
@@ -228,7 +228,7 @@ function cityInfo() {
<td width=50 rowspan=2 style='text-align:center;' class='bg1'><b>치안</b></td> <td width=50 rowspan=2 style='text-align:center;' class='bg1'><b>치안</b></td>
<td width=100 height=7>".bar($secu)."</td> <td width=100 height=7>".bar($secu)."</td>
<td width=50 rowspan=2 style='text-align:center;' class='bg1'><b>군사</b></td> <td width=50 rowspan=2 style='text-align:center;' class='bg1'><b>군사</b></td>
<td rowspan=2 style='text-align:center;'>{$gen2['name']}</td> <td rowspan=2 style='text-align:center;'>{$officers[2]}</td>
</tr> </tr>
<tr> <tr>
<td style='text-align:center;'>{$city['agri']}/{$city['agri2']}</td> <td style='text-align:center;'>{$city['agri']}/{$city['agri2']}</td>
@@ -243,7 +243,7 @@ function cityInfo() {
<td rowspan=2 style='text-align:center;' class='bg1'><b>시세</b></td> <td rowspan=2 style='text-align:center;' class='bg1'><b>시세</b></td>
<td height=7>".bar($trade)."</td> <td height=7>".bar($trade)."</td>
<td rowspan=2 style='text-align:center;' class='bg1'><b>시중</b></td> <td rowspan=2 style='text-align:center;' class='bg1'><b>시중</b></td>
<td rowspan=2 style='text-align:center;'>{$gen3['name']}</td> <td rowspan=2 style='text-align:center;'>{$officers[3]}</td>
</tr> </tr>
<tr> <tr>
<td style='text-align:center;'>{$city['def']}/{$city['def2']}</td> <td style='text-align:center;'>{$city['def']}/{$city['def2']}</td>
+7 -40
View File
@@ -427,20 +427,13 @@ function commandGroup($typename, $type=0) {
} }
} }
function printCommandTable() { function printCommandTable(General $generalObj) {
$db = DB::db(); $db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env'); $gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$userID = Session::getUserID(); $userID = Session::getUserID();
$gameStor->cacheAll(); $gameStor->turnOnCache();
$env = $gameStor->getAll(); $env = $gameStor->getAll();
$admin = $gameStor->getAll();
$session = Session::getInstance();
$generalID = $session->generalID;
$generalObj = General::createGeneralObjFromDB($generalID);
?> ?>
<select id='generalCommandList' name='commandtype' size=1 style='height:20px;width:260px;color:white;background-color:black;font-size:12px;'>"; <select id='generalCommandList' name='commandtype' size=1 style='height:20px;width:260px;color:white;background-color:black;font-size:12px;'>";
@@ -575,16 +568,8 @@ function chiefCommandTable() {
"; ";
} }
function myInfo() { function myInfo(General $generalObj) {
$db = DB::db(); generalInfo($generalObj->getID());
$connect=$db->get();
$userID = Session::getUserID();
$query = "select no from general where owner='{$userID}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$me = MYDB_fetch_array($result);
generalInfo($me['no']);
} }
function generalInfo($no) { function generalInfo($no) {
@@ -893,14 +878,6 @@ function generalInfo2($no) {
</table>"; </table>";
} }
function adminMsg() {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$msg = $gameStor->msg;
return "운영자 메세지 : <span style='color:yellow;'>$msg</span>";
}
function getOnlineNum() { function getOnlineNum() {
return KVStorage::getStorage(DB::db(), 'game_env')->online; return KVStorage::getStorage(DB::db(), 'game_env')->online;
} }
@@ -920,21 +897,11 @@ function onlinegen() {
return $onlinegen; return $onlinegen;
} }
function onlineNation() { function nationMsg(General $general) {
$db = DB::db(); $db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
return $gameStor->onlinenation;
}
function nationMsg() {
$db = DB::db();
$connect=$db->get();
$userID = Session::getUserID();
$msg = $db->queryFirstField( $msg = $db->queryFirstField(
'SELECT msg FROM nation WHERE nation = (SELECT nation FROM general WHERE `owner` = %i)', 'SELECT msg FROM nation WHERE nation = %i',
$userID $general->getNationID()
); );
return $msg?:''; return $msg?:'';
+8 -13
View File
@@ -10,19 +10,11 @@ namespace sammo;
*/ */
function getCharacterList(){ function getCharacterList(){
$infoText = [ $infoText = [];
9=>['안전', '사기 -5, 징·모병 비용 -20%'], foreach(GameConst::$allPersonality as $personalityID){
8=>['유지', '훈련 -5, 징·모병 비용 -20%'], $class = getPersonalityClass($personalityID);
7=>['재간', '명성 -10%, 징·모병 비용 -20%'], $infoText[$personalityID] = [$class::$name, $class::$info];
6=>['출세', '명성 +10%, 징·모병 비용 +20%'], }
5=>['할거', '명성 -10%, 훈련 +5'],
4=>['정복', '명성 -10%, 사기 +5'],
3=>['패권', '훈련 +5, 징·모병 비용 +20%'],
2=>['의협', '사기 +5, 징·모병 비용 +20%'],
1=>['대의', '명성 +10%, 훈련 -5'],
0=>['왕좌', '명성 +10%, 사기 -5'],
10=>['은둔', '명성 -10%, 계급 -10%, 사기 -5, 훈련 -5, 단련 성공률 +10%'],
];
return $infoText; return $infoText;
} }
@@ -35,6 +27,9 @@ function CharCall($call) {
foreach(getCharacterList() as $id => [$name, $info]){ foreach(getCharacterList() as $id => [$name, $info]){
$invTable[$name] = $id; $invTable[$name] = $id;
} }
if(!key_exists($call, $invTable)){
throw new \InvalidArgumentException("{$call}은 올바른 성격이 아님");
}
return $invTable[$call]; return $invTable[$call];
} }
+4 -3
View File
@@ -49,9 +49,10 @@ return "
"; ";
} }
function displayCharInfo(?int $type):string{ function displayCharInfo(string $type):string{
$info = getCharInfo($type); $class = getPersonalityClass($type);
$text = getGenChar($type); $info = $class::$info;
$text = $class::$name;
$templates = new \League\Plates\Engine(__dir__.'/templates'); $templates = new \League\Plates\Engine(__dir__.'/templates');
+28 -26
View File
@@ -17,11 +17,6 @@ if (!$userID) {
die(); die();
} }
$me = $db->queryFirstRow(
'SELECT no,con,turntime,newmsg,newvote,`level` from general where owner = %i',
$userID
);
//턴 실행. //턴 실행.
TurnExecutionHelper::executeAllCommand(); TurnExecutionHelper::executeAllCommand();
@@ -30,6 +25,11 @@ if(!$session->isGameLoggedIn()){
die(); die();
} }
$me = $db->queryFirstRow(
'SELECT no,con,turntime,newmsg,newvote,`level` from general where owner = %i',
$userID
);
//그새 사망이면 //그새 사망이면
if ($me === null) { if ($me === null) {
$session->logoutGame(); $session->logoutGame();
@@ -37,6 +37,8 @@ if ($me === null) {
die(); die();
} }
$gameStor->cacheAll(true);
if ($me['newmsg'] == 1 || $me['newvote'] == 1) { if ($me['newmsg'] == 1 || $me['newvote'] == 1) {
$db->update('general', [ $db->update('general', [
'newmsg'=>0, 'newmsg'=>0,
@@ -44,8 +46,6 @@ if ($me['newmsg'] == 1 || $me['newvote'] == 1) {
], 'owner=%i', $userID); ], 'owner=%i', $userID);
} }
$admin = $gameStor->getValues(['develcost','online','conlimit','tournament','tnmt_type','turnterm','scenario','scenario_text','extended_general','fiction','npcmode','vote','vote_title','map_theme']);
$plock = $db->queryFirstField('SELECT plock FROM plock LIMIT 1'); $plock = $db->queryFirstField('SELECT plock FROM plock LIMIT 1');
$con = checkLimit($me['con']); $con = checkLimit($me['con']);
@@ -54,29 +54,31 @@ if ($con >= 2) {
exit(); exit();
} }
$scenario = $admin['scenario_text']; $generalObj = General::createGeneralObjFromDB($me['no']);
$generalObj->setRawCity($db->queryFirstRow('SELECT * FROM city WHERE city = %i', $generalObj->getCityID()));
$scenario = $gameStor->scenario_text;
$valid = 0; $valid = 0;
if ($admin['extended_general'] == 0) { if ($gameStor->extended_general == 0) {
$extend = "표준"; $extend = "표준";
} else { } else {
$extend = "확장"; $extend = "확장";
$valid = 1; $valid = 1;
} }
if ($admin['fiction'] == 0) { if ($gameStor->fiction == 0) {
$fiction = "사실"; $fiction = "사실";
} else { } else {
$fiction = "가상"; $fiction = "가상";
$valid = 1; $valid = 1;
} }
if ($admin['npcmode'] == 0) { if ($gameStor->npcmode == 0) {
$npcmode = "불가능"; $npcmode = "불가능";
} else { } else {
$npcmode = "가능"; $npcmode = "가능";
$valid = 1; $valid = 1;
} }
$color = "cyan"; $color = "cyan";
$mapTheme = $admin['map_theme']; $mapTheme = $gameStor->map_theme;
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
@@ -136,8 +138,8 @@ $(function(){
<tr height=30> <tr height=30>
<td width=198><?=info(2)?></td> <td width=198><?=info(2)?></td>
<td width=198>전체 접속자 수 : <?=$admin['online']?> 명</td> <td width=198>전체 접속자 수 : <?=$gameStor->online?> 명</td>
<td width=198>턴당 갱신횟수 : <?=$admin['conlimit']?>회</td> <td width=198>턴당 갱신횟수 : <?=$gameStor->conlimit?>회</td>
<td width=398 colspan=2><?=info(3)?></td> <td width=398 colspan=2><?=info(3)?></td>
</tr> </tr>
<tr height=30> <tr height=30>
@@ -154,15 +156,15 @@ echo "
<td align=center> <td align=center>
"; ";
switch ($admin['tnmt_type']) { switch ($gameStor->tnmt_type) {
case 0: $str = "전력전"; break; case 0: $str = "전력전"; break;
case 1: $str = "통솔전"; break; case 1: $str = "통솔전"; break;
case 2: $str = "일기토"; break; case 2: $str = "일기토"; break;
case 3: $str = "설전"; break; case 3: $str = "설전"; break;
} }
$str2 = getTournament($admin['tournament']); $str2 = getTournament($gameStor->tournament);
$str3 = getTournamentTime(); $str3 = getTournamentTime();
if ($admin['tournament'] == 0) { if ($gameStor->tournament == 0) {
echo "<font color=magenta>현재 토너먼트 경기 없음</font>"; echo "<font color=magenta>현재 토너먼트 경기 없음</font>";
} else { } else {
echo "<marquee scrollamount=2>↑<font color=cyan>{$str}</font> {$str2} {$str3}↑</marquee>"; echo "<marquee scrollamount=2>↑<font color=cyan>{$str}</font> {$str2} {$str3}↑</marquee>";
@@ -185,8 +187,8 @@ echo "
<td colspan=2 align=center> <td colspan=2 align=center>
"; ";
$vote = $admin['vote']?:['']; $vote = $gameStor->vote?:[''];
$vote_title = Tag2Code($admin['vote_title']??'-'); $vote_title = Tag2Code($gameStor->vote_title??'-');
if ($vote[0] == "") { if ($vote[0] == "") {
echo "<font color=magenta>진행중 설문 없음</font>"; echo "<font color=magenta>진행중 설문 없음</font>";
} else { } else {
@@ -198,9 +200,9 @@ echo "
</td> </td>
</tr>"; </tr>";
?> ?>
<tr><td colspan=5 style="text-align:left;">접속중인 국가: <?=onlinenation()?></td></tr> <tr><td colspan=5 style="text-align:left;">접속중인 국가: <?=$gameStor->onlinenation?></td></tr>
<tr><td colspan=5 style="text-align:left;"><?=adminMsg()?></td></tr> <tr><td colspan=5 style="text-align:left;">운영자 메세지 : <span style='color:yellow;'><?=$gameStor->msg?></span></td></tr>
<tr><td colspan=5 style="text-align:left;"><div>【 국가방침 】</div><div><?=nationMsg()?></div></td></tr> <tr><td colspan=5 style="text-align:left;"><div>【 국가방침 】</div><div><?=nationMsg($generalObj)?></div></td></tr>
<tr><td colspan=5 style="text-align:left;">【 접속자 】<?=onlinegen()?></td></tr> <tr><td colspan=5 style="text-align:left;">【 접속자 】<?=onlinegen()?></td></tr>
<?php <?php
if ($session->userGrade >= 5) { if ($session->userGrade >= 5) {
@@ -244,7 +246,7 @@ else if($session->userGrade == 4){
</tr> </tr>
<tr> <tr>
<td rowspan=3 width=50 valign=top><?=turnTable()?></td> <td rowspan=3 width=50 valign=top><?=turnTable()?></td>
<td style="width:650px;border:none;text-align:center;"><?php cityInfo(); ?></td> <td style="width:650px;border:none;text-align:center;"><?php cityInfo($generalObj); ?></td>
</tr> </tr>
<tr> <tr>
<td style='width:650px;' align=right> <td style='width:650px;' align=right>
@@ -267,7 +269,7 @@ else if($session->userGrade == 4){
</tr> </tr>
<tr> <tr>
<td align=right style="'width:650px;border:none;"> <td align=right style="'width:650px;border:none;">
<?php printCommandTable()?> <?php printCommandTable($generalObj)?>
<input id="mainBtnSubmit" type=button style=background-color:<?=GameConst::$basecolor2?>;color:white;width:110px;font-size:13px; value='실 행' onclick='refreshing(this, 3,form2)'><input type=button style=background-color:<?=GameConst::$basecolor2?>;color:white;width:110px;font-size:13px; value='갱 신' onclick='refreshing(this, 0,0)'><input type=button style=background-color:<?=GameConst::$basecolor2?>;color:white;width:160px;font-size:13px; value='로비로' onclick=location.replace('../')><br> <input id="mainBtnSubmit" type=button style=background-color:<?=GameConst::$basecolor2?>;color:white;width:110px;font-size:13px; value='실 행' onclick='refreshing(this, 3,form2)'><input type=button style=background-color:<?=GameConst::$basecolor2?>;color:white;width:110px;font-size:13px; value='갱 신' onclick='refreshing(this, 0,0)'><input type=button style=background-color:<?=GameConst::$basecolor2?>;color:white;width:160px;font-size:13px; value='로비로' onclick=location.replace('../')><br>
</td> </td>
</tr> </tr>
@@ -275,7 +277,7 @@ else if($session->userGrade == 4){
<table class="tb_layout bg0" style="width:1000px;"> <table class="tb_layout bg0" style="width:1000px;">
<tr> <tr>
<td width=498 style="border:none;"><?php myNationInfo(); ?></td> <td width=498 style="border:none;"><?php myNationInfo(); ?></td>
<td width=498 style="border:none;"><?php myInfo(); ?></td> <td width=498 style="border:none;"><?php myInfo($generalObj); ?></td>
</tr> </tr>
<tr><td colspan=2><?=commandButton()?></td></tr> <tr><td colspan=2><?=commandButton()?></td></tr>
</table> </table>
@@ -326,7 +328,7 @@ if ($me['newmsg'] == 1) {
MessageBox("개인 서신이 도착했습니다!"); MessageBox("개인 서신이 도착했습니다!");
} }
if ($me['newvote'] == 1) { if ($me['newvote'] == 1) {
$develcost = $admin['develcost']*5; $develcost = $gameStor->develcost*5;
MessageBox("설문조사에 참여하시면 금{$develcost}과 유니크템을 드립니다! (우측 상단 설문조사 메뉴)"); MessageBox("설문조사에 참여하시면 금{$develcost}과 유니크템을 드립니다! (우측 상단 설문조사 메뉴)");
} }
?> ?>
+8 -17
View File
@@ -42,9 +42,9 @@ var defaultStatMax = <?=GameConst::$defaultStatMax?>;
var charInfoText = <?php var charInfoText = <?php
$charInfoText = []; $charInfoText = [];
for($i=0;$i<=9;$i++){ foreach(GameConst::$availablePersonality as $personalityID){
//XXX:하드코딩 금지! $personalityInfo = getPersonalityClass($personalityID)::$info;
$charInfoText[$i] = getCharInfo($i); $charInfoText[$personalityID];
} }
echo Json::encode((object)$charInfoText); echo Json::encode((object)$charInfoText);
?>; ?>;
@@ -120,20 +120,11 @@ if ($admin['show_img_level'] >= 1 && $member['grade'] >= 1 && $member['picture']
<td width=498 align=right id=bg1>성격</td> <td width=498 align=right id=bg1>성격</td>
<td colspan=2> <td colspan=2>
<select id="selChar" name=character size=1 maxlength=15 style=color:white;background-color:black;> <select id="selChar" name=character size=1 maxlength=15 style=color:white;background-color:black;>
<option selected value=11>????</option> <option selected value='Random'>????</option>
<!-- <?php foreach(GameConst::$availablePersonality as $personalityID): ?>
<option value=10>은둔</option> <?php $personalityName = getPersonalityClass($personalityID)::$name; ?>
--> <option value='<?=$personalityID?>'><?=$personalityName?></option>
<option value=9>안전</option> <?php endforeach; ?>
<option value=8>유지</option>
<option value=7>재간</option>
<option value=6>출세</option>
<option value=5>할거</option>
<option value=4>정복</option>
<option value=3>패권</option>
<option value=2>의협</option>
<option value=1>대의</option>
<option value=0>왕좌</option>
</select> <span id="charInfoText"></span> </select> <span id="charInfoText"></span>
</td> </td>
</tr> </tr>
+2 -2
View File
@@ -204,8 +204,8 @@ if ($admin['show_img_level'] >= 1 && $member['grade'] >= 1 && $member['picture']
} }
//성격 랜덤시 //성격 랜덤시
if ($character == 11) { if (!in_array($character, GameConst::$availablePersonality)){
$character = rand()%10; $character = Util::choiceRandom(GameConst::$availablePersonality);
} }
//상성 랜덤 //상성 랜덤
$affinity = rand()%150 + 1; $affinity = rand()%150 + 1;
+25 -9
View File
@@ -10,17 +10,33 @@ use function sammo\getItemCost2;
//XXX:임시용! //XXX:임시용!
class che_Dummy extends \sammo\BaseItem{ class che_Dummy extends \sammo\BaseItem{
static $id; protected $_id;
static $name; protected $_name;
static $info; protected $_info;
static $cost; protected $_cost;
static $consumable = false; protected $_consumable = false;
function getID(){
return $this->_id;
}
function getName(){
return $this->_name;
}
function getInfo(){
return $this->_info;
}
function getCost(){
return $this->_cost;
}
function isConsumable(){
return $this->_consumable;
}
public function __construct(int $itemCode) public function __construct(int $itemCode)
{ {
$this->id = $itemCode = true; $this->_id = $itemCode = true;
[$this->name, $this->info] = getItemInfo($itemCode); [$this->_name, $this->_info] = getItemInfo($itemCode);
$this->cost = getItemCost2($itemCode); $this->_cost = getItemCost2($itemCode);
$this->consumable = isConsumable($itemCode); $this->_consumable = isConsumable($itemCode);
} }
} }
+5 -5
View File
@@ -5,11 +5,11 @@ use \sammo\General;
class che_계략_삼략 extends \sammo\BaseItem{ class che_계략_삼략 extends \sammo\BaseItem{
static $id = 22; protected static $id = 22;
static $name = '삼략(계략)'; protected static $name = '삼략(계략)';
static $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p'; protected static $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p';
static $cost = 200; protected static $cost = 200;
static $consumable = false; protected static $consumable = false;
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
if($turnType == '계략'){ if($turnType == '계략'){
+5 -5
View File
@@ -5,11 +5,11 @@ use \sammo\General;
class che_계략_육도 extends \sammo\BaseItem{ class che_계략_육도 extends \sammo\BaseItem{
static $id = 21; protected static $id = 21;
static $name = '육도(계략)'; protected static $name = '육도(계략)';
static $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p'; protected static $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p';
static $cost = 200; protected static $cost = 200;
static $consumable = false; protected static $consumable = false;
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
if($turnType == '계략'){ if($turnType == '계략'){
+5 -5
View File
@@ -5,11 +5,11 @@ use \sammo\General;
class che_계략_이추 extends \sammo\BaseItem{ class che_계략_이추 extends \sammo\BaseItem{
static $id = 5; protected static $id = 5;
static $name = '이추(계략)'; protected static $name = '이추(계략)';
static $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +10%p'; protected static $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +10%p';
static $cost = 1000; protected static $cost = 1000;
static $consumable = true; protected static $consumable = true;
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
if($turnType == '계략'){ if($turnType == '계략'){
+5 -5
View File
@@ -5,11 +5,11 @@ use \sammo\General;
class che_계략_향낭 extends \sammo\BaseItem{ class che_계략_향낭 extends \sammo\BaseItem{
static $id = 5; protected static $id = 5;
static $name = '항냥(계략)'; protected static $name = '항냥(계략)';
static $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p'; protected static $info = '[계략] 화계·탈취·파괴·선동 : 성공률 +20%p';
static $cost = 3000; protected static $cost = 3000;
static $consumable = true; protected static $consumable = true;
public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{ public function onCalcDomestic(string $turnType, string $varType, float $value, $aux=null):float{
if($turnType == '계략'){ if($turnType == '계략'){
@@ -7,11 +7,11 @@ use \sammo\GeneralTriggerCaller;
class che_의술_청낭서 extends \sammo\BaseItem{ class che_의술_청낭서 extends \sammo\BaseItem{
static $id = 23; protected static $id = 23;
static $name = '청낭서(의술)'; protected static $name = '청낭서(의술)';
static $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복<br>[전투] 페이즈마다 20% 확률로 치료 발동(아군 피해 1/3 감소)'; protected static $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복<br>[전투] 페이즈마다 20% 확률로 치료 발동(아군 피해 1/3 감소)';
static $cost = 200; protected static $cost = 200;
static $consumable = false; protected static $consumable = false;
public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{
return new GeneralTriggerCaller([ return new GeneralTriggerCaller([
@@ -7,11 +7,11 @@ use \sammo\GeneralTriggerCaller;
class che_의술_태평청령 extends \sammo\BaseItem{ class che_의술_태평청령 extends \sammo\BaseItem{
static $id = 24; protected static $id = 24;
static $name = '태평청령(의술)'; protected static $name = '태평청령(의술)';
static $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복<br>[전투] 페이즈마다 20% 확률로 치료 발동(아군 피해 1/3 감소)'; protected static $info = '[군사] 매 턴마다 자신(100%)과 소속 도시 장수(적 포함 50%) 부상 회복<br>[전투] 페이즈마다 20% 확률로 치료 발동(아군 피해 1/3 감소)';
static $cost = 200; protected static $cost = 200;
static $consumable = false; protected static $consumable = false;
public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{
return new GeneralTriggerCaller([ return new GeneralTriggerCaller([
@@ -7,11 +7,11 @@ use \sammo\GeneralTriggerCaller;
class che_치료_도소연명 extends \sammo\BaseItem{ class che_치료_도소연명 extends \sammo\BaseItem{
static $id = 9; protected static $id = 9;
static $name = '도소연명(치료)'; protected static $name = '도소연명(치료)';
static $info = '[군사] 턴 실행 전 부상 회복.'; protected static $info = '[군사] 턴 실행 전 부상 회복.';
static $cost = 200; protected static $cost = 200;
static $consumable = false; protected static $consumable = false;
public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{
return new GeneralTriggerCaller([ return new GeneralTriggerCaller([
@@ -7,11 +7,11 @@ use \sammo\GeneralTriggerCaller;
class che_치료_무후행군 extends \sammo\BaseItem{ class che_치료_무후행군 extends \sammo\BaseItem{
static $id = 8; protected static $id = 8;
static $name = '무후행군(치료)'; protected static $name = '무후행군(치료)';
static $info = '[군사] 턴 실행 전 부상 회복.'; protected static $info = '[군사] 턴 실행 전 부상 회복.';
static $cost = 200; protected static $cost = 200;
static $consumable = false; protected static $consumable = false;
public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{
return new GeneralTriggerCaller([ return new GeneralTriggerCaller([
@@ -7,11 +7,11 @@ use \sammo\GeneralTriggerCaller;
class che_치료_오석산 extends \sammo\BaseItem{ class che_치료_오석산 extends \sammo\BaseItem{
static $id = 7; protected static $id = 7;
static $name = '오석산(치료)'; protected static $name = '오석산(치료)';
static $info = '[군사] 턴 실행 전 부상 회복.'; protected static $info = '[군사] 턴 실행 전 부상 회복.';
static $cost = 200; protected static $cost = 200;
static $consumable = false; protected static $consumable = false;
public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{
return new GeneralTriggerCaller([ return new GeneralTriggerCaller([
@@ -7,11 +7,11 @@ use \sammo\GeneralTriggerCaller;
class che_치료_정력견혈 extends \sammo\BaseItem{ class che_치료_정력견혈 extends \sammo\BaseItem{
static $id = 11; protected static $id = 11;
static $name = '정력견혈(치료)'; protected static $name = '정력견혈(치료)';
static $info = '[군사] 턴 실행 전 부상 회복.'; protected static $info = '[군사] 턴 실행 전 부상 회복.';
static $cost = 200; protected static $cost = 200;
static $consumable = false; protected static $consumable = false;
public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{
return new GeneralTriggerCaller([ return new GeneralTriggerCaller([
@@ -7,11 +7,11 @@ use \sammo\GeneralTriggerCaller;
class che_치료_칠엽청점 extends \sammo\BaseItem{ class che_치료_칠엽청점 extends \sammo\BaseItem{
static $id = 10; protected static $id = 10;
static $name = '칠엽청점(치료)'; protected static $name = '칠엽청점(치료)';
static $info = '[군사] 턴 실행 전 부상 회복.'; protected static $info = '[군사] 턴 실행 전 부상 회복.';
static $cost = 200; protected static $cost = 200;
static $consumable = false; protected static $consumable = false;
public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{
return new GeneralTriggerCaller([ return new GeneralTriggerCaller([
+5 -5
View File
@@ -7,11 +7,11 @@ use \sammo\GeneralTriggerCaller;
class che_치료_환약 extends \sammo\BaseItem{ class che_치료_환약 extends \sammo\BaseItem{
static $id = 1; protected static $id = 1;
static $name = '환약(치료)'; protected static $name = '환약(치료)';
static $info = '[군사] 턴 실행 전 부상 회복. 1회용'; protected static $info = '[군사] 턴 실행 전 부상 회복. 1회용';
static $cost = 100; protected static $cost = 100;
static $consumable = true; protected static $consumable = true;
public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{ public function getPreTurnExecuteTriggerList(General $general):?GeneralTriggerCaller{
return new GeneralTriggerCaller([ return new GeneralTriggerCaller([
+1 -1
View File
@@ -3,7 +3,7 @@ namespace sammo\ActionPersonality;
use \sammo\iAction; use \sammo\iAction;
use \sammo\General; use \sammo\General;
class che_대의 implements iAction{ class che_왕좌 implements iAction{
use \sammo\DefaultAction; use \sammo\DefaultAction;
static $id = 0; static $id = 0;
+21 -5
View File
@@ -7,11 +7,27 @@ use \sammo\General;
class BaseItem implements iAction{ class BaseItem implements iAction{
use \sammo\DefaultAction; use \sammo\DefaultAction;
static $id = 0; protected static $id = 0;
static $name = '-'; protected static $name = '-';
static $info = ''; protected static $info = '';
static $cost = null; protected static $cost = null;
static $consumable = false; protected static $consumable = false;
function getID(){
return $this->id;
}
function getName(){
return $this->name;
}
function getInfo(){
return $this->info;
}
function getCost(){
return $this->cost;
}
function isConsumable(){
return $this->consumable;
}
function isValidTurnItem(string $actionType, string $command):bool{ function isValidTurnItem(string $actionType, string $command):bool{
return false; return false;
+22 -9
View File
@@ -3,7 +3,7 @@ namespace sammo\Command;
use \sammo\{ use \sammo\{
Util, JosaUtil, DB, Util, JosaUtil, DB,
General, General, GameConst,
ActionLogger ActionLogger
}; };
@@ -47,7 +47,7 @@ abstract class BaseCommand{
protected $alternative = null; protected $alternative = null;
static private $isInitStatic = false; static protected $isInitStatic = false;
protected static function initStatic(){ protected static function initStatic(){
} }
@@ -62,7 +62,7 @@ abstract class BaseCommand{
$this->logger = $generalObj->getLogger(); $this->logger = $generalObj->getLogger();
$this->env = $env; $this->env = $env;
$this->arg = $arg; $this->arg = $arg;
if ($this->argTest()) { if (!$this->argTest()) {
return; return;
} }
$this->isArgValid = true; $this->isArgValid = true;
@@ -102,7 +102,8 @@ abstract class BaseCommand{
if($hasArgs){ if($hasArgs){
return; return;
} }
$this->city = $db->queryFirstRow('SELECT %lb FROM city WHERE city=%i', $args, $this->generalObj->getVar('city'));
$this->city = $db->queryFirstRow('SELECT %l FROM city WHERE city=%i', Util::formatListOfBackticks($args), $this->generalObj->getVar('city'));
if($this->generalObj->getRawCity() === null){ if($this->generalObj->getRawCity() === null){
$this->generalObj->setRawCity($this->city); $this->generalObj->setRawCity($this->city);
} }
@@ -115,6 +116,12 @@ abstract class BaseCommand{
return; return;
} }
$nationID = $this->generalObj->getNationID();
if($nationID == 0){
$this->nation = $this->generalObj->getStaticNation();
return;
}
$defaultArgs = ['nation', 'name', 'color', 'type', 'level', 'capital']; $defaultArgs = ['nation', 'name', 'color', 'type', 'level', 'capital'];
$args = array_unique(array_merge($defaultArgs, $args)); $args = array_unique(array_merge($defaultArgs, $args));
if($args == $defaultArgs){ if($args == $defaultArgs){
@@ -135,8 +142,10 @@ abstract class BaseCommand{
'gennum'=>1 'gennum'=>1
]; ];
$db = DB::db(); $db = DB::db();
$destNation = $db->queryFirstRow('SELECT %lb FROM nation WHERE nation=%i', $args, $nationNo); $destNation = $db->queryFirstRow('SELECT %l FROM nation WHERE nation=%i', Util::formatListOfBackticks($args), $nationID);
if($destNation === null){ if($destNation === null){
$destNation = []; $destNation = [];
foreach($args as $arg){ foreach($args as $arg){
@@ -163,13 +172,13 @@ abstract class BaseCommand{
$this->destCity = $db->queryFirstRow('SELECT * FROM city WHERE city=%i', $cityNo); $this->destCity = $db->queryFirstRow('SELECT * FROM city WHERE city=%i', $cityNo);
return; return;
} }
$this->destCity = $db->queryFirstRow('SELECT %lb FROM city WHERE city=%i', $args, $cityNo); $this->destCity = $db->queryFirstRow('SELECT %l FROM city WHERE city=%i', Util::formatListOfBackticks($args), $cityNo);
} }
protected function setDestNation(int $nationNo, ?array $args = null){ protected function setDestNation(int $nationID, ?array $args = null){
$this->resetTestCache(); $this->resetTestCache();
if($args === null || $args === []){ if($args === null || $args === []){
$this->destNation = getNationStaticInfo($nationNo); $this->destNation = getNationStaticInfo($nationID);
return; return;
} }
@@ -190,7 +199,7 @@ abstract class BaseCommand{
]; ];
$db = DB::db(); $db = DB::db();
$destNation = $db->queryFirstRow('SELECT %lb FROM nation WHERE nation=%i', $args, $nationNo); $destNation = $db->queryFirstRow('SELECT %l FROM nation WHERE nation=%i', Util::formatListOfBackticks($args), $nationID);
if($destNation === null){ if($destNation === null){
$destNation = []; $destNation = [];
foreach($args as $arg){ foreach($args as $arg){
@@ -287,7 +296,11 @@ abstract class BaseCommand{
} }
public function isReservable():bool{ public function isReservable():bool{
if($this->reservable !== null){
return $this->reservable;
}
return $this->testReservable() === null;
} }
public function isArgValid():bool{ public function isArgValid():bool{
+4 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -18,6 +18,9 @@ class che_NPC능동 extends Command\GeneralCommand{
static protected $actionName = 'NPC능동'; static protected $actionName = 'NPC능동';
protected function argTest():bool{ protected function argTest():bool{
if($this->arg === null){
return false;
}
if(!key_exists('optionText', $this->arg)){ if(!key_exists('optionText', $this->arg)){
return false; return false;
} }
+4 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -26,6 +26,9 @@ class che_강행 extends Command\GeneralCommand{
static public $reqArg = true; static public $reqArg = true;
protected function argTest():bool{ protected function argTest():bool{
if($this->arg === null){
return false;
}
if(!key_exists('destCityID', $this->arg)){ if(!key_exists('destCityID', $this->arg)){
return false; return false;
} }
+1 -5
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -38,10 +38,6 @@ class che_거병 extends Command\GeneralCommand{
$this->setCity(); $this->setCity();
$this->setNation(); $this->setNation();
if(!key_exists($colorType, GetNationColors())){
return false;
}
$relYear = $env['year'] - $env['startyear']; $relYear = $env['year'] - $env['startyear'];
$this->runnableConstraints=[ $this->runnableConstraints=[
+4 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -29,6 +29,9 @@ class che_건국 extends Command\GeneralCommand{
static public $reqArg = true; static public $reqArg = true;
protected function argTest():bool{ protected function argTest():bool{
if($this->arg === null){
return false;
}
$nationName = $this->arg['nationName']??null; $nationName = $this->arg['nationName']??null;
$nationType = $this->arg['nationType']??null; $nationType = $this->arg['nationType']??null;
$colorType = $this->arg['colorType']??null; $colorType = $this->arg['colorType']??null;
+1 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
//TODO: 아이템 클래스 재확정 후 재 구현! //TODO: 아이템 클래스 재확정 후 재 구현!
@@ -36,6 +36,9 @@ class che_군량매매 extends Command\GeneralCommand{
]; ];
protected function argTest():bool{ protected function argTest():bool{
if($this->arg === null){
return false;
}
$buyRice = $this->arg['buyRice']??null; $buyRice = $this->arg['buyRice']??null;
if(!is_bool($buyRice)){ if(!is_bool($buyRice)){
return false; return false;
+1 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
class che_농지개간 extends che_상업투자{ class che_농지개간 extends che_상업투자{
static protected $cityKey = 'agri'; static protected $cityKey = 'agri';
+1 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
+5 -2
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -28,6 +28,9 @@ class che_등용 extends Command\GeneralCommand{
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;
@@ -74,7 +77,7 @@ class che_등용 extends Command\GeneralCommand{
]; ];
if($this->destGeneralObj->getVar('level') == 12){ if($this->destGeneralObj->getVar('level') == 12){
$this->runnableConstraints[] = ['AlwaysFail', '군주에게는 등용장을 보낼 수 없습니다.']; $this->runnableConstraints[] = ConstraintHelper::AlwaysFail('군주에게는 등용장을 보낼 수 없습니다.');
} }
} }
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, TimeUtil, DB, Util, JosaUtil, TimeUtil,
@@ -27,7 +27,9 @@ class che_랜덤임관 extends Command\GeneralCommand{
static public $reqArg = true; static public $reqArg = true;
protected function argTest():bool{ protected function argTest():bool{
if($this->arg === null){
return false;
}
$destNationIDList = $this->arg['destNationIDList']??null; $destNationIDList = $this->arg['destNationIDList']??null;
//null은 에러, []는 정상 //null은 에러, []는 정상
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -21,8 +21,8 @@ use function \sammo\{
use \sammo\Constraint\Constraint; use \sammo\Constraint\Constraint;
use \sammo\Constraint\ConstraintHelper; use \sammo\Constraint\ConstraintHelper;
class che_모반 extends Command\GeneralCommand{ class che_모반시도 extends Command\GeneralCommand{
static protected $actionName = '모반'; static protected $actionName = '모반시도';
protected function argTest():bool{ protected function argTest():bool{
$this->arg = null; $this->arg = null;
@@ -34,9 +34,6 @@ class che_모반 extends Command\GeneralCommand{
$general = $this->generalObj; $general = $this->generalObj;
$this->setNation(); $this->setNation();
$destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'nation'], 1);
$this->setDestGeneral($destGeneral);
$this->runnableConstraints=[ $this->runnableConstraints=[
ConstraintHelper::NotBeNeutral(), ConstraintHelper::NotBeNeutral(),
+1 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
+1 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -49,7 +49,8 @@ class che_사기진작 extends Command\GeneralCommand{
} }
public function getCost():array{ public function getCost():array{
return [Util::round($this->getVar('crew')/100), 0]; $general = $this->generalObj;
return [Util::round($general->getVar('crew')/100), 0];
} }
public function getPreReqTurn():int{ public function getPreReqTurn():int{
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -36,7 +36,7 @@ class che_상업투자 extends Command\GeneralCommand{
'power'=>'무력경험', 'power'=>'무력경험',
'intel'=>'지력경험', 'intel'=>'지력경험',
]; ];
$statType = $statType[static::$statKey]; $statType = $statTypeBase[static::$statKey];
[$reqGold, $reqRice] = $this->getCost(); [$reqGold, $reqRice] = $this->getCost();
$title = "{$name}({$statType}"; $title = "{$name}({$statType}";
@@ -79,7 +79,7 @@ class che_상업투자 extends Command\GeneralCommand{
public function getCost():array{ public function getCost():array{
$develCost = $this->env['develcost']; $develCost = $this->env['develcost'];
$reqGold = $general->onCalcDomestic(static::$actionKey, 'cost', $develCost); $reqGold = $this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost);
$reqRice = 0; $reqRice = 0;
return [$reqGold, $reqRice]; return [$reqGold, $reqRice];
+1 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
+4 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -27,6 +27,9 @@ class che_선양 extends Command\GeneralCommand{
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;
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
class che_성벽보수 extends che_상업투자{ class che_성벽보수 extends che_상업투자{
static protected $cityKey = 'wall'; static protected $cityKey = 'wall';
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
class che_수비강화 extends che_상업투자{ class che_수비강화 extends che_상업투자{
static protected $cityKey = 'def'; static protected $cityKey = 'def';
+1 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
+4 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -26,6 +26,9 @@ class che_이동 extends Command\GeneralCommand{
static public $reqArg = true; static public $reqArg = true;
protected function argTest():bool{ protected function argTest():bool{
if($this->arg === null){
return false;
}
if(!key_exists('destCityID', $this->arg)){ if(!key_exists('destCityID', $this->arg)){
return false; return false;
} }
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -47,7 +47,7 @@ class che_인재탐색 extends Command\GeneralCommand{
]; ];
$relYear = $env['year'] - $env['startyear']; $relYear = $env['year'] - $env['startyear'];
if($relYear < 3 && $this->nation['gennum'] >= GameConst::$initialNationGenLimit){ if($this->nation['nation'] != 0 && $relYear < 3 && $this->nation['gennum'] >= GameConst::$initialNationGenLimit){
$nationName = $this->nation['name']; $nationName = $this->nation['name'];
$josaUn = JosaUtil::pick($nationName, '은'); $josaUn = JosaUtil::pick($nationName, '은');
$this->runnableConstraints[] = ConstraintHelper::AlwaysFail("현재 <D>{$nationName}</>{$josaUn} 탐색이 제한되고 있습니다."); $this->runnableConstraints[] = ConstraintHelper::AlwaysFail("현재 <D>{$nationName}</>{$josaUn} 탐색이 제한되고 있습니다.");
+4 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -26,6 +26,9 @@ class che_임관 extends Command\GeneralCommand{
static public $reqArg = true; static public $reqArg = true;
protected function argTest():bool{ protected function argTest():bool{
if($this->arg === null){
return false;
}
$destNationID = $this->arg['destNationID']??null; $destNationID = $this->arg['destNationID']??null;
$destGeneralID = $this->arg['destGeneralID']??null; $destGeneralID = $this->arg['destGeneralID']??null;
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
//TODO: 아이템 클래스 재확정 후 재 구현! //TODO: 아이템 클래스 재확정 후 재 구현!
@@ -35,6 +35,9 @@ class che_장비매매 extends Command\GeneralCommand{
]; ];
protected function argTest():bool{ protected function argTest():bool{
if($this->arg === null){
return false;
}
$itemType = $this->arg['itemType']??null; $itemType = $this->arg['itemType']??null;
if(!in_array($itemType, array_keys(static::$itemMap))){ if(!in_array($itemType, array_keys(static::$itemMap))){
return false; return false;
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -58,7 +58,7 @@ class che_정착장려 extends Command\GeneralCommand{
public function getCost():array{ public function getCost():array{
$develCost = $this->env['develcost'] * 2; $develCost = $this->env['develcost'] * 2;
$reqGold = 0; $reqGold = 0;
$reqRice = $general->onCalcDomestic(static::$actionKey, 'cost', $develCost); $reqRice = $this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost);
return [$reqGold, $reqRice]; return [$reqGold, $reqRice];
} }
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -58,7 +58,7 @@ class che_주민선정 extends Command\GeneralCommand{
public function getCost():array{ public function getCost():array{
$develCost = $this->env['develcost'] * 2; $develCost = $this->env['develcost'] * 2;
$reqGold = 0; $reqGold = 0;
$reqRice = $general->onCalcDomestic(static::$actionKey, 'cost', $develCost); $reqRice = $this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost);
return [$reqGold, $reqRice]; return [$reqGold, $reqRice];
} }
+4 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -27,6 +27,9 @@ class che_증여 extends Command\GeneralCommand{
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;
+1 -2
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -35,7 +35,6 @@ class che_집합 extends Command\GeneralCommand{
$this->setCity(); $this->setCity();
$this->setNation(); $this->setNation();
$this->setDestCity($this->arg['destCityID'], []);
[$reqGold, $reqRice] = $this->getCost(); [$reqGold, $reqRice] = $this->getCost();
+5 -2
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -42,6 +42,9 @@ class che_징병 extends Command\GeneralCommand{
} }
protected function argTest():bool{ protected function argTest():bool{
if($this->arg === null){
return false;
}
if(!key_exists('crewType', $this->arg)){ if(!key_exists('crewType', $this->arg)){
return false; return false;
} }
@@ -111,7 +114,7 @@ class che_징병 extends Command\GeneralCommand{
return [0, 0]; return [0, 0];
} }
$reqGold = $this->reqCrewType->costWithTech($this->nation['tech'], $this->reqCrew); $reqGold = $this->reqCrewType->costWithTech($this->nation['tech'], $this->reqCrew);
$reqGold = $general->onCalcDomestic('징병', 'cost', $reqGold, ['armType'=>$this->reqCrewType->armType]); $reqGold = $this->generalObj->onCalcDomestic('징병', 'cost', $reqGold, ['armType'=>$this->reqCrewType->armType]);
$reqGold *= static::$costOffset; $reqGold *= static::$costOffset;
$reqRice = $this->reqCrew / 100; $reqRice = $this->reqCrew / 100;
return [$reqGold, $reqRice]; return [$reqGold, $reqRice];
+4 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -27,6 +27,9 @@ class che_첩보 extends Command\GeneralCommand{
static public $reqArg = true; static public $reqArg = true;
protected function argTest():bool{ protected function argTest():bool{
if($this->arg === null){
return false;
}
if(!key_exists('destCityID', $this->arg)){ if(!key_exists('destCityID', $this->arg)){
return false; return false;
} }
+4 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -27,6 +27,9 @@ class che_출병 extends Command\GeneralCommand{
static public $reqArg = true; static public $reqArg = true;
protected function argTest():bool{ protected function argTest():bool{
if($this->arg === null){
return false;
}
if(!key_exists('destCityID', $this->arg)){ if(!key_exists('destCityID', $this->arg)){
return false; return false;
} }
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
class che_치안강화 extends che_상업투자{ class che_치안강화 extends che_상업투자{
static protected $cityKey = 'secu'; static protected $cityKey = 'secu';
+1 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
+1 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
+1 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
+1 -7
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -40,12 +40,6 @@ class che_해산 extends Command\GeneralCommand{
$this->setCity(); $this->setCity();
$this->setNation(['gennum']); $this->setNation(['gennum']);
if(!key_exists($colorType, GetNationColors())){
return false;
}
$relYear = $env['year'] - $env['startyear'];
$this->runnableConstraints=[ $this->runnableConstraints=[
ConstraintHelper::BeLord(), ConstraintHelper::BeLord(),
ConstraintHelper::WanderingNation(), ConstraintHelper::WanderingNation(),
+4 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -27,6 +27,9 @@ class che_헌납 extends Command\GeneralCommand{
static public $reqArg = true; static public $reqArg = true;
protected function argTest():bool{ protected function argTest():bool{
if($this->arg === null){
return false;
}
if(!key_exists('isGold', $this->arg)){ if(!key_exists('isGold', $this->arg)){
return false; return false;
} }
+4 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
@@ -29,6 +29,9 @@ class che_화계 extends Command\GeneralCommand{
static protected $injuryGeneral = true; static protected $injuryGeneral = true;
protected function argTest():bool{ protected function argTest():bool{
if($this->arg === null){
return false;
}
if(!key_exists('destCityID', $this->arg)){ if(!key_exists('destCityID', $this->arg)){
return false; return false;
} }
+1 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
namespace sammo\GeneralCommand; namespace sammo\Command\General;
use \sammo\{ use \sammo\{
DB, Util, JosaUtil, DB, Util, JosaUtil,
+5
View File
@@ -140,6 +140,11 @@ class GameConstBase
'che_안전', 'che_유지', 'che_재간', 'che_출세', 'che_할거', 'che_정복', 'che_안전', 'che_유지', 'che_재간', 'che_출세', 'che_할거', 'che_정복',
'che_패권', 'che_의협', 'che_대의', 'che_왕좌' 'che_패권', 'che_의협', 'che_대의', 'che_왕좌'
]; ];
/** @var array 존재하는 모든 성향 */
public static $allPersonality = [
'che_안전', 'che_유지', 'che_재간', 'che_출세', 'che_할거', 'che_정복',
'che_패권', 'che_의협', 'che_대의', 'che_왕좌', 'che_은둔', 'None'
];
/** @var array[string] 선택 가능한 커맨드 */ /** @var array[string] 선택 가능한 커맨드 */
public static $availableGeneralCommand = [ public static $availableGeneralCommand = [
+2 -2
View File
@@ -547,7 +547,7 @@ class General implements iAction{
'leader', 'leader2', 'power', 'power2', 'intel', 'intel2', 'weap', 'book', 'horse', 'item', 'leader', 'leader2', 'power', 'power2', 'intel', 'intel2', 'weap', 'book', 'horse', 'item',
'experience', 'dedication', 'level', 'gold', 'rice', 'crew', 'crewtype', 'train', 'atmos', 'turntime', 'experience', 'dedication', 'level', 'gold', 'rice', 'crew', 'crewtype', 'train', 'atmos', 'turntime',
'makelimit', 'killturn', 'block', 'dedlevel', 'explevel', 'age', 'belong', 'makelimit', 'killturn', 'block', 'dedlevel', 'explevel', 'age', 'belong',
'personal', 'special', 'special2', 'term', 'mode', 'npc', 'npc_org', 'deadyear', 'npcmsg', 'personal', 'special', 'special2', 'mode', 'npc', 'npc_org', 'deadyear', 'npcmsg',
'dex0', 'dex10', 'dex20', 'dex30', 'dex40', 'dex0', 'dex10', 'dex20', 'dex30', 'dex40',
'warnum', 'killnum', 'deathnum', 'killcrew', 'deathcrew', 'recwar', 'last_turn' 'warnum', 'killnum', 'deathnum', 'killcrew', 'deathcrew', 'recwar', 'last_turn'
]; ];
@@ -562,7 +562,7 @@ class General implements iAction{
$column = array_unique(array_merge($minimumColumn, $column)); $column = array_unique(array_merge($minimumColumn, $column));
} }
$rawGeneral = $db->queryFirstRow('SELECT $lb FROM general WHERE no = %i', $generalID); $rawGeneral = $db->queryFirstRow('SELECT %l FROM general WHERE no = %i', Util::formatListOfBackticks($column), $generalID);
if(!$rawGeneral){ if(!$rawGeneral){
return new DummyGeneral($constructMode > 0); return new DummyGeneral($constructMode > 0);
} }
+2 -2
View File
@@ -203,10 +203,10 @@ class NPC{
} }
if($this->ego == null || $isFictionMode){ if($this->ego == null || $isFictionMode){
$ego = mt_rand(0, 9);//TODO: 나중에 성격을 따로 분리할 경우 클래스를 참조. $ego = Util::choiceRandom(GameConst::$availablePersonality);
} }
else{ else{
$ego = \sammo\CharCall($this->ego); $ego = Util::getClassName(\sammo\getPersonalityClass($this->ego));
} }
$affinity = $this->affinity; $affinity = $this->affinity;
+1 -1
View File
@@ -71,7 +71,7 @@ CREATE TABLE `general` (
`history` MEDIUMTEXT NULL DEFAULT '', `history` MEDIUMTEXT NULL DEFAULT '',
`belong` INT(2) NULL DEFAULT '1', `belong` INT(2) NULL DEFAULT '1',
`betray` INT(2) NULL DEFAULT '0', `betray` INT(2) NULL DEFAULT '0',
`personal` INT(2) NULL DEFAULT '0', `personal` VARCHAR(20) NOT NULL DEFAULT 'None',
`special` VARCHAR(20) NOT NULL DEFAULT 'None', `special` VARCHAR(20) NOT NULL DEFAULT 'None',
`specage` INT(2) NULL DEFAULT '0', `specage` INT(2) NULL DEFAULT '0',
`special2` VARCHAR(20) NOT NULL DEFAULT 'None', `special2` VARCHAR(20) NOT NULL DEFAULT 'None',
+22 -1
View File
@@ -579,7 +579,7 @@ class Util extends \utilphp\util
} }
public static function getClassNameFromObj($object){ public static function getClassNameFromObj($object){
$reflect = new ReflectionClass($object); $reflect = new \ReflectionClass($object);
return $reflect->getShortName(); return $reflect->getShortName();
} }
@@ -603,4 +603,25 @@ class Util extends \utilphp\util
} }
return true; return true;
} }
/**
* MeekroDB에서 %lb의 처리가 이상하여 따로 만든 코드
*/
public static function formatListOfBackticks(array $array):string{
if(!$array){
throw new MustNotBeReachedException('backtick 목록에 없음');
}
//.이 들어간 경우에는 분리해서 묶어야함.
return join(',', array_map(function($value){
$value = trim($value, " \t\r\n\0\x0b`");
if(strpos($value, '.') !== false){
$value = explode('.', $value);
$value = array_map(function($str){
return trim($value, " \t\r\n\0\x0b`");
}, $value);
$value = join('`.`', $value);
}
return "`{$value}`";
}, $array));
}
}; };