[3cf9d39cf2]DB 스키마 정리, diplomacy 테이블 정리, 코드 정리

This commit is contained in:
2019-04-07 21:27:08 +09:00
parent 4a05b59b4b
commit 37e4105585
7 changed files with 16 additions and 118 deletions
+1 -38
View File
@@ -73,7 +73,6 @@ $sel[$type] = "selected";
<td width=130 align=center id=bg1>국 가 명</td> <td width=130 align=center id=bg1>국 가 명</td>
<td width=80 align=center id=bg1>상 태</td> <td width=80 align=center id=bg1>상 태</td>
<td width=60 align=center id=bg1>기 간</td> <td width=60 align=center id=bg1>기 간</td>
<td align=center id=bg1>비 고</td>
</tr> </tr>
<?php <?php
@@ -95,11 +94,7 @@ for ($i=0; $i < $dipcount; $i++) {
$me = $dip['me']; $me = $dip['me'];
$you = $dip['you']; $you = $dip['you'];
$query = "select reserved,showing from diplomacy where you='$me' and me='$you'"; if ($dip['state'] == 2) {
$result2 = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$dip2 = MYDB_fetch_array($result2);
if ($dip['state'] == 2 && $dip['fixed'] == "" && $dip['reserved'] == "" && $dip2['reserved'] == "") {
continue; continue;
} }
@@ -115,37 +110,6 @@ for ($i=0; $i < $dipcount; $i++) {
} }
$date = TimeUtil::now(); $date = TimeUtil::now();
$note = "";
if ($dip['fixed'] != "") {
if ($dip['state'] == 7) {
$note .= $dip['fixed'];
} else {
$note .= "<font color=gray>{$dip['fixed']}</font>";
}
if ($dip['reserved'] != "" || $dip2['reserved'] != "") {
$note .= "<br>";
}
}
if ($dip['reserved'] != "") {
if ($dip['showing'] >= $date) {
$note .= "<font color=skyblue>아국측 제의</font>: {$dip['reserved']}";
} else {
$note .= "<font color=gray>아국측 제의: {$dip['reserved']}</font>";
}
if ($dip2['reserved'] != "") {
$note .= "<br>";
}
}
if ($dip2['reserved'] != "") {
if ($dip2['showing'] >= $date) {
$note .= "<font color=limegreen>상대측 제의</font>: {$dip2['reserved']}";
} else {
$note .= "<font color=gray>상대측 제의: {$dip2['reserved']}</font>";
}
}
if ($note == "") {
$note = "&nbsp;";
}
echo " echo "
<tr> <tr>
@@ -153,7 +117,6 @@ for ($i=0; $i < $dipcount; $i++) {
<td align=center style=color:".newColor($nationColor[$you]).";background-color:{$nationColor[$you]};>$nationName[$you]</td> <td align=center style=color:".newColor($nationColor[$you]).";background-color:{$nationColor[$you]};>$nationName[$you]</td>
<td align=center>$state</td> <td align=center>$state</td>
<td align=center>{$dip['term']} 개월</td> <td align=center>{$dip['term']} 개월</td>
<td align=left style=font-size:7px;>{$note}</td>
</tr>"; </tr>";
} }
?> ?>
+2 -35
View File
@@ -106,19 +106,15 @@ for ($i=0; $i < $nationcount; $i++) {
<td align=center>-</td> <td align=center>-</td>
<td align=center>-</td> <td align=center>-</td>
<td align=center>-</td> <td align=center>-</td>
<td align=left style=font-size:7px;>-</td>
</tr>"; </tr>";
continue; continue;
} }
$query = "select state,term,fixed,reserved,showing from diplomacy where me='{$me['nation']}' and you='{$nation['nation']}'"; $query = "select state,term from diplomacy where me='{$me['nation']}' and you='{$nation['nation']}'";
$result2 = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), ""); $result2 = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$dip = MYDB_fetch_array($result2); $dip = MYDB_fetch_array($result2);
$query = "select reserved,showing from diplomacy where you='{$me['nation']}' and me='{$nation['nation']}'";
$result2 = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$dip2 = MYDB_fetch_array($result2);
//속령수 //속령수
$query = "select city from city where nation='{$nation['nation']}'"; $query = "select city from city where nation='{$nation['nation']}'";
$result2 = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), ""); $result2 = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
@@ -144,33 +140,6 @@ for ($i=0; $i < $nationcount; $i++) {
} }
$date = TimeUtil::now(); $date = TimeUtil::now();
$note = "";
if ($dip['fixed'] != "") {
if ($dip['state'] == 7) {
$note .= $dip['fixed'];
} else {
$note .= "<font color=gray>{$dip['fixed']}</font>";
}
if ($dip['reserved'] != "" || $dip2['reserved'] != "") {
$note .= "<br>";
}
}
if ($dip['showing'] >= $date) {
if ($dip['reserved'] != "") {
$note .= "<font color=skyblue>아국측 제의</font>: ".$dip['reserved'];
if ($dip2['reserved'] != "") {
$note .= "<br>";
}
}
}
if ($dip2['showing'] >= $date) {
if ($dip2['reserved'] != "") {
$note .= "<font color=limegreen>상대측 제의</font>: ".$dip2['reserved'];
}
}
if ($note == "") {
$note = "&nbsp;";
}
echo " echo "
<tr> <tr>
@@ -188,9 +157,7 @@ for ($i=0; $i < $nationcount; $i++) {
<td align=center>-</td> <td align=center>-</td>
<td align=center>-</td>"; <td align=center>-</td>";
} }
echo " echo "</tr>";
<td align=left style=font-size:7px;>{$note}</td>
</tr>";
} }
echo " echo "
</table> </table>
-2
View File
@@ -1725,7 +1725,6 @@ function command_61($turn, $command) {
타국에게 불가침을 제의합니다.<br> 타국에게 불가침을 제의합니다.<br>
제의할 국가를 목록에서 선택하세요.<br> 제의할 국가를 목록에서 선택하세요.<br>
배경색은 현재 제의가 불가능한 국가는 <font color=red>붉은색</font>, 현재 불가침중인 국가는 <font color=blue>푸른색</font>으로 표시됩니다.<br> 배경색은 현재 제의가 불가능한 국가는 <font color=red>붉은색</font>, 현재 불가침중인 국가는 <font color=blue>푸른색</font>으로 표시됩니다.<br>
비고는 불가침시 세부 조건등을 지정하는 곳입니다.(최대 45자) <font color=magenta>※유저 편의를 위한 것일뿐 시스템적으로 보장하지는 않습니다.</font><br>
<form name=form1 action=c_double.php method=post> <form name=form1 action=c_double.php method=post>
대상 국가 <select name=double size=1 style=color:white;background-color:black>"; 대상 국가 <select name=double size=1 style=color:white;background-color:black>";
@@ -1782,7 +1781,6 @@ function command_61($turn, $command) {
<option value=20>20</option> <option value=20>20</option>
</select> </select>
년<br> 년<br>
비고 : <input type=text name=note size=45 maxlength=45 style=text-align:left;color:white;background-color:black>
<input type=submit value=불가침> <input type=submit value=불가침>
<input type=hidden name=command value=$command>"; <input type=hidden name=command value=$command>";
for($i=0; $i < count($turn); $i++) { for($i=0; $i < count($turn); $i++) {
@@ -37,11 +37,6 @@ class che_불가침제의 extends Command\NationCommand{
return false; return false;
} }
$optionText = $this->arg['optionText']??'';
if(!is_string($optionText)){
return false;
}
if(!key_exists('year', $this->arg) || !key_exists('month', $this->arg) ){ if(!key_exists('year', $this->arg) || !key_exists('month', $this->arg) ){
return false; return false;
} }
@@ -61,7 +56,6 @@ class che_불가침제의 extends Command\NationCommand{
$this->arg = [ $this->arg = [
'destNationID'=>$destNationID, 'destNationID'=>$destNationID,
'optionText'=>$optionText,
'year'=>$year, 'year'=>$year,
'month'=>$month, 'month'=>$month,
]; ];
@@ -177,17 +171,10 @@ class che_불가침제의 extends Command\NationCommand{
'action'=>DiplomaticMessage::TYPE_NO_AGGRESSION, 'action'=>DiplomaticMessage::TYPE_NO_AGGRESSION,
'year'=>$year, 'year'=>$year,
'month'=>$month, 'month'=>$month,
'option'=>$this->arg['optionText'],
] ]
); );
$msg->send(); $msg->send();
//FIXME: 현재 내무부, 외교란이 구형 코드임. diplomacy_ticket을 이용하여 재구현
$db->update('diplomacy', [
'showing'=>$validUntil->format('Y-m-d H:i:s'),
'reserved'=>$this->arg['optionText'],
], 'me=%i AND you=%i', $nationID, $destNationID);
$general->setResultTurn(new LastTurn(static::getName(), $this->arg)); $general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->applyDB($db); $general->applyDB($db);
$destGeneral->applyDB($db); $destGeneral->applyDB($db);
+1 -9
View File
@@ -73,7 +73,6 @@ class DiplomaticMessage extends Message{
protected function noAggression(){ protected function noAggression(){
$year = Util::array_get($this->msgOption['year']); $year = Util::array_get($this->msgOption['year']);
$option = Util::array_get($this->msgOption['option'])??'';
if($year < 1 || $year > 30){ if($year < 1 || $year > 30){
return [self::INVALID, '올바르지 않은 불가침 서신입니다.']; return [self::INVALID, '올바르지 않은 불가침 서신입니다.'];
} }
@@ -81,7 +80,7 @@ class DiplomaticMessage extends Message{
$this->diplomacyDetail = "{$year}"; $this->diplomacyDetail = "{$year}";
$helper = new Engine\Diplomacy($this->src->nationID, $this->dest->nationID); $helper = new Engine\Diplomacy($this->src->nationID, $this->dest->nationID);
$chk = $helper->noAggression($year, $option); $chk = $helper->noAggression($year);
if($chk[0] !== self::ACCEPTED){ if($chk[0] !== self::ACCEPTED){
return $chk; return $chk;
} }
@@ -284,13 +283,6 @@ class DiplomaticMessage extends Message{
list($result, $reason) = $this->checkDiplomaticMessageValidation($general); list($result, $reason) = $this->checkDiplomaticMessageValidation($general);
$db->update('diplomacy', [
'reserved'=>'',
'showing'=>null
], '(me=%s AND you=%s) OR (you=%s AND me=%s)',
$this->src->nationID, $this->dest->nationID,
$this->src->nationID, $this->dest->nationID
);
if($result !== self::ACCEPTED){ if($result !== self::ACCEPTED){
pushGenLog(['no'=>$receiverID], ["<C>●</>{$reason} {$this->diplomacyName} 실패."]); pushGenLog(['no'=>$receiverID], ["<C>●</>{$reason} {$this->diplomacyName} 실패."]);
if($result === self::DECLINED){ if($result === self::DECLINED){
+8 -15
View File
@@ -273,7 +273,7 @@ class Diplomacy{
return $prev; return $prev;
} }
public function noAggression(int $when, string $option){ public function noAggression(int $when){
$chk = $this->checkValidNation(); $chk = $this->checkValidNation();
$chk = $this->checkNotWar($chk); $chk = $this->checkNotWar($chk);
$chk = $this->checkAlreadyMerging($chk); $chk = $this->checkAlreadyMerging($chk);
@@ -286,8 +286,7 @@ class Diplomacy{
$db = DB::db(); $db = DB::db();
$db->update('diplomacy',[ $db->update('diplomacy',[
'state'=>7, 'state'=>7,
'term'=>$when*12, 'term'=>$when*12
'fixed'=>$option
], ],
'(me=%i AND you=%i) OR (you=%i AND me=%i)', '(me=%i AND you=%i) OR (you=%i AND me=%i)',
$this->srcNation['nation'], $this->destNation['nation'], $this->srcNation['nation'], $this->destNation['nation'],
@@ -308,8 +307,7 @@ class Diplomacy{
$db = DB::db(); $db = DB::db();
$db->update('diplomacy',[ $db->update('diplomacy',[
'state'=>2, 'state'=>2,
'term'=>0, 'term'=>0
'fixed'=>''
], ],
'(me=%i AND you=%i) OR (you=%i AND me=%i)', '(me=%i AND you=%i) OR (you=%i AND me=%i)',
$this->srcNation['nation'], $this->destNation['nation'], $this->srcNation['nation'], $this->destNation['nation'],
@@ -330,8 +328,7 @@ class Diplomacy{
$db = DB::db(); $db = DB::db();
$db->update('diplomacy',[ $db->update('diplomacy',[
'state'=>2, 'state'=>2,
'term'=>0, 'term'=>0
'fixed'=>''
], ],
'(me=%i AND you=%i) OR (you=%i AND me=%i)', '(me=%i AND you=%i) OR (you=%i AND me=%i)',
$this->srcNation['nation'], $this->destNation['nation'], $this->srcNation['nation'], $this->destNation['nation'],
@@ -356,16 +353,14 @@ class Diplomacy{
$db = DB::db(); $db = DB::db();
$db->update('diplomacy',[ $db->update('diplomacy',[
'state'=>4, 'state'=>4,
'term'=>24, 'term'=>24
'fixed'=>''
], ],
'me=%i AND you=%i', 'me=%i AND you=%i',
$this->srcNation['nation'], $this->destNation['nation']); $this->srcNation['nation'], $this->destNation['nation']);
$db->update('diplomacy',[ $db->update('diplomacy',[
'state'=>3, 'state'=>3,
'term'=>24, 'term'=>24
'fixed'=>''
], ],
'you=%i AND me=%i', 'you=%i AND me=%i',
$this->srcNation['nation'], $this->destNation['nation']); $this->srcNation['nation'], $this->destNation['nation']);
@@ -389,16 +384,14 @@ class Diplomacy{
$db = DB::db(); $db = DB::db();
$db->update('diplomacy',[ $db->update('diplomacy',[
'state'=>6, 'state'=>6,
'term'=>24, 'term'=>24
'fixed'=>''
], ],
'me=%i AND you=%i', 'me=%i AND you=%i',
$this->srcNation['nation'], $this->destNation['nation']); $this->srcNation['nation'], $this->destNation['nation']);
$db->update('diplomacy',[ $db->update('diplomacy',[
'state'=>5, 'state'=>5,
'term'=>24, 'term'=>24
'fixed'=>''
], ],
'you=%i AND me=%i', 'you=%i AND me=%i',
$this->srcNation['nation'], $this->destNation['nation']); $this->srcNation['nation'], $this->destNation['nation']);
+4 -6
View File
@@ -540,8 +540,6 @@ create table diplomacy (
`state` INT(6) NULL DEFAULT '0', `state` INT(6) NULL DEFAULT '0',
`term` INT(6) NULL DEFAULT '0', `term` INT(6) NULL DEFAULT '0',
`dead` INT(8) NULL DEFAULT '0', `dead` INT(8) NULL DEFAULT '0',
`fixed` CHAR(128) NULL DEFAULT '',
`reserved` CHAR(128) NULL DEFAULT '',
`showing` DATETIME NULL DEFAULT NULL, `showing` DATETIME NULL DEFAULT NULL,
PRIMARY KEY (`no`), PRIMARY KEY (`no`),
@@ -552,17 +550,17 @@ CREATE TABLE `ng_diplomacy` (
`no` INT(11) NOT NULL AUTO_INCREMENT, `no` INT(11) NOT NULL AUTO_INCREMENT,
`src_nation_id` INT(11) NOT NULL, `src_nation_id` INT(11) NOT NULL,
`dest_nation_id` INT(11) NOT NULL, `dest_nation_id` INT(11) NOT NULL,
`group_id` INT(11) NOT NULL, `prev_no` INT(11) NULL DEFAULT NULL,
`revision` INT(11) NOT NULL DEFAULT '1',
`state` ENUM('proposed','activaed','cancelled') NOT NULL DEFAULT 'proposed', `state` ENUM('proposed','activaed','cancelled') NOT NULL DEFAULT 'proposed',
`text_brief` TEXT NOT NULL, `text_brief` TEXT NOT NULL,
`text_detail` TEXT NOT NULL, `text_detail` TEXT NOT NULL,
`date` DATETIME NOT NULL, `date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`src_signer` INT(11) NOT NULL, `src_signer` INT(11) NOT NULL,
`dest_signer` INT(11) NULL DEFAULT NULL, `dest_signer` INT(11) NULL DEFAULT NULL,
`aux` TEXT NULL DEFAULT NULL, `aux` TEXT NULL DEFAULT NULL,
PRIMARY KEY (`no`), PRIMARY KEY (`no`),
INDEX `by_group` (`src_nation_id`, `dest_nation_id`, `group_id`, `revision`) INDEX `by_nation_src` (`src_nation_id`, `dest_nation_id`, `state`, `date`),
INDEX `by_nation_dest` (`dest_nation_id`, `src_nation_id`, `state`, `date`)
) )
ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;