From 43f561ce113ac283656c8c20f2c6bf1cb044ad85 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 2 Sep 2018 16:03:04 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8F=84=EC=8B=9C=EC=9D=98=20=EB=AF=BC?= =?UTF-8?q?=EC=8B=AC=EC=9D=84=20int=EC=97=90=EC=84=9C=20float=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD=ED=95=98=EA=B3=A0=20=EB=AA=85?= =?UTF-8?q?=EC=B9=AD=EC=9D=84=20rate=EC=97=90=EC=84=9C=20trust=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/_admin5.php | 2 +- hwe/b_currentCity.php | 2 +- hwe/b_myCityInfo.php | 4 +- hwe/func.php | 6 +- hwe/func_gamerule.php | 12 ++-- hwe/func_npc.php | 14 ++--- hwe/func_process.php | 87 ++++++++++++++++----------- hwe/func_process_chief.php | 2 +- hwe/func_process_sabotage.php | 20 +++--- hwe/func_time_event.php | 23 ++++--- hwe/j_simulate_battle.php | 6 +- hwe/js/battle_simulator.js | 2 +- hwe/sammo/CityConstBase.php | 2 +- hwe/sammo/Event/Action/ChangeCity.php | 12 ++-- hwe/scenario/scenario_1010.json | 4 +- hwe/scenario/scenario_1020.json | 4 +- hwe/scenario/scenario_1030.json | 4 +- hwe/scenario/scenario_1040.json | 4 +- hwe/scenario/scenario_1050.json | 4 +- hwe/scenario/scenario_1060.json | 4 +- hwe/scenario/scenario_1070.json | 4 +- hwe/scenario/scenario_1080.json | 4 +- hwe/scenario/scenario_1090.json | 4 +- hwe/scenario/scenario_1100.json | 4 +- hwe/scenario/scenario_1110.json | 4 +- hwe/scenario/scenario_1120.json | 4 +- hwe/sql/schema.sql | 2 +- 27 files changed, 130 insertions(+), 114 deletions(-) diff --git a/hwe/_admin5.php b/hwe/_admin5.php index efef8682..64dcc2b7 100644 --- a/hwe/_admin5.php +++ b/hwe/_admin5.php @@ -249,7 +249,7 @@ for($i=0; $i < $nationCount; $i++) {  {$nation['dex40']}   {$gen['crew']}/{$gen['leader']}00   {$city['pop']}/{$city['pop2']}  -  {$city['rate']}%  +  ".round($city['trust'],1)."%   {$city['agri']}%   {$city['comm']}%   {$city['secu']}%  diff --git a/hwe/b_currentCity.php b/hwe/b_currentCity.php index a421229b..b9b22f20 100644 --- a/hwe/b_currentCity.php +++ b/hwe/b_currentCity.php @@ -399,7 +399,7 @@ foreach($generalsFormat as $general){ 민심 - + 시세 % 인구 diff --git a/hwe/b_myCityInfo.php b/hwe/b_myCityInfo.php index 1b362daa..6a3237f3 100644 --- a/hwe/b_myCityInfo.php +++ b/hwe/b_myCityInfo.php @@ -86,7 +86,7 @@ switch ($type) { case 1: break; case 2: $query .= " order by pop desc"; break; case 3: $query .= " order by poprate desc"; break; - case 4: $query .= " order by rate desc"; break; + case 4: $query .= " order by trust desc"; break; case 5: $query .= " order by agri desc"; break; case 6: $query .= " order by comm desc"; break; case 7: $query .= " order by secu desc"; break; @@ -152,7 +152,7 @@ for ($j=0; $j < $citycount; $j++) { 민심 - {$city['rate']} + ".round($city['trust'], 1)." 시세 {$city['trade']}% 인구 diff --git a/hwe/func.php b/hwe/func.php index 17e92afb..b66e984e 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -153,7 +153,7 @@ function cityInfo() { $nation = getNationStaticInfo($city['nation']); $pop = $city['pop'] / $city['pop2'] * 100; - $rate = $city['rate']; + $trust = $city['trust']; $agri = $city['agri'] / $city['agri2'] * 100; $comm = $city['comm'] / $city['comm2'] * 100; $secu = $city['secu'] / $city['secu2'] * 100; @@ -213,13 +213,13 @@ function cityInfo() { 주민 ".bar($pop)." 민심 - ".bar($rate)." + ".bar($trust)." 태수 {$gen1['name']} {$city['pop']}/{$city['pop2']} - {$city['rate']} + ".round($city['trust'], 1)." 농업 diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index 9ec888d2..2da58850 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -344,7 +344,7 @@ function preUpdateMonthly() { //보급선 체크 checkSupply(); //미보급도시 10% 감소 - $query = "update city set pop=pop*0.9,rate=rate*0.9,agri=agri*0.9,comm=comm*0.9,secu=secu*0.9,def=def*0.9,wall=wall*0.9 where supply='0'"; + $query = "update city set pop=pop*0.9,trust=trust*0.9,agri=agri*0.9,comm=comm*0.9,secu=secu*0.9,def=def*0.9,wall=wall*0.9 where supply='0'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); //미보급도시 장수 5% 감소 $query = "select city,nation from city where supply='0'"; @@ -357,7 +357,7 @@ function preUpdateMonthly() { MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); } //민심30이하 공백지 처리 - $query = "select city,name,gen1,gen2,gen3 from city where rate<='30' and supply='0'"; + $query = "select city,name,gen1,gen2,gen3 from city where trust<=30 and supply='0'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $cityCount = MYDB_num_rows($result); for($i=0; $i < $cityCount; $i++) { @@ -371,7 +371,7 @@ function preUpdateMonthly() { } pushWorldHistory($history, $admin['year'], $admin['month']); //민심30이하 공백지 처리 - $query = "update city set nation='0',gen1='0',gen2='0',gen3='0',conflict='{}',term=0,front=0 where rate<='30' and supply='0'"; + $query = "update city set nation='0',gen1='0',gen2='0',gen3='0',conflict='{}',term=0,front=0 where trust<=30 and supply='0'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); //접률감소 @@ -786,7 +786,7 @@ function checkMerge() { $query = "update troop set nation='{$you['nation']}' where nation='{$me['nation']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); // 통합국 모든 도시 5% 감소 - $query = "update city set pop=pop*0.95,agri=agri*0.95,comm=comm*0.95,secu=secu*0.95,rate=rate*0.95,def=def*0.95,wall=wall*0.95 where nation='{$you['nation']}'"; + $query = "update city set pop=pop*0.95,agri=agri*0.95,comm=comm*0.95,secu=secu*0.95,trust=trust*0.95,def=def*0.95,wall=wall*0.95 where nation='{$you['nation']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); // 외교 삭제 $query = "delete from diplomacy where me='{$me['nation']}' or you='{$me['nation']}'"; @@ -900,10 +900,10 @@ function checkSurrender() { $query = "update nation set gold=gold+'{$mynation['gold']}',rice=rice+'{$mynation['rice']}',surlimit='24',totaltech='$newTotalTech',tech='$newTech',gennum='{$newGenCount}' where nation='{$younation['nation']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); //합병 당한국 모든 도시 10%감소 - $query = "update city set pop=pop*0.9,agri=agri*0.9,comm=comm*0.9,secu=secu*0.9,rate=rate*0.9,def=def*0.9,wall=wall*0.9 where nation='{$me['nation']}'"; + $query = "update city set pop=pop*0.9,agri=agri*0.9,comm=comm*0.9,secu=secu*0.9,trust=trust*0.9,def=def*0.9,wall=wall*0.9 where nation='{$me['nation']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); //합병 시도국 모든 도시 5%감소 - $query = "update city set pop=pop*0.95,agri=agri*0.95,comm=comm*0.95,secu=secu*0.95,rate=rate*0.95,def=def*0.95,wall=wall*0.95 where nation='{$you['nation']}'"; + $query = "update city set pop=pop*0.95,agri=agri*0.95,comm=comm*0.95,secu=secu*0.95,trust=trust*0.95,def=def*0.95,wall=wall*0.95 where nation='{$you['nation']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); //국가 삭제 diff --git a/hwe/func_npc.php b/hwe/func_npc.php index c117bfba..8c832432 100644 --- a/hwe/func_npc.php +++ b/hwe/func_npc.php @@ -5,12 +5,12 @@ function SetDevelop($genType, $no, $city, $tech) { $db = DB::db(); $connect=$db->get(); - $query = "select rate,pop/pop2*100 as po,comm/comm2*100 as co,def/def2*100 as de,wall/wall2*100 as wa,secu/secu2*100 as se,agri/agri2*100 as ag from city where city='$city'"; + $query = "select trust,pop/pop2*100 as po,comm/comm2*100 as co,def/def2*100 as de,wall/wall2*100 as wa,secu/secu2*100 as se,agri/agri2*100 as ag from city where city='$city'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $city = MYDB_fetch_array($result); // 우선 선정 - if($city['rate'] < 95) { + if($city['trust'] < 95) { $command = EncodeCommand(0, 0, 0, 4); // 우선 선정 $query = "update general set turn0='$command' where no='$no'"; @@ -201,11 +201,11 @@ function processAI($no) { return; } - $query = "select city,region,nation,level,path,rate,gen1,gen2,gen3,pop,supply,front from city where city='{$general['city']}'"; + $query = "select city,region,nation,level,path,trust,gen1,gen2,gen3,pop,supply,front from city where city='{$general['city']}'"; $result = MYDB_query($query, $connect) or Error("processAI02 ".MYDB_error($connect),""); $city = MYDB_fetch_array($result); - $query = "select nation,level,tech,gold,rice,rate,type,color,name,war from nation where nation='{$general['nation']}'"; + $query = "select nation,level,tech,gold,rice,trust,type,color,name,war from nation where nation='{$general['nation']}'"; $result = MYDB_query($query, $connect) or Error("processAI03 ".MYDB_error($connect),""); $nation = MYDB_fetch_array($result)??[ 'nation'=>0, @@ -607,7 +607,7 @@ function processAI($no) { } elseif($dipState <= 1 || $isStart == 1) { //평시이거나 선포있어도 초반이면 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['trust'] < 95) { $command = EncodeCommand(0, 0, 0, 4); } //우선 선정 elseif($general['gold'] < 100) { //금없으면 쌀팜 $amount = intdiv(($general['rice'] - $general['gold'])/2, 100); // 100단위 $command = EncodeCommand(0, 1, $amount, 49); //팜 @@ -720,8 +720,8 @@ function processAI($no) { //전시일때 if($general['gold'] + $general['rice'] < $resrc*2) { $command = EncodeCommand(0, 0, 0, 9); } //금쌀없으면 조달 - 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['trust'] < 95 && $city['front'] == 0) { $command = EncodeCommand(0, 0, 0, 4); } // 우선 선정 + elseif($general['rice'] > $resrc && $city['trust'] < 50 && $city['front'] == 1) { $command = EncodeCommand(0, 0, 0, 4); } // 우선 선정 elseif($general['gold'] < $resrc || ($general['gold'] < $resrc *2 && $general['rice'] > $resrc * 6)) { // 금없으면 쌀팜 $amount = intdiv(($general['rice'] - $general['gold'])/2, 100); // 100단위 if($amount > 0) { $command = EncodeCommand(0, 1, $amount, 49); }// 팜 diff --git a/hwe/func_process.php b/hwe/func_process.php index f12b3669..f1205dd6 100644 --- a/hwe/func_process.php +++ b/hwe/func_process.php @@ -1,6 +1,8 @@ getValuesAsArray(['startyear', 'year', 'month', 'develcost']); + $date = substr($general['turntime'],11,5); if($type == 1){ $cityKey = 'agri'; - $keyName = '농지 개간'; + $actionName = '농지 개간'; } else{ $cityKey = 'comm'; - $keyName = '상업 투자'; + $actionName = '상업 투자'; } + $reqGold = $develCost; + + [$startYear, $year, $month, $develCost] = $gameStor->getValuesAsArray(['startyear', 'year', 'month', 'develcost']); + $city = $db->queryFirstRow('SELECT * FROM city WHERE city = %i', $general['city']); $nation = getNationStaticInfo($general['nation']); $lbonus = setLeadershipBonus($general, $nation['level']); + $logger = new ActionLogger($general['id'], $general['nation'], $year, $month); + $constraints = [ ['NoNeutral'], ['NoWanderingNation'], ['OccupiedCity'], ['SuppliedCity'], - ['ReqGeneralGold', $develCost], - ['RemainCityCapacity', [$cityKey, $keyName]] + ['ReqGeneralGold', $reqGold], + ['RemainCityCapacity', [$cityKey, $actionName]] ]; + $failReason =Constraint::testAll($constraints, [ + 'nation'=>$nation, + 'city'=>$city, + 'general'=>$general, + ]); + + if($failReason !== null){ + $logger->pushGeneralActionLog("{$failReason} {$sabotageName} 실패. <1>{$date}"); + return; + } } @@ -258,10 +276,10 @@ function process_1_old(&$general, $type) { $log[] = "●{$admin['month']}월:{$dtype}{$btype} 충분합니다. $dtype 실패. <1>$date"; } else { // 민심 50 이하이면 50과 같게 - if($city['rate'] < GameConst::$develrate) { $city['rate'] = GameConst::$develrate; } - $rate = $city['rate'] / 100; + if($city['trust'] < GameConst::$develrate) { $city['trust'] = GameConst::$develrate; } + $trust = $city['trust'] / 100; - $score = getGeneralIntel($general, true, true, true, false) * $rate; + $score = getGeneralIntel($general, true, true, true, false) * $trust; $score = $score * (100 + $general['explevel']/5)/100; $score = $score * (80 + rand() % 41)/100; // 80 ~ 120% @@ -281,7 +299,7 @@ function process_1_old(&$general, $type) { if($type == 1 && $general['special'] == 1) { $r['succ'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } if($type == 2 && $general['special'] == 2) { $r['succ'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } //민심 반영 - if($city['rate'] < 80) { $r['succ'] *= $city['rate'] / 80; } + if($city['trust'] < 80) { $r['succ'] *= $city['trust'] / 80; } //버그방지 if($score < 1) $score = 1; @@ -372,7 +390,7 @@ function process_3(&$general) { // 특기보정 : 발명 if($general['special'] == 3) { $r['succ'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } //민심 반영 - if($city['rate'] < 80) { $r['succ'] *= $city['rate'] / 80; } + if($city['trust'] < 80) { $r['succ'] *= $city['trust'] / 80; } //버그방지 if($score < 1) $score = 1; @@ -450,12 +468,12 @@ function process_4(&$general) { $log[] = "●{$admin['month']}월:고립된 도시입니다. 주민 선정 실패. <1>$date"; } elseif($general['rice'] < $admin['develcost']*2) { $log[] = "●{$admin['month']}월:군량이 모자랍니다. 주민 선정 실패. <1>$date"; - } elseif($city['rate'] >= 100) { + } elseif($city['trust'] >= 100) { $log[] = "●{$admin['month']}월:민심은 충분합니다. 주민 선정 실패. <1>$date"; } else { $score = getGeneralLeadership($general, true, true, true) / 10; - $score = $score * (100 + $general['explevel']/5)/100; - $score = $score * (80 + rand() % 41)/100; // 80 ~ 120% + $score *= (100 + $general['explevel']/5)/100; + $score *= (80 + rand() % 41)/100; // 80 ~ 120% // 국가보정 if($nation['type'] == 2 || $nation['type'] == 4 || $nation['type'] == 7 || $nation['type'] == 10) { $score *= 1.1; $admin['develcost'] *= 0.8; } @@ -476,13 +494,12 @@ function process_4(&$general) { if($r['fail'] > $rd) { $score = CriticalScore($score, 1); - $log[] = "●{$admin['month']}월:선정을 실패하여 민심이 $score 상승했습니다. <1>$date"; + $log[] = "●{$admin['month']}월:선정을 실패하여 민심이 ".round($score, 1)." 상승했습니다. <1>$date"; } elseif($r['succ'] + $r['fail'] > $rd) { $score = CriticalScore($score, 0); - $log[] = "●{$admin['month']}월:선정을 성공하여 민심이 $score 상승했습니다. <1>$date"; + $log[] = "●{$admin['month']}월:선정을 성공하여 민심이 ".round($score, 1)." 상승했습니다. <1>$date"; } else { - $score = Util::round($score); - $log[] = "●{$admin['month']}월:민심이 $score 상승했습니다. <1>$date"; + $log[] = "●{$admin['month']}월:민심이 ".round($score, 1)." 상승했습니다. <1>$date"; } $exp = $score * 7; @@ -492,10 +509,10 @@ function process_4(&$general) { $exp = CharExperience($exp, $general['personal']); $ded = CharDedication($ded, $general['personal']); - $score += $city['rate']; + $score += $city['trust']; if($score > 100) { $score = 100; } // 민심 상승 - $query = "update city set rate='$score' where city='{$general['city']}'"; + $query = "update city set trust='$score' where city='{$general['city']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); // 군량 하락 내정보다 2배 지력경험 경험, 공헌 상승 $general['rice'] -= $admin['develcost'] * 2; @@ -547,10 +564,10 @@ function process_5(&$general, $type) { $log[] = "●{$admin['month']}월:{$dtype}는 충분합니다. $dtype 실패. <1>$date"; } else { // 민심 50 이하이면 50과 같게 - if($city['rate'] < GameConst::$develrate) { $city['rate'] = GameConst::$develrate; } - $rate = $city['rate'] / 100; + if($city['trust'] < GameConst::$develrate) { $city['trust'] = GameConst::$develrate; } + $trust = $city['trust'] / 100; - $score = getGeneralPower($general, true, true, true, false) * $rate; + $score = getGeneralPower($general, true, true, true, false) * $trust; $score = $score * (100 + $general['explevel']/5)/100; $score = $score * (80 + rand() % 41)/100; // 80 ~ 120% @@ -569,7 +586,7 @@ function process_5(&$general, $type) { if($type == 1 && $general['special'] == 11) { $r['succ'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } if($type == 2 && $general['special'] == 10) { $r['succ'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } //민심 반영 - if($city['rate'] < 80) { $r['succ'] *= $city['rate'] / 80; } + if($city['trust'] < 80) { $r['succ'] *= $city['trust'] / 80; } //버그방지 if($score < 1) $score = 1; @@ -736,10 +753,10 @@ function process_8(&$general) { $log[] = "●{$admin['month']}월:치안은 충분합니다. $dtype 강화 실패. <1>$date"; } else { // 민심 50 이하이면 50과 같게 - if($city['rate'] < GameConst::$develrate) { $city['rate'] = GameConst::$develrate; } - $rate = $city['rate'] / 100; + if($city['trust'] < GameConst::$develrate) { $city['trust'] = GameConst::$develrate; } + $trust = $city['trust'] / 100; - $score = getGeneralPower($general, true, true, true, false) * $rate; + $score = getGeneralPower($general, true, true, true, false) * $trust; $score = $score * (100 + $general['explevel']/5)/100; $score = $score * (80 + rand() % 41)/100; // 80 ~ 120% @@ -757,7 +774,7 @@ function process_8(&$general) { // 특기보정 : 통찰 if($general['special'] == 12) { $r['succ'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } //민심 반영 - if($city['rate'] < 80) { $r['succ'] *= $city['rate'] / 80; } + if($city['trust'] < 80) { $r['succ'] *= $city['trust'] / 80; } //버그방지 if($score < 1) $score = 1; @@ -1005,7 +1022,7 @@ function process_11(&$general, $type) { $actLog->pushGeneralActionLog("주민이 모자랍니다. $dtype 실패. <1>$date"); return; } - if($city['rate'] < 20) { + if($city['trust'] < 20) { $actLog->pushGeneralActionLog("민심이 낮아 주민들이 도망갑니다. $dtype 실패. <1>$date"); return; } @@ -1027,16 +1044,16 @@ function process_11(&$general, $type) { $general['gold'] -= $cost; // 주민수 감소 // 민심 감소 if($type === '징병') { - $city['rate'] -= Util::round(($crew / $city['pop'])*100); + $city['trust'] -= ($crew / $city['pop'])*100; } else { - $city['rate'] -= Util::round(($crew / 2 / $city['pop'])*100); + $city['trust'] -= ($crew / 2 / $city['pop'])*100; } - if($city['rate'] < 0) { $city['rate'] = 0; } + if($city['trust'] < 0) { $city['trust'] = 0; } $db->update('city', [ 'pop'=>$db->sqleval('pop-%i', $crew), - 'rate'=>$city['rate'] + 'trust'=>$city['trust'] ], 'city = %i', $general['city']); // 통솔경험, 병종 변경, 병사수 변경, 훈련치 변경, 사기치 변경, 자금 군량 하락, 공헌도, 명성 상승 @@ -1689,13 +1706,13 @@ function process_31(&$general) { $josaUl = JosaUtil::pick($city['name'], '을'); $alllog[] = "●{$admin['month']}월:누군가가 {$city['name']}{$josaUl} 살피는 것 같습니다."; $log[] = "●{$admin['month']}월:{$city['name']}의 소문만 들을 수 있었습니다. <1>$date"; - $log[] = "【{$city['name']}】주민:{$city['pop']}, 민심:{$city['rate']}, 장수:$gencount, 병력:$crew"; + $log[] = "【{$city['name']}】주민:{$city['pop']}, 민심:".round($city['trust'], 1).", 장수:$gencount, 병력:$crew"; } elseif($dist[$destination] == 2) { $josaUl = JosaUtil::pick($city['name'], '을'); $alllog[] = "●{$admin['month']}월:누군가가 {$city['name']}{$josaUl} 살피는 것 같습니다."; $log[] = "●{$admin['month']}월:{$city['name']}의 어느정도 정보를 얻었습니다. <1>$date"; $log[] = "【첩보】농업:{$city['agri']}, 상업:{$city['comm']}, 치안:{$city['secu']}, 수비:{$city['def']}, 성벽:{$city['wall']}"; - $log[] = "【{$city['name']}】주민:{$city['pop']}, 민심:{$city['rate']}, 장수:$gencount, 병력:$crew"; + $log[] = "【{$city['name']}】주민:{$city['pop']}, 민심:".round($city['trust'], 1).", 장수:$gencount, 병력:$crew"; } else { $josaUl = JosaUtil::pick($city['name'], '을'); $alllog[] = "●{$admin['month']}월:누군가가 {$city['name']}{$josaUl} 살피는 것 같습니다."; @@ -1711,7 +1728,7 @@ function process_31(&$general) { $msg = []; $log[] = "【첩보】농업:{$city['agri']}, 상업:{$city['comm']}, 치안:{$city['secu']}, 수비:{$city['def']}, 성벽:{$city['wall']}"; - $log[] = "【{$city['name']}】주민:{$city['pop']}, 민심:{$city['rate']}, 장수:$gencount, 병력:$crew"; + $log[] = "【{$city['name']}】주민:{$city['pop']}, 민심:".round($city['trust'], 1).", 장수:$gencount, 병력:$crew"; if($general['nation'] != 0 && $city['nation'] != 0) { $query = "select name,tech from nation where nation='{$city['nation']}'"; diff --git a/hwe/func_process_chief.php b/hwe/func_process_chief.php index 555cc256..c425ff17 100644 --- a/hwe/func_process_chief.php +++ b/hwe/func_process_chief.php @@ -967,7 +967,7 @@ function process_65(&$general) { MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); //성 공백지로 - $query = "update city set pop=pop*0.1,rate=50,agri=agri*0.1,comm=comm*0.1,secu=secu*0.1,nation='0',front='0',gen1='0',gen2='0',gen3='0',conflict='{}' where city='{$destcity['city']}'"; + $query = "update city set pop=pop*0.1,trust=50,agri=agri*0.1,comm=comm*0.1,secu=secu*0.1,nation='0',front='0',gen1='0',gen2='0',gen3='0',conflict='{}' where city='{$destcity['city']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); //전장수 10% 삭감 diff --git a/hwe/func_process_sabotage.php b/hwe/func_process_sabotage.php index 90f8cdf3..ed2726c9 100644 --- a/hwe/func_process_sabotage.php +++ b/hwe/func_process_sabotage.php @@ -144,7 +144,7 @@ function process_32(&$general) { $dist = searchDistance($srcCityID, 5, false); $srcCity = $db->queryFirstRow('SELECT city,nation,supply FROM city WHERE city=%i', $srcCityID); - $destCity = $db->queryFirstRow('SELECT city,name,level,nation,secu,secu2,supply,agri,comm,def,wall,rate FROM city WHERE city=%i',$destCityID); + $destCity = $db->queryFirstRow('SELECT city,name,level,nation,secu,secu2,supply,agri,comm,def,wall,trust FROM city WHERE city=%i',$destCityID); $destCityName = $destCity['name']??null; $srcNationID = $general['nation']; @@ -278,7 +278,7 @@ function process_33(&$general) { $dist = searchDistance($srcCityID, 5, false); $srcCity = $db->queryFirstRow('SELECT city,nation,supply FROM city WHERE city=%i', $srcCityID); - $destCity = $db->queryFirstRow('SELECT city,name,level,nation,secu,secu2,supply,agri,comm,def,wall,rate FROM city WHERE city=%i',$destCityID); + $destCity = $db->queryFirstRow('SELECT city,name,level,nation,secu,secu2,supply,agri,comm,def,wall,trust FROM city WHERE city=%i',$destCityID); $destCityName = $destCity['name']??null; $srcNationID = $general['nation']; @@ -449,7 +449,7 @@ function process_34(&$general) { $dist = searchDistance($srcCityID, 5, false); $srcCity = $db->queryFirstRow('SELECT city,nation,supply FROM city WHERE city=%i', $srcCityID); - $destCity = $db->queryFirstRow('SELECT city,name,level,nation,secu,secu2,supply,agri,comm,def,wall,rate FROM city WHERE city=%i',$destCityID); + $destCity = $db->queryFirstRow('SELECT city,name,level,nation,secu,secu2,supply,agri,comm,def,wall,trust FROM city WHERE city=%i',$destCityID); $destCityName = $destCity['name']??null; $srcNationID = $general['nation']; @@ -587,7 +587,7 @@ function process_35(&$general) { $dist = searchDistance($srcCityID, 5, false); $srcCity = $db->queryFirstRow('SELECT city,nation,supply FROM city WHERE city=%i', $srcCityID); - $destCity = $db->queryFirstRow('SELECT city,name,level,nation,secu,secu2,supply,agri,comm,def,wall,rate FROM city WHERE city=%i',$destCityID); + $destCity = $db->queryFirstRow('SELECT city,name,level,nation,secu,secu2,supply,agri,comm,def,wall,trust FROM city WHERE city=%i',$destCityID); $destCityName = $destCity['name']??null; $srcNationID = $general['nation']; @@ -668,23 +668,23 @@ function process_35(&$general) { // 선동 최대 10 $secuAmount = Util::valueFit(Util::randRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax), null, $destCity['secu']); - $rateAmount = Util::valueFit( - Util::round(Util::randRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax) / 50), + $trustAmount = Util::valueFit( + Util::randRange(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax) / 50, null, - $destCity['rate'] + $destCity['trust'] ); $destCity['secu'] -= $secuAmount; - $destCity['rate'] -= $rateAmount; + $destCity['trust'] -= $trustAmount; $db->update('city', [ 'state'=>32, 'secu'=>$destCity['secu'], - 'rate'=>$destCity['rate'] + 'trust'=>$destCity['trust'] ], 'city=%i', $destCityID); $injuryCount = SabotageInjury($destCityID); - $logger->pushGeneralActionLog("도시의 치안이 {$secuAmount}, 민심이 {$rateAmount}만큼 감소하고, 장수 {$injuryCount}명이 부상 당했습니다.", ActionLogger::PLAIN); + $logger->pushGeneralActionLog("도시의 치안이 {$secuAmount}, 민심이 ".round($trustAmount, 1)."만큼 감소하고, 장수 {$injuryCount}명이 부상 당했습니다.", ActionLogger::PLAIN); $exp = Util::randRangeInt(201, 300); $exp *= getCharExpMultiplier($general['personal']); diff --git a/hwe/func_time_event.php b/hwe/func_time_event.php index 8c8f745d..92545222 100644 --- a/hwe/func_time_event.php +++ b/hwe/func_time_event.php @@ -150,7 +150,7 @@ function popIncrease() { $pop = $city['pop']; if($city['nation'] == 0) { $pop = $city['pop']; // 공백지는 증가하지 않게 - $cityrate = 50; + $citytrust = 50; $ratio = 0.99; // 공백지는 수비 빼고 약간씩 감소 $agri = intval($city['agri'] * $ratio); @@ -181,10 +181,9 @@ function popIncrease() { $pop = $city['pop'] + (int)($city['pop'] * $ratio) + 5000; // 기본 5000명은 증가 $ratio = round($ratio*100, 2); - $cityrate = $city['rate']; - $cityrate = $cityrate + (20 - $rate[$city['nation']]); - if($cityrate > 100) { $cityrate = 100; } - if($cityrate < 0) { $cityrate = 0; } + $citytrust = $city['trust']; + $citytrust = $citytrust + (20 - $rate[$city['nation']]); + $citytrust = Util::valueFit($citytrust, 0, 100); } if($pop > $city['pop2']) { $pop = $city['pop2']; } if($pop < 0) { $pop = 0; } @@ -195,7 +194,7 @@ function popIncrease() { if($wall > $city['wall2']) { $wall = $city['wall2']; } //시세 - $query = "update city set pop='$pop',rate='$cityrate',agri='$agri',comm='$comm',secu='$secu',def='$def',wall='$wall' where city='{$city['city']}'"; + $query = "update city set pop='$pop',trust='$citytrust',agri='$agri',comm='$comm',secu='$secu',def='$def',wall='$wall' where city='{$city['city']}'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); } } @@ -243,7 +242,7 @@ function getGoldIncome($nationNo, $rate, $admin_rate, $type) { $city = MYDB_fetch_array($cityresult); //민충 0~100 : 50~100 수입 - $ratio = $city['rate'] / 2 + 50; + $ratio = $city['trust'] / 2 + 50; $tax1 = ($city['pop'] * $city['comm'] / $city['comm2'] * $ratio / 1000) / 3; $tax1 *= (1 + $city['secu']/$city['secu2']/10); //치안에 따라 최대 10% 추가 //도시 관직 추가 세수 @@ -487,7 +486,7 @@ function getRiceIncome($nationNo, $rate, $admin_rate, $type) { $city = MYDB_fetch_array($cityresult); //민충 0~100 : 50~100 수입 - $ratio = $city['rate'] / 2 + 50; + $ratio = $city['trust'] / 2 + 50; $tax1 = ($city['pop'] * $city['agri'] / $city['agri2'] * $ratio / 1000) / 3; $tax2 = $city['def'] * $city['wall'] / $city['wall2'] / 3; $tax1 *= (1 + $city['secu']/$city['secu2']/10); //치안에 따라 최대 10% 추가 @@ -706,7 +705,7 @@ function disaster() { $ratio = 15 * $disasterratio[$i]; $ratio = (80 + $ratio) / 100.0; // 치안률 따라서 80~95% - $query = "update city set state='$state',pop=pop*{$ratio},rate=rate*{$ratio},agri=agri*{$ratio},comm=comm*{$ratio},secu=secu*{$ratio},def=def*{$ratio},wall=wall*{$ratio} where city='$disastercity[$i]'"; + $query = "update city set state='$state',pop=pop*{$ratio},trust=trust*{$ratio},agri=agri*{$ratio},comm=comm*{$ratio},secu=secu*{$ratio},def=def*{$ratio},wall=wall*{$ratio} where city='$disastercity[$i]'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); SabotageInjury($disastercity[$i], 1); @@ -717,19 +716,19 @@ function disaster() { $ratio = (101 + $ratio) / 100.0; // 치안률 따라서 101~105% $city = getCity($disastercity[$i]); - $city['pop'] *= $ratio; $city['rate'] *= $ratio; $city['agri'] *= $ratio; + $city['pop'] *= $ratio; $city['trust'] *= $ratio; $city['agri'] *= $ratio; $city['comm'] *= $ratio; $city['secu'] *= $ratio; $city['def'] *= $ratio; $city['wall'] *= $ratio; if($city['pop'] > $city['pop2']) { $city['pop'] = $city['pop2']; } - if($city['rate'] > 100) { $city['rate'] = 100; } + if($city['trust'] > 100) { $city['trust'] = 100; } if($city['agri'] > $city['agri2']) { $city['agri'] = $city['agri2']; } if($city['comm'] > $city['comm2']) { $city['comm'] = $city['comm2']; } if($city['secu'] > $city['secu2']) { $city['secu'] = $city['secu2']; } if($city['def'] > $city['def2']) { $city['def'] = $city['def2']; } if($city['wall'] > $city['wall2']) { $city['wall'] = $city['wall2']; } - $query = "update city set state='$state',pop='{$city['pop']}',rate='{$city['rate']}',agri='{$city['agri']}',comm='{$city['comm']}',secu='{$city['secu']}',def='{$city['def']}',wall='{$city['wall']}' where city='$disastercity[$i]'"; + $query = "update city set state='$state',pop='{$city['pop']}',trust='{$city['trust']}',agri='{$city['agri']}',comm='{$city['comm']}',secu='{$city['secu']}',def='{$city['def']}',wall='{$city['wall']}' where city='$disastercity[$i]'"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); } } diff --git a/hwe/j_simulate_battle.php b/hwe/j_simulate_battle.php index 059130d3..bf532bbe 100644 --- a/hwe/j_simulate_battle.php +++ b/hwe/j_simulate_battle.php @@ -152,12 +152,12 @@ $cityCheck = [ 'required'=>[ 'city', 'nation', 'supply', 'name', 'pop', 'agri', 'comm', 'secu', 'def', 'wall', - 'rate', 'level', + 'trust', 'level', 'pop2', 'agri2', 'comm2', 'secu2', 'def2', 'wall2', 'dead', 'state', 'gen1', 'gen2', 'gen3', 'conflict', ], 'numeric'=>[ - 'pop', 'agri', 'comm', 'secu', 'def', 'wall', 'rate', 'dead' + 'pop', 'agri', 'comm', 'secu', 'def', 'wall', 'trust', 'dead' ], 'integer'=>[ 'city', 'nation', 'supply', @@ -167,7 +167,7 @@ $cityCheck = [ 'min'=>[ ['def', 0], ['wall', 0], - ['rate', 0], + ['trust', 0], ['pop', 0], ['comm', 0], ['secu', 0], diff --git a/hwe/js/battle_simulator.js b/hwe/js/battle_simulator.js index 5791ba9c..0169d561 100644 --- a/hwe/js/battle_simulator.js +++ b/hwe/js/battle_simulator.js @@ -596,7 +596,7 @@ jQuery(function($){ def:1000, wall:1000, - rate:100, + trust:100, pop2:600000, agri2:12000, diff --git a/hwe/sammo/CityConstBase.php b/hwe/sammo/CityConstBase.php index 742f5a19..5b6005cf 100644 --- a/hwe/sammo/CityConstBase.php +++ b/hwe/sammo/CityConstBase.php @@ -240,7 +240,7 @@ class CityConstBase{ } protected static $buildInitCommon = [ - 'rate'=>50, + 'trust'=>50, 'trade'=>100, 'gen1'=>0, 'gen2'=>0, diff --git a/hwe/sammo/Event/Action/ChangeCity.php b/hwe/sammo/Event/Action/ChangeCity.php index 13e09af8..b69275a3 100644 --- a/hwe/sammo/Event/Action/ChangeCity.php +++ b/hwe/sammo/Event/Action/ChangeCity.php @@ -10,7 +10,7 @@ class ChangeCity extends \sammo\Event\Action{ 'agri'=>true, 'comm'=>true, 'secu'=>true, - 'rate'=>true, + 'trust'=>true, 'def'=>true, 'wall'=>true ]; @@ -49,8 +49,8 @@ class ChangeCity extends \sammo\Event\Action{ throw new \InvalidArgumentException('int, float, string이어야 합니다.'); } - if($key == 'rate'){ - $queries['rate'] = $this->genSQLRate($value); + if($key == 'trust'){ + $queries['trust'] = $this->genSQLTrust($value); continue; } @@ -60,13 +60,13 @@ class ChangeCity extends \sammo\Event\Action{ $this->queries = $queries; } - private function genSQLRate($value){ + private function genSQLTrust($value){ //민심은 max값이 100으로 고정이므로 처리 방식이 다름. if(is_float($value)){ if($value < 0){ throw new \InvalidArgumentException('음수를 곱할 수 없습니다.'); } - return DB::db()->sqleval('least(100, ROUND(`rate` * %d, 0))', $value); + return DB::db()->sqleval('least(100, `trust` * %d)', $value); } if(is_int($value)){ return DB::db()->sqleval('%i', Util::valueFit($value, 0, 100)); @@ -84,7 +84,7 @@ class ChangeCity extends \sammo\Event\Action{ if($op == '/' && $value == 0){ throw new \InvalidArgumentException('0으로 나눌 수 없습니다.'); } - return DB::db()->sqleval('least(100, greatest(0, ROUND(`rate` %l %d, 0)))', $op, $value); + return DB::db()->sqleval('least(100, greatest(0, `trust` %l %d, 0)))', $op, $value); } throw new \InvalidArgumentException('알 수 없는 패턴입니다.'); diff --git a/hwe/scenario/scenario_1010.json b/hwe/scenario/scenario_1010.json index 833e6379..c1e1e220 100644 --- a/hwe/scenario/scenario_1010.json +++ b/hwe/scenario/scenario_1010.json @@ -710,14 +710,14 @@ "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80 + "trust":80 }], ["ChangeCity", "occupied", { "pop":"70%", "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80, + "trust":80, "def":"70%", "wall":"70%" }] diff --git a/hwe/scenario/scenario_1020.json b/hwe/scenario/scenario_1020.json index 16b3738a..8a163f97 100644 --- a/hwe/scenario/scenario_1020.json +++ b/hwe/scenario/scenario_1020.json @@ -856,14 +856,14 @@ "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80 + "trust":80 }], ["ChangeCity", "occupied", { "pop":"70%", "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80, + "trust":80, "def":"70%", "wall":"70%" }] diff --git a/hwe/scenario/scenario_1030.json b/hwe/scenario/scenario_1030.json index 31beb5f2..09dde46d 100644 --- a/hwe/scenario/scenario_1030.json +++ b/hwe/scenario/scenario_1030.json @@ -781,14 +781,14 @@ "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80 + "trust":80 }], ["ChangeCity", "occupied", { "pop":"70%", "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80, + "trust":80, "def":"70%", "wall":"70%" }] diff --git a/hwe/scenario/scenario_1040.json b/hwe/scenario/scenario_1040.json index 8408fc18..ae8de94f 100644 --- a/hwe/scenario/scenario_1040.json +++ b/hwe/scenario/scenario_1040.json @@ -758,14 +758,14 @@ "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80 + "trust":80 }], ["ChangeCity", "occupied", { "pop":"70%", "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80, + "trust":80, "def":"70%", "wall":"70%" }] diff --git a/hwe/scenario/scenario_1050.json b/hwe/scenario/scenario_1050.json index 184d7670..57648539 100644 --- a/hwe/scenario/scenario_1050.json +++ b/hwe/scenario/scenario_1050.json @@ -733,14 +733,14 @@ "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80 + "trust":80 }], ["ChangeCity", "occupied", { "pop":"70%", "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80, + "trust":80, "def":"70%", "wall":"70%" }] diff --git a/hwe/scenario/scenario_1060.json b/hwe/scenario/scenario_1060.json index b65c9645..a622cda2 100644 --- a/hwe/scenario/scenario_1060.json +++ b/hwe/scenario/scenario_1060.json @@ -739,14 +739,14 @@ "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80 + "trust":80 }], ["ChangeCity", "occupied", { "pop":"70%", "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80, + "trust":80, "def":"70%", "wall":"70%" }] diff --git a/hwe/scenario/scenario_1070.json b/hwe/scenario/scenario_1070.json index 4d074e28..599e0f33 100644 --- a/hwe/scenario/scenario_1070.json +++ b/hwe/scenario/scenario_1070.json @@ -746,14 +746,14 @@ "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80 + "trust":80 }], ["ChangeCity", "occupied", { "pop":"70%", "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80, + "trust":80, "def":"70%", "wall":"70%" }] diff --git a/hwe/scenario/scenario_1080.json b/hwe/scenario/scenario_1080.json index 3d5ce369..697d5697 100644 --- a/hwe/scenario/scenario_1080.json +++ b/hwe/scenario/scenario_1080.json @@ -732,14 +732,14 @@ "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80 + "trust":80 }], ["ChangeCity", "occupied", { "pop":"70%", "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80, + "trust":80, "def":"70%", "wall":"70%" }] diff --git a/hwe/scenario/scenario_1090.json b/hwe/scenario/scenario_1090.json index 8bee3452..65e9d5b1 100644 --- a/hwe/scenario/scenario_1090.json +++ b/hwe/scenario/scenario_1090.json @@ -724,14 +724,14 @@ "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80 + "trust":80 }], ["ChangeCity", "occupied", { "pop":"70%", "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80, + "trust":80, "def":"70%", "wall":"70%" }] diff --git a/hwe/scenario/scenario_1100.json b/hwe/scenario/scenario_1100.json index beac190b..9f171f70 100644 --- a/hwe/scenario/scenario_1100.json +++ b/hwe/scenario/scenario_1100.json @@ -727,14 +727,14 @@ "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80 + "trust":80 }], ["ChangeCity", "occupied", { "pop":"70%", "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80, + "trust":80, "def":"70%", "wall":"70%" }] diff --git a/hwe/scenario/scenario_1110.json b/hwe/scenario/scenario_1110.json index 46b5072b..f2dd1ad0 100644 --- a/hwe/scenario/scenario_1110.json +++ b/hwe/scenario/scenario_1110.json @@ -724,14 +724,14 @@ "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80 + "trust":80 }], ["ChangeCity", "occupied", { "pop":"70%", "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80, + "trust":80, "def":"70%", "wall":"70%" }] diff --git a/hwe/scenario/scenario_1120.json b/hwe/scenario/scenario_1120.json index e5d99440..b7752870 100644 --- a/hwe/scenario/scenario_1120.json +++ b/hwe/scenario/scenario_1120.json @@ -746,14 +746,14 @@ "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80 + "trust":80 }], ["ChangeCity", "occupied", { "pop":"70%", "agri":"70%", "comm":"70%", "secu":"70%", - "rate":80, + "trust":80, "def":"70%", "wall":"70%" }] diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index c63f32ff..f921dc2f 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -457,7 +457,7 @@ create table city ( comm2 int(5) default 0, secu int(5) default 0, secu2 int(5) default 0, - rate int(3) default 0, + trust float default 0, trade int(3) default 100, dead int(7) default 0, def int(5) default 0,