floor를 intdiv로 변경

This commit is contained in:
2018-04-08 19:46:26 +09:00
parent f060716a3c
commit ba4ff29e4a
36 changed files with 291 additions and 256 deletions
+4
View File
@@ -180,6 +180,10 @@ $rootDB->insert('system', array(
$globalSalt = bin2hex(random_bytes(16)); $globalSalt = bin2hex(random_bytes(16));
'@phan-var-force string $servHost';
'@phan-var-force string $sharedIconPath';
'@phan-var-force string $gameImagePath';
$sharedIconPath = WebUtil::resolveRelativePath($sharedIconPath, $servHost); $sharedIconPath = WebUtil::resolveRelativePath($sharedIconPath, $servHost);
$gameImagePath = WebUtil::resolveRelativePath($gameImagePath, $servHost); $gameImagePath = WebUtil::resolveRelativePath($gameImagePath, $servHost);
+23 -22
View File
@@ -6,7 +6,7 @@ include "func.php";
//로그인 검사 //로그인 검사
$session = Session::requireGameLogin()->setReadOnly(); $session = Session::requireGameLogin()->setReadOnly();
if($session->userGrade < 5) { if ($session->userGrade < 5) {
//echo "<script>location.replace('_admin1.php');</script>"; //echo "<script>location.replace('_admin1.php');</script>";
echo '_admin1.php';//TODO:debug all and replace echo '_admin1.php';//TODO:debug all and replace
} }
@@ -18,7 +18,7 @@ $v->rule('integer', [
])->rule('dateFormat', [ ])->rule('dateFormat', [
'starttime' 'starttime'
]); ]);
if(!$v->validate()){ if (!$v->validate()) {
Error($v->errorStr()); Error($v->errorStr());
} }
@@ -33,33 +33,35 @@ $connect=$db->get();
$admin = getAdmin(); $admin = getAdmin();
switch($btn) { switch ($btn) {
case "변경": case "변경":
$msg = addslashes(SQ2DQ($msg)); $msg = addslashes(SQ2DQ($msg));
$query = "update game set msg='$msg'"; $query = "update game set msg='$msg'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
break; break;
case "로그쓰기": case "로그쓰기":
$lognum = $admin['historyindex'] + 1; $lognum = $admin['historyindex'] + 1;
if($lognum >= 29) { $lognum = 0; } if ($lognum >= 29) {
$lognum = 0;
}
$history[0] = "<R>★</><S>{$log}</>"; $history[0] = "<R>★</><S>{$log}</>";
pushWorldHistory($history); pushWorldHistory($history);
break; break;
case "변경1": case "변경1":
$query = "update game set starttime='$starttime'"; $query = "update game set starttime='$starttime'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
break; break;
case "변경2": case "변경2":
$query = "update game set maxgeneral='$maxgeneral'"; $query = "update game set maxgeneral='$maxgeneral'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
break; break;
case "변경3": case "변경3":
$query = "update game set maxnation='$maxnation'"; $query = "update game set maxnation='$maxnation'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
break; break;
case "변경4": case "변경4":
$query = "update game set startyear='$startyear'"; $query = "update game set startyear='$startyear'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
break; break;
case "1분턴": case "1분턴":
case "2분턴": case "2분턴":
@@ -69,7 +71,7 @@ switch($btn) {
case "30분턴": case "30분턴":
case "60분턴": case "60분턴":
case "120분턴": case "120분턴":
switch($btn) { switch ($btn) {
case "1분턴": $turnterm = 1; break; case "1분턴": $turnterm = 1; break;
case "2분턴": $turnterm = 2; break; case "2분턴": $turnterm = 2; break;
case "5분턴": $turnterm = 5; break; case "5분턴": $turnterm = 5; break;
@@ -84,30 +86,30 @@ switch($btn) {
$starttime = date("Y-m-d H:i:s", strtotime($admin['turntime']) - $turn * $unit); $starttime = date("Y-m-d H:i:s", strtotime($admin['turntime']) - $turn * $unit);
$starttime = cutTurn($starttime, $turnterm); $starttime = cutTurn($starttime, $turnterm);
$query = "update game set turnterm='$turnterm',starttime='$starttime'"; $query = "update game set turnterm='$turnterm',starttime='$starttime'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
// 턴시간이 길어지는 경우 랜덤턴 배정 // 턴시간이 길어지는 경우 랜덤턴 배정
if($turnterm < $admin['turnterm']) { if ($turnterm < $admin['turnterm']) {
$query = "select no from general"; $query = "select no from general";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$count = MYDB_num_rows($result); $count = MYDB_num_rows($result);
for($i=0; $i < $count; $i++) { for ($i=0; $i < $count; $i++) {
$gen = MYDB_fetch_array($result); $gen = MYDB_fetch_array($result);
$turntime = getRandTurn($turnterm); $turntime = getRandTurn($turnterm);
$query = "update general set turntime='$turntime' where no='{$gen['no']}'"; $query = "update general set turntime='$turntime' where no='{$gen['no']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
} }
// 턴시간이 너무 멀리 떨어진 선수 제대로 보정 // 턴시간이 너무 멀리 떨어진 선수 제대로 보정
} else { } else {
$query = "select no,turntime from general"; $query = "select no,turntime from general";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$count = MYDB_num_rows($result); $count = MYDB_num_rows($result);
for($i=0; $i < $count; $i++) { for ($i=0; $i < $count; $i++) {
$gen = MYDB_fetch_array($result); $gen = MYDB_fetch_array($result);
$num = floor((strtotime($gen['turntime']) - strtotime($admin['turntime'])) / $unit); $num = intdiv((strtotime($gen['turntime']) - strtotime($admin['turntime'])), $unit);
if($num > 0) { if ($num > 0) {
$gen['turntime'] = date("Y-m-d H:i:s", strtotime($gen['turntime']) - $unit * $num); $gen['turntime'] = date("Y-m-d H:i:s", strtotime($gen['turntime']) - $unit * $num);
$query = "update general set turntime='{$gen['turntime']}' where no='{$gen['no']}'"; $query = "update general set turntime='{$gen['turntime']}' where no='{$gen['no']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
} }
} }
} }
@@ -118,4 +120,3 @@ switch($btn) {
//echo "<script>location.replace('_admin1.php');</script>"; //echo "<script>location.replace('_admin1.php');</script>";
echo '_admin1.php';//TODO:debug all and replace echo '_admin1.php';//TODO:debug all and replace
+11 -11
View File
@@ -204,7 +204,7 @@ if($isgen == "장수공격" || $isgen == "성벽공격" || $isgen == "장수평
$avoid = 1; $avoid = 1;
// 병종간 특성 // 병종간 특성
if(floor($general['crewtype']/10) == 3) { // 귀병 if(intdiv($general['crewtype'], 10) == 3) { // 귀병
$int = $general['intel'] + getBookEff($general['book']); $int = $general['intel'] + getBookEff($general['book']);
if($general['crewtype'] == 30) { if($general['crewtype'] == 30) {
$ratio2 = $int * 5; // 0~500 즉 50% $ratio2 = $int * 5; // 0~500 즉 50%
@@ -394,7 +394,7 @@ if($isgen == "장수공격" || $isgen == "성벽공격" || $isgen == "장수평
$myAvoid = 1; $myAvoid = 1;
$opAvoid = 1; $opAvoid = 1;
// 병종간 특성 // 병종간 특성
if(floor($general['crewtype']/10) == 3) { // 귀병 if(intdiv($general['crewtype'], 10) == 3) { // 귀병
$int = $general['intel'] + getBookEff($general['book']); $int = $general['intel'] + getBookEff($general['book']);
if($general['crewtype'] == 30) { if($general['crewtype'] == 30) {
$ratio2 = $int * 5; // 0~500 즉 50% $ratio2 = $int * 5; // 0~500 즉 50%
@@ -476,7 +476,7 @@ if($isgen == "장수공격" || $isgen == "성벽공격" || $isgen == "장수평
} }
// 상대 장수 병종간 특성 // 상대 장수 병종간 특성
if(floor($oppose['crewtype']/10) == 3) { // 귀병 if(intdiv($oppose['crewtype'], 10) == 3) { // 귀병
$int = $oppose['intel'] + getBookEff($oppose['book']); $int = $oppose['intel'] + getBookEff($oppose['book']);
if($oppose['crewtype'] == 30) { if($oppose['crewtype'] == 30) {
$ratio2 = $int * 5; // 0~500 즉 50% $ratio2 = $int * 5; // 0~500 즉 50%
@@ -571,44 +571,44 @@ if($isgen == "장수공격" || $isgen == "성벽공격" || $isgen == "장수평
// my 입장 상성 // my 입장 상성
// 보병계열 > 궁병계열 // 보병계열 > 궁병계열
if(floor($general['crewtype']/10) == 0 && floor($oppose['crewtype']/10) == 1) { if(intdiv($general['crewtype'], 10) == 0 && intdiv($oppose['crewtype'], 10) == 1) {
$myCrew *= 0.8; $myCrew *= 0.8;
$opCrew *= 1.2; $opCrew *= 1.2;
} }
// 궁병계열 > 기병계열 // 궁병계열 > 기병계열
if(floor($general['crewtype']/10) == 1 && floor($oppose['crewtype']/10) == 2) { if(intdiv($general['crewtype'], 10) == 1 && intdiv($oppose['crewtype'], 10) == 2) {
$myCrew *= 0.8; $myCrew *= 0.8;
$opCrew *= 1.2; $opCrew *= 1.2;
} }
// 기병계열 > 보병계열 // 기병계열 > 보병계열
if(floor($general['crewtype']/10) == 2 && floor($oppose['crewtype']/10) == 0) { if(intdiv($general['crewtype'], 10) == 2 && intdiv($oppose['crewtype'], 10) == 0) {
$myCrew *= 0.8; $myCrew *= 0.8;
$opCrew *= 1.2; $opCrew *= 1.2;
} }
// 차병계열 // 차병계열
if(floor($general['crewtype']/10) == 4) { if(intdiv($general['crewtype'], 10) == 4) {
$myCrew *= 1.2; $myCrew *= 1.2;
$opCrew *= 0.8; $opCrew *= 0.8;
} }
// op 입장 상성 // op 입장 상성
// 보병계열 > 궁병계열 // 보병계열 > 궁병계열
if(floor($oppose['crewtype']/10) == 0 && floor($general['crewtype']/10) == 1) { if(intdiv($oppose['crewtype'], 10) == 0 && intdiv($general['crewtype'], 10) == 1) {
$opCrew *= 0.8; $opCrew *= 0.8;
$myCrew *= 1.2; $myCrew *= 1.2;
} }
// 궁병계열 > 기병계열 // 궁병계열 > 기병계열
if(floor($oppose['crewtype']/10) == 1 && floor($general['crewtype']/10) == 2) { if(intdiv($oppose['crewtype'], 10) == 1 && intdiv($general['crewtype'], 10) == 2) {
$opCrew *= 0.8; $opCrew *= 0.8;
$myCrew *= 1.2; $myCrew *= 1.2;
} }
// 기병계열 > 보병계열 // 기병계열 > 보병계열
if(floor($oppose['crewtype']/10) == 2 && floor($general['crewtype']/10) == 0) { if(intdiv($oppose['crewtype'], 10) == 2 && intdiv($general['crewtype'], 10) == 0) {
$opCrew *= 0.8; $opCrew *= 0.8;
$myCrew *= 1.2; $myCrew *= 1.2;
} }
// 차병계열 // 차병계열
if(floor($oppose['crewtype']/10) == 4) { if(intdiv($oppose['crewtype'], 10) == 4) {
$opCrew *= 1.2; $opCrew *= 1.2;
$myCrew *= 0.8; $myCrew *= 0.8;
} }
+2 -2
View File
@@ -171,10 +171,10 @@ for ($i=0; $i < 21; $i++) {
for ($k=0; $k < 10; $k++) { for ($k=0; $k < 10; $k++) {
if ($i == 5 || $i == 7 || $i == 20) { if ($i == 5 || $i == 7 || $i == 20) {
$data[$k] = floor($data[$k]/100).".".($data[$k]%100)." %"; $data[$k] = intdiv($data[$k], 100).".".($data[$k]%100)." %";
} }
if ($i >= 13 && $i <= 16) { if ($i >= 13 && $i <= 16) {
$data[$k] = floor($data[$k]/100).".".($data[$k]%100)." %"; $data[$k] = intdiv($data[$k], 100).".".($data[$k]%100)." %";
} }
echo "<td align=center>{$data[$k]}</td>"; echo "<td align=center>{$data[$k]}</td>";
} }
+3 -3
View File
@@ -128,9 +128,9 @@ for($j=0; $j < $gencount; $j++) {
} }
if($general['injury'] > 0) { if($general['injury'] > 0) {
$leader = floor($general['leader'] * (100 - $general['injury'])/100); $leader = intdiv($general['leader'] * (100 - $general['injury']), 100);
$power = floor($general['power'] * (100 - $general['injury'])/100); $power = intdiv($general['power'] * (100 - $general['injury']), 100);
$intel = floor($general['intel'] * (100 - $general['injury'])/100); $intel = intdiv($general['intel'] * (100 - $general['injury']), 100);
$leader = "<font color=red>{$leader}</font>{$lbonus}"; $leader = "<font color=red>{$leader}</font>{$lbonus}";
$power = "<font color=red>{$power}</font>"; $power = "<font color=red>{$power}</font>";
$intel = "<font color=red>{$intel}</font>"; $intel = "<font color=red>{$intel}</font>";
+25 -17
View File
@@ -49,51 +49,59 @@ $type = array(
"베 팅 수 익 금", "베 팅 수 익 금",
"베 팅 수 익 률" "베 팅 수 익 률"
); );
for($i=0; $i < 21; $i++) { for ($i=0; $i < 21; $i++) {
$query = "select * from hall where type={$i} order by rank"; $query = "select * from hall where type={$i} order by rank";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
echo " echo "
<tr><td align=center colspan=10 id=bg1><font size=4>$type[$i]</font></td></tr> <tr><td align=center colspan=10 id=bg1><font size=4>$type[$i]</font></td></tr>
<tr align=center id=bg2><td>1위</td><td>2위</td><td>3위</td><td>4위</td><td>5위</td><td>6위</td><td>7위</td><td>8위</td><td>9위</td><td>10위</td></tr> <tr align=center id=bg2><td>1위</td><td>2위</td><td>3위</td><td>4위</td><td>5위</td><td>6위</td><td>7위</td><td>8위</td><td>9위</td><td>10위</td></tr>
<tr>"; <tr>";
for($k=0; $k < 10; $k++) { for ($k=0; $k < 10; $k++) {
$gen = MYDB_fetch_array($result); $gen = MYDB_fetch_array($result);
$name[$k] = $gen['name']; $name[$k] = $gen['name'];
$nation[$k] = $gen['nation']; $nation[$k] = $gen['nation'];
$data[$k] = $gen['data']; $data[$k] = $gen['data'];
$color[$k] = $gen['color']; $color[$k] = $gen['color'];
$pic[$k] = $gen['picture']; $pic[$k] = $gen['picture'];
if($color[$k] == "") $color[$k] = GameConst::$basecolor4; if ($color[$k] == "") {
if($nation[$k] == "") $nation[$k] = "&nbsp;"; $color[$k] = GameConst::$basecolor4;
/*
if($pic[$k] == "") {
echo "<td align=center>&nbsp;</td>";
} else {
$imageTemp = GetImageURL($gen['imgsvr']);
echo "<td align=center><img src={$imageTemp}/{$pic[$k]}></img></td>";
} }
*/ if ($nation[$k] == "") {
$nation[$k] = "&nbsp;";
}
/*
if($pic[$k] == "") {
echo "<td align=center>&nbsp;</td>";
} else {
$imageTemp = GetImageURL($gen['imgsvr']);
echo "<td align=center><img src={$imageTemp}/{$pic[$k]}></img></td>";
}
*/
} }
// echo "</tr><tr>"; // echo "</tr><tr>";
for($k=0; $k < 10; $k++) { for ($k=0; $k < 10; $k++) {
echo "<td align=center style=background-color:{$color[$k]};color:".newColor($color[$k]).">{$nation[$k]}</td>"; echo "<td align=center style=background-color:{$color[$k]};color:".newColor($color[$k]).">{$nation[$k]}</td>";
} }
echo "</tr><tr>"; echo "</tr><tr>";
for($k=0; $k < 10; $k++) { for ($k=0; $k < 10; $k++) {
echo "<td align=center style=background-color:{$color[$k]};color:".newColor($color[$k]).">{$name[$k]}</td>"; echo "<td align=center style=background-color:{$color[$k]};color:".newColor($color[$k]).">{$name[$k]}</td>";
} }
echo "</tr><tr>"; echo "</tr><tr>";
for($k=0; $k < 10; $k++) { for ($k=0; $k < 10; $k++) {
if($i == 5 || $i == 7 || $i == 20) { $data[$k] = floor($data[$k]/100).".".($data[$k]%100)." %"; } if ($i == 5 || $i == 7 || $i == 20) {
if($i >= 13 && $i <= 16) { $data[$k] = floor($data[$k]/100).".".($data[$k]%100)." %"; } $data[$k] = intdiv($data[$k], 100).".".($data[$k]%100)." %";
}
if ($i >= 13 && $i <= 16) {
$data[$k] = intdiv($data[$k], 100).".".($data[$k]%100)." %";
}
echo "<td align=center>{$data[$k]}</td>"; echo "<td align=center>{$data[$k]}</td>";
} }
echo "</tr><tr><td colspan=10 height=5 id=bg1></td></tr>"; echo "</tr><tr><td colspan=10 height=5 id=bg1></td></tr>";
+23 -16
View File
@@ -15,47 +15,54 @@ $connect=$db->get();
increaseRefresh("연감", 5); increaseRefresh("연감", 5);
$query = "select startyear,year,month,conlimit from game limit 1"; $query = "select startyear,year,month,conlimit from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$admin = MYDB_fetch_array($result); $admin = MYDB_fetch_array($result);
$query = "select map,con,turntime from general where owner='{$userID}'"; $query = "select map,con,turntime from general where owner='{$userID}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$me = MYDB_fetch_array($result); $me = MYDB_fetch_array($result);
$con = checkLimit($me['con'], $admin['conlimit']); $con = checkLimit($me['con'], $admin['conlimit']);
if($con >= 2) { printLimitMsg($me['turntime']); exit(); } if ($con >= 2) {
printLimitMsg($me['turntime']);
exit();
}
$query = "select year,month from history order by no limit 1"; $query = "select year,month from history order by no limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$history = MYDB_fetch_array($result); $history = MYDB_fetch_array($result);
$s = ($history['year']*12) + $history['month']; $s = ($history['year']*12) + $history['month'];
$query = "select year,month from history order by no desc limit 1"; $query = "select year,month from history order by no desc limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$history = MYDB_fetch_array($result); $history = MYDB_fetch_array($result);
$e = ($history['year']*12) + $history['month']; $e = ($history['year']*12) + $history['month'];
if(!$yearmonth) { if (!$yearmonth) {
$year = $admin['year']; $year = $admin['year'];
$month = $admin['month'] - 1; $month = $admin['month'] - 1;
} else { } else {
$year = substr($yearmonth, 0, 3) - 0; $year = substr($yearmonth, 0, 3) - 0;
$month = substr($yearmonth, 3, 2) - 0; $month = substr($yearmonth, 3, 2) - 0;
if($btn == "◀◀ 이전달") { if ($btn == "◀◀ 이전달") {
$month -= 1; $month -= 1;
} elseif($btn == "다음달 ▶▶") { } elseif ($btn == "다음달 ▶▶") {
$month += 1; $month += 1;
} }
} }
$now = ($year*12) + $month; $now = ($year*12) + $month;
if($now < $s) { $now = $s; } if ($now < $s) {
if($now > $e) { $now = $e; } $now = $s;
}
if ($now > $e) {
$now = $e;
}
$year = floor($now / 12); $year = intdiv($now, 12);
$month = $now % 12; $month = $now % 12;
if($month <= 0) { if ($month <= 0) {
$year -= 1; $year -= 1;
$month += 12; $month += 12;
} }
@@ -82,12 +89,12 @@ if($month <= 0) {
<select name=yearmonth size=1> <select name=yearmonth size=1>
<?php <?php
$query = "select year,month from history"; $query = "select year,month from history";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$histCount = MYDB_num_rows($result); $histCount = MYDB_num_rows($result);
for($i=0; $i < $histCount; $i++) { for ($i=0; $i < $histCount; $i++) {
$history = MYDB_fetch_array($result); $history = MYDB_fetch_array($result);
$value = "".$history['year'].StringUtil::padStringAlignRight($history['month'], 2, "0"); $value = "".$history['year'].StringUtil::padStringAlignRight($history['month'], 2, "0");
if($history['year'] == $year && $history['month'] == $month) { if ($history['year'] == $year && $history['month'] == $month) {
echo " echo "
<option selected value={$value}>{$history['year']}년 {$history['month']}월</option>"; <option selected value={$value}>{$history['year']}년 {$history['month']}월</option>";
} else { } else {
@@ -97,7 +104,7 @@ for($i=0; $i < $histCount; $i++) {
} }
$query = "select log,genlog,nation,power,gen,city from history where year='$year' and month='$month'"; $query = "select log,genlog,nation,power,gen,city from history where year='$year' and month='$month'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$history = MYDB_fetch_array($result); $history = MYDB_fetch_array($result);
?> ?>
</select> </select>
+2 -2
View File
@@ -272,8 +272,8 @@ function getTrafficColor($per)
function getHex($dec) function getHex($dec)
{ {
$hex = floor($dec * 255 / 100); $hex = intdiv($dec * 255, 100);
$code = getHexCode(floor($hex / 16)); $code = getHexCode(intdiv($hex, 16));
$code .= getHexCode($hex % 16); $code .= getHexCode($hex % 16);
return $code; return $code;
} }
+1 -1
View File
@@ -208,7 +208,7 @@ for ($i=0; $i < $count; $i++) {
$chk = 1; $chk = 1;
} }
$pv = round($auction['value'] * 100 / $auction['amount']) / 100 + 0.001; $pv = round($auction['value'] * 100 / $auction['amount']) / 100 + 0.001;
$pv = substr($pv, 0, 4); $pv = substr((string)$pv, 0, 4);
if ($auction['stuff'] != 0) { if ($auction['stuff'] != 0) {
$pv = '-'; $pv = '-';
} }
+6
View File
@@ -3,6 +3,12 @@ namespace sammo;
include "lib.php"; include "lib.php";
include "func.php"; include "func.php";
$v = new Validator($_POST + $_GET);
$v->rule('required', 'gen')
->rule('integer', 'gen');
$gen = Util::getReq('gen', 'int');
//로그인 검사 //로그인 검사
$session = Session::requireGameLogin()->setReadOnly(); $session = Session::requireGameLogin()->setReadOnly();
$userID = Session::getUserID(); $userID = Session::getUserID();
+4 -4
View File
@@ -109,7 +109,7 @@ for ($i=0; $i < 2; $i++) {
} }
if ($general['win'] > 0) { if ($general['win'] > 0) {
$line[$i] = "<font color=red>"; $line[$i] = "<font color=red>";
$cent[floor($i/2)] = "<font color=red>"; $cent[intdiv($i, 2)] = "<font color=red>";
} else { } else {
$line[$i] = "<font color=white>"; $line[$i] = "<font color=white>";
} }
@@ -150,7 +150,7 @@ for ($i=0; $i < 4; $i++) {
} }
if ($general['win'] > 0) { if ($general['win'] > 0) {
$line[$i] = "<font color=red>"; $line[$i] = "<font color=red>";
$cent[floor($i/2)] = "<font color=red>"; $cent[intdiv($i, 2)] = "<font color=red>";
} else { } else {
$line[$i] = "<font color=white>"; $line[$i] = "<font color=white>";
} }
@@ -191,7 +191,7 @@ for ($i=0; $i < 8; $i++) {
} }
if ($general['win'] > 0) { if ($general['win'] > 0) {
$line[$i] = "<font color=red>"; $line[$i] = "<font color=red>";
$cent[floor($i/2)] = "<font color=red>"; $cent[intdiv($i, 2)] = "<font color=red>";
} else { } else {
$line[$i] = "<font color=white>"; $line[$i] = "<font color=white>";
} }
@@ -232,7 +232,7 @@ for ($i=0; $i < 16; $i++) {
} }
if ($general['win'] > 0) { if ($general['win'] > 0) {
$line[$i] = "<font color=red>"; $line[$i] = "<font color=red>";
$cent[floor($i/2)] = "<font color=red>"; $cent[intdiv($i, 2)] = "<font color=red>";
} else { } else {
$line[$i] = "<font color=white>"; $line[$i] = "<font color=white>";
} }
+4 -4
View File
@@ -99,7 +99,7 @@ if($myNation['level'] > 0) {
$where = 'city=0'; $where = 'city=0';
$cities = explode("|", $myNation['spy']); $cities = explode("|", $myNation['spy']);
for($i=0; $i < count($cities); $i++) { for($i=0; $i < count($cities); $i++) {
$city = floor($cities[$i]/10); $city = intdiv($cities[$i], 10);
$where .= " or city='{$city}'"; $where .= " or city='{$city}'";
} }
@@ -259,9 +259,9 @@ for($j=0; $j < $gencount; $j++) {
} }
if($general['injury'] > 0) { if($general['injury'] > 0) {
$leader = floor($general['leader'] * (100 - $general['injury'])/100); $leader = intdiv($general['leader'] * (100 - $general['injury']), 100);
$power = floor($general['power'] * (100 - $general['injury'])/100); $power = intdiv($general['power'] * (100 - $general['injury']), 100);
$intel = floor($general['intel'] * (100 - $general['injury'])/100); $intel = intdiv($general['intel'] * (100 - $general['injury']), 100);
$leader = "<font color=red>{$leader}</font>{$lbonus}"; $leader = "<font color=red>{$leader}</font>{$lbonus}";
$power = "<font color=red>{$power}</font>"; $power = "<font color=red>{$power}</font>";
$intel = "<font color=red>{$intel}</font>"; $intel = "<font color=red>{$intel}</font>";
+1 -1
View File
@@ -125,7 +125,7 @@ for ($i=0; $i < $nationcount; $i++) {
} }
$term = $admin['year'] * 12 + $admin['month'] + $dip['term']; $term = $admin['year'] * 12 + $admin['month'] + $dip['term'];
$year = floor($term / 12); $year = intdiv($term, 12);
$month = $term % 12; $month = $term % 12;
if ($month == 0) { if ($month == 0) {
+1 -1
View File
@@ -89,7 +89,7 @@ echo "
<td align=center width=108 style=background-color:".GameConst::$basecolor2.";>&nbsp;</td>"; <td align=center width=108 style=background-color:".GameConst::$basecolor2.";>&nbsp;</td>";
if($nationcount != 0) { if($nationcount != 0) {
$width = floor(888 / $nationcount); $width = intdiv(888, $nationcount);
} }
for($i=0; $i < $nationcount; $i++) { for($i=0; $i < $nationcount; $i++) {
+3 -3
View File
@@ -131,9 +131,9 @@ for ($j=0; $j < $gencount; $j++) {
} }
if ($general['injury'] > 0) { if ($general['injury'] > 0) {
$leader = floor($general['leader'] * (100 - $general['injury'])/100); $leader = intdiv($general['leader'] * (100 - $general['injury']), 100);
$power = floor($general['power'] * (100 - $general['injury'])/100); $power = intdiv($general['power'] * (100 - $general['injury']), 100);
$intel = floor($general['intel'] * (100 - $general['injury'])/100); $intel = intdiv($general['intel'] * (100 - $general['injury']), 100);
$leader = "<font color=red>{$leader}</font>{$lbonus}"; $leader = "<font color=red>{$leader}</font>{$lbonus}";
$power = "<font color=red>{$power}</font>"; $power = "<font color=red>{$power}</font>";
$intel = "<font color=red>{$intel}</font>"; $intel = "<font color=red>{$intel}</font>";
+3 -3
View File
@@ -122,9 +122,9 @@ for($j=0; $j < $gencount; $j++) {
} }
if($general['injury'] > 0) { if($general['injury'] > 0) {
$leader = floor($general['leader'] * (100 - $general['injury'])/100); $leader = intdiv($general['leader'] * (100 - $general['injury']), 100);
$power = floor($general['power'] * (100 - $general['injury'])/100); $power = intdiv($general['power'] * (100 - $general['injury']), 100);
$intel = floor($general['intel'] * (100 - $general['injury'])/100); $intel = intdiv($general['intel'] * (100 - $general['injury']), 100);
$leader = "<font color=red>{$leader}</font>{$lbonus}"; $leader = "<font color=red>{$leader}</font>{$lbonus}";
$power = "<font color=red>{$power}</font>"; $power = "<font color=red>{$power}</font>";
$intel = "<font color=red>{$intel}</font>"; $intel = "<font color=red>{$intel}</font>";
+4 -4
View File
@@ -223,7 +223,7 @@ for ($i=0; $i < 2; $i++) {
} }
if ($general['win'] > 0) { if ($general['win'] > 0) {
$line[$i] = "<font color=red>"; $line[$i] = "<font color=red>";
$cent[floor($i/2)] = "<font color=red>"; $cent[intdiv($i, 2)] = "<font color=red>";
} else { } else {
$line[$i] = "<font color=white>"; $line[$i] = "<font color=white>";
} }
@@ -264,7 +264,7 @@ for ($i=0; $i < 4; $i++) {
} }
if ($general['win'] > 0) { if ($general['win'] > 0) {
$line[$i] = "<font color=red>"; $line[$i] = "<font color=red>";
$cent[floor($i/2)] = "<font color=red>"; $cent[intdiv($i, 2)] = "<font color=red>";
} else { } else {
$line[$i] = "<font color=white>"; $line[$i] = "<font color=white>";
} }
@@ -305,7 +305,7 @@ for ($i=0; $i < 8; $i++) {
} }
if ($general['win'] > 0) { if ($general['win'] > 0) {
$line[$i] = "<font color=red>"; $line[$i] = "<font color=red>";
$cent[floor($i/2)] = "<font color=red>"; $cent[intdiv($i, 2)] = "<font color=red>";
} else { } else {
$line[$i] = "<font color=white>"; $line[$i] = "<font color=white>";
} }
@@ -346,7 +346,7 @@ for ($i=0; $i < 16; $i++) {
} }
if ($general['win'] > 0) { if ($general['win'] > 0) {
$line[$i] = "<font color=red>"; $line[$i] = "<font color=red>";
$cent[floor($i/2)] = "<font color=red>"; $cent[intdiv($i, 2)] = "<font color=red>";
} else { } else {
$line[$i] = "<font color=white>"; $line[$i] = "<font color=white>";
} }
+1 -1
View File
@@ -177,7 +177,7 @@ if($btn == "자동개최설정" && $session->userGrade >= 5) {
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$general = MYDB_fetch_array($result); $general = MYDB_fetch_array($result);
$grp = floor($code[$i] / 10); $grp = intdiv($code[$i], 10);
$grp_no = $code[$i] % 10; $grp_no = $code[$i] % 10;
$query = "insert into tournament (no, npc, name, ldr, pwr, itl, lvl, grp, grp_no, h, w, b) values ('{$general['no']}', '{$general['npc']}', '{$general['name']}', '{$general['leader']}', '{$general['power']}', '{$general['intel']}', '{$general['explevel']}', '$grp', '$grp_no', '{$general['horse']}', '{$general['weap']}', '{$general['book']}')"; $query = "insert into tournament (no, npc, name, ldr, pwr, itl, lvl, grp, grp_no, h, w, b) values ('{$general['no']}', '{$general['npc']}', '{$general['name']}', '{$general['leader']}', '{$general['power']}', '{$general['intel']}', '{$general['explevel']}', '$grp', '$grp_no', '{$general['horse']}', '{$general['weap']}', '{$general['book']}')";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
+7 -7
View File
@@ -796,9 +796,9 @@ function generalInfo($no) {
$horsename = getHorseName($general['horse']); $horsename = getHorseName($general['horse']);
$itemname = getItemName($general['item']); $itemname = getItemName($general['item']);
if($general['injury'] > 0) { if($general['injury'] > 0) {
$leader = floor($general['leader'] * (100 - $general['injury'])/100); $leader = intdiv($general['leader'] * (100 - $general['injury']), 100);
$power = floor($general['power'] * (100 - $general['injury'])/100); $power = intdiv($general['power'] * (100 - $general['injury']), 100);
$intel = floor($general['intel'] * (100 - $general['injury'])/100); $intel = intdiv($general['intel'] * (100 - $general['injury']), 100);
} else { } else {
$leader = $general['leader']; $leader = $general['leader'];
$power = $general['power']; $power = $general['power'];
@@ -1426,7 +1426,7 @@ function checkDelay() {
$threshold = 3; $threshold = 3;
} }
//지연 해야할 밀린 턴 횟수 //지연 해야할 밀린 턴 횟수
$iter = floor($admin['offset'] / $term); $iter = intdiv($admin['offset'], $term);
if($iter > $threshold) { if($iter > $threshold) {
$minute = $iter * $term; $minute = $iter * $term;
$query = "update game set turntime=DATE_ADD(turntime, INTERVAL $minute MINUTE),starttime=DATE_ADD(starttime, INTERVAL $minute MINUTE),tnmt_time=DATE_ADD(tnmt_time, INTERVAL $minute MINUTE)"; $query = "update game set turntime=DATE_ADD(turntime, INTERVAL $minute MINUTE),starttime=DATE_ADD(starttime, INTERVAL $minute MINUTE),tnmt_time=DATE_ADD(tnmt_time, INTERVAL $minute MINUTE)";
@@ -1780,9 +1780,9 @@ function turnDate($curtime) {
$curturn = cutTurn($curtime, $admin['turnterm']); $curturn = cutTurn($curtime, $admin['turnterm']);
$num = 0; $num = 0;
$term = $admin['turnterm']*60; $term = $admin['turnterm']*60;
$num = floor((strtotime($curturn) - strtotime($turn)) / $term); $num = intdiv((strtotime($curturn) - strtotime($turn)), $term);
$year = $admin['startyear'] + floor($num / 12); $year = $admin['startyear'] + intdiv($num, 12);
$month = 1 + (12+$num) % 12; $month = 1 + (12+$num) % 12;
// 바뀐 경우만 업데이트 // 바뀐 경우만 업데이트
@@ -2667,7 +2667,7 @@ function TrickInjury($city, $type=0) {
$injury = rand() % 100; $injury = rand() % 100;
if($injury < 30) { // 부상률 30% if($injury < 30) { // 부상률 30%
$injury = floor($injury / 2) + 1; // 부상 1~16 $injury = intdiv($injury, 2) + 1; // 부상 1~16
$query = "update general set crew=crew*0.98,atmos=atmos*0.98,train=train*0.98,injury=injury+'$injury' where no='{$general['no']}'"; $query = "update general set crew=crew*0.98,atmos=atmos*0.98,train=train*0.98,injury=injury+'$injury' where no='{$general['no']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
+2 -2
View File
@@ -3,7 +3,7 @@ namespace sammo;
function GetStuffName($stuff) { function GetStuffName($stuff) {
$type1 = $stuff % 10; $type1 = $stuff % 10;
$type2 = floor($stuff / 10); $type2 = intdiv($stuff, 10);
switch($type1) { switch($type1) {
case 0: $str = ""; break; case 0: $str = ""; break;
@@ -180,7 +180,7 @@ function processAuction() {
$bidder = MYDB_fetch_array($result); $bidder = MYDB_fetch_array($result);
$sel1 = $auction['stuff'] % 10; $sel1 = $auction['stuff'] % 10;
$sel2 = floor($auction['stuff'] / 10); $sel2 = intdiv($auction['stuff'], 10);
switch($sel1) { switch($sel1) {
case 1: $type = "weap"; break; case 1: $type = "weap"; break;
case 2: $type = "book"; break; case 2: $type = "book"; break;
+1 -1
View File
@@ -532,7 +532,7 @@ function processCommand($no) {
if($general['npc'] >= 2 || $general['killturn'] > $admin['killturn']) { if($general['npc'] >= 2 || $general['killturn'] > $admin['killturn']) {
$query = "update general set recturn=turn0,resturn='FAIL',myset=3,con=0,killturn=killturn-1 where no='{$general['no']}'"; $query = "update general set recturn=turn0,resturn='FAIL',myset=3,con=0,killturn=killturn-1 where no='{$general['no']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
} elseif(floor($command[0]) == 0 && $session->userGrade < 5) { } elseif(intval($command[0]) == 0 && $session->userGrade < 5) {
$query = "update general set recturn=turn0,resturn='FAIL',myset=3,con=0,killturn=killturn-1 where no='{$general['no']}'"; $query = "update general set recturn=turn0,resturn='FAIL',myset=3,con=0,killturn=killturn-1 where no='{$general['no']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
} else { } else {
+1 -1
View File
@@ -361,7 +361,7 @@ function getHonor($experience) {
function getExpLevel($experience) { function getExpLevel($experience) {
if($experience < 1000) { if($experience < 1000) {
$level = floor($experience / 100); $level = intdiv($experience, 100);
} else { } else {
for($level = 0; $experience > (($level+1)*($level+1)*10); $level++) { for($level = 0; $experience > (($level+1)*($level+1)*10); $level++) {
} }
+14 -14
View File
@@ -12,9 +12,9 @@ function abilityRand() {
$power = (rand()%100 + 1) / 100.0 + 1.0; $power = (rand()%100 + 1) / 100.0 + 1.0;
$intel = (rand()%100 + 1) / 100.0 + 1.0; $intel = (rand()%100 + 1) / 100.0 + 1.0;
$rate = $leader + $power + $intel; $rate = $leader + $power + $intel;
$leader = floor($leader / $rate * $total); $leader = intdiv($leader * $total, $rate);
$power = floor($power / $rate * $total); $power = intdiv($power * $total, $rate);
$intel = floor($intel / $rate * $total); $intel = intdiv($intel * $total, $rate);
while($leader+$power+$intel < 150) { while($leader+$power+$intel < 150) {
$leader++; $leader++;
@@ -30,9 +30,9 @@ function abilityLeadpow() {
$power = (rand()%100 + 1) / 100.0 + 6.0; $power = (rand()%100 + 1) / 100.0 + 6.0;
$intel = (rand()%100 + 1) / 100.0 + 1.0; $intel = (rand()%100 + 1) / 100.0 + 1.0;
$rate = $leader + $power + $intel; $rate = $leader + $power + $intel;
$leader = floor($leader / $rate * $total); $leader = intdiv($leader * $total, $rate);
$power = floor($power / $rate * $total); $power = intdiv($power * $total, $rate);
$intel = floor($intel / $rate * $total); $intel = intdiv($intel * $total, $rate);
while($leader+$power+$intel < 150) { while($leader+$power+$intel < 150) {
$leader++; $leader++;
@@ -47,9 +47,9 @@ function abilityLeadint() {
$power = (rand()%100 + 1) / 100.0 + 1.0; $power = (rand()%100 + 1) / 100.0 + 1.0;
$intel = (rand()%100 + 1) / 100.0 + 6.0; $intel = (rand()%100 + 1) / 100.0 + 6.0;
$rate = $leader + $power + $intel; $rate = $leader + $power + $intel;
$leader = floor($leader / $rate * $total); $leader = intdiv($leader * $total, $rate);
$power = floor($power / $rate * $total); $power = intdiv($power * $total, $rate);
$intel = floor($intel / $rate * $total); $intel = intdiv($intel * $total, $rate);
while($leader+$power+$intel < 150) { while($leader+$power+$intel < 150) {
$leader++; $leader++;
@@ -64,9 +64,9 @@ function abilityPowint() {
$power = (rand()%100 + 1) / 100.0 + 6.0; $power = (rand()%100 + 1) / 100.0 + 6.0;
$intel = (rand()%100 + 1) / 100.0 + 6.0; $intel = (rand()%100 + 1) / 100.0 + 6.0;
$rate = $leader + $power + $intel; $rate = $leader + $power + $intel;
$leader = floor($leader / $rate * $total); $leader = intdiv($leader * $total, $rate);
$power = floor($power / $rate * $total); $power = intdiv($power * $total, $rate);
$intel = floor($intel / $rate * $total); $intel = intdiv($intel * $total, $rate);
while($leader+$power+$intel < 150) { while($leader+$power+$intel < 150) {
$leader++; $leader++;
@@ -184,7 +184,7 @@ function getSpecial2($leader, $power, $intel, $nodex=1, $dex0=0, $dex10=0, $dex2
} }
function getGenDex($general, $type) { function getGenDex($general, $type) {
$type = floor($type / 10) * 10; $type = intdiv($type, 10) * 10;
return $general["dex{$type}"]; return $general["dex{$type}"];
} }
@@ -192,7 +192,7 @@ function addGenDex($no, $type, $exp) {
$db = DB::db(); $db = DB::db();
$connect=$db->get(); $connect=$db->get();
$type = floor($type / 10) * 10; $type = intdiv($type, 10) * 10;
$dexType = "dex{$type}"; $dexType = "dex{$type}";
if($type == 30) { $exp = round($exp * 0.90); } //귀병은 90%효율 if($type == 30) { $exp = round($exp * 0.90); } //귀병은 90%효율
elseif($type == 40) { $exp = round($exp * 0.90); } //차병은 90%효율 elseif($type == 40) { $exp = round($exp * 0.90); } //차병은 90%효율
+2 -2
View File
@@ -299,8 +299,8 @@ function DecodeMsg($msg, $type, $who, $date, $bg, $num=0) {
// 4 : 합병, 5 : 통합, 6 : 불가침, 7 : 종전, 8 : 파기 // 4 : 합병, 5 : 통합, 6 : 불가침, 7 : 종전, 8 : 파기
// 9 : 자신->타인, 10 : 타인 -> 자신, 11 : 등용 // 9 : 자신->타인, 10 : 타인 -> 자신, 11 : 등용
$category = $type % 100; $category = $type % 100;
$term = floor($type / 100); $term = intdiv($type, 100);
$from = floor($who / 10000); $from = intdiv($who, 10000);
$to = $who % 10000; $to = $who % 10000;
$query = "select name,picture,imgsvr,nation from general where no='$from'"; $query = "select name,picture,imgsvr,nation from general where no='$from'";
+12 -12
View File
@@ -154,7 +154,7 @@ function SetCrew($no, $personal, $gold, $leader, $genType, $tech, $region, $city
$cost = getCost($type) * getTechCost($tech); $cost = getCost($type) * getTechCost($tech);
$cost = CharCost($cost, $personal); $cost = CharCost($cost, $personal);
$crew = floor($gold / $cost); $crew = intdiv($gold, $cost);
if($leader < $crew) { $crew = $leader; } if($leader < $crew) { $crew = $leader; }
$command = EncodeCommand(0, $type, $crew, 11); $command = EncodeCommand(0, $type, $crew, 11);
@@ -577,7 +577,7 @@ function processAI($no) {
$result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),""); $result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),"");
$SelGen = MYDB_fetch_array($result); $SelGen = MYDB_fetch_array($result);
if($SelGen['no'] != 0) { if($SelGen['no'] != 0) {
$amount = floor($SelGen[$type] / 5000)*10 + 10; $amount = intdiv($SelGen[$type], 5000)*10 + 10;
if($amount > 100) $amount = 100; if($amount > 100) $amount = 100;
// 몰수 // 몰수
$command = EncodeCommand($type2, $SelGen['no'], $amount, 24); // 금,쌀 1000단위 몰수 $command = EncodeCommand($type2, $SelGen['no'], $amount, 24); // 금,쌀 1000단위 몰수
@@ -588,7 +588,7 @@ function processAI($no) {
$result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),""); $result = MYDB_query($query, $connect) or Error("processAI10 ".MYDB_error($connect),"");
$SelGen = MYDB_fetch_array($result); $SelGen = MYDB_fetch_array($result);
if($SelGen['no'] != 0) { if($SelGen['no'] != 0) {
$amount = floor(($nation[$type]-GameConst::$baserice) / 5000)*10 + 10; $amount = intdiv(($nation[$type]-GameConst::$baserice), 5000)*10 + 10;
if($amount > 100) $amount = 100; if($amount > 100) $amount = 100;
// 포상 // 포상
$command = EncodeCommand($type2, $SelGen['no'], $amount, 23); // 금 1000단위 포상 $command = EncodeCommand($type2, $SelGen['no'], $amount, 23); // 금 1000단위 포상
@@ -637,7 +637,7 @@ function processAI($no) {
} }
//국가 병량이 없을때 바로 헌납 //국가 병량이 없을때 바로 헌납
if($nation['rice'] < 2000 && $general['rice'] > 200) { if($nation['rice'] < 2000 && $general['rice'] > 200) {
$amount = floor(($general['rice'] - 200)/100) + 1; $amount = intdiv($general['rice'] - 200, 100) + 1;
if($amount > 20) { $amount = 20; } if($amount > 20) { $amount = 20; }
$command = EncodeCommand(0, 2, $amount, 44); //헌납 $command = EncodeCommand(0, 2, $amount, 44); //헌납
$query = "update general set turn0='$command' where no='{$general['no']}'"; $query = "update general set turn0='$command' where no='{$general['no']}'";
@@ -663,11 +663,11 @@ function processAI($no) {
if($general['gold'] + $general['rice'] < 200) { $command = EncodeCommand(0, 0, 0, 9); } //금쌀없으면 조달9 if($general['gold'] + $general['rice'] < 200) { $command = EncodeCommand(0, 0, 0, 9); } //금쌀없으면 조달9
elseif($general['rice'] > 100 && $city['rate'] < 95) { $command = EncodeCommand(0, 0, 0, 4); } //우선 선정 elseif($general['rice'] > 100 && $city['rate'] < 95) { $command = EncodeCommand(0, 0, 0, 4); } //우선 선정
elseif($general['gold'] < 100) { //금없으면 쌀팜 elseif($general['gold'] < 100) { //금없으면 쌀팜
$amount = floor(($general['rice'] - $general['gold']) / 100 / 2); // 100단위 $amount = intdiv(($general['rice'] - $general['gold']), 100 / 2); // 100단위
$command = EncodeCommand(0, 1, $amount, 49); //팜 $command = EncodeCommand(0, 1, $amount, 49); //팜
} elseif($general['gold'] < 700 && $general['rice'] < 700) { $command = EncodeCommand(0, 0, 0, 1); } //금쌀되면 내정 } elseif($general['gold'] < 700 && $general['rice'] < 700) { $command = EncodeCommand(0, 0, 0, 1); } //금쌀되면 내정
elseif($general['rice'] < 100) { //쌀없으면 쌀삼 elseif($general['rice'] < 100) { //쌀없으면 쌀삼
$amount = floor(($general['gold'] - $general['rice']) / 100 / 2); // 100단위 $amount = intdiv(($general['gold'] - $general['rice']), 100 / 2); // 100단위
$command = EncodeCommand(0, 2, $amount, 49); //삼 $command = EncodeCommand(0, 2, $amount, 49); //삼
} elseif($genType >= 2) { $command = EncodeCommand(0, 0, 0, 1); } //내정장일때 내정 } elseif($genType >= 2) { $command = EncodeCommand(0, 0, 0, 1); } //내정장일때 내정
else { else {
@@ -743,12 +743,12 @@ function processAI($no) {
else { $command = EncodeCommand(0, 0, 0, 1); } else { $command = EncodeCommand(0, 0, 0, 1); }
} elseif($general['rice'] < $resrc && $general['rice'] <= $general['gold']) { } elseif($general['rice'] < $resrc && $general['rice'] <= $general['gold']) {
//금이 더 많으면 매매 //금이 더 많으면 매매
$amount = floor(($general['gold'] - $general['rice']) / 100 / 2); // 100단위 $amount = intdiv(($general['gold'] - $general['rice']), 100 / 2); // 100단위
if($amount > 0) { $command = EncodeCommand(0, 2, $amount, 49); }//삼 if($amount > 0) { $command = EncodeCommand(0, 2, $amount, 49); }//삼
else { $command = EncodeCommand(0, 0, 0, (rand()%2)*8 + 1); } // 내정, 조달 else { $command = EncodeCommand(0, 0, 0, (rand()%2)*8 + 1); } // 내정, 조달
} elseif($general['gold'] < $resrc && $general['rice'] > $general['gold']) { } elseif($general['gold'] < $resrc && $general['rice'] > $general['gold']) {
//쌀이 더 많으면 매매 //쌀이 더 많으면 매매
$amount = floor(($general['rice'] - $general['gold']) / 100 / 2); // 100단위 $amount = intdiv(($general['rice'] - $general['gold']), 100 / 2); // 100단위
if($amount > 0) { $command = EncodeCommand(0, 1, $amount, 49); }//팜 if($amount > 0) { $command = EncodeCommand(0, 1, $amount, 49); }//팜
else { $command = EncodeCommand(0, 0, 0, (rand()%2)*8 + 1); } // 내정, 조달 else { $command = EncodeCommand(0, 0, 0, (rand()%2)*8 + 1); } // 내정, 조달
//자원, 병사 모두 충족 //자원, 병사 모두 충족
@@ -777,11 +777,11 @@ function processAI($no) {
elseif($general['rice'] > $resrc && $city['rate'] < 95 && $city['front'] == 0) { $command = EncodeCommand(0, 0, 0, 4); } // 우선 선정 elseif($general['rice'] > $resrc && $city['rate'] < 95 && $city['front'] == 0) { $command = EncodeCommand(0, 0, 0, 4); } // 우선 선정
elseif($general['rice'] > $resrc && $city['rate'] < 50 && $city['front'] == 1) { $command = EncodeCommand(0, 0, 0, 4); } // 우선 선정 elseif($general['rice'] > $resrc && $city['rate'] < 50 && $city['front'] == 1) { $command = EncodeCommand(0, 0, 0, 4); } // 우선 선정
elseif($general['gold'] < $resrc) { // 금없으면 쌀팜 elseif($general['gold'] < $resrc) { // 금없으면 쌀팜
$amount = floor(($general['rice'] - $general['gold']) / 100 / 2); // 100단위 $amount = intdiv(($general['rice'] - $general['gold']), 100 / 2); // 100단위
if($amount > 0) { $command = EncodeCommand(0, 1, $amount, 49); }// 팜 if($amount > 0) { $command = EncodeCommand(0, 1, $amount, 49); }// 팜
else { $command = EncodeCommand(0, 0, 0, 9); } // 조달 else { $command = EncodeCommand(0, 0, 0, 9); } // 조달
} elseif($general['rice'] < $resrc) { // 쌀없으면 쌀삼 } elseif($general['rice'] < $resrc) { // 쌀없으면 쌀삼
$amount = floor(($general['gold'] - $general['rice']) / 100 / 2); // 100단위 $amount = intdiv(($general['gold'] - $general['rice']), 100 / 2); // 100단위
if($amount > 0) { $command = EncodeCommand(0, 2, $amount, 49); }// 팜 if($amount > 0) { $command = EncodeCommand(0, 2, $amount, 49); }// 팜
else { $command = EncodeCommand(0, 0, 0, 9); } // 조달 else { $command = EncodeCommand(0, 0, 0, 9); } // 조달
} elseif($genType >= 2) { $command = EncodeCommand(0, 0, 0, 1); } //내정장일때 내정 } elseif($genType >= 2) { $command = EncodeCommand(0, 0, 0, 1); } //내정장일때 내정
@@ -1041,7 +1041,7 @@ function GoldBillRate($nation, $rate, $gold_rate, $type, $gold) {
$incomeList = getGoldIncome($nation, $rate, $gold_rate, $type); $incomeList = getGoldIncome($nation, $rate, $gold_rate, $type);
$income = $gold + $incomeList[0] + $incomeList[1]; $income = $gold + $incomeList[0] + $incomeList[1];
$outcome = getGoldOutcome($nation, 100); // 100%의 지급량 $outcome = getGoldOutcome($nation, 100); // 100%의 지급량
$bill = floor($income / $outcome * 90); // 수입의 90% 만 지급 $bill = intval($income / $outcome * 90); // 수입의 90% 만 지급
if($bill < 20) { $bill = 20; } if($bill < 20) { $bill = 20; }
if($bill > 200) { $bill = 200; } if($bill > 200) { $bill = 200; }
@@ -1057,7 +1057,7 @@ function RiceBillRate($nation, $rate, $rice_rate, $type, $rice) {
$incomeList = getRiceIncome($nation, $rate, $rice_rate, $type); $incomeList = getRiceIncome($nation, $rate, $rice_rate, $type);
$income = $rice + $incomeList[0] + $incomeList[1]; $income = $rice + $incomeList[0] + $incomeList[1];
$outcome = getRiceOutcome($nation, 100); // 100%의 지급량 $outcome = getRiceOutcome($nation, 100); // 100%의 지급량
$bill = floor($income / $outcome * 90); // 수입의 90% 만 지급 $bill = intval($income / $outcome * 90); // 수입의 90% 만 지급
if($bill < 20) { $bill = 20; } if($bill < 20) { $bill = 20; }
if($bill > 200) { $bill = 200; } if($bill > 200) { $bill = 200; }
+16 -16
View File
@@ -30,7 +30,7 @@ function getGeneralLeadership(&$general, $withInjury, $withItem, $withStatAdjust
//$withStatAdjust는 통솔에서 미사용 //$withStatAdjust는 통솔에서 미사용
if($useFloor){ if($useFloor){
return floor($leadership); return intval($leadership);
} }
return $leadership; return $leadership;
@@ -62,7 +62,7 @@ function getGeneralPower(&$general, $withInjury, $withItem, $withStatAdjust, $us
} }
if($useFloor){ if($useFloor){
return floor($power); return intval($power);
} }
return $power; return $power;
} }
@@ -93,7 +93,7 @@ function getGeneralIntel(&$general, $withInjury, $withItem, $withStatAdjust, $us
} }
if($useFloor){ if($useFloor){
return floor($intel); return intval($intel);
} }
return $intel; return $intel;
} }
@@ -350,7 +350,7 @@ function process_3(&$general) {
$ded = CharDedication($ded, $general['personal']); $ded = CharDedication($ded, $general['personal']);
// 부드러운 기술 제한 // 부드러운 기술 제한
if(TechLimit($admin['startyear'], $admin['year'], $nation['tech'])) { $score = floor($score/4); } if(TechLimit($admin['startyear'], $admin['year'], $nation['tech'])) { $score = intdiv($score, 4); }
//장수수 구함 //장수수 구함
$query = "select no from general where nation='{$general['nation']}'"; $query = "select no from general where nation='{$general['nation']}'";
@@ -887,11 +887,11 @@ function process_11(&$general, $type) {
$cost = round($cost); $cost = round($cost);
//특기 보정 : 보병, 궁병, 기병, 귀병, 공성, 징병 //특기 보정 : 보병, 궁병, 기병, 귀병, 공성, 징병
if(floor($armtype/10) == 0 && $general['special2'] == 50) { $cost *= 0.9; } if(intdiv($armtype, 10) == 0 && $general['special2'] == 50) { $cost *= 0.9; }
if(floor($armtype/10) == 1 && $general['special2'] == 51) { $cost *= 0.9; } if(intdiv($armtype, 10) == 1 && $general['special2'] == 51) { $cost *= 0.9; }
if(floor($armtype/10) == 2 && $general['special2'] == 52) { $cost *= 0.9; } if(intdiv($armtype, 10) == 2 && $general['special2'] == 52) { $cost *= 0.9; }
if(floor($armtype/10) == 3 && $general['special2'] == 40) { $cost *= 0.9; } if(intdiv($armtype, 10) == 3 && $general['special2'] == 40) { $cost *= 0.9; }
if(floor($armtype/10) == 4 && $general['special2'] == 43) { $cost *= 0.9; } if(intdiv($armtype, 10) == 4 && $general['special2'] == 43) { $cost *= 0.9; }
if($general['special2'] == 72) { $cost *= 0.5; } if($general['special2'] == 72) { $cost *= 0.5; }
if($type == 1) { $dtype = "징병"; } if($type == 1) { $dtype = "징병"; }
@@ -974,7 +974,7 @@ function process_11(&$general, $type) {
else { $valid = 0; } else { $valid = 0; }
// 초반 제한중 차병 불가 // 초반 제한중 차병 불가
if($admin['year'] < $admin['startyear']+3 && floor($armtype/10) == 4) { if($admin['year'] < $admin['startyear']+3 && intdiv($armtype, 10) == 4) {
$valid = 0; $valid = 0;
} }
@@ -1061,7 +1061,7 @@ function process_13(&$general) {
$log[] = "<C>●</>{$admin['month']}월:병사가 없습니다. 훈련 실패. <1>$date</>"; $log[] = "<C>●</>{$admin['month']}월:병사가 없습니다. 훈련 실패. <1>$date</>";
} elseif($general['train'] >= $_maxtrain) { } elseif($general['train'] >= $_maxtrain) {
$log[] = "<C>●</>{$admin['month']}월:병사들은 이미 정예병사들입니다. <1>$date</>"; $log[] = "<C>●</>{$admin['month']}월:병사들은 이미 정예병사들입니다. <1>$date</>";
// } elseif(floor($general['crewtype']/10) == 4) { // } elseif(intdiv($general['crewtype'], 10) == 4) {
// $log[] = "<C>●</>{$admin['month']}월:병기는 훈련이 불가능합니다. <1>$date</>"; // $log[] = "<C>●</>{$admin['month']}월:병기는 훈련이 불가능합니다. <1>$date</>";
} else { } else {
// 훈련시 // 훈련시
@@ -1082,7 +1082,7 @@ function process_13(&$general) {
$query = "update general set train='$score' where no='{$general['no']}'"; $query = "update general set train='$score' where no='{$general['no']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
// 사기 약간 감소 // 사기 약간 감소
$score = floor($general['atmos'] * $_atmosing); $score = intval($general['atmos'] * $_atmosing);
if($score < 0 ) { $score = 0; } if($score < 0 ) { $score = 0; }
$query = "update general set atmos='$score' where no='{$general['no']}'"; $query = "update general set atmos='$score' where no='{$general['no']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1133,7 +1133,7 @@ function process_14(&$general) {
$log[] = "<C>●</>{$admin['month']}월:자금이 모자랍니다. 사기진작 실패. <1>$date</>"; $log[] = "<C>●</>{$admin['month']}월:자금이 모자랍니다. 사기진작 실패. <1>$date</>";
} elseif($general['atmos'] >= $_maxatmos) { } elseif($general['atmos'] >= $_maxatmos) {
$log[] = "<C>●</>{$admin['month']}월:이미 사기는 하늘을 찌를듯 합니다. <1>$date</>"; $log[] = "<C>●</>{$admin['month']}월:이미 사기는 하늘을 찌를듯 합니다. <1>$date</>";
// } elseif(floor($general['crewtype']/10) == 4) { // } elseif(intdiv($general['crewtype'], 10) == 4) {
// $log[] = "<C>●</>{$admin['month']}월:병기는 사기 진작이 불가능합니다. <1>$date</>"; // $log[] = "<C>●</>{$admin['month']}월:병기는 사기 진작이 불가능합니다. <1>$date</>";
} else { } else {
$score = round(getGeneralLeadership($general, true, true, true)*100 / $general['crew'] * $_training); $score = round(getGeneralLeadership($general, true, true, true)*100 / $general['crew'] * $_training);
@@ -1185,7 +1185,7 @@ function process_15(&$general) {
$city = MYDB_fetch_array($result); $city = MYDB_fetch_array($result);
if($general['term']%100 == 15) { if($general['term']%100 == 15) {
$term = floor($general['term']/100) + 1; $term = intdiv($general['term'], 100) + 1;
$code = $term * 100 + 15; $code = $term * 100 + 15;
} else { } else {
$term = 1; $term = 1;
@@ -1738,7 +1738,7 @@ function process_31(&$general) {
if($nation['spy'] != "") { $cities = explode("|", $nation['spy']); } if($nation['spy'] != "") { $cities = explode("|", $nation['spy']); }
$exist = 0; $exist = 0;
for($i=0; $i < count($cities); $i++) { for($i=0; $i < count($cities); $i++) {
if(floor($cities[$i]/10) == $destination) { if(intdiv($cities[$i], 10) == $destination) {
$exist = 1; $exist = 1;
break; break;
} }
@@ -1796,7 +1796,7 @@ function process_41(&$general) {
} elseif($crewexp == 0) { } elseif($crewexp == 0) {
$log[] = "<C>●</>{$admin['month']}월:병사가 모자랍니다. 단련 실패. <1>$date</>"; $log[] = "<C>●</>{$admin['month']}월:병사가 모자랍니다. 단련 실패. <1>$date</>";
} else { } else {
$type = floor($general['crewtype'] / 10) * 10; $type = intdiv($general['crewtype'], 10) * 10;
switch($type) { switch($type) {
case 0: $crewstr = '보병'; break; case 0: $crewstr = '보병'; break;
case 1: $crewstr = '궁병'; break; case 1: $crewstr = '궁병'; break;
+11 -11
View File
@@ -986,7 +986,7 @@ function process_66(&$general) {
$code = $nation["l{$general['level']}term"]; $code = $nation["l{$general['level']}term"];
if($code%100 == 66) { if($code%100 == 66) {
$term = floor($code/100) + 1; $term = intdiv($code, 100) + 1;
$code = $term * 100 + 66; $code = $term * 100 + 66;
} else { } else {
$term = 1; $term = 1;
@@ -1075,7 +1075,7 @@ function process_67(&$general) {
$code = $nation["l{$general['level']}term"]; $code = $nation["l{$general['level']}term"];
if($code%100 == 67) { if($code%100 == 67) {
$term = floor($code/100) + 1; $term = intdiv($code, 100) + 1;
$code = $term * 100 + 67; $code = $term * 100 + 67;
} else { } else {
$term = 1; $term = 1;
@@ -1166,7 +1166,7 @@ function process_68(&$general) {
$code = $nation["l{$general['level']}term"]; $code = $nation["l{$general['level']}term"];
if($code%100 == 68) { if($code%100 == 68) {
$term = floor($code/100) + 1; $term = intdiv($code, 100) + 1;
$code = $term * 100 + 68; $code = $term * 100 + 68;
} else { } else {
$term = 1; $term = 1;
@@ -1275,7 +1275,7 @@ function process_71(&$general) {
$code = $nation["l{$general['level']}term"]; $code = $nation["l{$general['level']}term"];
if($code%100 == 71) { if($code%100 == 71) {
$term = floor($code/100) + 1; $term = intdiv($code, 100) + 1;
$code = $term * 100 + 71; $code = $term * 100 + 71;
} else { } else {
$term = 1; $term = 1;
@@ -1388,7 +1388,7 @@ function process_72(&$general) {
$code = $nation["l{$general['level']}term"]; $code = $nation["l{$general['level']}term"];
if($code%100 == 72) { if($code%100 == 72) {
$term = floor($code/100) + 1; $term = intdiv($code, 100) + 1;
$code = $term * 100 + 72; $code = $term * 100 + 72;
} else { } else {
$term = 1; $term = 1;
@@ -1507,7 +1507,7 @@ function process_73(&$general) {
$code = $nation["l{$general['level']}term"]; $code = $nation["l{$general['level']}term"];
if($code%100 == 73) { if($code%100 == 73) {
$term = floor($code/100) + 1; $term = intdiv($code, 100) + 1;
$code = $term * 100 + 73; $code = $term * 100 + 73;
} else { } else {
$term = 1; $term = 1;
@@ -1638,7 +1638,7 @@ function process_74(&$general) {
$code = $nation["l{$general['level']}term"]; $code = $nation["l{$general['level']}term"];
if($code%100 == 74) { if($code%100 == 74) {
$term = floor($code/100) + 1; $term = intdiv($code, 100) + 1;
$code = $term * 100 + 74; $code = $term * 100 + 74;
} else { } else {
$term = 1; $term = 1;
@@ -1778,7 +1778,7 @@ function process_75(&$general) {
$code = $nation["l{$general['level']}term"]; $code = $nation["l{$general['level']}term"];
if($code%100 == 75) { if($code%100 == 75) {
$term = floor($code/100) + 1; $term = intdiv($code, 100) + 1;
$code = $term * 100 + 75; $code = $term * 100 + 75;
} else { } else {
$term = 1; $term = 1;
@@ -1893,7 +1893,7 @@ function process_76(&$general) {
$code = $nation["l{$general['level']}term"]; $code = $nation["l{$general['level']}term"];
if($code%100 == 76) { if($code%100 == 76) {
$term = floor($code/100) + 1; $term = intdiv($code, 100) + 1;
$code = $term * 100 + 76; $code = $term * 100 + 76;
} else { } else {
$term = 1; $term = 1;
@@ -2121,7 +2121,7 @@ function process_77(&$general) {
$code = $nation["l{$general['level']}term"]; $code = $nation["l{$general['level']}term"];
if($code%100 == 77) { if($code%100 == 77) {
$term = floor($code/100) + 1; $term = intdiv($code, 100) + 1;
$code = $term * 100 + 77; $code = $term * 100 + 77;
} else { } else {
$term = 1; $term = 1;
@@ -2249,7 +2249,7 @@ function process_78(&$general) {
$code = $nation["l{$general['level']}term"]; $code = $nation["l{$general['level']}term"];
if($code%100 == 78) { if($code%100 == 78) {
$term = floor($code/100) + 1; $term = intdiv($code, 100) + 1;
$code = $term * 100 + 78; $code = $term * 100 + 78;
} else { } else {
$term = 1; $term = 1;
+9 -9
View File
@@ -155,18 +155,18 @@ function popIncrease() {
$cityrate = 50; $cityrate = 50;
$ratio = 0.99; // 공백지는 수비 빼고 약간씩 감소 $ratio = 0.99; // 공백지는 수비 빼고 약간씩 감소
$agri = floor($city['agri'] * $ratio); $agri = intval($city['agri'] * $ratio);
$comm = floor($city['comm'] * $ratio); $comm = intval($city['comm'] * $ratio);
$secu = floor($city['secu'] * $ratio); $secu = intval($city['secu'] * $ratio);
$def = $city['def']; $def = $city['def'];
$wall = $city['wall']; $wall = $city['wall'];
} else { } else {
$ratio = (20 - $rate[$city['nation']])/200; // 20일때 0% 0일때 10% 100일때 -40% $ratio = (20 - $rate[$city['nation']])/200; // 20일때 0% 0일때 10% 100일때 -40%
$agri = $city['agri'] + floor($city['agri'] * $ratio); //내정도 증감 $agri = $city['agri'] + intval($city['agri'] * $ratio); //내정도 증감
$comm = $city['comm'] + floor($city['comm'] * $ratio); $comm = $city['comm'] + intval($city['comm'] * $ratio);
$secu = $city['secu'] + floor($city['secu'] * $ratio); $secu = $city['secu'] + intval($city['secu'] * $ratio);
$def = $city['def'] + floor($city['def'] * $ratio); $def = $city['def'] + intval($city['def'] * $ratio);
$wall = $city['wall'] + floor($city['wall'] * $ratio); $wall = $city['wall'] + intval($city['wall'] * $ratio);
$ratio = (30 - $rate[$city['nation']])/200; // 20일때 5% 5일때 12.5% 50일때 -10% $ratio = (30 - $rate[$city['nation']])/200; // 20일때 5% 5일때 12.5% 50일때 -10%
if($ratio >= 0) { if($ratio >= 0) {
// 국가보정 // 국가보정
@@ -180,7 +180,7 @@ function popIncrease() {
$ratio *= (1 - $city['secu']/$city['secu2']/10); //치안에 따라 최대 10% 경감 $ratio *= (1 - $city['secu']/$city['secu2']/10); //치안에 따라 최대 10% 경감
} }
$pop = $city['pop'] + floor($city['pop'] * $ratio) + 5000; // 기본 5000명은 증가 $pop = $city['pop'] + (int)($city['pop'] * $ratio) + 5000; // 기본 5000명은 증가
$ratio = round($ratio*100, 2); $ratio = round($ratio*100, 2);
$cityrate = $city['rate']; $cityrate = $city['rate'];
+3 -3
View File
@@ -30,7 +30,7 @@ function processTournament() {
} }
//업데이트 횟수 //업데이트 횟수
$iter = floor($admin['offset'] / $unit) + 1; $iter = intdiv($admin['offset'], $unit) + 1;
for($i=0; $i < $iter; $i++) { for($i=0; $i < $iter; $i++) {
switch($tnmt) { switch($tnmt) {
@@ -519,7 +519,7 @@ function final16set() {
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$general = MYDB_fetch_array($result); $general = MYDB_fetch_array($result);
//16강에 추가 //16강에 추가
$newGrp = 20 + floor($i / 2); $newGrp = 20 + intdiv($i, 2);
$newGrp_no = $i % 2; $newGrp_no = $i % 2;
$query = "insert into tournament (no, npc, name, ldr, pwr, itl, lvl, grp, grp_no, h, w, b) values ('{$general['no']}', '{$general['npc']}', '{$general['name']}', '{$general['ldr']}', '{$general['pwr']}', '{$general['itl']}', '{$general['lvl']}', '$newGrp', '$newGrp_no', '{$general['h']}', '{$general['w']}', '{$general['b']}')"; $query = "insert into tournament (no, npc, name, ldr, pwr, itl, lvl, grp, grp_no, h, w, b) values ('{$general['no']}', '{$general['npc']}', '{$general['name']}', '{$general['ldr']}', '{$general['pwr']}', '{$general['itl']}', '{$general['lvl']}', '$newGrp', '$newGrp_no', '{$general['h']}', '{$general['w']}', '{$general['b']}')";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -552,7 +552,7 @@ function finalFight($tnmt_type, $tnmt, $phase, $type) {
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$general = MYDB_fetch_array($result); $general = MYDB_fetch_array($result);
//x강에 추가 //x강에 추가
$newGrp = floor($phase / 2) + $offset + 10; $newGrp = intdiv($phase, 2) + $offset + 10;
$newGrp_no = $phase % 2; $newGrp_no = $phase % 2;
$query = "insert into tournament (no, npc, name, ldr, pwr, itl, lvl, grp, grp_no, h, w, b) values ('{$general['no']}', '{$general['npc']}', '{$general['name']}', '{$general['ldr']}', '{$general['pwr']}', '{$general['itl']}', '{$general['lvl']}', '$newGrp', '$newGrp_no', '{$general['h']}', '{$general['w']}', '{$general['b']}')"; $query = "insert into tournament (no, npc, name, ldr, pwr, itl, lvl, grp, grp_no, h, w, b) values ('{$general['no']}', '{$general['npc']}', '{$general['name']}', '{$general['ldr']}', '{$general['pwr']}', '{$general['itl']}', '{$general['lvl']}', '$newGrp', '$newGrp_no', '{$general['h']}', '{$general['w']}', '{$general['b']}')";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
+1 -1
View File
@@ -162,7 +162,7 @@ if($sync == 0) {
} }
$killturn = 4800 / $turnterm; $killturn = 4800 / $turnterm;
if($npcmode == 1) { $killturn = floor($killturn / 3); } if($npcmode == 1) { $killturn = intdiv($killturn, 3); }
$env = [ $env = [
'scenario'=>$scenario, 'scenario'=>$scenario,
+22 -21
View File
@@ -4,7 +4,7 @@ namespace sammo;
include "lib.php"; include "lib.php";
include "func.php"; include "func.php";
$v = new Validator($_GET + $_POST); $v = new Validator($_POST + $_GET);
$v $v
->rule('required', [ ->rule('required', [
'name', 'name',
@@ -34,7 +34,7 @@ $v
->rule('min', 'character', 0) ->rule('min', 'character', 0)
->rule('max', 'character', 11); ->rule('max', 'character', 11);
if(!$v->validate()){ if (!$v->validate()) {
MessageBox($v->errorStr()); MessageBox($v->errorStr());
echo "<script>history.go(-1);</script>"; echo "<script>history.go(-1);</script>";
exit(1); exit(1);
@@ -59,7 +59,7 @@ $rootDB = RootDB::db();
//회원 테이블에서 정보확인 //회원 테이블에서 정보확인
$member = $rootDB->queryFirstRow('SELECT `no`, id, picture, grade, `name` FROM MEMBER WHERE no=%i', $userID); $member = $rootDB->queryFirstRow('SELECT `no`, id, picture, grade, `name` FROM MEMBER WHERE no=%i', $userID);
if(!$member) { if (!$member) {
MessageBox("잘못된 접근입니다!!!"); MessageBox("잘못된 접근입니다!!!");
echo "<script>history.go(-1);</script>"; echo "<script>history.go(-1);</script>";
exit(1); exit(1);
@@ -73,42 +73,42 @@ $gencount = $db->queryFirstField('SELECT count(`no`) FROM general WHERE noc<2');
$oldGeneral = $db->queryFirstField('SELECT `no` FROM general WHERE `owner`=%i', $userID); $oldGeneral = $db->queryFirstField('SELECT `no` FROM general WHERE `owner`=%i', $userID);
$oldName = $db->queryFirstField('SELECT `no` FROM general WHERE `name`=%i', $name); $oldName = $db->queryFirstField('SELECT `no` FROM general WHERE `name`=%i', $name);
if($oldGeneral) { if ($oldGeneral) {
echo("<script> echo("<script>
window.alert('이미 등록하셨습니다!') window.alert('이미 등록하셨습니다!')
history.go(-1) history.go(-1)
</script>"); </script>");
exit; exit;
} }
if($oldName) { if ($oldName) {
echo("<script> echo("<script>
window.alert('이미 있는 장수입니다. 다른 이름으로 등록해 주세요!') window.alert('이미 있는 장수입니다. 다른 이름으로 등록해 주세요!')
history.go(-1) history.go(-1)
</script>"); </script>");
exit; exit;
} }
if($admin['maxgeneral'] <= $gencount) { if ($admin['maxgeneral'] <= $gencount) {
echo("<script> echo("<script>
window.alert('더이상 등록할 수 없습니다!') window.alert('더이상 등록할 수 없습니다!')
history.go(-1) history.go(-1)
</script>"); </script>");
exit; exit;
} }
if(mb_strlen($name) < 1) { if (mb_strlen($name) < 1) {
echo("<script> echo("<script>
window.alert('이름이 짧습니다. 다시 가입해주세요!') window.alert('이름이 짧습니다. 다시 가입해주세요!')
history.go(-1) history.go(-1)
</script>"); </script>");
exit; exit;
} }
if(mb_strlen($name) > 6) { if (mb_strlen($name) > 6) {
echo("<script> echo("<script>
window.alert('이름이 유효하지 않습니다. 다시 가입해주세요!') window.alert('이름이 유효하지 않습니다. 다시 가입해주세요!')
history.go(-1) history.go(-1)
</script>"); </script>");
exit; exit;
} }
if($leader + $power + $intel > 150) { if ($leader + $power + $intel > 150) {
echo("<script> echo("<script>
window.alert('능력치가 150을 넘어섰습니다. 다시 가입해주세요!') window.alert('능력치가 150을 넘어섰습니다. 다시 가입해주세요!')
history.go(-1) history.go(-1)
@@ -118,8 +118,7 @@ if($leader + $power + $intel > 150) {
$genius = Util::randBool(0.01); $genius = Util::randBool(0.01);
// 현재 1% // 현재 1%
if($genius && $admin['genius'] > 0) { if ($genius && $admin['genius'] > 0) {
$db->update('game', [ $db->update('game', [
'genius'=>$db->sqleval('genius-1') 'genius'=>$db->sqleval('genius-1')
], true); ], true);
@@ -129,15 +128,15 @@ if($genius && $admin['genius'] > 0) {
// 공백지에서만 태어나게 // 공백지에서만 태어나게
$city = $db->queryFirstField("select city from city where level>=5 and level<=6 and nation=0 order by rand() limit 0,1"); $city = $db->queryFirstField("select city from city where level>=5 and level<=6 and nation=0 order by rand() limit 0,1");
if(!$city) { if (!$city) {
$city = $db->queryFirstField("select city from city where level>=5 and level<=6 order by rand() limit 0,1"); $city = $db->queryFirstField("select city from city where level>=5 and level<=6 order by rand() limit 0,1");
} }
$pleader = 0; $pleader = 0;
$ppower = 0; $ppower = 0;
$pintel = 0; $pintel = 0;
for($statBonusCnt = 3 + mt_rand(0, 2); $statBonusCnt > 0; $statBonusCnt--){ for ($statBonusCnt = 3 + mt_rand(0, 2); $statBonusCnt > 0; $statBonusCnt--) {
switch(Util::choiceRandomUsingWeight(array($leader, $power, $intel))){ switch (Util::choiceRandomUsingWeight(array($leader, $power, $intel))) {
case 0: case 0:
$pleader++; $pleader++;
break; break;
@@ -156,7 +155,7 @@ $intel = $intel + $pintel;
$age = 20 + ($pleader + $ppower + $pintel) * 2 - (mt_rand(0, 1)); $age = 20 + ($pleader + $ppower + $pintel) * 2 - (mt_rand(0, 1));
// 아직 남았고 천재등록상태이면 특기 부여 // 아직 남았고 천재등록상태이면 특기 부여
if($genius) { if ($genius) {
$specage2 = $age; $specage2 = $age;
$special2 = getSpecial2($leader, $power, $intel); $special2 = getSpecial2($leader, $power, $intel);
} else { } else {
@@ -167,7 +166,7 @@ if($genius) {
$specage = round((80 - $age)/12) + $age; $specage = round((80 - $age)/12) + $age;
$special = 0; $special = 0;
if($admin['scenario'] > 0) { if ($admin['scenario'] > 0) {
$specage2 = $age + 3; $specage2 = $age + 3;
$specage = $age + 3; $specage = $age + 3;
} }
@@ -175,12 +174,12 @@ if($admin['scenario'] > 0) {
$turntime = getRandTurn($admin['turnterm']); $turntime = getRandTurn($admin['turnterm']);
$lastconnect = date('Y-m-d H:i:s'); $lastconnect = date('Y-m-d H:i:s');
if($lastconnect >= $turntime) { if ($lastconnect >= $turntime) {
$turntime = addTurn($turntime, $admin['turnterm']); $turntime = addTurn($turntime, $admin['turnterm']);
} }
//특회 전콘 //특회 전콘
if($admin['show_img_level'] >= 1 && $member['grade'] >= 1 && $member['picture'] != "" && $pic == 1) { if ($admin['show_img_level'] >= 1 && $member['grade'] >= 1 && $member['picture'] != "" && $pic == 1) {
$face = $member['picture']; $face = $member['picture'];
$imgsvr = $member['imgsvr']; $imgsvr = $member['imgsvr'];
} else { } else {
@@ -189,7 +188,9 @@ if($admin['show_img_level'] >= 1 && $member['grade'] >= 1 && $member['picture']
} }
//성격 랜덤시 //성격 랜덤시
if($character == 11) $character = rand()%10; if ($character == 11) {
$character = rand()%10;
}
//상성 랜덤 //상성 랜덤
$affinity = rand()%150 + 1; $affinity = rand()%150 + 1;
@@ -234,7 +235,7 @@ $me = [
'no'=>$generalID 'no'=>$generalID
]; ];
if($genius) { if ($genius) {
$log[0] = "<C>●</>{$admin['month']}월:<G><b>{$cityname}</b></>에서 <Y>{$name}</>(이)라는 기재가 천하에 이름을 알립니다."; $log[0] = "<C>●</>{$admin['month']}월:<G><b>{$cityname}</b></>에서 <Y>{$name}</>(이)라는 기재가 천하에 이름을 알립니다.";
$log[1] = "<C>●</>{$admin['month']}월:<C>".getGenSpecial($special2)."</> 특기를 가진 <C>천재</>의 등장으로 온 천하가 떠들썩합니다."; $log[1] = "<C>●</>{$admin['month']}월:<C>".getGenSpecial($special2)."</> 특기를 가진 <C>천재</>의 등장으로 온 천하가 떠들썩합니다.";
@@ -250,7 +251,7 @@ $mylog[] = "<C>●</>문의사항이 있으시면 게시판에 글을 남겨주
$mylog[] = "<C>●</>부디 즐거운 삼모전 되시길 바랍니다 ^^"; $mylog[] = "<C>●</>부디 즐거운 삼모전 되시길 바랍니다 ^^";
$mylog[] = "<C>●</>통솔 <C>$pleader</> 무력 <C>$ppower</> 지력 <C>$pintel</> 의 보너스를 받으셨습니다."; $mylog[] = "<C>●</>통솔 <C>$pleader</> 무력 <C>$ppower</> 지력 <C>$pintel</> 의 보너스를 받으셨습니다.";
$mylog[] = "<C>●</>연령은 <C>$age</>세로 시작합니다."; $mylog[] = "<C>●</>연령은 <C>$age</>세로 시작합니다.";
if($genius) { if ($genius) {
$mylog[] = "<C>●</>축하합니다! 천재로 태어나 처음부터 <C>".getGenSpecial($special2)."</> 특기를 가지게 됩니다!"; $mylog[] = "<C>●</>축하합니다! 천재로 태어나 처음부터 <C>".getGenSpecial($special2)."</> 특기를 가지게 됩니다!";
pushGeneralHistory($me, "<C>●</>{$admin['year']}{$admin['month']}월:<C>".getGenSpecial($special2)."</> 특기를 가진 천재로 탄생."); pushGeneralHistory($me, "<C>●</>{$admin['year']}{$admin['month']}월:<C>".getGenSpecial($special2)."</> 특기를 가진 천재로 탄생.");
} }
+15 -6
View File
@@ -97,11 +97,20 @@ function LogText($prefix, $variable)
file_put_contents(ROOT.'/d_log/dbg_logs.txt', $text, FILE_APPEND); file_put_contents(ROOT.'/d_log/dbg_logs.txt', $text, FILE_APPEND);
} }
function extractSuperGlobals()
{
if (isset($_POST) && count($_POST) > 0) {
LogText($_SERVER['REQUEST_URI'], $_POST);
extract($_POST, EXTR_SKIP);
}
if (isset($_POST) && count($_POST) > 0) { if (isset($_GET) && count($_GET) > 0) {
LogText($_SERVER['REQUEST_URI'], $_REQUEST); LogText($_SERVER['REQUEST_URI'], $_GET);
extract($_GET, EXTR_SKIP);
extract($_POST, EXTR_SKIP); extract($_POST, EXTR_SKIP);
//XXX: $_POST를 추출 없이 그냥 쓰는 경우가 많아서 일단 디버깅을 위해 씀!!!! 절대 production 서버에서 사용 금지! }
//todo: $_POST로 제공되는 데이터를 각 페이지마다 분석할것.
} }
extractSuperGlobals();
+25 -25
View File
@@ -194,7 +194,7 @@ function processWar($general, $city) {
$avoid = 1; $avoid = 1;
// 병종간 특성 // 병종간 특성
if(floor($general['crewtype']/10) == 3) { // 귀병 if(intdiv($general['crewtype'], 10) == 3) { // 귀병
$int = round(getGeneralIntel($general, true, true, true, false)); $int = round(getGeneralIntel($general, true, true, true, false));
if($general['crewtype'] == 30) { if($general['crewtype'] == 30) {
$ratio2 = $int * 5; // 0~500 즉 50% $ratio2 = $int * 5; // 0~500 즉 50%
@@ -460,7 +460,7 @@ function processWar($general, $city) {
if($nation['type'] == 3 || $nation['type'] == 13) { $num *= 1.1; } if($nation['type'] == 3 || $nation['type'] == 13) { $num *= 1.1; }
if($nation['type'] == 5 || $nation['type'] == 6 || $nation['type'] == 7 || $nation['type'] == 8 || $nation['type'] == 12) { $num *= 0.9; } if($nation['type'] == 5 || $nation['type'] == 6 || $nation['type'] == 7 || $nation['type'] == 8 || $nation['type'] == 12) { $num *= 0.9; }
// 부드러운 기술 제한 // 부드러운 기술 제한
if(TechLimit($game['startyear'], $year, $nation['tech'])) { $num = floor($num/4); } if(TechLimit($game['startyear'], $year, $nation['tech'])) { $num = intdiv($num, 4); }
$query = "update nation set totaltech=totaltech+'$num',tech=totaltech/'$gencount' where nation='{$nation['nation']}'"; $query = "update nation set totaltech=totaltech+'$num',tech=totaltech/'$gencount' where nation='{$nation['nation']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
// 죽은수 기술로 누적 // 죽은수 기술로 누적
@@ -469,7 +469,7 @@ function processWar($general, $city) {
if($destnation['type'] == 3 || $destnation['type'] == 13) { $num *= 1.1; } if($destnation['type'] == 3 || $destnation['type'] == 13) { $num *= 1.1; }
if($destnation['type'] == 5 || $destnation['type'] == 6 || $destnation['type'] == 7 || $destnation['type'] == 8 || $destnation['type'] == 12) { $num *= 0.9; } if($destnation['type'] == 5 || $destnation['type'] == 6 || $destnation['type'] == 7 || $destnation['type'] == 8 || $destnation['type'] == 12) { $num *= 0.9; }
// 부드러운 기술 제한 // 부드러운 기술 제한
if(TechLimit($game['startyear'], $year, $destnation['tech'])) { $num = floor($num/4); } if(TechLimit($game['startyear'], $year, $destnation['tech'])) { $num = intdiv($num, 4); }
$query = "update nation set totaltech=totaltech+'$num',tech=totaltech/'$destgencount' where nation='{$destnation['nation']}'"; $query = "update nation set totaltech=totaltech+'$num',tech=totaltech/'$destgencount' where nation='{$destnation['nation']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
//양국 평균 기술가격 //양국 평균 기술가격
@@ -669,7 +669,7 @@ function processWar($general, $city) {
$myAvoid = 1; $myAvoid = 1;
$opAvoid = 1; $opAvoid = 1;
// 병종간 특성 // 병종간 특성
if(floor($general['crewtype']/10) == 3) { // 귀병 if(intdiv($general['crewtype'], 10) == 3) { // 귀병
$int = round(getGeneralIntel($general, true, true, true, false)); $int = round(getGeneralIntel($general, true, true, true, false));
if($general['crewtype'] == 30) { if($general['crewtype'] == 30) {
$ratio2 = $int * 5; // 0~500 즉 50% $ratio2 = $int * 5; // 0~500 즉 50%
@@ -810,7 +810,7 @@ function processWar($general, $city) {
} }
// 상대 장수 병종간 특성 // 상대 장수 병종간 특성
if(floor($oppose['crewtype']/10) == 3) { // 귀병 if(intdiv($oppose['crewtype'], 10) == 3) { // 귀병
$int = round(getGeneralIntel($oppose, true, true, true, false)); $int = round(getGeneralIntel($oppose, true, true, true, false));
if($oppose['crewtype'] == 30) { if($oppose['crewtype'] == 30) {
$ratio2 = $int * 5; // 0~500 즉 50% $ratio2 = $int * 5; // 0~500 즉 50%
@@ -966,44 +966,44 @@ function processWar($general, $city) {
// my 입장 상성 // my 입장 상성
// 보병계열 > 궁병계열 // 보병계열 > 궁병계열
if(floor($general['crewtype']/10) == 0 && floor($oppose['crewtype']/10) == 1) { if(intdiv($general['crewtype'], 10) == 0 && intdiv($oppose['crewtype'], 10) == 1) {
$myCrew *= 0.8; $myCrew *= 0.8;
$opCrew *= 1.2; $opCrew *= 1.2;
} }
// 궁병계열 > 기병계열 // 궁병계열 > 기병계열
if(floor($general['crewtype']/10) == 1 && floor($oppose['crewtype']/10) == 2) { if(intdiv($general['crewtype'], 10) == 1 && intdiv($oppose['crewtype'], 10) == 2) {
$myCrew *= 0.8; $myCrew *= 0.8;
$opCrew *= 1.2; $opCrew *= 1.2;
} }
// 기병계열 > 보병계열 // 기병계열 > 보병계열
if(floor($general['crewtype']/10) == 2 && floor($oppose['crewtype']/10) == 0) { if(intdiv($general['crewtype'], 10) == 2 && intdiv($oppose['crewtype'], 10) == 0) {
$myCrew *= 0.8; $myCrew *= 0.8;
$opCrew *= 1.2; $opCrew *= 1.2;
} }
// 차병계열 // 차병계열
if(floor($general['crewtype']/10) == 4) { if(intdiv($general['crewtype'], 10) == 4) {
$myCrew *= 1.2; $myCrew *= 1.2;
$opCrew *= 0.8; $opCrew *= 0.8;
} }
// op 입장 상성 // op 입장 상성
// 보병계열 > 궁병계열 // 보병계열 > 궁병계열
if(floor($oppose['crewtype']/10) == 0 && floor($general['crewtype']/10) == 1) { if(intdiv($oppose['crewtype'], 10) == 0 && intdiv($general['crewtype'], 10) == 1) {
$opCrew *= 0.8; $opCrew *= 0.8;
$myCrew *= 1.2; $myCrew *= 1.2;
} }
// 궁병계열 > 기병계열 // 궁병계열 > 기병계열
if(floor($oppose['crewtype']/10) == 1 && floor($general['crewtype']/10) == 2) { if(intdiv($oppose['crewtype'], 10) == 1 && intdiv($general['crewtype'], 10) == 2) {
$opCrew *= 0.8; $opCrew *= 0.8;
$myCrew *= 1.2; $myCrew *= 1.2;
} }
// 기병계열 > 보병계열 // 기병계열 > 보병계열
if(floor($oppose['crewtype']/10) == 2 && floor($general['crewtype']/10) == 0) { if(intdiv($oppose['crewtype'], 10) == 2 && intdiv($general['crewtype'], 10) == 0) {
$opCrew *= 0.8; $opCrew *= 0.8;
$myCrew *= 1.2; $myCrew *= 1.2;
} }
// 차병계열 // 차병계열
if(floor($oppose['crewtype']/10) == 4) { if(intdiv($oppose['crewtype'], 10) == 4) {
$opCrew *= 1.2; $opCrew *= 1.2;
$myCrew *= 0.8; $myCrew *= 0.8;
} }
@@ -1335,7 +1335,7 @@ function processWar($general, $city) {
if($nation['type'] == 3 || $nation['type'] == 13) { $num *= 1.1; } if($nation['type'] == 3 || $nation['type'] == 13) { $num *= 1.1; }
if($nation['type'] == 5 || $nation['type'] == 6 || $nation['type'] == 7 || $nation['type'] == 8 || $nation['type'] == 12) { $num *= 0.9; } if($nation['type'] == 5 || $nation['type'] == 6 || $nation['type'] == 7 || $nation['type'] == 8 || $nation['type'] == 12) { $num *= 0.9; }
// 부드러운 기술 제한 // 부드러운 기술 제한
if(TechLimit($game['startyear'], $year, $nation['tech'])) { $num = floor($num/4); } if(TechLimit($game['startyear'], $year, $nation['tech'])) { $num = intdiv($num, 4); }
$query = "update nation set totaltech=totaltech+'$num',tech=totaltech/'$gencount' where nation='{$nation['nation']}'"; $query = "update nation set totaltech=totaltech+'$num',tech=totaltech/'$gencount' where nation='{$nation['nation']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1358,7 +1358,7 @@ function processWar($general, $city) {
if($destnation['type'] == 3 || $destnation['type'] == 13) { $num *= 1.1; } if($destnation['type'] == 3 || $destnation['type'] == 13) { $num *= 1.1; }
if($destnation['type'] == 5 || $destnation['type'] == 6 || $destnation['type'] == 7 || $destnation['type'] == 8 || $destnation['type'] == 12) { $num *= 0.9; } if($destnation['type'] == 5 || $destnation['type'] == 6 || $destnation['type'] == 7 || $destnation['type'] == 8 || $destnation['type'] == 12) { $num *= 0.9; }
// 부드러운 기술 제한 // 부드러운 기술 제한
if(TechLimit($game['startyear'], $year, $destnation['tech'])) { $num = floor($num/4); } if(TechLimit($game['startyear'], $year, $destnation['tech'])) { $num = intdiv($num, 4); }
$query = "update nation set totaltech=totaltech+'$num',tech=totaltech/'$destgencount' where nation='{$destnation['nation']}'"; $query = "update nation set totaltech=totaltech+'$num',tech=totaltech/'$destgencount' where nation='{$destnation['nation']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
//양국 평균 기술가격 //양국 평균 기술가격
@@ -1430,9 +1430,9 @@ function processWar($general, $city) {
} }
// 경험치 상승 // 경험치 상승
if(floor($oppose['crewtype']/10) == 3) { // 귀병 if(intdiv($oppose['crewtype'], 10) == 3) { // 귀병
$oppose['intel2']++; $oppose['intel2']++;
} elseif(floor($oppose['crewtype']/10) == 4) { // 차병 } elseif(intdiv($oppose['crewtype'], 10) == 4) { // 차병
$oppose['leader2']++; $oppose['leader2']++;
} else { } else {
$oppose['power2']++; $oppose['power2']++;
@@ -1489,9 +1489,9 @@ function processWar($general, $city) {
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
// 경험치 상승 // 경험치 상승
if(floor($general['crewtype']/10) == 3) { // 귀병 if(intdiv($general['crewtype'], 10) == 3) { // 귀병
$general['intel2'] += $exp2; $general['intel2'] += $exp2;
} elseif(floor($general['crewtype']/10) == 4) { // 차병 } elseif(intdiv($general['crewtype'], 10) == 4) { // 차병
$general['leader2'] += $exp2; $general['leader2'] += $exp2;
} else { } else {
$general['power2'] += $exp2; $general['power2'] += $exp2;
@@ -1568,9 +1568,9 @@ function getAtt($game, $general, $tech, $lbonus) {
$general['lbonus'] = $lbonus; $general['lbonus'] = $lbonus;
if(floor($general['crewtype']/10) == 3) { // 귀병 지100% if(intdiv($general['crewtype'], 10) == 3) { // 귀병 지100%
$ratio = getGeneralIntel($general, true, true, true)*2 - 40; $ratio = getGeneralIntel($general, true, true, true)*2 - 40;
} elseif(floor($general['crewtype']/10) == 4) { // 차병 통100% } elseif(intdiv($general['crewtype'], 10) == 4) { // 차병 통100%
$ratio = getGeneralLeadership($general, true, true, true)*2 - 40; $ratio = getGeneralLeadership($general, true, true, true)*2 - 40;
} else { } else {
$ratio = getGeneralPower($general, true, true, true)*2 - 40; //10일때 -20, 70일때 100, 100일때 160 $ratio = getGeneralPower($general, true, true, true)*2 - 40; //10일때 -20, 70일때 100, 100일때 160
@@ -1756,8 +1756,8 @@ function ConquerCity($game, $general, $city, $nation, $destnation) {
for($i=0; $i < $gencount; $i++) { for($i=0; $i < $gencount; $i++) {
$gen = MYDB_fetch_array($result); $gen = MYDB_fetch_array($result);
$loseGold = floor($gen['gold'] * (rand()%30+20)/100.0); $loseGold = intdiv($gen['gold'] * (rand()%30+20), 100);
$loseRice = floor($gen['rice'] * (rand()%30+20)/100.0); $loseRice = intdiv($gen['rice'] * (rand()%30+20), 100);
$genlog[1] = "<C>●</>도주하며 금<C>$loseGold</> 쌀<C>$loseRice</>을 분실했습니다."; $genlog[1] = "<C>●</>도주하며 금<C>$loseGold</> 쌀<C>$loseRice</>을 분실했습니다.";
$query = "update general set gold=gold-{$loseGold},rice=rice-{$loseRice} where no={$gen['no']}"; $query = "update general set gold=gold-{$loseGold},rice=rice-{$loseRice} where no={$gen['no']}";
@@ -1803,8 +1803,8 @@ function ConquerCity($game, $general, $city, $nation, $destnation) {
$losenation['gold'] += $loseGeneralGold; $losenation['gold'] += $loseGeneralGold;
$losenation['rice'] += $loseGeneralRice; $losenation['rice'] += $loseGeneralRice;
$losenation['gold'] = floor($losenation['gold'] / 2); $losenation['gold'] = intdiv($losenation['gold'], 2);
$losenation['rice'] = floor($losenation['gold'] / 2); $losenation['rice'] = intdiv($losenation['gold'], 2);
// 기본량 제외 금쌀50% + 장수들 분실 금쌀50% 흡수 // 기본량 제외 금쌀50% + 장수들 분실 금쌀50% 흡수
$query = "update nation set gold=gold+'{$losenation['gold']}',rice=rice+'{$losenation['rice']}' where nation='{$general['nation']}'"; $query = "update nation set gold=gold+'{$losenation['gold']}',rice=rice+'{$losenation['rice']}' where nation='{$general['nation']}'";
+2 -2
View File
@@ -269,7 +269,7 @@ function command_11($turn, $command) {
$ownRegions[$city['region']] = 1; $ownRegions[$city['region']] = 1;
} }
$leader = floor($me['leader'] * (100 - $me['injury'])/100) + getHorseEff($me['horse']) + $lbonus; $leader = intdiv($me['leader'] * (100 - $me['injury']), 100) + getHorseEff($me['horse']) + $lbonus;
$crew = $leader - round($me['crew']/100); $crew = $leader - round($me['crew']/100);
$abil = getTechAbil($nation['tech']); $abil = getTechAbil($nation['tech']);
$cost = getTechCost($nation['tech']); $cost = getTechCost($nation['tech']);
@@ -477,7 +477,7 @@ function command_12($turn, $command) {
$ownRegions[$city['region']] = 1; $ownRegions[$city['region']] = 1;
} }
$leader = floor($me['leader'] * (100 - $me['injury'])/100) + getHorseEff($me['horse']) + $lbonus; $leader = intdiv($me['leader'] * (100 - $me['injury']), 100) + getHorseEff($me['horse']) + $lbonus;
$crew = $leader - round($me['crew']/100); $crew = $leader - round($me['crew']/100);
$abil = getTechAbil($nation['tech']); $abil = getTechAbil($nation['tech']);
$cost = getTechCost($nation['tech']); $cost = getTechCost($nation['tech']);
+1 -1
View File
@@ -26,7 +26,7 @@ if($session->userGrade < 6){
]); ]);
} }
$request = $_GET + $_POST; $request = $_POST + $_GET;
$tmpFile = 'd_log/arc.zip'; $tmpFile = 'd_log/arc.zip';
+26 -27
View File
@@ -3,40 +3,40 @@ namespace sammo;
class Util extends \utilphp\util class Util extends \utilphp\util
{ {
private static function _parseReq($value, string $type)
private static function _parseReq($value, string $type){ {
if(is_array($value)){ if (is_array($value)) {
if($type === 'array_int'){ if ($type === 'array_int') {
return array_map('intval', $value); return array_map('intval', $value);
} }
if($type === 'array_string'){ if ($type === 'array_string') {
return array_map(function($item){ return array_map(function ($item) {
return (string)$item; return (string)$item;
}, $value); }, $value);
} }
if($type === 'array'){ if ($type === 'array') {
return $value; return $value;
} }
throw new \InvalidArgumentException('지원할 수 없는 type 지정. array 가 붙은 type이어야 합니다'); throw new \InvalidArgumentException('지원할 수 없는 type 지정. array 가 붙은 type이어야 합니다');
} }
if($type === 'bool'){ if ($type === 'bool') {
$value = strtolower($value); $value = strtolower($value);
if($value === 'false' || $value === 'no' || $value === 'n' || $value === 'x' || $value === 'null'){ if ($value === 'false' || $value === 'no' || $value === 'n' || $value === 'x' || $value === 'null') {
return false; return false;
} }
return !!$value; return !!$value;
} }
if($type === 'int'){ if ($type === 'int') {
return (int)$value; return (int)$value;
} }
if($type === 'float'){ if ($type === 'float') {
return (float)$value; return (float)$value;
} }
if($type === 'string'){ if ($type === 'string') {
return (string)$value; return (string)$value;
} }
@@ -44,23 +44,22 @@ class Util extends \utilphp\util
} }
/** /**
* $_GET, $_POST에서 값을 가져오는 함수. Util::array_get($_POST[$name]) 축약 가능. * $_POST, $_GET에서 값을 가져오는 함수. Util::array_get($_POST[$name]) 축약 가능.
* 타입이 복잡해질 경우 함수를 통하지 않고 json으로 요청할 것을 권장. * 타입이 복잡해질 경우 함수를 통하지 않고 json으로 요청할 것을 권장.
* *
* @param string $name 가져오고자 하는 key 이름. * @param string $name 가져오고자 하는 key 이름.
* @param string $type 가져오고자 하는 type. [string, int, float, bool, array, array_string, array_int] * @param string $type 가져오고자 하는 type. [string, int, float, bool, array, array_string, array_int]
* @param mixed $ifNotExists 만약 $_GET과 $_POST에 값이 없을 경우 반환하는 변수. 값은 $type을 검사하지 않음. * @param mixed $ifNotExists 만약 $_POST와 $_GET에 값이 없을 경우 반환하는 변수. 값은 $type을 검사하지 않음.
* @return int|float|string|array|null * @return int|float|string|array|null
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public static function getReq(string $name, string $type = 'string', $ifNotExists = null){ public static function getReq(string $name, string $type = 'string', $ifNotExists = null)
if(isset($_GET[$name])){ {
$value = $_GET[$name]; if (isset($_POST[$name])) {
}
else if(isset($_POST[$name])){
$value = $_POST[$name]; $value = $_POST[$name];
} } elseif (isset($_GET[$name])) {
else{ $value = $_GET[$name];
} else {
return $ifNotExists; return $ifNotExists;
} }
@@ -70,18 +69,18 @@ class Util extends \utilphp\util
/** /**
* $_POST에서 값을 가져오는 함수. Util::array_get($_POST[$name]) 축약 가능. $_GET에서도 가져올 있다면 getReq 사용. * $_POST에서 값을 가져오는 함수. Util::array_get($_POST[$name]) 축약 가능. $_GET에서도 가져올 있다면 getReq 사용.
* 타입이 복잡해질 경우 함수를 통하지 않고 json으로 요청할 것을 권장. * 타입이 복잡해질 경우 함수를 통하지 않고 json으로 요청할 것을 권장.
* *
* @param string $name 가져오고자 하는 key 이름. * @param string $name 가져오고자 하는 key 이름.
* @param string $type 가져오고자 하는 type. [string, int, float, bool, array, array_string, array_int] * @param string $type 가져오고자 하는 type. [string, int, float, bool, array, array_string, array_int]
* @param mixed $ifNotExists 만약 $_GET과 $_POST에 값이 없을 경우 반환하는 변수. 값은 $type을 검사하지 않음. * @param mixed $ifNotExists 만약 $_GET과 $_POST에 값이 없을 경우 반환하는 변수. 값은 $type을 검사하지 않음.
* @return int|float|string|array|null * @return int|float|string|array|null
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public static function getPost(string $name, string $type = 'string', $ifNotExists = null){ public static function getPost(string $name, string $type = 'string', $ifNotExists = null)
if(isset($_POST[$name])){ {
if (isset($_POST[$name])) {
$value = $_POST[$name]; $value = $_POST[$name];
} } else {
else{
return $ifNotExists; return $ifNotExists;
} }