도시의 민심을 int에서 float으로 변경하고 명칭을 rate에서 trust로 변경

This commit is contained in:
2018-09-02 16:03:04 +09:00
parent 34a84c6548
commit a093b0f8e8
27 changed files with 130 additions and 114 deletions
+1 -1
View File
@@ -249,7 +249,7 @@ for($i=0; $i < $nationCount; $i++) {
<td align=center>&nbsp;{$nation['dex40']}&nbsp;</td>
<td align=center>&nbsp;{$gen['crew']}/{$gen['leader']}00&nbsp;</td>
<td align=center>&nbsp;{$city['pop']}/{$city['pop2']}&nbsp;</td>
<td align=center>&nbsp;{$city['rate']}%&nbsp;</td>
<td align=center>&nbsp;".round($city['trust'],1)."%&nbsp;</td>
<td align=center>&nbsp;{$city['agri']}%&nbsp;</td>
<td align=center>&nbsp;{$city['comm']}%&nbsp;</td>
<td align=center>&nbsp;{$city['secu']}%&nbsp;</td>
+1 -1
View File
@@ -399,7 +399,7 @@ foreach($generalsFormat as $general){
</tr>
<tr>
<td align=center class=bg1>민심</td>
<td align=center><?=$city['rate']?></td>
<td align=center><?=round($city['trust'], 1)?></td>
<td align=center class=bg1>시세</td>
<td align=center><?=$city['trade']?>%</td>
<td align=center class=bg1>인구</td>
+2 -2
View File
@@ -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++) {
</tr>
<tr>
<td align=center id=bg1>민심</td>
<td align=center>{$city['rate']}</td>
<td align=center>".round($city['trust'], 1)."</td>
<td align=center id=bg1>시세</td>
<td align=center>{$city['trade']}%</td>
<td align=center id=bg1>인구</td>
+3 -3
View File
@@ -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() {
<td rowspan=2 style='text-align:center;' class='bg1'><b>주민</b></td>
<td height=7 colspan=3>".bar($pop)."</td>
<td rowspan=2 style='text-align:center;' class='bg1'><b>민심</b></td>
<td height=7>".bar($rate)."</td>
<td height=7>".bar($trust)."</td>
<td rowspan=2 style='text-align:center;' class='bg1'><b>태수</b></td>
<td rowspan=2 style='text-align:center;'>{$gen1['name']}</td>
</tr>
<tr>
<td colspan=3 style='text-align:center;'>{$city['pop']}/{$city['pop2']}</td>
<td style='text-align:center;'>{$city['rate']}</td>
<td style='text-align:center;'>".round($city['trust'], 1)."</td>
</tr>
<tr>
<td width=50 rowspan=2 style='text-align:center;' class='bg1'><b>농업</b></td>
+6 -6
View File
@@ -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),"");
//국가 삭제
+7 -7
View File
@@ -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); }// 팜
+52 -35
View File
@@ -1,6 +1,8 @@
<?php
namespace sammo;
use Constraint\Constraint;
/**
* 장수의 통솔을 받아옴
*
@@ -195,29 +197,45 @@ function process_1(array $general, int $type){
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
[$startYear, $year, $month, $develCost] = $gameStor->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[] = "<C>●</>{$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[] = "<C>●</>{$admin['month']}월:고립된 도시입니다. 주민 선정 실패. <1>$date</>";
} elseif($general['rice'] < $admin['develcost']*2) {
$log[] = "<C>●</>{$admin['month']}월:군량이 모자랍니다. 주민 선정 실패. <1>$date</>";
} elseif($city['rate'] >= 100) {
} elseif($city['trust'] >= 100) {
$log[] = "<C>●</>{$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[] = "<C>●</>{$admin['month']}월:선정을 <span class='ev_failed'>실패</span>하여 민심이 <C>$score</> 상승했습니다. <1>$date</>";
$log[] = "<C>●</>{$admin['month']}월:선정을 <span class='ev_failed'>실패</span>하여 민심이 <C>".round($score, 1)."</> 상승했습니다. <1>$date</>";
} elseif($r['succ'] + $r['fail'] > $rd) {
$score = CriticalScore($score, 0);
$log[] = "<C>●</>{$admin['month']}월:선정을 <S>성공</>하여 민심이 <C>$score</> 상승했습니다. <1>$date</>";
$log[] = "<C>●</>{$admin['month']}월:선정을 <S>성공</>하여 민심이 <C>".round($score, 1)."</> 상승했습니다. <1>$date</>";
} else {
$score = Util::round($score);
$log[] = "<C>●</>{$admin['month']}월:민심이 <C>$score</> 상승했습니다. <1>$date</>";
$log[] = "<C>●</>{$admin['month']}월:민심이 <C>".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[] = "<C>●</>{$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[] = "<C>●</>{$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[] = "<C>●</>{$admin['month']}월:누군가가 <G><b>{$city['name']}</b></>{$josaUl} 살피는 것 같습니다.";
$log[] = "<C>●</>{$admin['month']}월:<G><b>{$city['name']}</b></>의 소문만 들을 수 있었습니다. <1>$date</>";
$log[] = "【<G>{$city['name']}</>】주민:{$city['pop']}, 민심:{$city['rate']}, 장수:$gencount, 병력:$crew";
$log[] = "【<G>{$city['name']}</>】주민:{$city['pop']}, 민심:".round($city['trust'], 1).", 장수:$gencount, 병력:$crew";
} elseif($dist[$destination] == 2) {
$josaUl = JosaUtil::pick($city['name'], '을');
$alllog[] = "<C>●</>{$admin['month']}월:누군가가 <G><b>{$city['name']}</b></>{$josaUl} 살피는 것 같습니다.";
$log[] = "<C>●</>{$admin['month']}월:<G><b>{$city['name']}</b></>의 어느정도 정보를 얻었습니다. <1>$date</>";
$log[] = "【<M>첩보</>】농업:{$city['agri']}, 상업:{$city['comm']}, 치안:{$city['secu']}, 수비:{$city['def']}, 성벽:{$city['wall']}";
$log[] = "【<G>{$city['name']}</>】주민:{$city['pop']}, 민심:{$city['rate']}, 장수:$gencount, 병력:$crew";
$log[] = "【<G>{$city['name']}</>】주민:{$city['pop']}, 민심:".round($city['trust'], 1).", 장수:$gencount, 병력:$crew";
} else {
$josaUl = JosaUtil::pick($city['name'], '을');
$alllog[] = "<C>●</>{$admin['month']}월:누군가가 <G><b>{$city['name']}</b></>{$josaUl} 살피는 것 같습니다.";
@@ -1711,7 +1728,7 @@ function process_31(&$general) {
$msg = [];
$log[] = "【<M>첩보</>】농업:{$city['agri']}, 상업:{$city['comm']}, 치안:{$city['secu']}, 수비:{$city['def']}, 성벽:{$city['wall']}";
$log[] = "【<G>{$city['name']}</>】주민:{$city['pop']}, 민심:{$city['rate']}, 장수:$gencount, 병력:$crew";
$log[] = "【<G>{$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']}'";
+1 -1
View File
@@ -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% 삭감
+10 -10
View File
@@ -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("도시의 치안이 <C>{$secuAmount}</>, 민심이 <C>{$rateAmount}</>만큼 감소하고, 장수 <C>{$injuryCount}</>명이 부상 당했습니다.", ActionLogger::PLAIN);
$logger->pushGeneralActionLog("도시의 치안이 <C>{$secuAmount}</>, 민심이 <C>".round($trustAmount, 1)."</>만큼 감소하고, 장수 <C>{$injuryCount}</>명이 부상 당했습니다.", ActionLogger::PLAIN);
$exp = Util::randRangeInt(201, 300);
$exp *= getCharExpMultiplier($general['personal']);
+11 -12
View File
@@ -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),"");
}
}
+3 -3
View File
@@ -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],
+1 -1
View File
@@ -596,7 +596,7 @@ jQuery(function($){
def:1000,
wall:1000,
rate:100,
trust:100,
pop2:600000,
agri2:12000,
+1 -1
View File
@@ -240,7 +240,7 @@ class CityConstBase{
}
protected static $buildInitCommon = [
'rate'=>50,
'trust'=>50,
'trade'=>100,
'gen1'=>0,
'gen2'=>0,
+6 -6
View File
@@ -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('알 수 없는 패턴입니다.');
+2 -2
View File
@@ -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%"
}]
+2 -2
View File
@@ -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%"
}]
+2 -2
View File
@@ -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%"
}]
+2 -2
View File
@@ -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%"
}]
+2 -2
View File
@@ -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%"
}]
+2 -2
View File
@@ -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%"
}]
+2 -2
View File
@@ -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%"
}]
+2 -2
View File
@@ -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%"
}]
+2 -2
View File
@@ -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%"
}]
+2 -2
View File
@@ -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%"
}]
+2 -2
View File
@@ -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%"
}]
+2 -2
View File
@@ -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%"
}]
+1 -1
View File
@@ -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,