코드 수정
This commit is contained in:
+5
-2
@@ -17,8 +17,7 @@ return [
|
||||
// (See `backward_compatibility_checks` for additional options)
|
||||
"target_php_version" => '8.0',
|
||||
'backward_compatibility_checks ' => false,
|
||||
'ignore_undeclared_variables_in_global_scope' => false,
|
||||
'minimum_severity'=>\Phan\Issue::SEVERITY_CRITICAL,
|
||||
'minimum_severity'=>\Phan\Issue::SEVERITY_NORMAL,
|
||||
|
||||
'file_list' => [
|
||||
'f_config/config.php',
|
||||
@@ -170,6 +169,10 @@ return [
|
||||
'vendor/'
|
||||
],
|
||||
|
||||
'suppress_issue_types' => [
|
||||
'PhanUnreferencedUseNormal',
|
||||
],
|
||||
|
||||
// A list of plugin files to execute.
|
||||
// See https://github.com/phan/phan/tree/master/.phan/plugins for even more.
|
||||
// (Pass these in as relative paths.
|
||||
|
||||
+2
-2
@@ -8,8 +8,8 @@ mb_internal_encoding("UTF-8");
|
||||
mb_http_output('UTF-8');
|
||||
mb_regex_encoding('UTF-8');
|
||||
|
||||
ini_set("session.cache_expire", 10080); // minutes
|
||||
ini_set("session.gc_maxlifetime", 604800); // seconds
|
||||
ini_set("session.cache_expire", '10080'); // minutes
|
||||
ini_set("session.gc_maxlifetime", '604800'); // seconds
|
||||
|
||||
function getFriendlyErrorType($type)
|
||||
{
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ function MYDB_num_rows(\mysqli_result $result) : int
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
* @return mixed[]|null
|
||||
*/
|
||||
function MYDB_fetch_array(\mysqli_result $result)
|
||||
{
|
||||
|
||||
@@ -176,14 +176,17 @@ if($showServers){
|
||||
|
||||
$nation['typeName'] = getNationType($nation['type']);
|
||||
$nation['levelName'] = getNationLevel($nation['level']);
|
||||
if($nation['generals']){
|
||||
$generals = $db->query('SELECT `general_no`, `name`, `last_yearmonth` FROM ng_old_generals WHERE server_id=%s AND general_no IN %li', $serverID, $nation['generals']);
|
||||
/** @var int[]|null $nationGenerals */
|
||||
$nationGenerals = $nation['generals'];
|
||||
|
||||
if($nationGenerals){
|
||||
$generals = $db->query('SELECT `general_no`, `name`, `last_yearmonth` FROM ng_old_generals WHERE server_id=%s AND general_no IN %li', $serverID, $nationGenerals);
|
||||
|
||||
if(count($generals) != count($nation['generals']) && $serverID == UniqueConst::$serverID){
|
||||
$liveGenerals = $nation['generals'];
|
||||
if(count($generals) != count($nationGenerals) && $serverID == UniqueConst::$serverID){
|
||||
$liveGenerals = $nationGenerals;
|
||||
foreach($generals as $general){
|
||||
if(in_array($general['general_no'], $nation['generals'])){
|
||||
unset($nation['generals'][$general['general_no']]);
|
||||
if(in_array($general['general_no'], $nationGenerals)){
|
||||
unset($nationGenerals[$general['general_no']]);
|
||||
}
|
||||
}
|
||||
$liveGenerals = $db->query('SELECT `no`as`general_no`, `name` FROM general WHERE no IN %li', $liveGenerals);
|
||||
|
||||
+2
-32
@@ -113,38 +113,8 @@ if ($session->userGrade >= 5) {
|
||||
|
||||
switch ($admin['tournament']) {
|
||||
case 1:
|
||||
echo "<select name=gen size=1 style=color:white;background-color:black;>";
|
||||
|
||||
$query = "select no,name,npc,tnmt,leadership,strength,intel,leadership+strength+intel as total from general where tournament=0 and gold>='{$admin['develcost']}' order by {$tp3} desc";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
|
||||
$genCount = MYDB_num_rows($result);
|
||||
|
||||
for ($i=0; $i < $genCount; $i++) {
|
||||
$general = MYDB_fetch_array($result);
|
||||
if ($general['npc'] >= 2) {
|
||||
$npc = "cyan";
|
||||
} elseif ($general['npc'] == 1) {
|
||||
$npc = "skyblue";
|
||||
} elseif ($general['tnmt'] > 0) {
|
||||
$npc = "blue";
|
||||
} else {
|
||||
$npc = "white";
|
||||
}
|
||||
echo "<option style=color:{$npc}; value={$general['no']}>[{$general[$tp3]}]{$general['name']}</option>";
|
||||
}
|
||||
echo "
|
||||
</select>
|
||||
<input type=submit name=btn value='투입'>
|
||||
<input type=submit name=btn value='무명투입'>
|
||||
<input type=submit name=btn value='쪼렙투입'>
|
||||
<input type=submit name=btn value='일반투입'>
|
||||
<input type=submit name=btn value='굇수투입'>
|
||||
<input type=submit name=btn value='랜덤투입'>
|
||||
<input type=submit name=btn value='쪼렙전부투입'>
|
||||
<input type=submit name=btn value='일반전부투입'>
|
||||
<input type=submit name=btn value='굇수전부투입'>
|
||||
<input type=submit name=btn value='랜덤전부투입'>
|
||||
<input type=submit name=btn value='무명전부투입'>";
|
||||
echo "<input type=submit name=btn value='랜덤투입'>";
|
||||
echo "<input type=submit name=btn value='랜덤전부투입'>";
|
||||
break;
|
||||
case 2: echo "<input type=submit name=btn value='예선'><input type=submit name=btn value='예선전부'>"; break;
|
||||
case 3: echo "<input type=submit name=btn value='추첨'><input type=submit name=btn value='추첨전부'>"; break;
|
||||
|
||||
+16
-99
@@ -20,13 +20,10 @@ $userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$connect=$db->get();
|
||||
|
||||
$admin = $gameStor->getValues(['tournament','phase','tnmt_type','develcost']);
|
||||
|
||||
$query = "select no,name,tournament from general where owner='{$userID}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$me = MYDB_fetch_array($result);
|
||||
$me = $db->queryFirstList('SELECT no,name,tournament from general where owner=%i',$userID);
|
||||
|
||||
switch($admin['tnmt_type']) {
|
||||
case 0: $tp = "total"; $tp2 = "전력전"; $tp3 = "leadership+strength+intel"; break;
|
||||
@@ -102,57 +99,8 @@ if($btn == "자동개최설정") {
|
||||
$gameStor->tnmt_auto = 0;
|
||||
$gameStor->tournament = 0;
|
||||
$gameStor->phase = 0;
|
||||
} elseif($btn == "투입" || $btn == "무명투입" || $btn == "쪼렙투입" || $btn == "일반투입" || $btn == "굇수투입" || $btn == "랜덤투입") {
|
||||
if($btn == "투입") {
|
||||
$query = "select no,name,npc,leadership,strength,intel,explevel,gold,horse,weapon,book from general where no='$gen'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$general = MYDB_fetch_array($result);
|
||||
$general['gold'] -= $admin['develcost'];
|
||||
} elseif($btn == "무명투입") {
|
||||
$general['no'] = 0;
|
||||
$general['name'] = "무명장수";
|
||||
$general['npc'] = 2;
|
||||
$general['leadership'] = 10;
|
||||
$general['strength'] = 10;
|
||||
$general['intel'] = 10;
|
||||
$general['explevel'] = 10;
|
||||
$general['gold'] = 0;
|
||||
} elseif($btn == "쪼렙투입") {
|
||||
$sel = rand() % 32;
|
||||
$query = "select no,name,npc,leadership,strength,intel,explevel,gold,leadership+strength+intel as total,horse,weapon,book from general where tournament=0 and gold>='{$admin['develcost']}' and npc>=2 order by {$tp} limit {$sel},1";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$general = MYDB_fetch_array($result);
|
||||
$general['gold'] -= $admin['develcost'];
|
||||
} elseif($btn == "일반투입") {
|
||||
//참가한 사람 평균치
|
||||
$query = "select AVG({$tp3}) as av from general where tournament=1";
|
||||
$genResult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$avgGen = MYDB_fetch_array($genResult);
|
||||
|
||||
//그 장수보다 높은장수 수
|
||||
$query = "select no from general where tournament=0 and gold>='{$admin['develcost']}' and npc>=2 and {$tp3}>{$avgGen['av']}";
|
||||
$genResult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$genCount = MYDB_num_rows($genResult);
|
||||
|
||||
$sel = rand() % 32 + $genCount - 8;
|
||||
|
||||
$query = "select no,name,npc,leadership,strength,intel,explevel,leadership+strength+intel as total,horse,weapon,book from general where tournament=0 and gold>='{$admin['develcost']}' and npc>=2 order by {$tp} desc limit {$sel},1";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$general = MYDB_fetch_array($result);
|
||||
$general['gold'] -= $admin['develcost'];
|
||||
} elseif($btn == "굇수투입") {
|
||||
$sel = rand() % 32;
|
||||
$query = "select no,name,npc,leadership,strength,intel,explevel,gold,leadership+strength+intel as total,horse,weapon,book from general where tournament=0 and gold>='{$admin['develcost']}' and npc>=2 order by {$tp} desc limit {$sel},1";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$general = MYDB_fetch_array($result);
|
||||
$general['gold'] -= $admin['develcost'];
|
||||
} elseif($btn == "랜덤투입") {
|
||||
$query = "select no,name,npc,leadership,strength,intel,explevel,gold,leadership+strength+intel as total,horse,weapon,book from general where tournament=0 and gold>='{$admin['develcost']}' and npc>=2 order by rand() limit 0,1";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$general = MYDB_fetch_array($result);
|
||||
$general['gold'] -= $admin['develcost'];
|
||||
//참가
|
||||
}
|
||||
} elseif($btn == "랜덤투입") {
|
||||
$general = $db->queryFirstRow('SELECT no,name,npc,leadership,strength,intel,explevel,leadership+strength+intel as total,horse,weapon,book from general where tournament=0 order by rand() limit 1');
|
||||
|
||||
$occupied = [];
|
||||
foreach($db->queryFirstColumn('SELECT grp FROM tournament WHERE grp < 10 GROUP BY grp HAVING count(*)=8') as $grp){
|
||||
@@ -179,7 +127,6 @@ if($btn == "자동개최설정") {
|
||||
]);
|
||||
$db->update('general', [
|
||||
'tournament'=>1,
|
||||
'gold'=>$general['gold']
|
||||
], 'no=%i', $general['no']);
|
||||
}
|
||||
|
||||
@@ -189,50 +136,21 @@ if($btn == "자동개최설정") {
|
||||
$gameStor->phase = 0;
|
||||
}
|
||||
|
||||
} elseif($btn == "쪼렙전부투입" || $btn == "일반전부투입" || $btn == "굇수전부투입" || $btn == "랜덤전부투입") {
|
||||
$z = 0;
|
||||
} elseif($btn == "랜덤전부투입") {
|
||||
$code = [];
|
||||
for($i=0; $i < 8; $i++) {
|
||||
$query = "select grp from tournament where grp='$i'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$grpCount = MYDB_num_rows($result);
|
||||
for($k=$grpCount; $k < 8; $k++) {
|
||||
$code[$z++] = $i * 10 + $k;
|
||||
foreach($db->queryAllLists('SELECT grp, count(*) FROM tournament WHERE 0 <= grp AND grp < 8 GROUP BY grp') as [$grpIdx, $cnt]){
|
||||
foreach(Util::range($cnt, 8) as $grpNo){
|
||||
$code[] = $grpIdx * 10 + $grpNo;
|
||||
}
|
||||
}
|
||||
//섞기
|
||||
for($i=0; $i < $z; $i++) {
|
||||
$index = rand() % $z;
|
||||
$temp = $code[$i];
|
||||
$code[$i] = $code[$index];
|
||||
$code[$index] = $temp;
|
||||
}
|
||||
$z = count($code);
|
||||
|
||||
for($i=0; $i < $z; $i++) {
|
||||
|
||||
$generals = $db->query('SELECT no,name,npc,leadership,strength,intel,explevel,leadership+strength+intel as total,horse,weapon,book from general where tournament=0 order by rand() limit %i', $z);
|
||||
|
||||
foreach(Util::range($z) as $i){
|
||||
$sel = rand() % 32;
|
||||
if($btn == "쪼렙전부투입") {
|
||||
$query = "select no,name,npc,leadership,strength,intel,explevel,leadership+strength+intel as total,horse,weapon,book from general where tournament=0 and gold>='{$admin['develcost']}' and npc>=2 order by {$tp} limit {$sel},1";
|
||||
} elseif($btn == "일반전부투입") {
|
||||
//참가한 사람 평균치
|
||||
$query = "select AVG({$tp3}) as av from general where tournament=1";
|
||||
$genResult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$avgGen = MYDB_fetch_array($genResult);
|
||||
|
||||
//그 장수보다 높은장수 수
|
||||
$query = "select no from general where tournament=0 and gold>='{$admin['develcost']}' and npc>=2 and {$tp3}>{$avgGen['av']}";
|
||||
$genResult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$genCount = MYDB_num_rows($genResult);
|
||||
|
||||
$sel += $genCount - 8;
|
||||
|
||||
$query = "select no,name,npc,leadership,strength,intel,explevel,leadership+strength+intel as total,horse,weapon,book from general where tournament=0 and gold>='{$admin['develcost']}' and npc>=2 order by {$tp} desc limit {$sel},1";
|
||||
} elseif($btn == "굇수전부투입") {
|
||||
$query = "select no,name,npc,leadership,strength,intel,explevel,leadership+strength+intel as total,horse,weapon,book from general where tournament=0 and gold>='{$admin['develcost']}' and npc>=2 order by {$tp} desc limit {$sel},1";
|
||||
} else {
|
||||
$query = "select no,name,npc,leadership,strength,intel,explevel,leadership+strength+intel as total,horse,weapon,book from general where tournament=0 and gold>='{$admin['develcost']}' and npc>=2 order by rand() limit 0,1";
|
||||
}
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$general = MYDB_fetch_array($result);
|
||||
$general = $generals[$i];
|
||||
|
||||
$grp = intdiv($code[$i], 10);
|
||||
$grp_no = $code[$i] % 10;
|
||||
@@ -250,11 +168,10 @@ if($btn == "자동개최설정") {
|
||||
'w'=>$general['weapon'],
|
||||
'b'=>$general['book']
|
||||
]);
|
||||
$db->update('general', [
|
||||
'tournament'=>1,
|
||||
'gold'=>$db->sqleval('gold - %i', $admin['develcost'])
|
||||
], 'no=%i', $general['no']);
|
||||
}
|
||||
$db->update('general', [
|
||||
'tournament'=>1,
|
||||
], 'no=%li', array_column($generals, 'no'));
|
||||
|
||||
$gameStor->tournament = 2;
|
||||
$gameStor->phase = 0;
|
||||
|
||||
@@ -167,7 +167,7 @@ function getTournament(int $tnmt) {
|
||||
][$tnmt]??"TOURNAMENT_TYPE_ERR_{$tnmt}";
|
||||
}
|
||||
|
||||
function printRow($k, $npc, $name, $abil, $tgame, $win, $draw, $lose, $gd, $gl, $prmt) {
|
||||
function printRow(int $k, int $npc, string $name, int $abil, int $tgame, int $win, int $draw, int $lose, int $gd, int $gl, int $prmt) {
|
||||
if($prmt > 0) { $name = "<font color=orange>".$name."</font>"; }
|
||||
elseif($npc >= 2) { $name = "<font color=cyan>".$name."</font>"; }
|
||||
elseif($npc == 1) { $name = "<font color=skyblue>".$name."</font>"; }
|
||||
|
||||
@@ -334,19 +334,16 @@ class WarUnit{
|
||||
|
||||
function getHP():int{
|
||||
throw new NotInheritedMethodException();
|
||||
return 0;
|
||||
}
|
||||
|
||||
function decreaseHP(int $damage):int{
|
||||
$this->dead += $damage;
|
||||
throw new NotInheritedMethodException();
|
||||
return 0;
|
||||
}
|
||||
|
||||
function increaseKilled(int $damage):int{
|
||||
$this->killed += $damage;
|
||||
throw new NotInheritedMethodException();
|
||||
return 0;
|
||||
}
|
||||
|
||||
function calcDamage():int{
|
||||
@@ -376,6 +373,5 @@ class WarUnit{
|
||||
|
||||
function applyDB(\MeekroDB $db):bool{
|
||||
throw new MustNotBeReachedException('Must be WarUnitCity or WarUnitGeneral');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top class="bg1">국가열전</td>
|
||||
<td colspan=5 class='bg0' style="text-align:left;"><?=$this->ConvertLog($history)?></td>
|
||||
<td colspan=5 class='bg0' style="text-align:left;"><?=array_map($this->ConvertLog, $history)?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -183,19 +183,19 @@ class StringUtil
|
||||
}
|
||||
|
||||
public static function uniord(string $c) {
|
||||
$c0 = ord($c{0});
|
||||
$c0 = ord($c[0]);
|
||||
if ($c0 >=0 && $c0 <= 127)
|
||||
return $c0;
|
||||
if ($c0 >= 192 && $c0 <= 223)
|
||||
return ($c0-192)*64 + (ord($c{1})-128);
|
||||
return ($c0-192)*64 + (ord($c[1])-128);
|
||||
if ($c0 >= 224 && $c0 <= 239)
|
||||
return ($c0-224)*4096 + (ord($c{1})-128)*64 + (ord($c{2})-128);
|
||||
return ($c0-224)*4096 + (ord($c[1])-128)*64 + (ord($c[2])-128);
|
||||
if ($c0 >= 240 && $c0 <= 247)
|
||||
return ($c0-240)*262144 + (ord($c{1})-128)*4096 + (ord($c{2})-128)*64 + (ord($c{3})-128);
|
||||
return ($c0-240)*262144 + (ord($c[1])-128)*4096 + (ord($c[2])-128)*64 + (ord($c[3])-128);
|
||||
if ($c0 >= 248 && $c0 <= 251)
|
||||
return ($c0-248)*16777216 + (ord($c{1})-128)*262144 + (ord($c{2})-128)*4096 + (ord($c{3})-128)*64 + (ord($c{4})-128);
|
||||
return ($c0-248)*16777216 + (ord($c[1])-128)*262144 + (ord($c[2])-128)*4096 + (ord($c[3])-128)*64 + (ord($c[4])-128);
|
||||
if ($c0 >= 252 && $c0 <= 253)
|
||||
return ($c0-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128);
|
||||
return ($c0-252)*1073741824 + (ord($c[1])-128)*16777216 + (ord($c[2])-128)*262144 + (ord($c[3])-128)*4096 + (ord($c[4])-128)*64 + (ord($c[5])-128);
|
||||
if ($c0 >= 254 && $c0 <= 255) // error
|
||||
return FALSE;
|
||||
return 0;
|
||||
|
||||
+20
-3
@@ -685,8 +685,25 @@ class Util extends \utilphp\util
|
||||
* 길이가 다른 경우, 앞의 결과를 먼저 비교한 뒤, 짧은쪽의 값을 null으로 가정하여 길이 처리
|
||||
*/
|
||||
public static function arrayCompare(iterable $lhs, iterable $rhs, ?callable $comp=null){
|
||||
$lhsIter = new \Iterator($lhs);
|
||||
$rhsIter = new \Iterator($rhs);
|
||||
if($lhs instanceof \Traversable){
|
||||
$lhsIter = new \IteratorIterator($lhs);
|
||||
}
|
||||
else if(is_array($lhs)){
|
||||
$lhsIter = new \ArrayIterator($lhs);
|
||||
}
|
||||
else{
|
||||
throw new \InvalidArgumentException('$lhs is not Traversable');
|
||||
}
|
||||
|
||||
if($rhs instanceof \Traversable){
|
||||
$rhsIter = new \IteratorIterator($rhs);
|
||||
}
|
||||
else if(is_array($rhs)){
|
||||
$rhsIter = new \ArrayIterator($rhs);
|
||||
}
|
||||
else{
|
||||
throw new \InvalidArgumentException('$rhs is not Traversable');
|
||||
}
|
||||
|
||||
while($lhsIter->valid() && $rhsIter->valid()){
|
||||
$lhsVal = $lhsIter->current();
|
||||
@@ -759,7 +776,7 @@ class Util extends \utilphp\util
|
||||
* @param null|int $to
|
||||
* @param null|int $step
|
||||
* @return \Traversable
|
||||
* @throws InvalidArgumentException
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public static function range(int $from, ?int $to=null, ?int $step=null):\Traversable{
|
||||
if($to === null){
|
||||
|
||||
Reference in New Issue
Block a user