func_time_event 재작성, 수입관련 코드 수정
This commit is contained in:
@@ -65,12 +65,6 @@ $admin = getAdmin();
|
|||||||
<td width=110 align=right>최대 국가</td>
|
<td width=110 align=right>최대 국가</td>
|
||||||
<td width=285><input type=text size=3 maxlength=2 style=color:white;background-color:black;text-align:right; name=maxnation value=<?=$admin['maxnation']?>><input type=submit name=btn value=변경3></td>
|
<td width=285><input type=text size=3 maxlength=2 style=color:white;background-color:black;text-align:right; name=maxnation value=<?=$admin['maxnation']?>><input type=submit name=btn value=변경3></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td width=110 align=right></td>
|
|
||||||
<td width=285></td>
|
|
||||||
<td width=110 align=right>현재 수입률</td>
|
|
||||||
<td width=285><?=$admin['gold_rate']?>%</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td width=110 align=right>시작 년도</td>
|
<td width=110 align=right>시작 년도</td>
|
||||||
<td width=285><input type=text size=3 maxlength=3 style=color:white;background-color:black;text-align:right; name=startyear value='<?=$admin['startyear']?>'><input type=submit name=btn value=변경4></td>
|
<td width=285><input type=text size=3 maxlength=3 style=color:white;background-color:black;text-align:right; name=startyear value='<?=$admin['startyear']?>'><input type=submit name=btn value=변경4></td>
|
||||||
|
|||||||
+74
-96
@@ -15,7 +15,8 @@ increaseRefresh("내무부", 1);
|
|||||||
|
|
||||||
$me = $db->queryFirstRow('SELECT no, nation, level, con, turntime, belong, permission, penalty FROM general WHERE owner=%i', $userID);
|
$me = $db->queryFirstRow('SELECT no, nation, level, con, turntime, belong, permission, penalty FROM general WHERE owner=%i', $userID);
|
||||||
|
|
||||||
$nation = $db->queryFirstRow('SELECT msg, scoutmsg FROM nation WHERE nation = %i', $me['nation']);
|
$nationID = $me['nation'];
|
||||||
|
$nation = $db->queryFirstRow('SELECT nation,name,color,type,gold,rice,bill,rate,scout,war,secretlimit,msg,scoutmsg FROM nation WHERE nation = %i', $nationID);
|
||||||
|
|
||||||
$con = checkLimit($me['con']);
|
$con = checkLimit($me['con']);
|
||||||
if ($con >= 2) {
|
if ($con >= 2) {
|
||||||
@@ -89,111 +90,88 @@ var scoutmsg = <?=Json::encode($nation['scoutmsg']??'')?>;
|
|||||||
<?php
|
<?php
|
||||||
$admin = $gameStor->getValues(['year','month']);
|
$admin = $gameStor->getValues(['year','month']);
|
||||||
|
|
||||||
$query = "select nation,name,color,power,gennum from nation order by power desc";
|
$cityCntList = Util::convertPairArrayToDict($db->queryAllLists('SELECT nation, count(city) FROM city GROUP BY nation'));
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
|
$dipStateList = Util::convertArrayToDict($db->query('SELECT you,state,term FROM diplomacy WHERE me = %i', $nationID), 'you');
|
||||||
$nationcount = MYDB_num_rows($result);
|
|
||||||
for ($i=0; $i < $nationcount; $i++) {
|
|
||||||
$nation = MYDB_fetch_array($result);
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach(getAllNationStaticInfo() as $staticNation):
|
||||||
//속령수
|
//속령수
|
||||||
$citycount = $db->queryFirstField('SELECT count(city) FROM city WHERE nation=%i', $nation['nation']);
|
$staticNationID = $staticNation['nation'];
|
||||||
|
$cityCnt = $cityCntList[$staticNation['nation']];
|
||||||
|
|
||||||
// 아국표시
|
$dipStateText = '-';
|
||||||
if ($nation['nation'] == $me['nation']) {
|
$dipTermText = '-';
|
||||||
echo "
|
$dipEndDateText = '-';
|
||||||
<tr>
|
if($staticNationID !== $nationID){
|
||||||
<td align=center style=color:".newColor($nation['color']).";background-color:{$nation['color']};>{$nation['name']}</td>
|
$diplomacyState = $dipStateList[$staticNationID];
|
||||||
<td align=center>{$nation['power']}</td>
|
|
||||||
<td align=center>{$nation['gennum']}</td>
|
|
||||||
<td align=center>$citycount</td>
|
|
||||||
<td align=center>-</td>
|
|
||||||
<td align=center>-</td>
|
|
||||||
<td align=center>-</td>
|
|
||||||
</tr>";
|
|
||||||
|
|
||||||
continue;
|
$dipStateText = [
|
||||||
|
0 => "<font color=red>교 전</font>",
|
||||||
|
1 => "<font color=magenta>선포중</font>",
|
||||||
|
2 => "통 상",
|
||||||
|
3 => "<font color=cyan>통합수락중</font>",
|
||||||
|
4 => "<font color=cyan>통합제의중</font>",
|
||||||
|
5 => "<font color=cyan>합병수락중</font>",
|
||||||
|
6 => "<font color=cyan>합병제의중</font>",
|
||||||
|
7 => "<font color=green>불가침</font>",
|
||||||
|
][$diplomacyState['state']];
|
||||||
|
|
||||||
|
if($diplomacyState['term']){
|
||||||
|
$dipEndMonth = $admin['month'] + $diplomacyState['term'] - 1;
|
||||||
|
$dipEndYear = $admin['year'] + intdiv($dipEndMonth, 12);
|
||||||
|
$dipEndMonth = $dipEndMonth % 12 + 1;
|
||||||
|
|
||||||
|
$dipTermText = $diplomacyState['term'].'개월';
|
||||||
|
$dipEndDateText = "{$dipEndYear}年 {$dipEndMonth}月";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
$dip = $db->queryFirstRow('SELECT state,term FROM diplomacy WHERE me = %i AND you = %i', $me['nation'], $nation['nation']);
|
<tr>
|
||||||
|
<td class='center' style='color:<?=newColor($staticNation['color'])?>;background-color:<?=$staticNation['color']?>'><?=$staticNation['name']?></td>
|
||||||
|
<td class='center'><?=$staticNation['power']?></td>
|
||||||
switch ($dip['state']) {
|
<td class='center'><?=$staticNation['gennum']?></td>
|
||||||
case 0: $state = "<font color=red>교 전</font>"; break;
|
<td class='center'><?=$cityCnt?></td>
|
||||||
case 1: $state = "<font color=magenta>선포중</font>"; break;
|
<td class='center'><?=$dipStateText?></td>
|
||||||
case 2: $state = "통 상"; break;
|
<td class='center'><?=$dipTermText?></td>
|
||||||
case 3: $state = "<font color=cyan>통합수락중</font>"; break;
|
<td class='center'><?=$dipEndDateText?></td>
|
||||||
case 4: $state = "<font color=cyan>통합제의중</font>"; break;
|
</tr>
|
||||||
case 5: $state = "<font color=cyan>합병수락중</font>"; break;
|
<?php endforeach; ?>
|
||||||
case 6: $state = "<font color=cyan>합병제의중</font>"; break;
|
|
||||||
case 7: $state = "<font color=green>불가침</font>"; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$term = $admin['year'] * 12 + $admin['month'] + $dip['term'];
|
|
||||||
$year = intdiv($term, 12);
|
|
||||||
$month = $term % 12;
|
|
||||||
|
|
||||||
if ($month == 0) {
|
|
||||||
$month = 12;
|
|
||||||
$year--;
|
|
||||||
}
|
|
||||||
|
|
||||||
$date = TimeUtil::now();
|
|
||||||
|
|
||||||
echo "
|
|
||||||
<tr>
|
|
||||||
<td align=center style=color:".newColor($nation['color']).";background-color:{$nation['color']};>{$nation['name']}</td>
|
|
||||||
<td align=center>{$nation['power']}</td>
|
|
||||||
<td align=center>{$nation['gennum']}</td>
|
|
||||||
<td align=center>$citycount</td>
|
|
||||||
<td align=center>$state</td>";
|
|
||||||
if ($dip['term'] != 0) {
|
|
||||||
echo"
|
|
||||||
<td align=center>{$dip['term']} 개월</td>
|
|
||||||
<td align=center>{$year}年 {$month}月</td>";
|
|
||||||
} else {
|
|
||||||
echo"
|
|
||||||
<td align=center>-</td>
|
|
||||||
<td align=center>-</td>";
|
|
||||||
}
|
|
||||||
echo "</tr>";
|
|
||||||
}
|
|
||||||
echo "
|
|
||||||
</table>
|
</table>
|
||||||
";
|
|
||||||
|
|
||||||
$query = "select nation,name,color,type,gold,rice,bill,rate,scout,war,secretlimit from nation where nation='{$me['nation']}'";
|
<?php
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
|
// 수입 연산
|
||||||
$nation = MYDB_fetch_array($result);
|
$cityList = $db->query('SELECT * FROM city WHERE nation=%i', $nationID);
|
||||||
|
$dedicationList = $db->query('SELECT dedication FROM general WHERE nation=%i AND npc!=5', $nationID);
|
||||||
|
|
||||||
$admin = $gameStor->getValues(['gold_rate','rice_rate']);
|
$goldIncome = getGoldIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||||
// 금 수지
|
$warIncome = getWarGoldIncome($nation['type'], $cityList);
|
||||||
$deadIncome = getDeadIncome($nation['nation'], $nation['type'], $admin['gold_rate']);
|
$totalGoldIncome = $goldIncome + $warIncome;
|
||||||
|
|
||||||
$goldincomeList = getGoldIncome($nation['nation'], $nation['rate'], $admin['gold_rate'], $nation['type']);
|
$riceIncome = getRiceIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||||
$goldincome = $goldincomeList[0] + $goldincomeList[1] + $deadIncome;
|
$wallIncome = getWallIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||||
$goldoutcome = getGoldOutcome($nation['nation'], $nation['bill']);
|
$totalRiceIncome = $riceIncome + $wallIncome;
|
||||||
$riceincomeList = getRiceIncome($nation['nation'], $nation['rate'], $admin['rice_rate'], $nation['type']);
|
|
||||||
$riceincome = $riceincomeList[0] + $riceincomeList[1];
|
|
||||||
$riceoutcome = getRiceOutcome($nation['nation'], $nation['bill']);
|
|
||||||
|
|
||||||
|
$outcome = getOutcome($nation['bill'], $dedicationList);
|
||||||
|
|
||||||
|
$budgetgold = $nation['gold'] + $totalGoldIncome - $outcome;
|
||||||
|
$budgetrice = $nation['rice'] + $totalRiceIncome - $outcome;
|
||||||
|
$budgetgolddiff = $totalGoldIncome - $outcome;
|
||||||
|
$budgetricediff = $totalRiceIncome - $outcome;
|
||||||
|
|
||||||
$budgetgold = $nation['gold'] + $goldincome - $goldoutcome + $deadIncome;
|
|
||||||
$budgetrice = $nation['rice'] + $riceincome - $riceoutcome;
|
|
||||||
$budgetgolddiff = $goldincome - $goldoutcome + $deadIncome;
|
|
||||||
$budgetricediff = $riceincome - $riceoutcome;
|
|
||||||
if ($budgetgolddiff > 0) {
|
if ($budgetgolddiff > 0) {
|
||||||
$budgetgolddiff = "+{$budgetgolddiff}";
|
$budgetgolddiff = '+'.number_format($budgetgolddiff);
|
||||||
} else {
|
} else {
|
||||||
$budgetgolddiff = "$budgetgolddiff";
|
$budgetgolddiff = number_format($budgetgolddiff);
|
||||||
}
|
}
|
||||||
if ($budgetricediff > 0) {
|
if ($budgetricediff > 0) {
|
||||||
$budgetricediff = "+{$budgetricediff}";
|
$budgetricediff = '+'.number_format($budgetricediff);
|
||||||
} else {
|
} else {
|
||||||
$budgetricediff = "$budgetricediff";
|
$budgetricediff = number_format($budgetricediff);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<table align=center width=1000 class='tb_layout bg0'>
|
<table width=1000 class='tb_layout bg0 center'>
|
||||||
<form name=form1 method=post action=c_dipcenter.php>
|
<form name=form1 method=post action=c_dipcenter.php>
|
||||||
<tr><td colspan=2 height=10></td></tr>
|
<tr><td colspan=2 height=10></td></tr>
|
||||||
<tr><td colspan=2 align=center bgcolor=orange>국 가 방 침 & 임관 권유 메시지</td></tr>
|
<tr><td colspan=2 align=center bgcolor=orange>국 가 방 침 & 임관 권유 메시지</td></tr>
|
||||||
@@ -236,33 +214,33 @@ if ($budgetricediff > 0) {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width=248 align=right class=bg1>현 재 </td>
|
<td width=248 align=right class=bg1>현 재 </td>
|
||||||
<td width=248 align=center><?=$nation['gold']?></td>
|
<td width=248 align=center><?=number_format($nation['gold'])?></td>
|
||||||
<td width=248 align=right class=bg1>현 재 </td>
|
<td width=248 align=right class=bg1>현 재 </td>
|
||||||
<td width=248 align=center><?=$nation['rice']?></td>
|
<td width=248 align=center><?=number_format($nation['rice'])?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align=right class=bg1>단기수입 </td>
|
<td align=right class=bg1>단기수입 </td>
|
||||||
<td align=center>+<?=$deadIncome?></td>
|
<td align=center>+<?=number_format($warIncome)?></td>
|
||||||
<td align=right class=bg1>둔전수입 </td>
|
<td align=right class=bg1>둔전수입 </td>
|
||||||
<td align=center>+<?=$riceincomeList[1]?></td>
|
<td align=center>+<?=number_format($wallIncome)?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align=right class=bg1>세 금 </td>
|
<td align=right class=bg1>세 금 </td>
|
||||||
<td align=center>+<?=$goldincomeList[0]?></td>
|
<td align=center>+<?=number_format($goldIncome)?></td>
|
||||||
<td align=right class=bg1>세 곡 </td>
|
<td align=right class=bg1>세 곡 </td>
|
||||||
<td align=center>+<?=$riceincomeList[0]?></td>
|
<td align=center>+<?=number_format($riceIncome)?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align=right class=bg1>수입 / 지출 </td>
|
<td align=right class=bg1>수입 / 지출 </td>
|
||||||
<td align=center>+<?=$goldincome?> / -<?=$goldoutcome?></td>
|
<td align=center>+<?=number_format($totalGoldIncome)?> / -<?=number_format($outcome)?></td>
|
||||||
<td align=right class=bg1>수입 / 지출 </td>
|
<td align=right class=bg1>수입 / 지출 </td>
|
||||||
<td align=center>+<?=$riceincome?> / -<?=$riceoutcome?></td>
|
<td align=center>+<?=number_format($totalRiceIncome)?> / -<?=number_format($outcome)?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align=right class=bg1>국고 예산 </td>
|
<td align=right class=bg1>국고 예산 </td>
|
||||||
<td align=center><?=$budgetgold?> (<?=$budgetgolddiff?>)</td>
|
<td align=center><?=number_format($budgetgold)?> (<?=$budgetgolddiff?>)</td>
|
||||||
<td align=right class=bg1>병량 예산 </td>
|
<td align=right class=bg1>병량 예산 </td>
|
||||||
<td align=center><?=$budgetrice?> (<?=$budgetricediff?>)</td>
|
<td align=center><?=number_format($budgetrice)?> (<?=$budgetricediff?>)</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align=right class=bg1>세율 (5 ~ 30%) </td>
|
<td align=right class=bg1>세율 (5 ~ 30%) </td>
|
||||||
|
|||||||
+62
-71
@@ -9,15 +9,12 @@ $userID = Session::getUserID();
|
|||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$connect=$db->get();
|
|
||||||
|
|
||||||
increaseRefresh("세력정보", 1);
|
increaseRefresh("세력정보", 1);
|
||||||
|
|
||||||
$query = "select no,nation,level from general where owner='{$userID}'";
|
$nationID = $db->queryFirstField('SELECT nation FROM general WHERE owner=%i', $userID);
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$me = MYDB_fetch_array($result);
|
|
||||||
|
|
||||||
if($me['level'] == 0) {
|
if($nationID == 0) {
|
||||||
echo "재야입니다.";
|
echo "재야입니다.";
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
@@ -45,121 +42,115 @@ if($me['level'] == 0) {
|
|||||||
</table>
|
</table>
|
||||||
<br>
|
<br>
|
||||||
<?php
|
<?php
|
||||||
$query = "select nation from general where owner='{$userID}'";
|
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$me = MYDB_fetch_array($result);
|
|
||||||
|
|
||||||
$query = "select nation,gennum,power,rate,bill,type,gold,rice,color,name,level,tech,history,capital from nation where nation='{$me['nation']}'";
|
$nation = $db->queryFirstRow('SELECT nation,gennum,power,rate,bill,type,gold,rice,color,name,level,tech,history,capital FROM nation WHERE natoin=%i', $nationID); //국가정보
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
$cityList = $db->query('SELECT * FROM city WHERE nation=%i', $nationID);
|
||||||
$nation = MYDB_fetch_array($result); //국가정보
|
|
||||||
|
|
||||||
$query = "select city,name,pop,pop2 from city where nation='{$nation['nation']}'"; // 도시 이름 목록
|
$currPop = 0;
|
||||||
$cityresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
$maxPop = 0;
|
||||||
$citycount = MYDB_num_rows($cityresult);
|
$cityNames = [];
|
||||||
|
|
||||||
$totalpop = 0;
|
foreach($cityList as $city){
|
||||||
$maxpop = 0;
|
$currPop += $city['pop'];
|
||||||
$cityname = [];
|
$maxPop += $city['pop2'];
|
||||||
for($j=0; $j < $citycount; $j++) {
|
if($city['city'] == $nation['capital']){
|
||||||
$city = MYDB_fetch_array($cityresult);
|
$cityNames[] = "<span style='color:cyan;'>{$city['name']}</span>";
|
||||||
if($city['city'] == $nation['capital']) { $cityname[$j] = "<font color=cyan>[{$city['name']}]</font>"; }
|
}
|
||||||
else { $cityname[$j] = $city['name']; }
|
else{
|
||||||
$totalpop += $city['pop'];
|
$cityNames[] = $city['name'];
|
||||||
$maxpop += $city['pop2'];
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = "select sum(crew) as totcrew,sum(leadership)*100 as maxcrew from general where nation='{$nation['nation']}'";
|
[$currCrew, $maxCrew] = $db->queryFirstList('SELECT sum(crew), sum(leadership)*100 FROM general WHERE nation=%i AND npc != 5', $nation['nation']);
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
$dedicationList = $db->query('SELECT dedication FROM general WHERE nation=%i AND npc!=5', $nationID);
|
||||||
$general = MYDB_fetch_array($result);
|
|
||||||
|
|
||||||
$admin = $gameStor->getValues(['gold_rate','rice_rate']);
|
$goldIncome = getGoldIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||||
// 금 수지
|
$warIncome = getWarGoldIncome($nation['type'], $cityList);
|
||||||
$deadIncome = getDeadIncome($nation['nation'], $nation['type'], $admin['gold_rate']);
|
$totalGoldIncome = $goldIncome + $warIncome;
|
||||||
|
|
||||||
$goldincomeList = getGoldIncome($nation['nation'], $nation['rate'], $admin['gold_rate'], $nation['type']);
|
$riceIncome = getRiceIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||||
$goldincome = $goldincomeList[0] + $goldincomeList[1] + $deadIncome;
|
$wallIncome = getWallIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||||
$goldoutcome = getGoldOutcome($nation['nation'], $nation['bill']);
|
$totalRiceIncome = $riceIncome + $wallIncome;
|
||||||
$riceincomeList = getRiceIncome($nation['nation'], $nation['rate'], $admin['rice_rate'], $nation['type']);
|
|
||||||
$riceincome = $riceincomeList[0] + $riceincomeList[1];
|
|
||||||
$riceoutcome = getRiceOutcome($nation['nation'], $nation['bill']);
|
|
||||||
|
|
||||||
|
$outcome = getOutcome($nation['bill'], $dedicationList);
|
||||||
|
|
||||||
$budgetgold = $nation['gold'] + $goldincome - $goldoutcome + $deadIncome;
|
$budgetgold = $nation['gold'] + $totalGoldIncome - $outcome;
|
||||||
$budgetrice = $nation['rice'] + $riceincome - $riceoutcome;
|
$budgetrice = $nation['rice'] + $totalRiceIncome - $outcome;
|
||||||
$budgetgolddiff = $goldincome - $goldoutcome + $deadIncome;
|
$budgetgolddiff = $totalGoldIncome - $outcome;
|
||||||
$budgetricediff = $riceincome - $riceoutcome;
|
$budgetricediff = $totalRiceIncome - $outcome;
|
||||||
if($budgetgolddiff > 0) { $budgetgolddiff = "+{$budgetgolddiff}"; }
|
|
||||||
else { $budgetgolddiff = "$budgetgolddiff"; }
|
|
||||||
if($budgetricediff > 0) { $budgetricediff = "+{$budgetricediff}"; }
|
|
||||||
else { $budgetricediff = "$budgetricediff"; }
|
|
||||||
|
|
||||||
|
if ($budgetgolddiff > 0) {
|
||||||
|
$budgetgolddiff = '+'.number_format($budgetgolddiff);
|
||||||
|
} else {
|
||||||
|
$budgetgolddiff = number_format($budgetgolddiff);
|
||||||
|
}
|
||||||
|
if ($budgetricediff > 0) {
|
||||||
|
$budgetricediff = '+'.number_format($budgetricediff);
|
||||||
|
} else {
|
||||||
|
$budgetricediff = number_format($budgetricediff);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
echo "
|
echo "
|
||||||
<table align=center width=1000 class='tb_layout bg2'>
|
<table align=center width=1000 class='tb_layout bg2'>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan=8 align=center style=color:".newColor($nation['color'])."; bgcolor={$nation['color']}>【 ";echo $me['nation']==0?"공 백 지":"{$nation['name']}";echo " 】</td>
|
<td colspan=8 align=center style='color:<?=newColor($nation['color'])?>; bgcolor=<?=$nation['color']?>'>【<?=$nation['name']?>】</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width=98 align=center id=bg1>총주민</td>
|
<td width=98 align=center id=bg1>총주민</td>
|
||||||
<td width=198 align=center>{$totalpop}/{$maxpop}</td>
|
<td width=198 align=center><?=number_format($currPop)?>/<?=number_format($maxPop)?></td>
|
||||||
<td width=98 align=center id=bg1>총병사</td>
|
<td width=98 align=center id=bg1>총병사</td>
|
||||||
<td width=198 align=center>{$general['totcrew']}/{$general['maxcrew']}</td>
|
<td width=198 align=center><?=number_format($currCrew)?>/<?=number_format($maxCrew)?></td>
|
||||||
<td width=98 align=center id=bg1>국 력</td>
|
<td width=98 align=center id=bg1>국 력</td>
|
||||||
<td width=298 align=center colspan=3>{$nation['power']}</td>
|
<td width=298 align=center colspan=3><?=$nation['power']?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align=center id=bg1>국 고</td>
|
<td align=center id=bg1>국 고</td>
|
||||||
<td align=center>"; echo $nation['gold']==0?"-":"{$nation['gold']}"; echo "</td>
|
<td align=center><?=number_format($nation['gold'])?></td>
|
||||||
<td align=center id=bg1>병 량</td>
|
<td align=center id=bg1>병 량</td>
|
||||||
<td align=center>"; echo $nation['rice']==0?"-":"{$nation['rice']}"; echo "</td>
|
<td align=center><?=number_format($nation['rice'])?></td>
|
||||||
<td align=center id=bg1>세 율</td>
|
<td align=center id=bg1>세 율</td>
|
||||||
<td align=center colspan=3>"; echo $me['nation']==0?"해당 없음":"{$nation['rate']} %"; echo "</td>
|
<td align=center colspan=3><?=$nation['rate']?> %</td>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align=center id=bg1>세금/단기</td>
|
<td align=center id=bg1>세금/단기</td>
|
||||||
<td align=center>+$goldincomeList[0] / +$deadIncome</td>
|
<td align=center>+<?=number_format($goldIncome)?> / +<?=number_format($warIncome)?></td>
|
||||||
<td align=center id=bg1>세곡/둔전</td>
|
<td align=center id=bg1>세곡/둔전</td>
|
||||||
<td align=center>+$riceincomeList[0] / +$riceincomeList[1]</td>
|
<td align=center>+<?=number_format($$riceIncome)?> / +<?=number_format($$wallIncome)?></td>
|
||||||
<td align=center id=bg1>지급률</td>
|
<td align=center id=bg1>지급률</td>
|
||||||
<td align=center colspan=3>"; echo $me['nation']==0?"해당 없음":"{$nation['bill']} %"; echo "</td>
|
<td align=center colspan=3><?=$nation['bill']?> %</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align=center id=bg1>수입/지출</td>
|
<td align=center id=bg1>수입/지출</td>
|
||||||
<td align=center>+$goldincome / -$goldoutcome</td>
|
<td align=center>+<?=number_format($totalGoldIncome)?> / -<?=number_format($outcome)?></td>
|
||||||
<td align=center id=bg1>수입/지출</td>
|
<td align=center id=bg1>수입/지출</td>
|
||||||
<td align=center>+$riceincome / -$riceoutcome</td>
|
<td align=center>+<?=number_format($totalRiceIncome)?> / -<?=number_format($outcome)?></td>
|
||||||
<td align=center id=bg1>속 령</td>
|
<td align=center id=bg1>속 령</td>
|
||||||
<td width=98 align=center>$citycount</td>
|
<td width=98 align=center><?=count($cityList)?></td>
|
||||||
<td width=98 align=center id=bg1>장 수</td>
|
<td width=98 align=center id=bg1>장 수</td>
|
||||||
<td width=98 align=center>{$nation['gennum']}</td>
|
<td width=98 align=center><?=$nation['gennum']?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align=center id=bg1>국고 예산</td>
|
<td align=center id=bg1>국고 예산</td>
|
||||||
<td align=center>{$budgetgold} ({$budgetgolddiff})</td>
|
<td align=center><?=number_format($budgetgold)?> (<?=$budgetgolddiff?>)</td>
|
||||||
<td align=center id=bg1>병량 예산</td>
|
<td align=center id=bg1>병량 예산</td>
|
||||||
<td align=center>{$budgetrice} ({$budgetricediff})</td>
|
<td align=center><?=number_format($budgetrice)?> (<?=$budgetricediff?>)</td>
|
||||||
<td align=center id=bg1>기술력</td>
|
<td align=center id=bg1>기술력</td>
|
||||||
<td align=center>".floor($nation['tech'])."</td>
|
<td align=center><?=number_format(floor($nation['tech']))?></td>
|
||||||
<td align=center id=bg1>작 위</td>
|
<td align=center id=bg1>작 위</td>
|
||||||
<td align=center>".getNationLevel($nation['level'])."</td>
|
<td align=center><?=getNationLevel($nation['level'])?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align=center valign=top id=bg1> 속령일람 :</td>
|
<td align=center valign=top id=bg1> 속령일람 :</td>
|
||||||
<td colspan=7>";
|
<td colspan=7><?=join(', ', $cityNames)?></td>
|
||||||
for($j=0; $j < $citycount; $j++) {
|
|
||||||
echo "$cityname[$j], ";
|
|
||||||
}
|
|
||||||
echo"
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align=center valign=top id=bg1>국가열전</td>
|
<td align=center valign=top id=bg1>국가열전</td>
|
||||||
<td colspan=7 id=bg0>".ConvertLog($nation['history'])."</td>
|
<td colspan=7 id=bg0><?=ConvertLog($nation['history'])?></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<br>";
|
<br>
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<table align=center width=1000 class='tb_layout bg0'>
|
<table align=center width=1000 class='tb_layout bg0'>
|
||||||
<tr><td><?=backButton()?></td></tr>
|
<tr><td><?=backButton()?></td></tr>
|
||||||
|
|||||||
+3
-43
@@ -1784,14 +1784,10 @@ function isNeighbor(int $nation1, int $nation2, bool $includeNoSupply=true) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SabotageInjuryEx(array $cityGeneralList, bool $isSabotage):int{
|
function SabotageInjury(array $cityGeneralList, string $reason):int{
|
||||||
$injuryCount = 0;
|
$injuryCount = 0;
|
||||||
if($isSabotage){
|
$josaRo = JosaUtil::pick($reason, '로');
|
||||||
$text = '<M>계략</>으로 인해 <R>부상</>을 당했습니다.';
|
$text = "<M>{$reason}</>{$josaRo} 인해 <R>부상</>을 당했습니다.";
|
||||||
}
|
|
||||||
else{
|
|
||||||
$text = '<M>재난</>으로 인해 <R>부상</>을 당했습니다.';
|
|
||||||
}
|
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
@@ -1815,42 +1811,6 @@ function SabotageInjuryEx(array $cityGeneralList, bool $isSabotage):int{
|
|||||||
return $injuryCount;
|
return $injuryCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SabotageInjury($city, $type=0) {
|
|
||||||
$db = DB::db();
|
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
|
||||||
$connect=$db->get();
|
|
||||||
$log = [];
|
|
||||||
|
|
||||||
$injuryCount = 0;
|
|
||||||
|
|
||||||
$admin = $gameStor->getValues(['year', 'month']);
|
|
||||||
|
|
||||||
$query = "select no,name,nation from general where city='$city'";
|
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$gencount = MYDB_num_rows($result);
|
|
||||||
if($type == 0) {
|
|
||||||
$log[0] = "<C>●</>{$admin['month']}월:<M>계략</>으로 인해 <R>부상</>을 당했습니다.";
|
|
||||||
} else {
|
|
||||||
$log[0] = "<C>●</>{$admin['month']}월:<M>재난</>으로 인해 <R>부상</>을 당했습니다.";
|
|
||||||
}
|
|
||||||
for($i=0; $i < $gencount; $i++) {
|
|
||||||
$general = MYDB_fetch_array($result);
|
|
||||||
|
|
||||||
$injury = rand() % 100;
|
|
||||||
if($injury < 30) { // 부상률 30%
|
|
||||||
$injury = intdiv($injury, 2) + 1; // 부상 1~16
|
|
||||||
|
|
||||||
$query = "update general set crew=crew*0.98,atmos=atmos*0.98,train=train*0.98,injury=injury+'$injury' where no='{$general['no']}'";
|
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
|
|
||||||
pushGenLog($general, $log);
|
|
||||||
$injuryCount += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $injuryCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getRandTurn($term, ?\DateTimeInterface $baseDateTime = null) {
|
function getRandTurn($term, ?\DateTimeInterface $baseDateTime = null) {
|
||||||
if($baseDateTime === null){
|
if($baseDateTime === null){
|
||||||
$baseDateTime = new \DateTimeImmutable();
|
$baseDateTime = new \DateTimeImmutable();
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ function preUpdateMonthly() {
|
|||||||
$gameStor->develcost = $develcost;
|
$gameStor->develcost = $develcost;
|
||||||
|
|
||||||
//매달 사망자 수입 결산
|
//매달 사망자 수입 결산
|
||||||
processDeadIncome($ratio);
|
processWarIncome($ratio);
|
||||||
|
|
||||||
//계략, 전쟁표시 해제
|
//계략, 전쟁표시 해제
|
||||||
$query = "update city set state=0 where state=31 or state=33";
|
$query = "update city set state=0 where state=31 or state=33";
|
||||||
|
|||||||
+398
-503
@@ -9,7 +9,6 @@ namespace sammo;
|
|||||||
function processSpring() {
|
function processSpring() {
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$connect=$db->get();
|
|
||||||
|
|
||||||
//인구 증가
|
//인구 증가
|
||||||
popIncrease();
|
popIncrease();
|
||||||
@@ -41,24 +40,25 @@ function processSpring() {
|
|||||||
|
|
||||||
function processGoldIncome() {
|
function processGoldIncome() {
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$connect=$db->get();
|
|
||||||
$gameStor = new KVStorage($db, 'game_env');
|
$gameStor = new KVStorage($db, 'game_env');
|
||||||
|
|
||||||
$admin = $gameStor->getValues(['year','month','gold_rate']);
|
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
|
||||||
$adminLog = [];
|
$adminLog = [];
|
||||||
|
|
||||||
$query = "select name,nation,gold,rate_tmp,bill,type from nation";
|
|
||||||
$nationresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
$nationList = $db->query('SELECT name,nation,capital,gold,rate_tmp,bill,type from nation');
|
||||||
$nationcount = MYDB_num_rows($nationresult);
|
$cityListByNation = Util::arrayGroupBy($db->query('SELECT * FROM city'), 'nation');
|
||||||
|
$generalRawListByNation = Util::arrayGroupBy($db->query('SELECT no,name,nation,gold,level,dedication,city FROM general'), 'nation');
|
||||||
|
|
||||||
//국가별 처리
|
//국가별 처리
|
||||||
for($i=0; $i < $nationcount; $i++) {
|
foreach($nationList as $nation) {
|
||||||
$nation = MYDB_fetch_array($nationresult);
|
$nationID = $nation['nation'];
|
||||||
|
|
||||||
|
$generalRawList = $generalRawListByNation[$nationID];
|
||||||
|
$income = getGoldIncome($nation['level'], $nation['type'], $nation['rate_tmp'], $nation['capital'], $cityListByNation[$nationID]);
|
||||||
|
$originoutcome = getOutcome(100, $generalRawList);
|
||||||
|
$outcome= Util::round($nation['bill'] / 100 * $originoutcome);
|
||||||
|
|
||||||
$incomeList = getGoldIncome($nation['nation'], $nation['rate_tmp'], $admin['gold_rate'], $nation['type']);
|
|
||||||
$income = $incomeList[0] + $incomeList[1];
|
|
||||||
$originoutcome = getGoldOutcome($nation['nation'], 100); // 100%의 지급량
|
|
||||||
$outcome = Util::round($originoutcome * $nation['bill'] / 100); // 지급량에 따른 요구량
|
|
||||||
// 실제 지급량 계산
|
// 실제 지급량 계산
|
||||||
$nation['gold'] += $income;
|
$nation['gold'] += $income;
|
||||||
// 기본량도 안될경우
|
// 기본량도 안될경우
|
||||||
@@ -85,297 +85,254 @@ function processGoldIncome() {
|
|||||||
." // 지급률 : ".tab2((string)round($ratio*100,2),5," ")
|
." // 지급률 : ".tab2((string)round($ratio*100,2),5," ")
|
||||||
." % // 결과금 : ".tab2((string)$nation['gold'],6," ");
|
." % // 결과금 : ".tab2((string)$nation['gold'],6," ");
|
||||||
|
|
||||||
$query = "select no,name,nation from general where nation='{$nation['nation']}' and level>='9'";
|
$incomeLog = "<C>●</>이번 수입은 금 <C>$income</>입니다.";
|
||||||
$coreresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$corecount = MYDB_num_rows($coreresult);
|
|
||||||
$corelog = ["<C>●</>이번 수입은 금 <C>$income</>입니다."];
|
|
||||||
for($j=0; $j < $corecount; $j++) {
|
|
||||||
$coregen = MYDB_fetch_array($coreresult);
|
|
||||||
pushGenLog($coregen, $corelog);
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = "update nation set gold='{$nation['gold']}' where nation='{$nation['nation']}'";
|
$db->update('nation', [
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
'gold'=>$nation['gold']
|
||||||
|
], 'nation=%i', $nationID);
|
||||||
$query = "select no,name,nation,dedication,gold from general where nation='{$nation['nation']}' AND npc != 5";
|
|
||||||
$genresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$gencount = MYDB_num_rows($genresult);
|
|
||||||
|
|
||||||
// 각 장수들에게 지급
|
// 각 장수들에게 지급
|
||||||
for($j=0; $j < $gencount; $j++) {
|
foreach ($generalRawList as $rawGeneral) {
|
||||||
$general = MYDB_fetch_array($genresult);
|
$generalObj = new General($rawGeneral, null, $year, $month, false);
|
||||||
$gold = Util::round(getBill($general['dedication'])*$ratio);
|
$gold = Util::round(getBill($generalObj->getVar('dedication'))*$ratio);
|
||||||
$general['gold'] += $gold;
|
$generalObj->increaseVar('gold', $gold);
|
||||||
|
|
||||||
$query = "update general set gold='{$general['gold']}' where no='{$general['no']}'";
|
$logger = $generalObj->getLogger();
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
if($generalObj->getVar('level') > 4){
|
||||||
|
$logger->pushGeneralActionLog($incomeLog, $logger::PLAIN);
|
||||||
pushGenLog($general, ["<C>●</>봉급으로 금 <C>$gold</>을 받았습니다."]);
|
}
|
||||||
|
$logger->pushGeneralActionLog("봉급으로 금 <C>$gold</>을 받았습니다.", $logger::PLAIN);
|
||||||
|
$generalObj->applyDB($db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pushWorldHistory(["<C>●</>{$admin['year']}년 {$admin['month']}월:<W><b>【지급】</b></>봄이 되어 봉록에 따라 자금이 지급됩니다."], $admin['year'], $admin['month']);
|
$logger = new ActionLogger(0, 0, $year, $month);
|
||||||
|
$logger->pushGlobalHistoryLog('<W><b>【지급】</b></>봄이 되어 봉록에 따라 자금이 지급됩니다.');
|
||||||
|
$logger->flush();
|
||||||
|
|
||||||
pushAdminLog($adminLog);
|
pushAdminLog($adminLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
function popIncrease() {
|
function popIncrease() {
|
||||||
$db = DB::db();
|
$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);
|
|
||||||
|
|
||||||
for($i=0; $i < $nationcount; $i++) {
|
|
||||||
$nation = MYDB_fetch_array($nationresult);
|
|
||||||
$rate[$nation['nation']] = $nation['rate_tmp'];
|
|
||||||
$type[$nation['nation']] = $nation['type'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = "select * from city where supply='1'"; // 도시 목록
|
|
||||||
$cityresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$citycount = MYDB_num_rows($cityresult);
|
|
||||||
|
|
||||||
// 인구 및 민심
|
|
||||||
for($i=0; $i < $citycount; $i++) {
|
|
||||||
$city = MYDB_fetch_array($cityresult);
|
|
||||||
|
|
||||||
$pop = $city['pop'];
|
|
||||||
if($city['nation'] == 0) {
|
|
||||||
$pop = $city['pop']; // 공백지는 증가하지 않게
|
|
||||||
$citytrust = 50;
|
|
||||||
|
|
||||||
$ratio = 0.99; // 공백지는 수비 빼고 약간씩 감소
|
|
||||||
$agri = intval($city['agri'] * $ratio);
|
|
||||||
$comm = intval($city['comm'] * $ratio);
|
|
||||||
$secu = intval($city['secu'] * $ratio);
|
|
||||||
$def = $city['def'];
|
|
||||||
$wall = $city['wall'];
|
|
||||||
} else {
|
|
||||||
$ratio = (20 - $rate[$city['nation']])/200; // 20일때 0% 0일때 10% 100일때 -40%
|
|
||||||
$agri = $city['agri'] + intval($city['agri'] * $ratio); //내정도 증감
|
|
||||||
$comm = $city['comm'] + intval($city['comm'] * $ratio);
|
|
||||||
$secu = $city['secu'] + intval($city['secu'] * $ratio);
|
|
||||||
$def = $city['def'] + intval($city['def'] * $ratio);
|
|
||||||
$wall = $city['wall'] + intval($city['wall'] * $ratio);
|
|
||||||
$ratio = (30 - $rate[$city['nation']])/200; // 20일때 5% 5일때 12.5% 50일때 -10%
|
|
||||||
if($ratio >= 0) {
|
|
||||||
// 국가보정
|
|
||||||
if($type[$city['nation']] == 4 || $type[$city['nation']] == 6 || $type[$city['nation']] == 7 || $type[$city['nation']] == 8 || $type[$city['nation']] == 12 || $type[$city['nation']] == 13) { $ratio *= 1.2; }
|
|
||||||
if($type[$city['nation']] == 1 || $type[$city['nation']] == 3) { $ratio *= 0.8; }
|
|
||||||
$ratio *= (1 + $city['secu']/$city['secu2']/10); //치안에 따라 최대 10% 추가
|
|
||||||
} else {
|
|
||||||
// 국가보정
|
|
||||||
if($type[$city['nation']] == 4 || $type[$city['nation']] == 6 || $type[$city['nation']] == 7 || $type[$city['nation']] == 8 || $type[$city['nation']] == 12 || $type[$city['nation']] == 13) { $ratio *= 0.8; }
|
|
||||||
if($type[$city['nation']] == 1 || $type[$city['nation']] == 3) { $ratio *= 1.2; }
|
|
||||||
$ratio *= (1 - $city['secu']/$city['secu2']/10); //치안에 따라 최대 10% 경감
|
|
||||||
}
|
|
||||||
|
|
||||||
$pop = $city['pop'] + (int)($city['pop'] * $ratio) + 5000; // 기본 5000명은 증가
|
|
||||||
|
|
||||||
$ratio = round($ratio*100, 2);
|
|
||||||
$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; }
|
|
||||||
if($agri > $city['agri2']) { $agri = $city['agri2']; }
|
|
||||||
if($comm > $city['comm2']) { $comm = $city['comm2']; }
|
|
||||||
if($secu > $city['secu2']) { $secu = $city['secu2']; }
|
|
||||||
if($def > $city['def2']) { $def= $city['def2']; }
|
|
||||||
if($wall > $city['wall2']) { $wall = $city['wall2']; }
|
|
||||||
|
|
||||||
//시세
|
|
||||||
$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),"");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getGoldIncome($nationNo, $rate, $admin_rate, $type) {
|
|
||||||
$db = DB::db();
|
|
||||||
$connect=$db->get();
|
|
||||||
|
|
||||||
$level2 = [];
|
|
||||||
$level3 = [];
|
|
||||||
$level4 = [];
|
|
||||||
|
|
||||||
|
$nationList = $db->queryAllLists('SELECT nation,rate_tmp,type FROM nation');
|
||||||
|
|
||||||
|
// 인구 및 민심
|
||||||
|
|
||||||
$query = "select no,city from general where nation='$nationNo' and level=4"; // 태수
|
$db->update('city', [
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
'trust'=>50,
|
||||||
$count = MYDB_num_rows($result);
|
'agri'=>$db->sqleval('agri * 0.99'),
|
||||||
for($j=0; $j < $count; $j++) {
|
'comm'=>$db->sqleval('comm * 0.99'),
|
||||||
$gen = MYDB_fetch_array($result);
|
'secu'=>$db->sqleval('secu * 0.99'),
|
||||||
$level4[$gen['no']] = $gen['city'];
|
'def'=>$db->sqleval('def * 0.99'),
|
||||||
|
'wall'=>$db->sqleval('wall * 0.99'),
|
||||||
|
], 'nation=0');
|
||||||
|
|
||||||
|
foreach($nationList as [$nationID, $taxRate, $nationType]){
|
||||||
|
$nationTypeObj = buildNationTypeClass($nationType);
|
||||||
|
|
||||||
|
|
||||||
|
$popRatio = (30 - $taxRate)/200; // 20일때 5% 5일때 12.5% 50일때 -10%
|
||||||
|
$popRatio = $nationTypeObj->onCalcNationalIncome('pop', $popRatio);
|
||||||
|
|
||||||
|
$updateVar = [];
|
||||||
|
if($popRatio >= 0){
|
||||||
|
$updateVar['pop'] = $db->sqleval('least(pop2, %i + pop * (1 + %d * (1 + secu / secu2 / 10)))', 5000, $popRatio);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$updateVar['pop'] = $db->sqleval('least(pop2, %i + pop * (1 + %d * (1 - secu / secu2 / 10)))', 5000, $popRatio);
|
||||||
|
}
|
||||||
|
|
||||||
|
$genericRatio = (20 - $taxRate) / 200; // 20일때 0% 0일때 10% 100일때 -40%
|
||||||
|
foreach(['agri', 'comm', 'secu', 'def', 'wall'] as $key){
|
||||||
|
$updateVar[$key] = $db->sqleval('least(%b, %b * (1 + %d))', $key.'2', $key, $genericRatio);
|
||||||
|
}
|
||||||
|
|
||||||
|
$trustDiff = 20 - $taxRate;
|
||||||
|
$updateVar['trust'] = $db->sqleval('greatest(0, least(100, trust + %i))', $trustDiff);
|
||||||
|
|
||||||
|
$db->update('city', $updateVar, 'nation = %i AND supply = 1', $nationID);
|
||||||
}
|
}
|
||||||
$query = "select no,city from general where nation='$nationNo' and level=3"; // 군사
|
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$count = MYDB_num_rows($result);
|
|
||||||
for($j=0; $j < $count; $j++) {
|
|
||||||
$gen = MYDB_fetch_array($result);
|
|
||||||
$level3[$gen['no']] = $gen['city'];
|
|
||||||
}
|
|
||||||
$query = "select no,city from general where nation='$nationNo' and level=2"; // 종사
|
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$count = MYDB_num_rows($result);
|
|
||||||
for($j=0; $j < $count; $j++) {
|
|
||||||
$gen = MYDB_fetch_array($result);
|
|
||||||
$level2[$gen['no']] = $gen['city'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$nation = getNationStaticInfo($nationNo);
|
|
||||||
|
|
||||||
$query = "select * from city where nation='$nationNo' and supply='1'"; // 도시 목록
|
|
||||||
$cityresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$citycount = MYDB_num_rows($cityresult);
|
|
||||||
|
|
||||||
//총 수입 구함
|
|
||||||
$income = [0, 0]; // income[0] : 세수, income[1] : 수비병 세수
|
|
||||||
for($j=0; $j < $citycount; $j++) {
|
|
||||||
$city = MYDB_fetch_array($cityresult);
|
|
||||||
|
|
||||||
//민충 0~100 : 50~100 수입
|
|
||||||
$ratio = $city['trust'] / 2 + 50;
|
|
||||||
$tax1 = ($city['pop'] * $city['comm'] / $city['comm2'] * $ratio / 1000) / 3;
|
|
||||||
$tax1 *= (1 + $city['secu']/$city['secu2']/10); //치안에 따라 최대 10% 추가
|
|
||||||
//도시 관직 추가 세수
|
|
||||||
if(Util::array_get($level4[$city['officer4']]) == $city['city']) { $tax1 *= 1.05; }
|
|
||||||
if(Util::array_get($level3[$city['officer3']]) == $city['city']) { $tax1 *= 1.05; }
|
|
||||||
if(Util::array_get($level2[$city['officer2']]) == $city['city']) { $tax1 *= 1.05; }
|
|
||||||
//수도 추가 세수 130%~105%
|
|
||||||
if($city['city'] == $nation['capital']) { $tax1 *= 1+(1/3/$nation['level']); };
|
|
||||||
|
|
||||||
$income[0] += $tax1;
|
|
||||||
}
|
|
||||||
$income[0] *= ($rate / 20);
|
|
||||||
|
|
||||||
// 국가보정
|
|
||||||
if($type == 1) { $income[0] *= 1.1; $income[1] *= 1.1; }
|
|
||||||
if($type == 9 || $type == 10 || $type == 11) { $income[0] *= 0.9; $income[1] *= 0.9; }
|
|
||||||
|
|
||||||
$income[0] = Util::round($income[0] * ($admin_rate/100));
|
|
||||||
$income[1] = Util::round($income[1] * ($admin_rate/100));
|
|
||||||
|
|
||||||
return $income;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function processDeadIncome($admin_rate) {
|
function calcCityWarGoldIncome(array $rawCity, iAction $nationType):int{
|
||||||
|
if($rawCity['supply'] == 0){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$warIncome = $rawCity['dead'] / 10;
|
||||||
|
$warIncome = Util::round($nationType->onCalcNationalIncome('gold', $warIncome));
|
||||||
|
return $warIncome;
|
||||||
|
}
|
||||||
|
|
||||||
|
function calcCityGoldIncome(array $rawCity, int $officerCnt, bool $isCapital, int $nationLevel, iAction $nationType):int{
|
||||||
|
if($rawCity['supply'] == 0){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$trustRatio = $rawCity['trust'] / 200 + 0.5;//0.5 ~ 1
|
||||||
|
|
||||||
|
$cityIncome = $rawCity['pop'] * $rawCity['comm'] / $rawCity['comm2'] * $trustRatio / 30;
|
||||||
|
$cityIncome *= 1 + $rawCity['secu']/$rawCity['secu2']/10;
|
||||||
|
$cityIncome *= pow(1.05, $officerCnt);
|
||||||
|
if($isCapital){
|
||||||
|
$cityIncome *= 1 + 1/(3*$nationLevel);
|
||||||
|
}
|
||||||
|
$cityIncome = Util::round($nationType->onCalcNationalIncome('gold', $cityIncome));
|
||||||
|
|
||||||
|
return $cityIncome;
|
||||||
|
}
|
||||||
|
|
||||||
|
function calcCityRiceIncome(array $rawCity, int $officerCnt, bool $isCapital, int $nationLevel, iAction $nationType):int{
|
||||||
|
if($rawCity['supply'] == 0){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$trustRatio = $rawCity['trust'] / 200 + 0.5;//0.5 ~ 1
|
||||||
|
|
||||||
|
$cityIncome = $rawCity['pop'] * $rawCity['agri'] / $rawCity['agri'] * $trustRatio / 30;
|
||||||
|
$cityIncome *= 1 + $rawCity['secu']/$rawCity['secu2']/10;
|
||||||
|
$cityIncome *= pow(1.05, $officerCnt);
|
||||||
|
if($isCapital){
|
||||||
|
$cityIncome *= 1 + 1/(3*$nationLevel);
|
||||||
|
}
|
||||||
|
$cityIncome = Util::round($nationType->onCalcNationalIncome('rice', $cityIncome));
|
||||||
|
|
||||||
|
return $cityIncome;
|
||||||
|
}
|
||||||
|
|
||||||
|
function calcCityWallRiceIncome(array $rawCity, int $officerCnt, bool $isCapital, int $nationLevel, iAction $nationType):int{
|
||||||
|
if($rawCity['supply'] == 0){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$wallIncome = $rawCity['def'] * $rawCity['wall'] / $rawCity['wall2'] / 3;
|
||||||
|
$wallIncome *= 1 + $rawCity['secu']/$rawCity['secu2']/10;
|
||||||
|
$wallIncome *= pow(1.05, $officerCnt);
|
||||||
|
if($isCapital){
|
||||||
|
$wallIncome *= 1 + 1/(3*$nationLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
$wallIncome = Util::round($nationType->onCalcNationalIncome('rice', $wallIncome));
|
||||||
|
|
||||||
|
return $wallIncome;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getGoldIncome(int $nationLevel, string $nationType, float $taxRate, int $capitalID, array $cityList){
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$connect=$db->get();
|
|
||||||
|
$officers = [];
|
||||||
|
foreach($db->queryAllLists('SELECT no, city FROM general WHERE nation = %i AND level IN (2,3,4)') as [$genID, $cityID]){
|
||||||
|
$officers[$genID] = $cityID;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nationTypeObj = buildNationTypeClass($nationType);
|
||||||
|
|
||||||
|
$cityIncome = 0;
|
||||||
|
foreach($cityList as $rawCity){
|
||||||
|
$cityID = $rawCity['city'];
|
||||||
|
foreach ([2,3,4] as $officerLevel) {
|
||||||
|
$officerCnt = 0;
|
||||||
|
if($officers[$rawCity['officer'.$officerLevel]] == $cityID){
|
||||||
|
$officerCnt += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$cityIncome += calcCityGoldIncome($rawCity, $officerCnt, $capitalID == $cityID, $nationLevel, $nationTypeObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
$cityIncome *= ($taxRate / 20);
|
||||||
|
|
||||||
|
return $cityIncome;
|
||||||
|
}
|
||||||
|
|
||||||
|
function processWarIncome() {
|
||||||
|
$db = DB::db();
|
||||||
|
|
||||||
|
$cityListByNation = Util::arrayGroupBy($db->query('SELECT * FROM city'), 'nation');
|
||||||
|
|
||||||
foreach(getAllNationStaticInfo() as $nation){
|
foreach(getAllNationStaticInfo() as $nation){
|
||||||
if($nation['level'] <= 0){
|
if($nation['level'] <= 0){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$income = getDeadIncome($nation['nation'], $nation['type'], $admin_rate);
|
$nationID = $nation['nation'];
|
||||||
|
$income = getWarGoldIncome($nation['type'], $cityListByNation[$nationID]);
|
||||||
// 단기수입 금만적용
|
$db->update('nation', [
|
||||||
// $query = "update nation set gold=gold+'$income',rice=rice+'$income' where nation='{$nation['nation']}'";
|
'gold'=>$db->sqleval('gold + %i', $income)
|
||||||
$query = "update nation set gold=gold+'$income' where nation='{$nation['nation']}'";
|
], 'nation=%i', $nationID);
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10%수입, 20%부상병
|
// 10%수입, 20%부상병
|
||||||
$query = "update city set pop=pop+dead*0.2,dead='0'";
|
$db->update('city', [
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
'pop'=>$db->sqleval('pop + dead * %d', 0.2),
|
||||||
|
'dead'=>0
|
||||||
|
], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDeadIncome($nation, $type, $admin_rate) {
|
function getWarGoldIncome(string $nationType, $cityList){
|
||||||
$db = DB::db();
|
$nationTypeObj = buildNationTypeClass($nationType);
|
||||||
$connect=$db->get();
|
|
||||||
|
|
||||||
$query = "select dead from city where nation='$nation' and dead>'0' and supply='1'"; // 도시 목록
|
$cityIncome = 0;
|
||||||
$cityResult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
foreach($cityList as $rawCity){
|
||||||
$cityCount = MYDB_num_rows($cityResult);
|
$cityIncome += calcCityWarGoldIncome($rawCity, $nationTypeObj);
|
||||||
|
|
||||||
$income = 0; // 단기수입
|
|
||||||
if($cityCount > 0) {
|
|
||||||
for($k=0; $k < $cityCount; $k++) {
|
|
||||||
$city = MYDB_fetch_array($cityResult);
|
|
||||||
|
|
||||||
$income += $city['dead'];
|
|
||||||
}
|
|
||||||
$income /= 10;
|
|
||||||
|
|
||||||
// 국가보정
|
|
||||||
if($type == 1) { $income *= 1.1; }
|
|
||||||
if($type == 9 || $type == 10) { $income *= 0.9; }
|
|
||||||
|
|
||||||
$income = Util::round($income * $admin_rate / 100);
|
|
||||||
}
|
|
||||||
return $income;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getGoldOutcome($nation, $bill) {
|
|
||||||
$db = DB::db();
|
|
||||||
$connect=$db->get();
|
|
||||||
|
|
||||||
$query = "select dedication from general where nation='$nation' AND npc != 5"; // 장수 목록
|
|
||||||
$genresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$gencount = MYDB_num_rows($genresult);
|
|
||||||
|
|
||||||
//총 지출 구함
|
|
||||||
$outcome = 0;
|
|
||||||
for($j=0; $j < $gencount; $j++) {
|
|
||||||
$general = MYDB_fetch_array($genresult);
|
|
||||||
$outcome += getBill($general['dedication']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$outcome = Util::round($outcome * $bill / 100);
|
return $cityIncome;
|
||||||
|
|
||||||
return $outcome;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//7월마다 실행
|
//7월마다 실행
|
||||||
function processFall() {
|
function processFall() {
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$connect=$db->get();
|
|
||||||
|
|
||||||
//인구 증가
|
//인구 증가
|
||||||
popIncrease();
|
popIncrease();
|
||||||
|
|
||||||
// 7월엔 무조건 내정 1% 감소
|
// 7월엔 무조건 내정 1% 감소
|
||||||
$query = "update city set dead=0,agri=agri*0.99,comm=comm*0.99,secu=secu*0.99,def=def*0.99,wall=wall*0.99";
|
$db->update('city',[
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
'dead'=>0,
|
||||||
|
'agri'=>$db->sqleval('agri * 0.99'),
|
||||||
|
'comm'=>$db->sqleval('comm * 0.99'),
|
||||||
|
'secu'=>$db->sqleval('secu * 0.99'),
|
||||||
|
'def'=>$db->sqleval('def * 0.99'),
|
||||||
|
'wall'=>$db->sqleval('wall * 0.99'),
|
||||||
|
],true);
|
||||||
|
|
||||||
// 유지비 3%
|
|
||||||
$query = "update general set rice=rice*0.97 where rice>10000";
|
// > 10000 유지비 3%, > 1000 유지비 1%
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
// 유지비 1%
|
// 유지비 1%
|
||||||
$query = "update general set rice=rice*0.99 where rice>1000 and rice<=10000";
|
$db->update('general', [
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
'rice'=>$db->sqleval('IF(rice > 10000, rice * 0.97, rice * 0.99)')
|
||||||
// 유지비 5%
|
], 'rice > 1000');
|
||||||
$query = "update nation set rice=rice*0.95 where rice>100000";
|
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
// > 100000 유지비 5%, > 100000 유지비 3%, > 1000 유지비 1%
|
||||||
// 유지비 3%
|
$db->update('nation', [
|
||||||
$query = "update nation set rice=rice*0.97 where rice>10000 and rice<=100000";
|
'rice'=>$db->sqleval('IF(rice > 100000, rice * 0.95, IF(rice > 10000, rice * 0.97, rice * 0.99))')
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
], 'rice > 1000');
|
||||||
// 유지비 1%
|
|
||||||
$query = "update nation set rice=rice*0.99 where rice>2000 and rice<=10000";
|
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function processRiceIncome() {
|
function processRiceIncome() {
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$connect=$db->get();
|
|
||||||
|
|
||||||
$admin = $gameStor->getValues(['year','month','rice_rate']);
|
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
|
||||||
$adminLog = [];
|
$adminLog = [];
|
||||||
|
|
||||||
$query = "select name,nation,rice,rate_tmp,bill,type from nation";
|
$nationList = $db->query('SELECT name,nation,capital,rice,rate_tmp,bill,type from nation');
|
||||||
$nationresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
$cityListByNation = Util::arrayGroupBy($db->query('SELECT * FROM city'), 'nation');
|
||||||
$nationcount = MYDB_num_rows($nationresult);
|
$generalRawListByNation = Util::arrayGroupBy($db->query('SELECT no,name,nation,rice,level,dedication,city FROM general'), 'nation');
|
||||||
|
|
||||||
//국가별 처리
|
//국가별 처리
|
||||||
for($i=0; $i < $nationcount; $i++) {
|
foreach($nationList as $nation) {
|
||||||
$nation = MYDB_fetch_array($nationresult);
|
$nationID = $nation['nation'];
|
||||||
|
|
||||||
$incomeList = getRiceIncome($nation['nation'], $nation['rate_tmp'], $admin['rice_rate'], $nation['type']);
|
$generalRawList = $generalRawListByNation[$nationID];
|
||||||
$income = $incomeList[0] + $incomeList[1];
|
$income = getRiceIncome($nation['level'], $nation['type'], $nation['rate_tmp'], $nation['capital'], $cityListByNation[$nationID]);
|
||||||
$originoutcome = getRiceOutcome($nation['nation'], 100); // 100%의 지급량
|
$income += getWallIncome($nation['level'], $nation['type'], $nation['rate_tmp'], $nation['capital'], $cityListByNation[$nationID]);
|
||||||
$outcome = Util::round($originoutcome * $nation['bill'] / 100); // 지급량에 따른 요구량
|
$originoutcome = getOutcome(100, $generalRawList);
|
||||||
|
$outcome= Util::round($nation['bill'] / 100 * $originoutcome);
|
||||||
|
|
||||||
// 실제 지급량 계산
|
// 실제 지급량 계산
|
||||||
$nation['rice'] += $income;
|
$nation['rice'] += $income;
|
||||||
@@ -403,123 +360,98 @@ function processRiceIncome() {
|
|||||||
." // 지급률 : ".tab2((string)round($ratio*100,2),5," ")
|
." // 지급률 : ".tab2((string)round($ratio*100,2),5," ")
|
||||||
." % // 결과곡 : ".tab2((string)$nation['rice'],6," ");
|
." % // 결과곡 : ".tab2((string)$nation['rice'],6," ");
|
||||||
|
|
||||||
$query = "select no,name,nation from general where nation='{$nation['nation']}' and level>='9'";
|
$incomeLog = "<C>●</>이번 수입은 쌀 <C>$income</>입니다.";
|
||||||
$coreresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$corecount = MYDB_num_rows($coreresult);
|
|
||||||
$corelog = ["<C>●</>이번 수입은 쌀 <C>$income</>입니다."];
|
|
||||||
for($j=0; $j < $corecount; $j++) {
|
|
||||||
$coregen = MYDB_fetch_array($coreresult);
|
|
||||||
pushGenLog($coregen, $corelog);
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = "update nation set rice='{$nation['rice']}' where nation='{$nation['nation']}'";
|
$db->update('nation', [
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
'rice'=>$nation['rice']
|
||||||
|
], 'nation=%i', $nationID);
|
||||||
$query = "select no,name,nation,dedication,rice from general where nation='{$nation['nation']}' AND npc != 5";
|
|
||||||
$genresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$gencount = MYDB_num_rows($genresult);
|
|
||||||
|
|
||||||
// 각 장수들에게 지급
|
// 각 장수들에게 지급
|
||||||
for($j=0; $j < $gencount; $j++) {
|
foreach ($generalRawList as $rawGeneral) {
|
||||||
$general = MYDB_fetch_array($genresult);
|
$generalObj = new General($rawGeneral, null, $year, $month, false);
|
||||||
$rice = Util::round(getBill($general['dedication'])*$ratio);
|
$rice = Util::round(getBill($generalObj->getVar('dedication'))*$ratio);
|
||||||
$general['rice'] += $rice;
|
$generalObj->increaseVar('rice', $rice);
|
||||||
|
|
||||||
$query = "update general set rice='{$general['rice']}' where no='{$general['no']}'";
|
$logger = $generalObj->getLogger();
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
if($generalObj->getVar('level') > 4){
|
||||||
|
$logger->pushGeneralActionLog($incomeLog, $logger::PLAIN);
|
||||||
pushGenLog($general, ["<C>●</>봉급으로 쌀 <C>$rice</>을 받았습니다."]);
|
}
|
||||||
|
$logger->pushGeneralActionLog("봉급으로 쌀 <C>$rice</>을 받았습니다.", $logger::PLAIN);
|
||||||
|
$generalObj->applyDB($db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pushWorldHistory(["<C>●</>{$admin['year']}년 {$admin['month']}월:<W><b>【지급】</b></>가을이 되어 봉록에 따라 군량이 지급됩니다."], $admin['year'], $admin['month']);
|
$logger = new ActionLogger(0, 0, $year, $month);
|
||||||
|
$logger->pushGlobalHistoryLog('<W><b>【지급】</b></>가을이 되어 봉록에 따라 군량이 지급됩니다.');
|
||||||
|
$logger->flush();
|
||||||
|
|
||||||
pushAdminLog($adminLog);
|
pushAdminLog($adminLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRiceIncome($nationNo, $rate, $admin_rate, $type) {
|
function getRiceIncome(int $nationLevel, string $nationType, float $taxRate, int $capitalID, array $cityList) {
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$connect=$db->get();
|
|
||||||
|
|
||||||
$level2 = [];
|
$officers = [];
|
||||||
$level3 = [];
|
foreach($db->queryAllLists('SELECT no, city FROM general WHERE nation = %i AND level IN (2,3,4)') as [$genID, $cityID]){
|
||||||
$level4 = [];
|
$officers[$genID] = $cityID;
|
||||||
|
|
||||||
$query = "select no,city from general where nation='$nationNo' and level=4"; // 태수
|
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$count = MYDB_num_rows($result);
|
|
||||||
for($j=0; $j < $count; $j++) {
|
|
||||||
$gen = MYDB_fetch_array($result);
|
|
||||||
$level4[$gen['no']] = $gen['city'];
|
|
||||||
}
|
|
||||||
$query = "select no,city from general where nation='$nationNo' and level=3"; // 군사
|
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$count = MYDB_num_rows($result);
|
|
||||||
for($j=0; $j < $count; $j++) {
|
|
||||||
$gen = MYDB_fetch_array($result);
|
|
||||||
$level3[$gen['no']] = $gen['city'];
|
|
||||||
}
|
|
||||||
$query = "select no,city from general where nation='$nationNo' and level=2"; // 종사
|
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$count = MYDB_num_rows($result);
|
|
||||||
for($j=0; $j < $count; $j++) {
|
|
||||||
$gen = MYDB_fetch_array($result);
|
|
||||||
$level2[$gen['no']] = $gen['city'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$nation = getNationStaticInfo($nationNo);
|
$nationTypeObj = buildNationTypeClass($nationType);
|
||||||
|
|
||||||
$query = "select * from city where nation='$nationNo' and supply='1'"; // 도시 목록
|
$cityIncome = 0;
|
||||||
$cityresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
foreach($cityList as $rawCity){
|
||||||
$citycount = MYDB_num_rows($cityresult);
|
$cityID = $rawCity['city'];
|
||||||
|
foreach ([2,3,4] as $officerLevel) {
|
||||||
|
$officerCnt = 0;
|
||||||
|
if($officers[$rawCity['officer'.$officerLevel]] == $cityID){
|
||||||
|
$officerCnt += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//총 수입 구함
|
$cityIncome += calcCityRiceIncome($rawCity, $officerCnt, $capitalID == $cityID, $nationLevel, $nationTypeObj);
|
||||||
$income = [0, 0]; // income[0] : 세수, income[1] : 수비병 세수
|
|
||||||
for($j=0; $j < $citycount; $j++) {
|
|
||||||
$city = MYDB_fetch_array($cityresult);
|
|
||||||
|
|
||||||
//민충 0~100 : 50~100 수입
|
|
||||||
$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% 추가
|
|
||||||
$tax2 *= (1 + $city['secu']/$city['secu2']/10); //치안에 따라 최대 10% 추가
|
|
||||||
//도시 관직 추가 세수
|
|
||||||
if(Util::array_get($level4[$city['officer4']]) == $city['city']) { $tax1 *= 1.05; $tax2 *= 1.05; }
|
|
||||||
if(Util::array_get($level3[$city['officer3']]) == $city['city']) { $tax1 *= 1.05; $tax2 *= 1.05; }
|
|
||||||
if(Util::array_get($level2[$city['officer2']]) == $city['city']) { $tax1 *= 1.05; $tax2 *= 1.05; }
|
|
||||||
//수도 추가 세수 130%~105%
|
|
||||||
if($city['city'] == $nation['capital']) { $tax1 *= 1+(1/3/$nation['level']); $tax2 *= 1+(1/3/$nation['level']); }
|
|
||||||
$income[0] += $tax1;
|
|
||||||
$income[1] += $tax2;
|
|
||||||
}
|
}
|
||||||
$income[0] *= ($rate / 20);
|
|
||||||
|
|
||||||
// 국가보정
|
$cityIncome *= ($taxRate / 20);
|
||||||
if($type == 8) { $income[0] *= 1.1; $income[1] *= 1.1; }
|
|
||||||
if($type == 2 || $type == 4 || $type == 13) { $income[0] *= 0.9; $income[1] *= 0.9; }
|
return $cityIncome;
|
||||||
|
|
||||||
$income[0] = Util::round($income[0] * ($admin_rate/100));
|
|
||||||
$income[1] = Util::round($income[1] * ($admin_rate/100));
|
|
||||||
|
|
||||||
return $income;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRiceOutcome($nation, $bill) {
|
function getWallIncome(int $nationLevel, string $nationType, float $taxRate, int $capitalID, array $cityList) {
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$connect=$db->get();
|
|
||||||
|
|
||||||
$query = "select dedication from general where nation='$nation' AND npc != 5"; // 장수 목록
|
$officers = [];
|
||||||
$genresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
foreach($db->queryAllLists('SELECT no, city FROM general WHERE nation = %i AND level IN (2,3,4)') as [$genID, $cityID]){
|
||||||
$gencount = MYDB_num_rows($genresult);
|
$officers[$genID] = $cityID;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nationTypeObj = buildNationTypeClass($nationType);
|
||||||
|
|
||||||
|
$cityIncome = 0;
|
||||||
|
foreach($cityList as $rawCity){
|
||||||
|
$cityID = $rawCity['city'];
|
||||||
|
foreach ([2,3,4] as $officerLevel) {
|
||||||
|
$officerCnt = 0;
|
||||||
|
if($officers[$rawCity['officer'.$officerLevel]] == $cityID){
|
||||||
|
$officerCnt += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$cityIncome += calcCityWallRiceIncome($rawCity, $officerCnt, $capitalID == $cityID, $nationLevel, $nationTypeObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
$cityIncome *= ($taxRate / 20);
|
||||||
|
|
||||||
|
return $cityIncome;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOutcome(float $billRate, array $generalList) {
|
||||||
//총 지출 구함
|
//총 지출 구함
|
||||||
$outcome = 0;
|
$outcome = 0;
|
||||||
for($j=0; $j < $gencount; $j++) {
|
foreach($generalList as $general){
|
||||||
$general = MYDB_fetch_array($genresult);
|
|
||||||
$outcome += getBill($general['dedication']);
|
$outcome += getBill($general['dedication']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$outcome = Util::round($outcome * $bill / 100);
|
$outcome = Util::round($outcome * $billRate / 100);
|
||||||
|
|
||||||
return $outcome;
|
return $outcome;
|
||||||
}
|
}
|
||||||
@@ -529,18 +461,17 @@ function tradeRate() {
|
|||||||
|
|
||||||
foreach($db->query('SELECT city,level FROM city') as $city){
|
foreach($db->query('SELECT city,level FROM city') as $city){
|
||||||
//시세
|
//시세
|
||||||
switch($city['level']) {
|
$prob = [
|
||||||
case 1: $per = 0; break;
|
1=>0,
|
||||||
case 2: $per = 0; break;
|
2=>0,
|
||||||
case 3: $per = 0; break;
|
3=>0,
|
||||||
case 4: $per = 0.2; break;
|
4=>0.2,
|
||||||
case 5: $per = 0.4; break;
|
5=>0.4,
|
||||||
case 6: $per = 0.6; break;
|
6=>0.6,
|
||||||
case 7: $per = 0.8; break;
|
7=>0.8,
|
||||||
case 8: $per = 1; break;
|
8=>1
|
||||||
default:$per = 0; break;
|
][$city['level']];
|
||||||
}
|
if($prob > 0 && Util::randBool($prob)) {
|
||||||
if($per > 0 && Util::randBool($per)) {
|
|
||||||
$trade = Util::randRangeInt(95, 105);
|
$trade = Util::randRangeInt(95, 105);
|
||||||
} else {
|
} else {
|
||||||
$trade = null;
|
$trade = null;
|
||||||
@@ -554,172 +485,136 @@ function tradeRate() {
|
|||||||
function disaster() {
|
function disaster() {
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$connect=$db->get();
|
|
||||||
|
|
||||||
$admin = $gameStor->getValues(['startyear', 'year', 'month']);
|
[$startYear, $year, $month] = $gameStor->getValuesAsArray(['startyear', 'year', 'month']);
|
||||||
|
|
||||||
//재난표시 초기화
|
//재난표시 초기화
|
||||||
$query = "update city set state=0 where state<=10";
|
$db->update('city',[
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
'state'=>0,
|
||||||
|
], 'state <= 10');
|
||||||
|
|
||||||
// 초반 3년은 스킵
|
// 초반 3년은 스킵
|
||||||
if($admin['startyear'] + 3 > $admin['year']) return;
|
if($startYear + 3 > $year) return;
|
||||||
|
|
||||||
$query = "select city,name,secu,secu2 from city"; // 도시 목록
|
|
||||||
$cityresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$citycount = MYDB_num_rows($cityresult);
|
|
||||||
|
|
||||||
$disastertype = rand() % 4;
|
$boomingRate = [
|
||||||
$isgood = 0;
|
1=>0,
|
||||||
if($admin['month'] == 4 && $disastertype == 3) { $isgood = 1; }
|
4=>0.25,
|
||||||
if($admin['month'] == 7 && $disastertype == 3) { $isgood = 1; }
|
7=>0.25,
|
||||||
|
10=>0
|
||||||
|
];
|
||||||
|
|
||||||
$disastercity = [];
|
$isGood = Util::randBool($boomingRate[$month]);
|
||||||
$disasterratio = [];
|
|
||||||
$disastername = [];
|
|
||||||
|
|
||||||
for($i=0; $i < $citycount; $i++) {
|
|
||||||
$city = MYDB_fetch_array($cityresult);
|
$targetCityList = [];
|
||||||
|
|
||||||
|
foreach($db->query('SELECT city,name,secu,secu2 FROM city') as $city){
|
||||||
//호황 발생 도시 선택 ( 기본 2% )
|
//호황 발생 도시 선택 ( 기본 2% )
|
||||||
//재해 발생 도시 선택 ( 기본 6% )
|
//재해 발생 도시 선택 ( 기본 6% )
|
||||||
if($isgood == 1) { $ratio = 2 + Util::round($city['secu']/$city['secu2']*5); } // 2 ~ 7%
|
if($isGood){
|
||||||
else { $ratio = 6 - Util::round($city['secu']/$city['secu2']*5); } // 1 ~ 6%
|
$raiseProp = 0.02 + ($city['secu'] / $city['secu2']) * 0.05; // 2 ~ 7%
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$raiseProp = 0.06 - ($city['secu'] / $city['secu2']) * 0.05; // 1 ~ 6%
|
||||||
|
}
|
||||||
|
|
||||||
if(rand()%100+1 < $ratio) {
|
if(Util::randBool($raiseProp)) {
|
||||||
$disastercity[] = $city['city'];
|
$targetCityList[] = $city;
|
||||||
$disasterratio[] = Util::valueFit($city['secu'] / 0.8 / $city['secu2'], 0, 1);
|
|
||||||
$disastername[] = $city['name'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$disastername = "<G><b>".join(' ', $disastername)."</b></>";
|
if(!$targetCityList){
|
||||||
$disaster = [];
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//재해 처리
|
$targetCityNames = "<G><b>".join(' ', Util::squeezeFromArray($targetCityList, 'name'))."</b></>";
|
||||||
if(count($disastercity)) {
|
$disasterTextList = [
|
||||||
$state = 0;
|
1 => [
|
||||||
switch($admin['month']) {
|
['재난', 4, '역병이 발생하여 도시가 황폐해지고 있습니다.'],
|
||||||
//봄
|
['재난', 5, '지진으로 피해가 속출하고 있습니다.'],
|
||||||
case 1:
|
['재난', 3, '추위가 풀리지 않아 얼어죽는 백성들이 늘어나고 있습니다.'],
|
||||||
switch($disastertype) {
|
['재난', 9, '황건적이 출현해 도시를 습격하고 있습니다.'],
|
||||||
case 0:
|
],
|
||||||
$disaster[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<M><b>【재난】</b></>{$disastername}에 역병이 발생하여 도시가 황폐해지고 있습니다.";
|
4 => [
|
||||||
$state = 4;
|
['재난', 7, '홍수로 인해 피해가 급증하고 있습니다.'],
|
||||||
break;
|
['재난', 5, '지진으로 피해가 속출하고 있습니다.'],
|
||||||
case 1:
|
['재난', 6, '태풍으로 인해 피해가 속출하고 있습니다.'],
|
||||||
$disaster[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<M><b>【재난】</b></>{$disastername}에 지진으로 피해가 속출하고 있습니다.";
|
],
|
||||||
$state = 5;
|
7 => [
|
||||||
break;
|
['재난', 8, '메뚜기 떼가 발생하여 도시가 황폐해지고 있습니다.'],
|
||||||
case 2:
|
['재난', 5, '지진으로 피해가 속출하고 있습니다.'],
|
||||||
$disaster[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<M><b>【재난】</b></>{$disastername}에 추위가 풀리지 않아 얼어죽는 백성들이 늘어나고 있습니다.";
|
['재난', 8, '흉년이 들어 굶어죽는 백성들이 늘어나고 있습니다.'],
|
||||||
$state = 3;
|
],
|
||||||
break;
|
10 => [
|
||||||
case 3:
|
['재난', 3, '혹한으로 도시가 황폐해지고 있습니다.'],
|
||||||
$disaster[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<M><b>【재난】</b></>{$disastername}에 황건적이 출현해 도시를 습격하고 있습니다.";
|
['재난', 5, '지진으로 피해가 속출하고 있습니다.'],
|
||||||
$state = 9;
|
['재난', 3, '눈이 많이 쌓여 도시가 황폐해지고 있습니다.'],
|
||||||
break;
|
['재난', 9, '황건적이 출현해 도시를 습격하고 있습니다.'],
|
||||||
}
|
]
|
||||||
break;
|
];
|
||||||
//여름
|
|
||||||
case 4:
|
$boomingTextList = [
|
||||||
switch($disastertype) {
|
1 => null,
|
||||||
case 0:
|
4 => [
|
||||||
$disaster[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<M><b>【재난】</b></>{$disastername}에 홍수로 인해 피해가 급증하고 있습니다.";
|
['호황', 2, '호황으로 도시가 번창하고 있습니다.'],
|
||||||
$state = 7;
|
],
|
||||||
break;
|
7 => [
|
||||||
case 1:
|
['풍작', 1, '풍작으로 도시가 번창하고 있습니다.'],
|
||||||
$disaster[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<M><b>【재난】</b></>{$disastername}에 지진으로 피해가 속출하고 있습니다.";
|
],
|
||||||
$state = 5;
|
10 => null
|
||||||
break;
|
];
|
||||||
case 2:
|
|
||||||
$disaster[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<M><b>【재난】</b></>{$disastername}에 태풍으로 인해 피해가 속출하고 있습니다.";
|
[$logTitle, $stateCode, $logBody] = Util::choiceRandom(($isGood?$boomingTextList:$disasterTextList)[$month]);
|
||||||
$state = 6;
|
|
||||||
break;
|
$logger = new ActionLogger(0, 0, $year, $month, false);
|
||||||
case 3:
|
|
||||||
$disaster[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【호황】</b></>{$disastername}에 호황으로 도시가 번창하고 있습니다.";
|
$logger->pushGlobalHistoryLog("<M><b>【{$logTitle}】</b></>{$targetCityNames}에 {$logBody}");
|
||||||
$state = 2;
|
$logger->flush();
|
||||||
$isGood = 1;
|
|
||||||
break;
|
if ($isGood) {
|
||||||
}
|
//NOTE: 쿼리 1번이지만 복잡하기 vs 쿼리 여러번이지만 조금 더 깔끔하기
|
||||||
break;
|
foreach ($targetCityList as $city) {
|
||||||
//가을
|
$affectRatio = Util::valueFit($city['secu'] / $city['secu2'] / 0.8, 0, 1);
|
||||||
case 7:
|
$affectRatio = 0.8 + $affectRatio * 0.15;
|
||||||
switch($disastertype) {
|
|
||||||
case 0:
|
$db->update('city', [
|
||||||
$disaster[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<M><b>【재난】</b></>{$disastername}에 메뚜기 떼가 발생하여 도시가 황폐해지고 있습니다.";
|
'state'=>$stateCode,
|
||||||
$state = 8;
|
'pop'=>$db->sqleval('pop * %d', $affectRatio),
|
||||||
break;
|
'trust'=>$db->sqleval('trust * %d', $affectRatio),
|
||||||
case 1:
|
'agri'=>$db->sqleval('agri * %d', $affectRatio),
|
||||||
$disaster[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<M><b>【재난】</b></>{$disastername}에 지진으로 피해가 속출하고 있습니다.";
|
'comm'=>$db->sqleval('comm * %d', $affectRatio),
|
||||||
$state = 5;
|
'secu'=>$db->sqleval('secu * %d', $affectRatio),
|
||||||
break;
|
'def'=>$db->sqleval('def * %d', $affectRatio),
|
||||||
case 2:
|
'wall'=>$db->sqleval('wall * %d', $affectRatio),
|
||||||
$disaster[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<M><b>【재난】</b></>{$disastername}에 흉년이 들어 굶어죽는 백성들이 늘어나고 있습니다.";
|
], 'city = %i', $city['city']);
|
||||||
$state = 8;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
$disaster[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<C><b>【풍작】</b></>{$disastername}에 풍작으로 도시가 번창하고 있습니다.";
|
|
||||||
$state = 1;
|
|
||||||
$isGood = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
//겨울
|
|
||||||
case 10:
|
|
||||||
switch($disastertype) {
|
|
||||||
case 0:
|
|
||||||
$disaster[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<M><b>【재난】</b></>{$disastername}에 혹한으로 도시가 황폐해지고 있습니다.";
|
|
||||||
$state = 3;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
$disaster[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<M><b>【재난】</b></>{$disastername}에 지진으로 피해가 속출하고 있습니다.";
|
|
||||||
$state = 5;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
$disaster[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<M><b>【재난】</b></>{$disastername}에 눈이 많이 쌓여 도시가 황폐해지고 있습니다.";
|
|
||||||
$state = 3;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
$disaster[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<M><b>【재난】</b></>{$disastername}에 황건적이 출현해 도시를 습격하고 있습니다.";
|
|
||||||
$state = 9;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if($isgood == 0) {
|
else{
|
||||||
for($i=0; $i < count($disastercity); $i++) {
|
foreach ($targetCityList as $city) {
|
||||||
$ratio = 15 * $disasterratio[$i];
|
$affectRatio = Util::valueFit($city['secu'] / $city['secu2'] / 0.8, 0, 1);
|
||||||
$ratio = (80 + $ratio) / 100.0; // 치안률 따라서 80~95%
|
$affectRatio = 1.01 + $affectRatio * 0.04;
|
||||||
|
|
||||||
$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]'";
|
$db->update('city', [
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
'state'=>$stateCode,
|
||||||
|
'pop'=>$db->sqleval('greatest(pop * %d, pop2)', $affectRatio),
|
||||||
SabotageInjury($disastercity[$i], 1);
|
'trust'=>$db->sqleval('greatest(trust * %d, 100)', $affectRatio),
|
||||||
}
|
'agri'=>$db->sqleval('greatest(agri * %d, agri2)', $affectRatio),
|
||||||
} else {
|
'comm'=>$db->sqleval('greatest(comm * %d, comm2)', $affectRatio),
|
||||||
for($i=0; $i < count($disastercity); $i++) {
|
'secu'=>$db->sqleval('greatest(secu * %d, secu2)', $affectRatio),
|
||||||
$ratio = 4 * $disasterratio[$i];
|
'def'=>$db->sqleval('greatest(def * %d, def2)', $affectRatio),
|
||||||
$ratio = (101 + $ratio) / 100.0; // 치안률 따라서 101~105%
|
'wall'=>$db->sqleval('greatest(wall * %d, wall2)', $affectRatio),
|
||||||
|
], 'city = %i', $city['city']);
|
||||||
$city = getCity($disastercity[$i]);
|
|
||||||
$city['pop'] *= $ratio; $city['trust'] *= $ratio; $city['agri'] *= $ratio;
|
$generalList = array_map(
|
||||||
$city['comm'] *= $ratio; $city['secu'] *= $ratio; $city['def'] *= $ratio;
|
function($rawGeneral) use ($city, $year, $month){
|
||||||
$city['wall'] *= $ratio;
|
return new General($rawGeneral, $city, $year, $month, false);
|
||||||
|
},
|
||||||
if($city['pop'] > $city['pop2']) { $city['pop'] = $city['pop2']; }
|
$db->query('SELECT no, nation, city, injury, crew, atmos, train FROM general WHERE city = %i', $city['city'])
|
||||||
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']; }
|
SabotageInjury($generalList, '재난');
|
||||||
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']}',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),"");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pushWorldHistory($disaster, $admin['year'], $admin['month']);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
class ActionLogger{
|
class ActionLogger{
|
||||||
|
//TODO: global을 따로 뗴어내고, 장수 Logger를 상속해서 받는 형식으로.
|
||||||
protected $generalId;
|
protected $generalId;
|
||||||
protected $nationId;
|
protected $nationId;
|
||||||
protected $autoFlush;
|
protected $autoFlush;
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ class che_화계 extends Command\GeneralCommand{
|
|||||||
[$year, $month] = [$env['year'], $env['month']];
|
[$year, $month] = [$env['year'], $env['month']];
|
||||||
|
|
||||||
foreach($db->query(
|
foreach($db->query(
|
||||||
'SELECT `no`,name,city,nation,level,leadership,horse,strength,weapon,intel,book,item,last_turn,injury,special,special2 FROM general WHERE city = %i',
|
'SELECT `no`,name,city,nation,level,leadership,horse,strength,weapon,intel,book,item,last_turn,injury,special,special2,injury,crew,atmos,train FROM general WHERE city = %i',
|
||||||
$destCityID,
|
$destCityID,
|
||||||
$destNationID
|
$destNationID
|
||||||
) as $rawDestCityGeneral){
|
) as $rawDestCityGeneral){
|
||||||
@@ -276,7 +276,7 @@ class che_화계 extends Command\GeneralCommand{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(static::$injuryGeneral){
|
if(static::$injuryGeneral){
|
||||||
$injuryCount = \sammo\SabotageInjuryEx($destCityGeneralList, true);
|
$injuryCount = \sammo\SabotageInjury($destCityGeneralList, '계략');
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$injuryCount = 0;
|
$injuryCount = 0;
|
||||||
|
|||||||
+18
-6
@@ -1863,10 +1863,16 @@ class GeneralAI{
|
|||||||
$env = $this->env;
|
$env = $this->env;
|
||||||
|
|
||||||
$nationID = $nation['nation'];
|
$nationID = $nation['nation'];
|
||||||
|
|
||||||
|
$cityList = $db->query('SELECT * FROM city WHERE nation=%i', $nationID);
|
||||||
|
$dedicationList = $db->query('SELECT dedication FROM general WHERE nation=%i AND npc!=5', $nationID);
|
||||||
|
|
||||||
|
$goldIncome = getGoldIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||||
|
$warIncome = getWarGoldIncome($nation['type'], $cityList);
|
||||||
|
$income = $goldIncome + $warIncome;
|
||||||
|
|
||||||
|
$outcome = getOutcome(100, $dedicationList);
|
||||||
|
|
||||||
$incomeList = getGoldIncome($nation['nation'], $nation['rate'], $env['gold_rate'], $nation['type']);
|
|
||||||
$income = $nation['gold'] + $incomeList[0] + $incomeList[1];
|
|
||||||
$outcome = getGoldOutcome($nation['nation'], 100); // 100%의 지급량
|
|
||||||
$bill = intval($income / $outcome * 80); // 수입의 80% 만 지급
|
$bill = intval($income / $outcome * 80); // 수입의 80% 만 지급
|
||||||
|
|
||||||
if($bill < 20) { $bill = 20; }
|
if($bill < 20) { $bill = 20; }
|
||||||
@@ -1886,9 +1892,15 @@ class GeneralAI{
|
|||||||
|
|
||||||
$nationID = $nation['nation'];
|
$nationID = $nation['nation'];
|
||||||
|
|
||||||
$incomeList = getRiceIncome($nation['nation'], $nation['rate'], $env['gold_rate'], $nation['type']);
|
$cityList = $db->query('SELECT * FROM city WHERE nation=%i', $nationID);
|
||||||
$income = $nation['rice'] + $incomeList[0] + $incomeList[1];
|
$dedicationList = $db->query('SELECT dedication FROM general WHERE nation=%i AND npc!=5', $nationID);
|
||||||
$outcome = getRiceOutcome($nation['nation'], 100); // 100%의 지급량
|
|
||||||
|
$riceIncome = getRiceIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||||
|
$wallIncome = getWallIncome($nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||||
|
$income = $riceIncome + $wallIncome;
|
||||||
|
|
||||||
|
$outcome = getOutcome(100, $dedicationList);
|
||||||
|
|
||||||
$bill = intval($income / $outcome * 80); // 수입의 80% 만 지급
|
$bill = intval($income / $outcome * 80); // 수입의 80% 만 지급
|
||||||
|
|
||||||
if($bill < 20) { $bill = 20; }
|
if($bill < 20) { $bill = 20; }
|
||||||
|
|||||||
@@ -284,6 +284,14 @@ class Util extends \utilphp\util
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function convertPairArrayToDict($arr){
|
||||||
|
$result = [];
|
||||||
|
foreach($arr as [$key, $val]){
|
||||||
|
$result[$key] = $val;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
public static function convertDictToArray($dict, bool $withKey=true)
|
public static function convertDictToArray($dict, bool $withKey=true)
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
@@ -300,6 +308,15 @@ class Util extends \utilphp\util
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function squeezeFromArray(array $dict, string $key){
|
||||||
|
$result = [];
|
||||||
|
foreach($dict as $dictKey=>$value){
|
||||||
|
$result[$dictKey] = $value[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
public static function isDict($array)
|
public static function isDict($array)
|
||||||
{
|
{
|
||||||
if($array === null){
|
if($array === null){
|
||||||
|
|||||||
Reference in New Issue
Block a user