From cfb2a2dbd561a8ac5db1bfb3a5feabc78f3014f8 Mon Sep 17 00:00:00 2001 From: hide_d Date: Fri, 6 Apr 2018 23:18:42 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A0=95=EC=A0=81=20=EB=B6=84=EC=84=9D=20?= =?UTF-8?q?=EA=B2=B0=EA=B3=BC=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .phan/config.php | 2 + hwe/b_currentCity.php | 6 +-- hwe/func_converter.php | 40 +++++++++--------- hwe/func_gamerule.php | 25 +++++++----- hwe/func_message.php | 12 ++++-- hwe/func_npc.php | 1 + hwe/func_process.php | 61 ++++++++++++++++++---------- hwe/func_process_chief.php | 24 +++++++---- hwe/func_process_personnel.php | 11 +---- hwe/func_process_trick.php | 4 +- hwe/func_string.php | 12 +++--- hwe/func_time_event.php | 74 ++++++++++++++++++++-------------- hwe/func_tournament.php | 8 +++- hwe/sammo/GameConst.php | 63 +++++++++++++++-------------- 14 files changed, 197 insertions(+), 146 deletions(-) diff --git a/.phan/config.php b/.phan/config.php index 206280e8..e9a06956 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -13,6 +13,8 @@ return [ // of the php executable used to execute phan. "target_php_version" => '7.0', 'backward_compatibility_checks ' => false, + 'ignore_undeclared_variables_in_global_scope' => false, + 'minimum_severity'=>\Phan\Issue::SEVERITY_NORMAL, 'file_list' => [ 'f_config/config.php', diff --git a/hwe/b_currentCity.php b/hwe/b_currentCity.php index 2659008e..8c58bdbe 100644 --- a/hwe/b_currentCity.php +++ b/hwe/b_currentCity.php @@ -97,9 +97,9 @@ if($me['level'] == 0) { if($myNation['level'] > 0) { // 첩보도시도 목록에 추가 $where = 'city=0'; - $citys = explode("|", $myNation['spy']); - for($i=0; $i < count($citys); $i++) { - $city = floor($citys[$i]/10); + $cities = explode("|", $myNation['spy']); + for($i=0; $i < count($cities); $i++) { + $city = floor($cities[$i]/10); $where .= " or city='{$city}'"; } diff --git a/hwe/func_converter.php b/hwe/func_converter.php index 31e55648..aad5052c 100644 --- a/hwe/func_converter.php +++ b/hwe/func_converter.php @@ -388,20 +388,20 @@ function getLevelPer($exp, $level) { return $per; } -function getBill($dedication) { +function getBill(int $dedication) : int{ for($level = 0; $dedication > (($level+1)*($level+1)*100); $level++) { } return ($level * 200 + 400); } -function getCost(int $armtype) { +function getCost(int $armtype) : int { //FIXME: 정말로 side effect가 없으려면 query는 밖으로 이동해야함. //TODO: 병종 값이 column으로 들어있는건 전혀 옳지 않음. key->value 형태로 바꿔야함 return DB::db()->queryFirstColumn('select %b from game limit 1', sprintf('cst%d', $armtype)); } -function TechLimit($startyear, $year, $tech) { +function TechLimit($startyear, $year, $tech) : int { $limit = 0; if($year < $startyear+ 5 && $tech >= 1000) { $limit = 1; } if($year < $startyear+10 && $tech >= 2000) { $limit = 1; } @@ -418,7 +418,7 @@ function TechLimit($startyear, $year, $tech) { return $limit; } -function getTechAbil($tech) { +function getTechAbil($tech) : int{ if($tech < 1000) { $abil = 0; } elseif($tech < 2000) { $abil = 25; } elseif($tech < 3000) { $abil = 50; } @@ -435,7 +435,7 @@ function getTechAbil($tech) { return $abil; } -function getTechCost($tech) { +function getTechCost($tech) : float{ if($tech < 1000) { $cost = 1.00; } elseif($tech < 2000) { $cost = 1.15; } elseif($tech < 3000) { $cost = 1.30; } @@ -452,7 +452,7 @@ function getTechCost($tech) { return $cost; } -function getTechCall($tech) { +function getTechCall($tech) : string { if($tech < 1000) { $str = '0등급'; } elseif($tech < 2000) { $str = '1등급'; } elseif($tech < 3000) { $str = '2등급'; } @@ -469,7 +469,7 @@ function getTechCall($tech) { return $str; } -function getDexCall($dex) { +function getDexCall($dex) : string { if($dex < 2500) { $str = 'F-'; } elseif($dex < 7500) { $str = 'F'; } elseif($dex < 15000) { $str = 'F+'; } @@ -504,7 +504,7 @@ function getDexCall($dex) { return $str; } -function getDexLevel($dex) { +function getDexLevel($dex) : int { if($dex < 2500) { $lvl = 0; } elseif($dex < 7500) { $lvl = 1; } elseif($dex < 15000) { $lvl = 2; } @@ -545,7 +545,7 @@ function getDexLog($dex1, $dex2) { } -function getWeapName($weap) { +function getWeapName($weap) : string { switch($weap) { case 0: $weapname = '-'; break; case 1: $weapname = '단도(+1)'; break; @@ -579,7 +579,7 @@ function getWeapName($weap) { return $weapname; } -function getWeapEff($weap) { +function getWeapEff($weap) : int{ switch($weap) { case 7: $weap = 7; break; case 8: $weap = 7; break; @@ -606,7 +606,7 @@ function getWeapEff($weap) { return $weap; } -function getBookName($book) { +function getBookName($book) : string { switch($book) { case 0: $bookname = '-'; break; case 1: $bookname = '효경전(+1)'; break; @@ -640,7 +640,7 @@ function getBookName($book) { return $bookname; } -function getBookEff($book) { +function getBookEff($book) : int { switch($book) { case 7: $book = 7; break; case 8: $book = 7; break; @@ -667,7 +667,7 @@ function getBookEff($book) { return $book; } -function getHorseName($horse) { +function getHorseName($horse) : string { switch($horse) { case 0: $horsename = '-'; break; case 1: $horsename = '노기(+1)'; break; @@ -701,7 +701,7 @@ function getHorseName($horse) { return $horsename; } -function getHorseEff($horse) { +function getHorseEff($horse) : int { switch($horse) { case 7: $horse = 7; break; case 8: $horse = 7; break; @@ -728,7 +728,7 @@ function getHorseEff($horse) { return $horse; } -function getItemName($item) { +function getItemName($item) : string { switch($item) { case 0: $itemname = '-'; break; case 1: $itemname = '환약(치료)'; break; @@ -762,7 +762,7 @@ function getItemName($item) { return $itemname; } -function getItemCost2($weap) { +function getItemCost2($weap) : int { switch($weap) { case 0: $weapcost = 0; break; case 1: $weapcost = 100; break; @@ -776,7 +776,7 @@ function getItemCost2($weap) { return $weapcost; } -function getItemCost($weap) { +function getItemCost($weap) : int { switch($weap) { case 0: $weapcost = 0; break; case 1: $weapcost = 1000; break; @@ -792,7 +792,7 @@ function getItemCost($weap) { -function ConvertLog($str, $type=1) { +function ConvertLog(string $str, $type=1) : string { //TODO: 이 함수는 없애야 한다. CSS로 대신하자 if($type > 0) { $str = str_replace("<1>", "", $str); @@ -833,7 +833,7 @@ function ConvertLog($str, $type=1) { -function newColor($color) { +function newColor($color) : string { switch($color) { case "": case "#330000": @@ -860,6 +860,6 @@ function newColor($color) { return $color; } -function backColor($color) { +function backColor($color) : string { return newColor($color); } diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index f66d0cd3..ecf8e872 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -458,7 +458,6 @@ function preUpdateMonthly() { for($i=0; $i < $gencount; $i++) { $general = MYDB_fetch_array($result); - unset($log); $log = []; $log = checkDedication($general, $log); $log = checkExperience($general, $log); @@ -472,14 +471,14 @@ function preUpdateMonthly() { for($i=0; $i < $nationCount; $i++) { $nation = MYDB_fetch_array($result); $spy = ""; $k = 0; - $citys = []; - if($nation['spy'] != "") { $citys = explode("|", (string)$nation['spy']); } - while(count($citys)) { - $citys[$k]--; - if($citys[$k]%10 != 0) { $spy .= (string)$citys[$k]; } + $cities = []; + if($nation['spy'] != "") { $cities = explode("|", (string)$nation['spy']); } + while(count($cities)) { + $cities[$k]--; + if($cities[$k]%10 != 0) { $spy .= (string)$cities[$k]; } $k++; - if($k >= count($citys)) { break; } - if($citys[$k-1]%10 != 0) { $spy .= "|"; } + if($k >= count($cities)) { break; } + if($cities[$k-1]%10 != 0) { $spy .= "|"; } } $query = "update nation set spy='$spy' where nation='{$nation['nation']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); @@ -497,6 +496,8 @@ function postUpdateMonthly() { $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $admin = MYDB_fetch_array($result); + $history = []; + //각 국가 전월 장수수 대비 당월 장수수로 단합도 산정 //각 국가 장수수를 구하고 국력 산정 // $query = "select nation,gennum from nation where level>0"; @@ -531,6 +532,7 @@ group by A.nation "; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $nationCount = MYDB_num_rows($result); + $genNum = []; for($i=0; $i < $nationCount; $i++) { $nation = MYDB_fetch_array($result); $genNum[$nation['nation']] = $nation['gennum']; @@ -573,6 +575,7 @@ group by A.nation $query = "select me,you from diplomacy where state='1' and term<='1' and me●{$admin['year']}년 {$admin['month']}월:【통일】{$nation['name']}(이)가 전토를 통일하였습니다."]; pushWorldHistory($history, $admin['year'], $admin['month']); //연감 월결산 diff --git a/hwe/func_message.php b/hwe/func_message.php index a6ee5415..822cfadb 100644 --- a/hwe/func_message.php +++ b/hwe/func_message.php @@ -7,7 +7,9 @@ class Message{ public $mailbox; public $type; public $isSender; + /** @var mixed[] */ public $src; + /** @var mixed[] */ public $dest; public $time; public $text; @@ -35,7 +37,7 @@ class Message{ $this->dest['nation_id'] = null; } - $this->datetime = $row['time']; + $this->time = $row['time']; $this->text = $db_message['text']; $this->option = $db_message['option']; } @@ -119,7 +121,7 @@ function sendRawMessage($msgType, $isSender, $mailbox, $src, $dest, $msg, $date, $dest['nation'] = Util::array_get($destNation['name'], '재야'); $dest['color'] = Util::array_get($destNation['color'], '#ffffff'); - if(!$isSender && $mailBox < 9000 && Util::array_get($msgOption['alert'], false)){ + if(!$isSender && $mailbox < 9000 && Util::array_get($msgOption['alert'], false)){ //TODO:newmsg보단 lastmsg로 datetime을 넣는게 더 나아보임 DB::db()->update('general', array( 'newmsg' => true @@ -149,7 +151,7 @@ function sendRawMessage($msgType, $isSender, $mailbox, $src, $dest, $msg, $date, function sendMessage($msgType, $src, $dest, $msg, $date = null, $validUntil = null, $msgOption = null){ if($date === null){ - $date = $datetime->format('Y-m-d H:i:s'); + $date = (new \Datetime())->format('Y-m-d H:i:s'); } if($validUntil === null){ @@ -252,7 +254,7 @@ function getMailboxList(){ "color"=>"#ffffff" ]; - $result = array_map(function($nation){ + $result = array_map(function($nation) use ($generalNations) { $nationID = $nation['nation']; $mailbox = $nationID + 9000; $nation = $nation['name']; @@ -300,6 +302,7 @@ function DecodeMsg($msg, $type, $who, $date, $bg, $num=0) { $sndr = MYDB_fetch_array($result); if($sndr['nation'] == 0) { + $sndrnation = []; $sndrnation['name'] = '재야'; $sndrnation['color'] = '#FFFFFF'; } else { @@ -327,6 +330,7 @@ function DecodeMsg($msg, $type, $who, $date, $bg, $num=0) { $rcvr = MYDB_fetch_array($result); if($rcvr['nation'] == 0) { + $rcvrnation = []; $rcvrnation['name'] = '재야'; $rcvrnation['color'] = '#FFFFFF'; } else { diff --git a/hwe/func_npc.php b/hwe/func_npc.php index b82e70bc..994fa84d 100644 --- a/hwe/func_npc.php +++ b/hwe/func_npc.php @@ -84,6 +84,7 @@ function SetCrew($no, $personal, $gold, $leader, $genType, $tech, $region, $city $db = DB::db(); $connect=$db->get(); + $type = 0; switch($genType) { case 0: //무장 case 2: //무내정장 diff --git a/hwe/func_process.php b/hwe/func_process.php index 8a89c371..b76024d7 100644 --- a/hwe/func_process.php +++ b/hwe/func_process.php @@ -107,27 +107,41 @@ function getGeneralIntel(&$general, $withInjury, $withItem, $withStatAdjust, $us * @return array 계산된 실패, 성공 확률 ('succ' => 성공 확률, 'fail' => 실패 확률) */ function CriticalRatioDomestic(&$general, $type) { - $leader = getGeneralLeadership($general, false, true, false, false); - $power = getGeneralPower($general, false, true, false, false); - $intel = getGeneralIntel($general, false, true, false, false); + $leader = getGeneralLeadership($general, false, true, true, false); + $power = getGeneralPower($general, false, true, true, false); + $intel = getGeneralIntel($general, false, true, true, false); $avg = ($leader+$power+$intel) / 3; - // 707010장수 18/21% 706515장수 16/27% 706020장수 14/33% xx50xx장수 10/50% + /* + * 능력치가 높아질 수록 성공 확률 감소. 실패 확률도 감소 + + * 무력 내정 기준(지력 내정 방식과 구조 동일) + 756510(32%/30%), 707010(28%/25%), 657510(23%/20%) + 106575(23%/20%), 107070(20%/17%), 107565(17%/15%) + 506040(33%/30%), 505050(43%/40%), 504060(50%/50%) + + * 통솔 내정 기준 + 756510(25%/22%), 707010(31%/28%), 657510(38%,35%), + 505050(50%,50%), 107070(50%,50%) + */ switch($type) { case 0: $ratio = $avg / $leader; break; case 1: $ratio = $avg / $power; break; case 2: $ratio = $avg / $intel; break; } - if($ratio > 1) $ratio = 1; + $ratio = min($ratio, 1.2); - $r['fail'] = (0.2 / $ratio - 0.1) * 100; - $r['succ'] = ($ratio - 0.5) * 100; + $fail = pow($ratio / 1.2, 1.4) - 0.3; + $succ = pow($ratio / 1.2, 1.5) - 0.25; - if($r['fail'] < 0) { $r['fail'] = 0; } - $r['succ'] += $r['fail']; - if($r['succ'] > 100) { $r['succ'] = 100; } + $fail = min(max($fail, 0), 0.5); + $succ = min(max($succ, 0), 0.5); - return $r; + + return array( + 'succ'=>$succ, + 'fail'=>$fail + ); } /** @@ -1456,7 +1470,7 @@ function process_26(&$general) { $ded = CharDedication($ded, $general['personal']); //부대원에게 로그 전달 - $genlog[] = "{$troop['name']}의 부대원들은 {$city['name']}(으)로 집합되었습니다."; + $genlog = ["{$troop['name']}의 부대원들은 {$city['name']}(으)로 집합되었습니다."]; for($i=0; $i < $gencount; $i++) { $troopgen = MYDB_fetch_array($result); @@ -1602,7 +1616,7 @@ function process_30(&$general) { $query = "select no,name from general where nation='{$general['nation']}' and level<'12'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $gencount = MYDB_num_rows($result); - $genlog[0] = "●방랑군 세력이 {$destcity['name']}(으)로 강행했습니다."; + $genlog = ["●방랑군 세력이 {$destcity['name']}(으)로 강행했습니다."]; for($j=0; $j < $gencount; $j++) { $gen = MYDB_fetch_array($result); pushGenLog($gen, $genlog); @@ -1652,6 +1666,7 @@ function process_31(&$general) { $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $gencount = MYDB_num_rows($result); $crew = 0; + $typecount = []; for($i=0; $i < $gencount; $i++) { $gen = MYDB_fetch_array($result); if($gen['crew'] != 0) { $typecount[$gen['crewtype']]++; $crew += $gen['crew']; } @@ -1720,20 +1735,21 @@ function process_31(&$general) { $query = "select spy from nation where nation='{$general['nation']}'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $nation = MYDB_fetch_array($result); - if($nation['spy'] != "") { $citys = explode("|", $nation['spy']); } - for($i=0; $i < count($citys); $i++) { - if(floor($citys[$i]/10) == $destination) { + if($nation['spy'] != "") { $cities = explode("|", $nation['spy']); } + $exist = 0; + for($i=0; $i < count($cities); $i++) { + if(floor($cities[$i]/10) == $destination) { $exist = 1; break; } } // 기존 첩보 목록에 없으면 새로 등록, 있으면 갱신 if($exist == 0) { - $citys[] = $destination * 10 + 3; + $cities[] = $destination * 10 + 3; } else { - $citys[$i] = $destination * 10 + 3; + $cities[$i] = $destination * 10 + 3; } - $spy = implode("|", $citys); + $spy = implode("|", $cities); $query = "update nation set spy='$spy' where nation='{$general['nation']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); @@ -2037,6 +2053,7 @@ function process_43(&$general) { $db = DB::db(); $connect=$db->get(); + $genlog = []; $log = []; $alllog = []; $history = []; @@ -2169,10 +2186,10 @@ function process_44(&$general) { $log[] = "●{$admin['month']}월:자금이 없습니다. 헌납 실패. <1>$date"; } elseif($what == 2 && $general['rice'] <= 0) { $log[] = "●{$admin['month']}월:군량이 없습니다. 헌납 실패. <1>$date"; - } elseif($general['nation'] != $city['nation'] && $mynation['level'] != 0) { - $log[] = "●{$admin['month']}월:아국이 아닙니다. 증여 실패. <1>$date"; + } elseif($general['nation'] != $city['nation'] && $nation['level'] != 0) { + $log[] = "●{$admin['month']}월:아국이 아닙니다. 헌납 실패. <1>$date"; } elseif($city['supply'] == 0) { - $log[] = "●{$admin['month']}월:고립된 도시입니다. 증여 실패. <1>$date"; + $log[] = "●{$admin['month']}월:고립된 도시입니다. 헌납 실패. <1>$date"; } else { // $alllog[] = "●{$admin['month']}월:{$nation['name']}에서 장수들이 재산을 헌납 하고 있습니다."; $log[] = "●{$admin['month']}월: $dtype $amount을 헌납했습니다. <1>$date"; diff --git a/hwe/func_process_chief.php b/hwe/func_process_chief.php index a11de667..63340123 100644 --- a/hwe/func_process_chief.php +++ b/hwe/func_process_chief.php @@ -5,6 +5,7 @@ function process_23(&$general) { $db = DB::db(); $connect=$db->get(); + $genlog = []; $log = []; $alllog = []; $history = []; @@ -106,6 +107,7 @@ function process_24(&$general) { $db = DB::db(); $connect=$db->get(); + $genlog = []; $log = []; $alllog = []; $history = []; @@ -341,7 +343,7 @@ function process_51(&$general) { } //기존 메세지 한칸씩 뒤로 미룸 for($i=$deleted-1; $i >=0; $i--) { - moveMsg("nation", "dip", $i+1, $younatin["dip{$i}"], $younation["dip{$i}_type"], $younation["dip{$i}_who"], $younation["dip{$i}_when"], "nation", $younation['nation']); + moveMsg("nation", "dip", $i+1, $younation["dip{$i}"], $younation["dip{$i}_type"], $younation["dip{$i}_who"], $younation["dip{$i}_when"], "nation", $younation['nation']); } //권고 서신시 장수번호/상대국 번호 $me = $general['no'] * 10000 + $younation['nation']; @@ -429,9 +431,9 @@ function process_52(&$general) { $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $gencount = MYDB_num_rows($result); + $genlog = ["{$younation['name']}(으)로 금$gold 쌀$rice을 지원했습니다."]; for($i=0; $i < $gencount; $i++) { $gen = MYDB_fetch_array($result); - $genlog[0] = "{$younation['name']}(으)로 금$gold 쌀$rice을 지원했습니다."; pushGenLog($gen, $genlog); } pushGeneralHistory($general, "●{$admin['year']}년 {$admin['month']}월:{$younation['name']}(으)로 금$gold 쌀$rice을 지원"); @@ -1241,6 +1243,7 @@ function process_71(&$general) { $log = []; $alllog = []; $history = []; + $tricklog = []; $date = substr($general['turntime'],11,5); @@ -1346,6 +1349,7 @@ function process_72(&$general) { $log = []; $alllog = []; $history = []; + $tricklog = []; $date = substr($general['turntime'],11,5); @@ -1460,6 +1464,7 @@ function process_73(&$general) { $log = []; $alllog = []; $history = []; + $tricklog = []; $date = substr($general['turntime'],11,5); @@ -1590,6 +1595,7 @@ function process_74(&$general) { $log = []; $alllog = []; $history = []; + $tricklog = []; $date = substr($general['turntime'],11,5); @@ -1685,20 +1691,21 @@ function process_74(&$general) { $query = "select city from city where nation='{$destcity['nation']}' and supply=1"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $cityCount = MYDB_num_rows($result); + $cities = []; for($i=0; $i < $cityCount; $i++) { $dCity = MYDB_fetch_array($result); - $citys[$i] = $dCity['city']; + $cities[$i] = $dCity['city']; } //상대국 유저 랜덤 배치 $query = "select no,name from general where nation='{$destcity['nation']}' and city='{$destcity['city']}'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $count = MYDB_num_rows($result); - $opplog[0] = "●상대국의 허보에 당했다! <1>$date"; + $opplog = ["●상대국의 허보에 당했다! <1>$date"]; for($i=0; $i < $count; $i++) { $gen = MYDB_fetch_array($result); - $selCity = $citys[rand() % $cityCount]; + $selCity = $cities[rand() % $cityCount]; //현재도시이면 한번 다시 랜덤추첨 - if($selCity == $destcity['city']) { $selCity = $citys[rand() % $cityCount]; } + if($selCity == $destcity['city']) { $selCity = $cities[rand() % $cityCount]; } $query = "update general set city={$selCity} where no='{$gen['no']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); @@ -1732,6 +1739,7 @@ function process_75(&$general) { $log = []; $alllog = []; $history = []; + $tricklog = []; $date = substr($general['turntime'],11,5); @@ -2076,6 +2084,7 @@ function process_77(&$general) { $log = []; $alllog = []; $history = []; + $tricklog = []; $date = substr($general['turntime'],11,5); @@ -2203,6 +2212,7 @@ function process_78(&$general) { $log = []; $alllog = []; $history = []; + $tricklog = []; $date = substr($general['turntime'],11,5); @@ -2366,7 +2376,7 @@ function process_81(&$general) { $query = "select no,name from general where nation='{$general['nation']}' and no!='{$general['no']}'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $cnt = MYDB_num_rows($result); - $genlog[0] = "{$general['name']}(이)가 국기를 변경합니다."; + $genlog = ["{$general['name']}(이)가 국기를 변경합니다."]; for($i=0; $i < $cnt; $i++) { $gen = MYDB_fetch_array($result); pushGenLog($gen, $genlog); diff --git a/hwe/func_process_personnel.php b/hwe/func_process_personnel.php index 52e605df..e2ff16f9 100644 --- a/hwe/func_process_personnel.php +++ b/hwe/func_process_personnel.php @@ -409,10 +409,6 @@ function process_29(&$general) { $gennum = $gencount; if($gencount < 10) $gencount = 10; - // 국가보정 - if($nation['type'] == 11) { $term3 = round($term3 / 2); } - if($nation['type'] == 12) { $term3 = $term3 * 2; } - //국가 기술력 그대로 $query = "update nation set totaltech=tech*'$gencount',gennum='$gennum' where nation='{$general['nation']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); @@ -462,11 +458,6 @@ function process_45(&$general) { } elseif($general['level'] == 12) { $log[] = "●{$admin['month']}월:군주입니다. 하야 실패. <1>$date"; } else { - $exp = 100; - - // 성격 보정 - $exp = CharExperience($exp, $general['personal']); - $ded = CharDedication($ded, $general['personal']); $query = "select no from diplomacy where me='{$general['nation']}' and state>='3' and state<='4'"; $dipresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); @@ -713,6 +704,7 @@ function process_54(&$general) { $connect=$db->get(); $log = []; + $youlog = []; $alllog = []; $history = []; $date = substr($general['turntime'],11,5); @@ -920,6 +912,7 @@ function process_57(&$general) { $connect=$db->get(); $log = []; + $youlog = []; $alllog = []; $history = []; $date = substr($general['turntime'],11,5); diff --git a/hwe/func_process_trick.php b/hwe/func_process_trick.php index 4b0eb8d4..d2852291 100644 --- a/hwe/func_process_trick.php +++ b/hwe/func_process_trick.php @@ -229,8 +229,8 @@ function process_33(&$general) { $nation['gold'] -= $gold; $nation['rice'] -= $rice; - if($nation['gold'] < GameConst::$minNationalgold) { $gold += ($nation['gold'] - GameConst::$minNationalgold); $nation['gold'] = GameConst::$minNationalgold; } - if($nation['rice'] < GameConst::$minNationalrice) { $rice += ($nation['rice'] - GameConst::$minNationalrice); $nation['rice'] = GameConst::$minNationalrice; } + if($nation['gold'] < GameConst::$minNationalGold) { $gold += ($nation['gold'] - GameConst::$minNationalGold); $nation['gold'] = GameConst::$minNationalGold; } + if($nation['rice'] < GameConst::$minNationalRice) { $rice += ($nation['rice'] - GameConst::$minNationalRice); $nation['rice'] = GameConst::$minNationalRice; } $query = "update nation set gold='{$nation['gold']}',rice='{$nation['rice']}' where nation='{$destcity['nation']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $query = "update city set state=34 where city='$destination'"; diff --git a/hwe/func_string.php b/hwe/func_string.php index 4a3f7162..c8219a3a 100644 --- a/hwe/func_string.php +++ b/hwe/func_string.php @@ -2,17 +2,17 @@ namespace sammo; -function getFont($str) { +function getFont(string $str) { if(strlen($str) >= 22) { $str = "{$str}"; } return $str; } -function SQ2DQ($str) { +function SQ2DQ(string $str) { return str_replace("'", "'", $str); } -function Tag2Code($str) { +function Tag2Code(string $str) { // return htmlspecialchars(nl2br(str_replace(" ", " ", $str))); // $str = str_replace("&", "&", $str); $str = str_replace("'", "'", $str); @@ -24,14 +24,14 @@ function Tag2Code($str) { return nl2br($str); } -function BadTag2Code($str) { +function BadTag2Code(string $str) { /* FIXME: 제대로된 tag 변환 코드 사용 */ $str = str_replace("★{$admin['year']}년 {$admin['month']}월: 모두들 즐거운 게임 하고 계신가요? ^^ 삼국일보 애독해 주시고, 훼접은 삼가주세요~"], $admin['year'], $admin['month']); } function processGoldIncome() { @@ -51,6 +51,7 @@ function processGoldIncome() { $query = "select year,month,gold_rate from game limit 1"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $admin = MYDB_fetch_array($result); + $adminLog = []; $query = "select name,nation,gold,rate_tmp,bill,type from nation"; $nationresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); @@ -83,12 +84,17 @@ function processGoldIncome() { // 실지급율 $ratio = $realoutcome / $originoutcome; } - $adminLog[] = StringUtil::Fill2($nation['name'],12," ")." // 세금 : ".StringUtil::Fill2($income,6," ")." // 세출 : ".StringUtil::Fill2($originoutcome,6," ")." // 실제 : ".tab2($realoutcome,6," ")." // 지급율 : ".tab2(round($ratio*100,2),5," ")." % // 결과금 : ".tab2($nation['gold'],6," "); + $adminLog[] = StringUtil::Fill2((string)$nation['name'],12," ") + ." // 세금 : ".StringUtil::Fill2((string)$income,6," ") + ." // 세출 : ".StringUtil::Fill2((string)$originoutcome,6," ") + ." // 실제 : ".tab2((string)$realoutcome,6," ") + ." // 지급율 : ".tab2((string)round($ratio*100,2),5," ") + ." % // 결과금 : ".tab2((string)$nation['gold'],6," "); $query = "select no,name,nation from general where nation='{$nation['nation']}' and level>='9'"; $coreresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $corecount = MYDB_num_rows($coreresult); - $corelog[0] = "●이번 수입은 금 $income입니다."; + $corelog = ["●이번 수입은 금 $income입니다."]; for($j=0; $j < $corecount; $j++) { $coregen = MYDB_fetch_array($coreresult); pushGenLog($coregen, $corelog); @@ -110,13 +116,11 @@ function processGoldIncome() { $query = "update general set gold='{$general['gold']}' where no='{$general['no']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $log[0] = "●봉급으로 금 $gold을 받았습니다."; - pushGenLog($general, $log); + pushGenLog($general, ["●봉급으로 금 $gold을 받았습니다."]); } } - $history[0] = "●{$admin['year']}년 {$admin['month']}월:【지급】봄이 되어 봉록에 따라 자금이 지급됩니다."; - pushWorldHistory($history, $admin['year'], $admin['month']); + pushWorldHistory(["●{$admin['year']}년 {$admin['month']}월:【지급】봄이 되어 봉록에 따라 자금이 지급됩니다."], $admin['year'], $admin['month']); pushAdminLog($adminLog); } @@ -124,6 +128,9 @@ function popIncrease() { $db = DB::db(); $connect=$db->get(); + $rate = []; + $type = []; + $query = "select nation,rate_tmp,type from nation"; $nationresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $nationcount = MYDB_num_rows($nationresult); @@ -233,7 +240,7 @@ function getGoldIncome($nationNo, $rate, $admin_rate, $type) { $citycount = MYDB_num_rows($cityresult); //총 수입 구함 - $income[0] = 0; $income[1] = 0; // income[0] : 세수, income[1] : 수비병 세수 + $income = [0, 0]; // income[0] : 세수, income[1] : 수비병 세수 for($j=0; $j < $citycount; $j++) { $city = MYDB_fetch_array($cityresult); @@ -367,6 +374,7 @@ function processRiceIncome() { $query = "select year,month,rice_rate from game limit 1"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $admin = MYDB_fetch_array($result); + $adminLog = []; $query = "select name,nation,rice,rate_tmp,bill,type from nation"; $nationresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); @@ -400,12 +408,17 @@ function processRiceIncome() { // 실지급율 $ratio = $realoutcome / $originoutcome; } - $adminLog[] = StringUtil::Fill2($nation['name'],12," ")." // 세곡 : ".StringUtil::Fill2($income,6," ")." // 세출 : ".StringUtil::Fill2($originoutcome,6," ")." // 실제 : ".tab2($realoutcome,6," ")." // 지급율 : ".tab2(round($ratio*100,2),5," ")." % // 결과곡 : ".tab2($nation['rice'],6," "); + $adminLog[] = StringUtil::Fill2($nation['name'],12," ") + ." // 세곡 : ".StringUtil::Fill2((string)$income,6," ") + ." // 세출 : ".StringUtil::Fill2((string)$originoutcome,6," ") + ." // 실제 : ".tab2((string)$realoutcome,6," ") + ." // 지급율 : ".tab2((string)round($ratio*100,2),5," ") + ." % // 결과곡 : ".tab2((string)$nation['rice'],6," "); $query = "select no,name,nation from general where nation='{$nation['nation']}' and level>='9'"; $coreresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $corecount = MYDB_num_rows($coreresult); - $corelog[0] = "●이번 수입은 쌀 $income입니다."; + $corelog = ["●이번 수입은 쌀 $income입니다."]; for($j=0; $j < $corecount; $j++) { $coregen = MYDB_fetch_array($coreresult); pushGenLog($coregen, $corelog); @@ -427,13 +440,11 @@ function processRiceIncome() { $query = "update general set rice='{$general['rice']}' where no='{$general['no']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $log[0] = "●봉급으로 쌀 $rice을 받았습니다."; - pushGenLog($general, $log); + pushGenLog($general, ["●봉급으로 쌀 $rice을 받았습니다."]); } } - $history[0] = "●{$admin['year']}년 {$admin['month']}월:【지급】가을이 되어 봉록에 따라 군량이 지급됩니다."; - pushWorldHistory($history, $admin['year'], $admin['month']); + pushWorldHistory(["●{$admin['year']}년 {$admin['month']}월:【지급】가을이 되어 봉록에 따라 군량이 지급됩니다."], $admin['year'], $admin['month']); pushAdminLog($adminLog); } @@ -474,7 +485,7 @@ function getRiceIncome($nationNo, $rate, $admin_rate, $type) { $citycount = MYDB_num_rows($cityresult); //총 수입 구함 - $income[0] = 0; $income[1] = 0; // income[0] : 세수, income[1] : 수비병 세수 + $income = [0, 0]; // income[0] : 세수, income[1] : 수비병 세수 for($j=0; $j < $citycount; $j++) { $city = MYDB_fetch_array($cityresult); @@ -581,6 +592,10 @@ function disaster() { if($admin['month'] == 4 && $disastertype == 3) { $isgood = 1; } if($admin['month'] == 7 && $disastertype == 3) { $isgood = 1; } + $disastercity = []; + $disasterratio = []; + $disastername = []; + for($i=0; $i < $citycount; $i++) { $city = MYDB_fetch_array($cityresult); //호황 발생 도시 선택 ( 기본 3% 이므로 약 3개 도시 ) @@ -589,14 +604,13 @@ function disaster() { else { $ratio = 6 - round(1.0*$city['secu']/$city['secu2']*3); } // 3 ~ 6% if(rand()%100+1 < $ratio) { - $idx = count($disastercity); - $disastercity[$idx] = $city['city']; - $disasterratio[$idx] = 1.0 * $city['secu'] / $city['secu2']; - $disastername .= $city['name']." "; + $disastercity[] = $city['city']; + $disasterratio[] = 1.0 * $city['secu'] / $city['secu2']; + $disastername[] = $city['name']; } } - $disastername = "{$disastername}"; + $disastername = "".join(' ', $disastername).""; $disaster = []; //재해 처리 diff --git a/hwe/func_tournament.php b/hwe/func_tournament.php index 57e09b72..edf6d668 100644 --- a/hwe/func_tournament.php +++ b/hwe/func_tournament.php @@ -571,6 +571,11 @@ function setGift($tnmt_type, $tnmt, $phase) { $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $admin = MYDB_fetch_array($result); + $genNo = []; + $genName = []; + $genGold = []; + $genCall = []; + switch($tnmt_type) { case 0: $tp = "전력전"; $tp2 = "tt"; break; case 1: $tp = "통솔전"; $tp2 = "tl"; break; @@ -708,8 +713,7 @@ function setGift($tnmt_type, $tnmt, $phase) { $query = "update general set gold=gold+'$gold',betwingold=betwingold+'$gold',betwin=betwin+1 where no='{$gen['no']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); //로그 - $log[0] = "{$tp} 대회의 베팅 당첨으로 {$gold}의 금 획득!"; - pushGenLog($gen, $log); + pushGenLog($gen, ["{$tp} 대회의 베팅 당첨으로 {$gold}의 금 획득!"]); } } diff --git a/hwe/sammo/GameConst.php b/hwe/sammo/GameConst.php index 9fe44ba7..3fe47c18 100644 --- a/hwe/sammo/GameConst.php +++ b/hwe/sammo/GameConst.php @@ -1,7 +1,8 @@