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=80 align=center id=bg1>상 태</td>
|
||||
<td width=60 align=center id=bg1>기 간</td>
|
||||
<td align=center id=bg1>비 고</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
@@ -95,11 +94,7 @@ for ($i=0; $i < $dipcount; $i++) {
|
||||
$me = $dip['me'];
|
||||
$you = $dip['you'];
|
||||
|
||||
$query = "select reserved,showing from diplomacy where you='$me' and me='$you'";
|
||||
$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'] == "") {
|
||||
if ($dip['state'] == 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -115,37 +110,6 @@ for ($i=0; $i < $dipcount; $i++) {
|
||||
}
|
||||
|
||||
$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 "
|
||||
<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>$state</td>
|
||||
<td align=center>{$dip['term']} 개월</td>
|
||||
<td align=left style=font-size:7px;>{$note}</td>
|
||||
</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=left style=font-size:7px;>-</td>
|
||||
</tr>";
|
||||
|
||||
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), "");
|
||||
$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']}'";
|
||||
$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');
|
||||
$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 "
|
||||
<tr>
|
||||
@@ -188,9 +157,7 @@ for ($i=0; $i < $nationcount; $i++) {
|
||||
<td align=center>-</td>
|
||||
<td align=center>-</td>";
|
||||
}
|
||||
echo "
|
||||
<td align=left style=font-size:7px;>{$note}</td>
|
||||
</tr>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "
|
||||
</table>
|
||||
|
||||
@@ -93,11 +93,6 @@ if($command == 61) {
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
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);
|
||||
$str = "type=type";
|
||||
for($i=0; $i < $count; $i++) {
|
||||
|
||||
@@ -605,11 +605,6 @@ function process_61(&$general) {
|
||||
$validMinutes = max(30, $turnterm*3);
|
||||
$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(
|
||||
Message::MSGTYPE_DIPLOMACY,
|
||||
$src,
|
||||
@@ -619,19 +614,11 @@ function process_61(&$general) {
|
||||
$validUntil,
|
||||
[
|
||||
'action'=>DiplomaticMessage::TYPE_NO_AGGRESSION,
|
||||
'year'=>$when,
|
||||
'option'=>$option
|
||||
'year'=>$when
|
||||
]
|
||||
);
|
||||
$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</>"]);
|
||||
}
|
||||
|
||||
|
||||
@@ -1739,7 +1739,6 @@ function command_61($turn, $command) {
|
||||
타국에게 불가침을 제의합니다.<br>
|
||||
제의할 국가를 목록에서 선택하세요.<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>
|
||||
대상 국가 <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>
|
||||
</select>
|
||||
년<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=hidden name=command value=$command>";
|
||||
for($i=0; $i < count($turn); $i++) {
|
||||
|
||||
@@ -73,7 +73,6 @@ class DiplomaticMessage extends Message{
|
||||
|
||||
protected function noAggression(){
|
||||
$year = Util::array_get($this->msgOption['year']);
|
||||
$option = Util::array_get($this->msgOption['option'])??'';
|
||||
if($year < 1 || $year > 30){
|
||||
return [self::INVALID, '올바르지 않은 불가침 서신입니다.'];
|
||||
}
|
||||
@@ -81,7 +80,7 @@ class DiplomaticMessage extends Message{
|
||||
$this->diplomacyDetail = "{$year}년";
|
||||
|
||||
$helper = new Engine\Diplomacy($this->src->nationID, $this->dest->nationID);
|
||||
$chk = $helper->noAggression($year, $option);
|
||||
$chk = $helper->noAggression($year);
|
||||
if($chk[0] !== self::ACCEPTED){
|
||||
return $chk;
|
||||
}
|
||||
@@ -284,13 +283,6 @@ class DiplomaticMessage extends Message{
|
||||
|
||||
|
||||
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){
|
||||
pushGenLog(['no'=>$receiverID], ["<C>●</>{$reason} {$this->diplomacyName} 실패."]);
|
||||
if($result === self::DECLINED){
|
||||
|
||||
@@ -273,7 +273,7 @@ class Diplomacy{
|
||||
return $prev;
|
||||
}
|
||||
|
||||
public function noAggression(int $when, string $option){
|
||||
public function noAggression(int $when){
|
||||
$chk = $this->checkValidNation();
|
||||
$chk = $this->checkNotWar($chk);
|
||||
$chk = $this->checkAlreadyMerging($chk);
|
||||
@@ -286,8 +286,7 @@ class Diplomacy{
|
||||
$db = DB::db();
|
||||
$db->update('diplomacy',[
|
||||
'state'=>7,
|
||||
'term'=>$when*12,
|
||||
'fixed'=>$option
|
||||
'term'=>$when*12
|
||||
],
|
||||
'(me=%i AND you=%i) OR (you=%i AND me=%i)',
|
||||
$this->srcNation['nation'], $this->destNation['nation'],
|
||||
@@ -308,8 +307,7 @@ class Diplomacy{
|
||||
$db = DB::db();
|
||||
$db->update('diplomacy',[
|
||||
'state'=>2,
|
||||
'term'=>0,
|
||||
'fixed'=>''
|
||||
'term'=>0
|
||||
],
|
||||
'(me=%i AND you=%i) OR (you=%i AND me=%i)',
|
||||
$this->srcNation['nation'], $this->destNation['nation'],
|
||||
@@ -330,8 +328,7 @@ class Diplomacy{
|
||||
$db = DB::db();
|
||||
$db->update('diplomacy',[
|
||||
'state'=>2,
|
||||
'term'=>0,
|
||||
'fixed'=>''
|
||||
'term'=>0
|
||||
],
|
||||
'(me=%i AND you=%i) OR (you=%i AND me=%i)',
|
||||
$this->srcNation['nation'], $this->destNation['nation'],
|
||||
@@ -356,16 +353,14 @@ class Diplomacy{
|
||||
$db = DB::db();
|
||||
$db->update('diplomacy',[
|
||||
'state'=>4,
|
||||
'term'=>24,
|
||||
'fixed'=>''
|
||||
'term'=>24
|
||||
],
|
||||
'me=%i AND you=%i',
|
||||
$this->srcNation['nation'], $this->destNation['nation']);
|
||||
|
||||
$db->update('diplomacy',[
|
||||
'state'=>3,
|
||||
'term'=>24,
|
||||
'fixed'=>''
|
||||
'term'=>24
|
||||
],
|
||||
'you=%i AND me=%i',
|
||||
$this->srcNation['nation'], $this->destNation['nation']);
|
||||
@@ -389,16 +384,14 @@ class Diplomacy{
|
||||
$db = DB::db();
|
||||
$db->update('diplomacy',[
|
||||
'state'=>6,
|
||||
'term'=>24,
|
||||
'fixed'=>''
|
||||
'term'=>24
|
||||
],
|
||||
'me=%i AND you=%i',
|
||||
$this->srcNation['nation'], $this->destNation['nation']);
|
||||
|
||||
$db->update('diplomacy',[
|
||||
'state'=>5,
|
||||
'term'=>24,
|
||||
'fixed'=>''
|
||||
'term'=>24
|
||||
],
|
||||
'you=%i AND me=%i',
|
||||
$this->srcNation['nation'], $this->destNation['nation']);
|
||||
|
||||
+4
-6
@@ -644,8 +644,6 @@ create table diplomacy (
|
||||
`state` INT(6) NULL DEFAULT '0',
|
||||
`term` INT(6) NULL DEFAULT '0',
|
||||
`dead` INT(8) NULL DEFAULT '0',
|
||||
`fixed` CHAR(128) NULL DEFAULT '',
|
||||
`reserved` CHAR(128) NULL DEFAULT '',
|
||||
`showing` DATETIME NULL DEFAULT NULL,
|
||||
|
||||
PRIMARY KEY (`no`),
|
||||
@@ -656,17 +654,17 @@ CREATE TABLE `ng_diplomacy` (
|
||||
`no` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`src_nation_id` INT(11) NOT NULL,
|
||||
`dest_nation_id` INT(11) NOT NULL,
|
||||
`group_id` INT(11) NOT NULL,
|
||||
`revision` INT(11) NOT NULL DEFAULT '1',
|
||||
`prev_no` INT(11) NULL DEFAULT NULL,
|
||||
`state` ENUM('proposed','activaed','cancelled') NOT NULL DEFAULT 'proposed',
|
||||
`text_brief` 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,
|
||||
`dest_signer` INT(11) NULL DEFAULT NULL,
|
||||
`aux` TEXT NULL DEFAULT NULL,
|
||||
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user