무작위 징병, 무작위 모병 추가, 테스트용 시나리오 추가

This commit is contained in:
2020-01-30 01:24:30 +09:00
parent 8394c9780c
commit 09e693cb74
7 changed files with 1201 additions and 1 deletions
+182
View File
@@ -1077,6 +1077,188 @@ function process_11(&$general, $type) {
$actLog->pushGeneralActionLog($log, ActionLogger::RAWTEXT);
}
function process_18(&$general, $type) {
if($type == 1){
$type = '무작위 징병';
}
else{
$type = '무작위 모병';
}
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$date = substr($general['turntime'],11,5);
if($type === '무작위 징병') {
$defaultatmos = GameConst::$defaultAtmosLow;
$defaulttrain = GameConst::$defaultTrainLow;
}
else {
$defaultatmos = GameConst::$defaultAtmosHigh;
$defaulttrain = GameConst::$defaultTrainHigh;
}
[$startyear, $year, $month] = $gameStor->getValuesAsArray(['startyear', 'year', 'month']);
$actLog = new ActionLogger($general['no'], $general['nation'], $year, $month);
$command = DecodeCommand($general['turn0']);
$crewType = $command[2];
$rawCrew = $command[1];
$ownCities = [];
$ownRegions = [];
[$year, $startyear] = $gameStor->getValuesAsArray(['year','startyear']);
$relativeYear = $year - $startyear;
foreach(CityConst::all() as $city){
$ownCities[$city->id] = 1;
$ownRegions[$city->region] = 1;
}
$srcCrewType = GameUnitConst::byID($general['crewtype']);
$dstCrewType = GameUnitConst::byID($crewType);
if($dstCrewType === null){
$actLog->pushGeneralActionLog("병종 코드 에러. $type 실패. <1>$date</>");
return;
}
if($srcCrewType->armType != $dstCrewType->armType){
$general['crew'] = 0;
$general['train'] = $defaulttrain;
$general['atmos'] = $defaultatmos;
}
if($general['crew'] != 0) {
$dtype = "추가".$type;
}
else {
$dtype = $type;
}
if(!$general['nation']){
$actLog->pushGeneralActionLog("재야입니다. $dtype 실패. <1>$date</>");
return;
}
$city = $db->queryFirstRow('SELECT * FROM city WHERE city = %i', $general['city']);
if($city['nation'] != $general['nation']){
$actLog->pushGeneralActionLog("아국이 아닙니다. $dtype 실패. <1>$date</>");
return;
}
[$nationLevel, $tech] = $db->queryFirstList('SELECT `level`,tech FROM nation WHERE nation=%i', $general['nation']);
$candidateList = [];
foreach(GameUnitConst::byType($dstCrewType->armType) as $crewTypeCandidate){
if(!$crewTypeCandidate->isValid($ownCities, $ownRegions, $relativeYear, $tech)){
continue;
}
$candidateList[$crewTypeCandidate->id] = $crewTypeCandidate->reqTech + 1000;
}
$crewTypeObj = GameUnitConst::byID(Util::choiceRandomUsingWeight($candidateList));
$lbonus = setLeadershipBonus($general, $nationLevel);
//NOTE: 입력 변수는 100명 단위임
$crew = $rawCrew * 100;
if($crew + $general['crew'] > getGeneralLeadership($general, true, true, true)*100) {
$crew = max(0, getGeneralLeadership($general, true, true, true) * 100 - $general['crew']);
}
if($crew <= 0) {
$actLog->pushGeneralActionLog("더이상 $dtype 할 수 없습니다. $dtype 실패. <1>$date</>");
return;
}
$cost = $crewTypeObj->costWithTech($tech, $crew);
if($type === '무작위 모병') {
$cost *= 2;
}
//성격 보정
$cost = Util::round(CharCost($cost, $general['personal']));
//특기 보정 : 징병, 보병, 궁병, 기병, 귀병, 공성
if($general['special2'] == 72) { $cost *= 0.5; }
else if($general['special2'] == 50 && $crewTypeObj->armType == GameUnitConstBase::T_FOOTMAN) { $cost *= 0.9; }
else if($general['special2'] == 51 && $crewTypeObj->armType == GameUnitConstBase::T_ARCHER) { $cost *= 0.9; }
else if($general['special2'] == 52 && $crewTypeObj->armType == GameUnitConstBase::T_CAVALRY) { $cost *= 0.9; }
else if($general['special2'] == 40 && $crewTypeObj->armType == GameUnitConstBase::T_WIZARD) { $cost *= 0.9; }
else if($general['special2'] == 53 && $crewTypeObj->armType == GameUnitConstBase::T_SIEGE) { $cost *= 0.9; }
if($general['gold'] < $cost){
$actLog->pushGeneralActionLog("자금이 모자랍니다. $dtype 실패. <1>$date</>");
return;
}
if($general['rice'] < $crew / 100) {
$actLog->pushGeneralActionLog("군량이 모자랍니다. $dtype 실패. <1>$date</>");
return;
}
if($city['pop']-30000 < $crew) { // 주민 30000명 이상만 가능
$actLog->pushGeneralActionLog("주민이 모자랍니다. $dtype 실패. <1>$date</>");
return;
}
if($city['rate'] < 20) {
$actLog->pushGeneralActionLog("민심이 낮아 주민들이 도망갑니다. $dtype 실패. <1>$date</>");
return;
}
$josaUl = JosaUtil::pick($crewTypeObj->name, '을');
$actLog->pushGeneralActionLog($crewTypeObj->name."{$josaUl} <C>{$crew}</>명 {$dtype}했습니다. <1>$date</>");
$exp = Util::round($crew / 100);
$ded = Util::round($crew / 100);
// 숙련도 증가
addGenDex($general['no'], GameConst::$maxAtmosByCommand, GameConst::$maxTrainByCommand, $crewType, $crew/100);
// 성격 보정
$exp = CharExperience($exp, $general['personal']);
$ded = CharDedication($ded, $general['personal']);
$atmos = Util::round(($general['atmos'] * $general['crew'] + $defaultatmos * $crew) / ($general['crew'] + $crew));
$train = Util::round(($general['train'] * $general['crew'] + $defaulttrain * $crew) / ($general['crew'] + $crew));
$general['crew'] += $crew;
$general['gold'] -= $cost;
// 주민수 감소 // 민심 감소
if($type === '무작위 징병') {
$city['rate'] -= Util::round(($crew / $city['pop'])*100);
}
else {
$city['rate'] -= Util::round(($crew / 2 / $city['pop'])*100);
}
if($city['rate'] < 0) { $city['rate'] = 0; }
$db->update('city', [
'pop'=>$db->sqleval('pop-%i', $crew),
'rate'=>$city['rate']
], 'city = %i', $general['city']);
// 통솔경험, 병종 변경, 병사수 변경, 훈련치 변경, 사기치 변경, 자금 군량 하락, 공헌도, 명성 상승
$general['leader2']++;
$db->update('general', [
'resturn'=>'SUCCESS',
'leader2'=>$general['leader2'],
'crewtype'=>$crewTypeObj->id,
'crew'=>$general['crew'],
'train'=>$train,
'atmos'=>$atmos,
'gold'=>$general['gold'],
'rice'=>$db->sqleval('rice - %i', Util::round($crew/100)),
'dedication'=>$db->sqleval('dedication + %i', $ded),
'experience'=>$db->sqleval('experience + %i', $exp)
], 'no=%i', $general['no']);
checkAbilityEx($general['no'], $actLog);
$log = uniqueItem($general, []);//TODO: uniqueItem 재 구현
$actLog->pushGeneralActionLog($log, ActionLogger::RAWTEXT);
}
function process_13(&$general) {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');