- 기존의 랜덤 코드는 deprecated 처리 - 서버 시작 시 랜덤하게 정해진 hiddenSeed를 활용 - 랜덤 생성 단위 - 월 실행 - 사령턴 실행 결과 - 커맨드 실행 결과 - 작위 보상 - 부대장 생성 - 유니크 획득 시도 - 설문 조사 - 장수 생성 - NPC국 생성, NPC 생성, NPC의 토너먼트 베팅 - 전투 - 도시 점령 - 자율 행동 선택 - 랜덤 턴 변경 - 거래장, 토너먼트 등 구 랜덤 코드를 이용하는 잔여 코드 있음
103 lines
4.0 KiB
PHP
103 lines
4.0 KiB
PHP
<?php
|
|
namespace sammo\Command\General;
|
|
|
|
use \sammo\{
|
|
DB, Util, JosaUtil,
|
|
General,
|
|
ActionLogger,
|
|
GameConst, GameUnitConst,
|
|
Command,
|
|
RandUtil
|
|
};
|
|
|
|
class che_탈취 extends che_화계{
|
|
static protected $actionName = '탈취';
|
|
|
|
static protected $statType = 'strength';
|
|
static protected $injuryGeneral = false;
|
|
|
|
protected function affectDestCity(RandUtil $rng, int $injuryCount){
|
|
$general = $this->generalObj;
|
|
$nationID = $general->getNationID();
|
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
|
|
|
$logger = $general->getLogger();
|
|
|
|
$destCity = $this->destCity;
|
|
|
|
$destCityName = $destCity['name'];
|
|
$destCityID = $destCity['city'];
|
|
$destNationID = $destCity['nation'];
|
|
|
|
$commandName = $this->getName();
|
|
$db = DB::db();
|
|
|
|
// 탈취 최대 800 * 8 * sqrt(1 + (year - startyear) / 4) / 2
|
|
$yearCoef = sqrt(1 + ($this->env['year'] - $this->env['startyear']) / 4) / 2;
|
|
$commRatio = $destCity['comm'] / $destCity['comm_max'];
|
|
$agriRatio = $destCity['agri'] / $destCity['agri_max'];
|
|
$gold = $rng->nextRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax) * $destCity['level'] * $yearCoef * (0.25 + $commRatio / 4);
|
|
$rice = $rng->nextRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax) * $destCity['level'] * $yearCoef * (0.25 + $agriRatio / 4);
|
|
|
|
if($destCity['supply']){
|
|
[$destNationGold, $destNationRice] = $db->queryFirstList('SELECT gold,rice FROM nation WHERE nation=%i', $destNationID);
|
|
|
|
$destNationGold -= $gold;
|
|
$destNationRice -= $rice;
|
|
|
|
if($destNationGold < GameConst::$minNationalGold) {
|
|
$gold += $destNationGold - GameConst::$minNationalGold;
|
|
$destNationGold = GameConst::$minNationalGold;
|
|
}
|
|
if($destNationRice < GameConst::$minNationalRice) {
|
|
$rice += $destNationRice - GameConst::$minNationalRice;
|
|
$destNationRice = GameConst::$minNationalRice;
|
|
}
|
|
|
|
$db->update('nation', [
|
|
'gold'=>$destNationGold,
|
|
'rice'=>$destNationRice
|
|
], 'nation=%i', $destNationID);
|
|
$db->update('city', [
|
|
'state'=>34
|
|
], 'city=%i', $destCityID);
|
|
}
|
|
else{
|
|
$db->update('city', [
|
|
'comm'=>Util::valueFit($destCity['comm'] - $gold / 12, 0),
|
|
'agri'=>Util::valueFit($destCity['agri'] - $rice / 12, 0),
|
|
'state'=>34
|
|
], 'city=%i', $destCityID);
|
|
}
|
|
|
|
// 본국으로 일부 회수, 재야이면 본인이 전량 소유
|
|
if($nationID != 0) {
|
|
$db->update('nation', [
|
|
'gold' => $db->sqleval('gold + %i', Util::round($gold * 0.7)),
|
|
'rice' => $db->sqleval('rice + %i', Util::round($rice * 0.7))
|
|
], 'nation=%i', $nationID);
|
|
$general->increaseVar('gold', $gold - Util::round($gold * 0.7));
|
|
$general->increaseVar('rice', $rice - Util::round($rice * 0.7));
|
|
} else {
|
|
$general->increaseVar('gold', $gold);
|
|
$general->increaseVar('rice', $rice);
|
|
}
|
|
|
|
$db->update('city', [
|
|
'state'=>32,
|
|
'agri'=>$destCity['agri'],
|
|
'comm'=>$destCity['comm']
|
|
], 'city=%i', $destCityID);
|
|
|
|
$goldText = number_format($gold);
|
|
$riceText = number_format($rice);
|
|
|
|
$josaYi = JosaUtil::pick($destCityName, '이');
|
|
$logger->pushGlobalActionLog("<G><b>{$destCityName}</b></>에서 금과 쌀을 도둑맞았습니다.");
|
|
$josaYi = JosaUtil::pick($commandName, '이');
|
|
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>에 {$commandName}{$josaYi} 성공했습니다. <1>$date</>");
|
|
|
|
$logger->pushGeneralActionLog("금<C>{$goldText}</> 쌀<C>{$riceText}</>을 획득했습니다.", ActionLogger::PLAIN);
|
|
}
|
|
|
|
} |