DB 스키마 정리, diplomacy 테이블 정리, 코드 정리
This commit is contained in:
+1
-38
@@ -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 = date('Y-m-d H:i:s');
|
$date = date('Y-m-d H:i:s');
|
||||||
$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 = " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
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
@@ -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 = date('Y-m-d H:i:s');
|
$date = date('Y-m-d H:i:s');
|
||||||
$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 = " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
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>
|
||||||
|
|||||||
@@ -93,11 +93,6 @@ if($command == 61) {
|
|||||||
$me = MYDB_fetch_array($result);
|
$me = MYDB_fetch_array($result);
|
||||||
|
|
||||||
if($me['level'] >= 5) {
|
if($me['level'] >= 5) {
|
||||||
$note = StringUtil::neutralize($note, 90);
|
|
||||||
|
|
||||||
$query = "update diplomacy set reserved='{$note}' where me='{$me['nation']}' and you='$double'";
|
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
|
|
||||||
$count = count($turn);
|
$count = count($turn);
|
||||||
$str = "type=type";
|
$str = "type=type";
|
||||||
for($i=0; $i < $count; $i++) {
|
for($i=0; $i < $count; $i++) {
|
||||||
|
|||||||
@@ -605,11 +605,6 @@ function process_61(&$general) {
|
|||||||
$validMinutes = max(30, $turnterm*3);
|
$validMinutes = max(30, $turnterm*3);
|
||||||
$validUntil->add(new \DateInterval("PT{$validMinutes}M"));
|
$validUntil->add(new \DateInterval("PT{$validMinutes}M"));
|
||||||
|
|
||||||
//FIXME: 현재 command가 숫자로만 이루어져 있어서 문자열을 처리할 수 없다.
|
|
||||||
//XXX: 으악.
|
|
||||||
//TODO: 커맨드 처리 방식을 json으로 변경
|
|
||||||
$option = $db->queryFirstField('SELECT reserved FROM diplomacy WHERE me=%i AND you=%i', $src->nationID, $dest->nationID);
|
|
||||||
|
|
||||||
$msg = new DiplomaticMessage(
|
$msg = new DiplomaticMessage(
|
||||||
Message::MSGTYPE_DIPLOMACY,
|
Message::MSGTYPE_DIPLOMACY,
|
||||||
$src,
|
$src,
|
||||||
@@ -619,19 +614,11 @@ function process_61(&$general) {
|
|||||||
$validUntil,
|
$validUntil,
|
||||||
[
|
[
|
||||||
'action'=>DiplomaticMessage::TYPE_NO_AGGRESSION,
|
'action'=>DiplomaticMessage::TYPE_NO_AGGRESSION,
|
||||||
'year'=>$when,
|
'year'=>$when
|
||||||
'option'=>$option
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$msg->send();
|
$msg->send();
|
||||||
|
|
||||||
//NOTE: 현재 내무부 외교란의 비고는 diplomacy가 기준이니까 유지할 필요는 있다.
|
|
||||||
//FIXME: 외교란도 message란의 diplomacy를 참조하든가 하도록.
|
|
||||||
$db->update('diplomacy', [
|
|
||||||
'showing'=>$validUntil->format('Y-m-d H:i:s')
|
|
||||||
], 'me=%i AND you=%i', $src->nationID, $dest->nationID);
|
|
||||||
// 3턴후
|
|
||||||
|
|
||||||
pushGenLog($general, ["<C>●</>{$month}월:<D><b>{$destNation['name']}</b></>으로 불가침 제의 서신을 보냈습니다.<1>$date</>"]);
|
pushGenLog($general, ["<C>●</>{$month}월:<D><b>{$destNation['name']}</b></>으로 불가침 제의 서신을 보냈습니다.<1>$date</>"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1739,7 +1739,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>";
|
||||||
|
|
||||||
@@ -1796,7 +1795,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++) {
|
||||||
|
|||||||
@@ -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){
|
||||||
|
|||||||
@@ -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
@@ -644,8 +644,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`),
|
||||||
@@ -656,17 +654,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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user