forked from devsam/core
버그 수정
This commit is contained in:
@@ -76,7 +76,7 @@ foreach($nationTurnList as $officer_level=>$turnBrief){
|
||||
$nationTurnBrief[$officer_level] = [
|
||||
'name'=>$general->getName(),
|
||||
'turnTime'=>$general->getTurnTime($general::TURNTIME_FULL),
|
||||
'officerlevelText'=>getOfficerLevelText($general->getVar('officer_level'), $nationLevel),
|
||||
'officerLevelText'=>getOfficerLevelText($general->getVar('officer_level'), $nationLevel),
|
||||
'npcType'=>$general->getVar('npc'),
|
||||
'turn'=>$turnBrief
|
||||
];
|
||||
|
||||
@@ -77,7 +77,7 @@ $viewColumns = [
|
||||
|
||||
$customViewColumns = [
|
||||
'officerLevel'=>1,
|
||||
'officerlevelText'=>1,
|
||||
'officerLevelText'=>1,
|
||||
'lbonus'=>1,
|
||||
'ownerName'=>1,
|
||||
'honorText'=>1,
|
||||
@@ -106,7 +106,7 @@ $specialViewFilter = [
|
||||
}
|
||||
return $rawGeneral['owner_name'];
|
||||
},
|
||||
'officerlevelText'=>function($rawGeneral)use($nationArr){
|
||||
'officerLevelText'=>function($rawGeneral)use($nationArr){
|
||||
return getOfficerLevelText($rawGeneral['officer_level'], $nationArr['level']);
|
||||
},
|
||||
'honorText'=>function($rawGeneral){
|
||||
|
||||
@@ -286,7 +286,7 @@ function do추방(General $general, int $myOfficerLevel):?string{
|
||||
], 'nation=%i AND officer_level=12', $nationID);
|
||||
|
||||
$db->update('nation', [
|
||||
'gennum'=>$db->sqleval('gennum - 1'),
|
||||
'gennum'=>$db->sqleval('gennum - %i', $general->getVar('npc')!=5?1:0),
|
||||
'gold'=>$db->sqleval('gold + %i', $gold),
|
||||
'rice'=>$db->sqleval('rice + %i', $rice),
|
||||
], 'nation = %i', $nationID);
|
||||
@@ -294,7 +294,7 @@ function do추방(General $general, int $myOfficerLevel):?string{
|
||||
//이번분기는 추방불가(초반 제외)
|
||||
$db->update('nation', [
|
||||
"l{$myOfficerLevel}set"=>1,
|
||||
'gennum'=>$db->sqleval('gennum - 1'),
|
||||
'gennum'=>$db->sqleval('gennum - %i', $general->getVar('npc')!=5?1:0),
|
||||
'gold'=>$db->sqleval('gold + %i', $gold),
|
||||
'rice'=>$db->sqleval('rice + %i', $rice),
|
||||
], 'nation = %i', $nationID);
|
||||
|
||||
+22
-15
@@ -522,7 +522,8 @@ function ConquerCity($admin, $general, $city, $nation, $destnation) {
|
||||
$loseGeneralRice = 0;
|
||||
//멸망국 장수들 역사 기록 및 로그 전달
|
||||
$josaYi = JosaUtil::pick($losenation['name'], '이');
|
||||
$genlog = ["<C>●</><D><b>{$losenation['name']}</b></>{$josaYi} <R>멸망</>했습니다."];
|
||||
$destroyLog = "<D><b>{$losenation['name']}</b></>{$josaYi} <R>멸망</>했습니다.";
|
||||
$destroyHistoryLog = "<D><b>{$losenation['name']}</b></>{$josaYi} <R>멸망</>";
|
||||
|
||||
|
||||
// 국가 백업
|
||||
@@ -536,21 +537,25 @@ function ConquerCity($admin, $general, $city, $nation, $destnation) {
|
||||
$oldNation['history'] = getNationHistoryAll($city['nation']);
|
||||
|
||||
foreach($oldNationGenerals as $gen){
|
||||
$oldGeneralObj = new General($gen, null, null, $oldNation, $year, $month, false);
|
||||
|
||||
$loseGold = intdiv($gen['gold'] * (rand()%30+20), 100);
|
||||
$loseRice = intdiv($gen['rice'] * (rand()%30+20), 100);
|
||||
$genlog[1] = "<C>●</>도주하며 금<C>$loseGold</> 쌀<C>$loseRice</>을 분실했습니다.";
|
||||
$generalLogger = $oldGeneralObj->getLogger();
|
||||
$generalLogger->pushGeneralHistoryLog($destroyHistoryLog);
|
||||
$generalLogger->pushGeneralActionLog($destroyLog, ActionLogger::PLAIN);
|
||||
$generalLogger->pushGeneralActionLog("도주하며 금<C>$loseGold</> 쌀<C>$loseRice</>을 분실했습니다.", ActionLogger::PLAIN);
|
||||
$oldGeneralObj->increaseVar('gold', -$loseGold);
|
||||
$oldGeneralObj->increaseVar('rice', -$loseRice);
|
||||
$oldGeneralObj->addExperience(-$oldGeneralObj->getVar('experience')*0.1, false);
|
||||
$oldGeneralObj->addDedication(-$oldGeneralObj->getVar('dedication')*0.5, false);
|
||||
|
||||
$query = "update general set gold=gold-{$loseGold},rice=rice-{$loseRice} where no={$gen['no']}";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
|
||||
pushGenLog($gen['no'], $genlog);
|
||||
|
||||
pushGeneralHistory($gen['no'], ["<C>●</>{$year}년 {$month}월:<D><b>{$losenation['name']}</b></>{$josaYi} <R>멸망</>"]);
|
||||
pushOldNationStop($gen['no'], $city['nation']);
|
||||
|
||||
$loseGeneralGold += $loseGold;
|
||||
$loseGeneralRice += $loseRice;
|
||||
|
||||
$oldGeneralObj->applyDB($db);
|
||||
|
||||
//모두 등용장 발부
|
||||
if($admin['join_mode'] != 'onlyRandom' && Util::randBool(0.5)) {
|
||||
@@ -565,7 +570,6 @@ function ConquerCity($admin, $general, $city, $nation, $destnation) {
|
||||
setGeneralCommand($gen['no'], [0], 'che_임관', ['destNationID'=>$nation['nation']]);
|
||||
}
|
||||
}
|
||||
unset($genlog[1]);
|
||||
|
||||
// 승전국 보상
|
||||
$losenation['gold'] -= GameConst::$basegold;
|
||||
@@ -596,16 +600,19 @@ function ConquerCity($admin, $general, $city, $nation, $destnation) {
|
||||
|
||||
//분쟁기록 모두 지움
|
||||
DeleteConflict($city['nation']);
|
||||
// 전 장수 공헌 명성치 깎음
|
||||
//TODO: experience를 General에
|
||||
$query = "update general set dedication=dedication*0.5,experience=experience*0.9 where nation='{$city['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
|
||||
// 전 도시 공백지로
|
||||
$query = "update city set nation='0',conflict='{}',term=0 where nation='{$city['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
// 전 장수 소속 무소속으로, 재야로, 부대 탈퇴
|
||||
$query = "update general set nation='0',belong='0',officer_level='0',officer_city=0,troop='0' where nation='{$city['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$db->update('general',[
|
||||
'nation'=>0,
|
||||
'belong'=>0,
|
||||
'officer_level'=>0,
|
||||
'officer_city'=>0,
|
||||
'troop'=>0,
|
||||
], 'nation=%i',$city['nation']);
|
||||
|
||||
// 부대도 삭제
|
||||
$query = "delete from troop where nation='{$city['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
|
||||
@@ -112,7 +112,7 @@ class che_하야 extends Command\GeneralCommand{
|
||||
$db->update('nation', [
|
||||
'gold'=>$db->sqleval('gold + %i', $lostGold),
|
||||
'rice'=>$db->sqleval('rice + %i', $lostRice),
|
||||
'gennum'=>$db->sqleval('gennum - 1')
|
||||
'gennum'=>$db->sqleval('gennum - %i', $general->getVar('npc')!=5?1:0)
|
||||
], 'nation=%i', $nationID);
|
||||
\sammo\refreshNationStaticInfo();
|
||||
|
||||
|
||||
@@ -508,14 +508,14 @@ class GameUnitConstBase{
|
||||
if(!key_exists($armType, $constType)){
|
||||
$constType[$armType] = [];
|
||||
}
|
||||
$constType[$armType][] = $unit;
|
||||
$constType[$armType][$id] = $unit;
|
||||
|
||||
if($unit->reqCities){
|
||||
foreach($unit->reqCities as $reqCity){
|
||||
if(!key_exists($reqCity, $constCity)){
|
||||
$constCity[$reqCity] = [];
|
||||
}
|
||||
$constCity[$reqCity][] = $unit;
|
||||
$constCity[$reqCity][$id] = $unit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,7 +525,7 @@ class GameUnitConstBase{
|
||||
if(!key_exists($reqRegion, $constRegion)){
|
||||
$constRegion[$reqRegion] = [];
|
||||
}
|
||||
$constRegion[$reqRegion][] = $unit;
|
||||
$constRegion[$reqRegion][$id] = $unit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+20
-22
@@ -1027,7 +1027,7 @@ class GeneralAI
|
||||
|
||||
protected function do유저장긴급포상(LastTurn $lastTurn): ?NationCommand
|
||||
{
|
||||
if(!$this->userGenerals){
|
||||
if(!$this->userWarGenerals){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1059,7 +1059,7 @@ class GeneralAI
|
||||
|
||||
$crewtype = $targetUserGeneral->getCrewTypeObj();
|
||||
$reqMoney = $crewtype->costWithTech($this->nation['tech'], $targetUserGeneral->getLeadership(false)) * 2 * 4 * 1.1;
|
||||
if ($this->env['year'] > $this->env['startyear'] + 5) {
|
||||
if ($this->env['year'] > $this->env['startyear'] + 3) {
|
||||
$reqMoney = max($reqMoney, $reqHumanMinRes);
|
||||
}
|
||||
$enoughMoney = $reqMoney * 1.5;
|
||||
@@ -1159,7 +1159,7 @@ class GeneralAI
|
||||
|
||||
$crewtype = $targetUserGeneral->getCrewTypeObj();
|
||||
$reqMoney = $crewtype->costWithTech($this->nation['tech'], $targetUserGeneral->getLeadership(false)) * 2 * 4 * 1.1;
|
||||
if ($this->env['year'] > $this->env['startyear'] + 5) {
|
||||
if ($this->env['year'] > $this->env['startyear'] + 3) {
|
||||
$reqMoney = max($reqMoney, $reqHumanMinRes);
|
||||
}
|
||||
$enoughMoney = $reqMoney * 1.5;
|
||||
@@ -1169,6 +1169,8 @@ class GeneralAI
|
||||
}
|
||||
//국고와 '충분한 금액'의 기하평균
|
||||
$payAmount = sqrt(($enoughMoney - $targetUserGeneral->getVar($resName)) * $resVal);
|
||||
$payAmount = Util::valueFit($payAmount, $resVal - $reqNationRes * 0.5);
|
||||
|
||||
if($payAmount < $this->nationPolicy->minimumResourceActionAmount){
|
||||
continue;
|
||||
}
|
||||
@@ -1251,6 +1253,7 @@ class GeneralAI
|
||||
}
|
||||
//국고와 '충분한 금액'의 기하평균
|
||||
$payAmount = sqrt(($enoughMoney - $targetNPCGeneral->getVar($resName)) * $resVal);
|
||||
$payAmount = Util::valueFit($payAmount, $resVal - $reqNationRes * 0.5);
|
||||
|
||||
if($payAmount < $this->nationPolicy->minimumResourceActionAmount){
|
||||
continue;
|
||||
@@ -1337,6 +1340,7 @@ class GeneralAI
|
||||
}
|
||||
//국고와 '충분한 금액'의 기하평균
|
||||
$payAmount = sqrt(($enoughMoney - $targetNPCGeneral->getVar($resName)) * $resVal);
|
||||
$payAmount = Util::valueFit($payAmount, $resVal - $reqNationRes * 0.5);
|
||||
|
||||
if ($resVal < $payAmount / 2) {
|
||||
continue;
|
||||
@@ -2142,26 +2146,18 @@ class GeneralAI
|
||||
];
|
||||
|
||||
$availableArmType = [];
|
||||
if($genType & self::t무장){
|
||||
if($this->fullStrength > $this->fullIntel * 0.9){
|
||||
$availableArmType[GameUnitConst::T_FOOTMAN] = $dex[GameUnitConst::T_FOOTMAN] * $this->fullStrength;
|
||||
$availableArmType[GameUnitConst::T_ARCHER] = $dex[GameUnitConst::T_ARCHER] * $this->fullStrength;
|
||||
$availableArmType[GameUnitConst::T_CAVALRY] = $dex[GameUnitConst::T_CAVALRY] * $this->fullStrength;
|
||||
}
|
||||
if($genType & self::t지장){
|
||||
if($this->fullIntel > $this->fullStrength * 0.9){
|
||||
$availableArmType[GameUnitConst::T_WIZARD] = $dex[GameUnitConst::T_WIZARD] * $this->fullIntel * 3;
|
||||
}
|
||||
|
||||
if($availableArmType){
|
||||
$armType = Util::choiceRandomUsingWeight($availableArmType);
|
||||
}
|
||||
else{
|
||||
$armType = Util::choiceRandom([GameUnitConst::T_FOOTMAN,GameUnitConst::T_ARCHER,GameUnitConst::T_CAVALRY]);
|
||||
}
|
||||
|
||||
$armType = Util::choiceRandomUsingWeight($availableArmType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$cities = [];
|
||||
$regions = [];
|
||||
@@ -2187,13 +2183,12 @@ class GeneralAI
|
||||
throw new MustNotBeReachedException('에러:'.var_dump([$general->getName(), $general->getAuxVar('armType'), $armType, $cities, $regions, $relYear, $tech], true));
|
||||
}
|
||||
|
||||
LogText('징병1', "{$general->getAuxVar('armType')}, {$armType}, {$type}");
|
||||
|
||||
if($this->generalPolicy->can고급병종){
|
||||
$currCrewType = $general->getCrewTypeObj();
|
||||
if ($currCrewType->isValid($cities, $regions, $relYear, $tech)) {
|
||||
$currScore = $crewtype->pickScore($tech);
|
||||
if($types[$type] * 0.8 < $currScore){
|
||||
$type = $currCrewType->id;
|
||||
}
|
||||
if ($currCrewType->isValid($cities, $regions, $relYear, $tech) && $currCrewType->reqTech >= 2000) {
|
||||
$type = $currCrewType->id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2227,7 +2222,7 @@ class GeneralAI
|
||||
]);
|
||||
}
|
||||
else if($gold < $cost && $gold * 2 >= $cost){
|
||||
$crew *= $gold / $cost;
|
||||
$crew *= 0.5;
|
||||
$crew = Util::round($crew-49, -2);
|
||||
$cmd = buildGeneralCommandClass('che_징병', $general, $env, [
|
||||
'crewType' => $type,
|
||||
@@ -2717,7 +2712,7 @@ class GeneralAI
|
||||
protected function do거병(): ?GeneralCommand
|
||||
{
|
||||
$general = $this->general;
|
||||
// 초반이면서 능력이 좋은놈 위주로 1%확률로 거병
|
||||
// 초반이면서 능력이 좋은놈 위주로 거병
|
||||
if($general->getVar('makelimit')){
|
||||
return null;
|
||||
}
|
||||
@@ -2733,7 +2728,10 @@ class GeneralAI
|
||||
return null;
|
||||
}
|
||||
|
||||
if(!Util::randBool(0.01)){
|
||||
//XXX: 건국기한 2년
|
||||
$more = Util::valueFit(3 - $this->env['year'] + $this->env['init_year'], 1, 3);
|
||||
LogText('건국', $more);
|
||||
if(!Util::randBool(0.005*$more)){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
|
||||
if($hasNationTurn){
|
||||
if($tryAutorun){
|
||||
$nationCommandObj = $ai->chooseNationTurn($nationCommandObj);
|
||||
//LogText("NationTurn", "General, {$general->getName()}, {$general->getID()}, {$general->getStaticNation()['name']}, {$nationCommandObj->getBrief()}, {$nationCommandObj->reason}, ");
|
||||
LogText("NationTurn", "General, {$general->getName()}, {$general->getID()}, {$general->getStaticNation()['name']}, {$nationCommandObj->getBrief()}, {$nationCommandObj->reason}, ");
|
||||
}
|
||||
$resultNationTurn = $turnObj->processNationCommand(
|
||||
$nationCommandObj
|
||||
@@ -293,7 +293,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
|
||||
$autorunMode = true;
|
||||
$generalCommandObj = $newGeneralCommandObj;
|
||||
}
|
||||
//LogText("turn", "General, {$general->getName()}, {$general->getID()}, {$general->getStaticNation()['name']}, {$generalCommandObj->getBrief()}, {$generalCommandObj->reason}, ");
|
||||
LogText("turn", "General, {$general->getName()}, {$general->getID()}, {$general->getStaticNation()['name']}, {$generalCommandObj->getBrief()}, {$generalCommandObj->reason}, ");
|
||||
}
|
||||
|
||||
$turnObj->processCommand($generalCommandObj, $autorunMode);
|
||||
|
||||
Reference in New Issue
Block a user