버그 수정

This commit is contained in:
2020-04-19 18:48:56 +09:00
parent e63b46b004
commit 0608f9b3c7
11 changed files with 90 additions and 60 deletions
+2 -7
View File
@@ -1051,13 +1051,8 @@ function fight($tnmt_type, $tnmt, $phs, $group, $g1, $g2, $type) {
if($energy2 <= 0) { $sel = 0; break; }
}
$query = "select {$tp2}g as gl from general where no='{$gen1['no']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$general1 = MYDB_fetch_array($result);
$query = "select {$tp2}g as gl from general where no='{$gen2['no']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$general2 = MYDB_fetch_array($result);
$general1 = $db->queryFirstRow('SELECT value as gl FROM rank_data WHERE general_id = %i AND type = %s', $gen1['no'], $tp2.'g');
$general2 = $db->queryFirstRow('SELECT value as gl FROM rank_data WHERE general_id = %i AND type = %s', $gen2['no'], $tp2.'g');
switch($sel) {
case 0:
@@ -35,7 +35,10 @@ class che_군량매매 extends Command\GeneralCommand{
}
$buyRice = boolval($buyRice);
$amount = $this->arg['amount']??null;
if(!is_int($amount)){
if(is_float($amount)){
$amount = Util::toInt($amount);
}
else if(!is_int($amount)){
return false;
}
$amount = Util::valueFit($amount, 100, GameConst::$maxResourceActionAmount);
+4 -1
View File
@@ -43,7 +43,10 @@ class che_증여 extends Command\GeneralCommand{
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
$destGeneralID = $this->arg['destGeneralID'];
if(!is_int($amount)){
if(is_float($amount)){
$amount = Util::toInt($amount);
}
else if(!is_int($amount)){
return false;
}
$amount = Util::valueFit($amount, 100, GameConst::$maxResourceActionAmount);
+4 -1
View File
@@ -38,7 +38,10 @@ class che_헌납 extends Command\GeneralCommand{
}
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
if(!is_int($amount)){
if(is_float($amount)){
$amount = Util::toInt($amount);
}
else if(!is_int($amount)){
return false;
}
$amount = Util::valueFit($amount, 100, GameConst::$maxResourceActionAmount);
+4 -1
View File
@@ -44,7 +44,10 @@ class che_몰수 extends Command\NationCommand{
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
$destGeneralID = $this->arg['destGeneralID'];
if(!is_int($amount)){
if(is_float($amount)){
$amount = Util::toInt($amount);
}
else if(!is_int($amount)){
return false;
}
$amount = Util::valueFit($amount, 100, GameConst::$maxResourceActionAmount);
+6 -6
View File
@@ -170,12 +170,12 @@ class che_증축 extends Command\NationCommand{
$db->update('city', [
'level'=>$db->sqleval('level+1'),
'pop2'=>$db->sqleval('pop_max + %i', GameConst::$expandCityPopIncreaseAmount),
'agri2'=>$db->sqleval('agri_max + %i', GameConst::$expandCityDevelIncreaseAmount),
'comm2'=>$db->sqleval('comm_max + %i', GameConst::$expandCityDevelIncreaseAmount),
'secu2'=>$db->sqleval('secu_max + %i', GameConst::$expandCityDevelIncreaseAmount),
'def2'=>$db->sqleval('def_max + %i', GameConst::$expandCityWallIncreaseAmount),
'wall2'=>$db->sqleval('wall_max + %i', GameConst::$expandCityWallIncreaseAmount),
'pop_max'=>$db->sqleval('pop_max + %i', GameConst::$expandCityPopIncreaseAmount),
'agri_max'=>$db->sqleval('agri_max + %i', GameConst::$expandCityDevelIncreaseAmount),
'comm_max'=>$db->sqleval('comm_max + %i', GameConst::$expandCityDevelIncreaseAmount),
'secu_max'=>$db->sqleval('secu_max + %i', GameConst::$expandCityDevelIncreaseAmount),
'def_max'=>$db->sqleval('def_max + %i', GameConst::$expandCityWallIncreaseAmount),
'wall_max'=>$db->sqleval('wall_max + %i', GameConst::$expandCityWallIncreaseAmount),
], 'city=%i', $destCityID);
[$reqGold, $reqRice] = $this->getCost();
+4 -1
View File
@@ -41,7 +41,10 @@ class che_포상 extends Command\NationCommand{
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
$destGeneralID = $this->arg['destGeneralID'];
if(!is_int($amount)){
if(is_float($amount)){
$amount = Util::toInt($amount);
}
else if(!is_int($amount)){
return false;
}
$amount = Util::valueFit($amount, 100, GameConst::$maxResourceActionAmount);
+1
View File
@@ -13,6 +13,7 @@ class GameUnitConstBase{
const T_WIZARD = 4;
const T_SIEGE = 5;
const T_MISC = 6;
const CREWTYPE_CASTLE = 1000;
const DEFAULT_CREWTYPE = 1100;
+59 -40
View File
@@ -360,7 +360,7 @@ class GeneralAI
//충분히 징병 가능한 도시의 부대는 제자리 유지
$city = $this->supplyCities[$currentCityID];
if($city['pop'] / $city['pop2'] >= $this->nationPolicy->safeRecruitCityPopulationRatio){
if($city['pop'] / $city['pop_max'] >= $this->nationPolicy->safeRecruitCityPopulationRatio){
continue;
}
@@ -744,7 +744,7 @@ class GeneralAI
$dev = min($city['dev'], 0.999);
$score = 1 - $dev;
$score **= 2;
$score /= sqrt(count($city['generals']) + 1);
$score /= sqrt(count($city['generals']??[]) + 1);
$cityCandidiates[$city['city']] = $score;
}
@@ -961,7 +961,7 @@ class GeneralAI
$dev = min($city['dev'], 0.999);
$score = 1 - $dev;
$score **= 2;
$score /= sqrt(count($city['generals']) + 1);
$score /= sqrt(count($city['generals']??[]) + 1);
$cityCandidiates[$city['city']] = $score;
}
@@ -1045,6 +1045,10 @@ class GeneralAI
];
}
}
if(!$candidateArgs){
return null;
}
$cmd = buildNationCommandClass(
'che_포상', $this->general, $this->env, $lastTurn,
@@ -1133,6 +1137,9 @@ class GeneralAI
}
}
if(!$candidateArgs){
return null;
}
$cmd = buildNationCommandClass(
'che_포상', $this->general, $this->env, $lastTurn,
@@ -1203,6 +1210,10 @@ class GeneralAI
];
}
}
if(!$candidateArgs){
return null;
}
$cmd = buildNationCommandClass(
'che_포상', $this->general, $this->env, $lastTurn,
@@ -1304,6 +1315,10 @@ class GeneralAI
}
}
if(!$candidateArgs){
return null;
}
$cmd = buildNationCommandClass(
'che_포상', $this->general, $this->env, $lastTurn,
@@ -1422,6 +1437,10 @@ class GeneralAI
}
}
if(!$candidateArgs){
return null;
}
$cmd = buildNationCommandClass(
'che_몰수', $this->general, $this->env, $lastTurn,
@@ -1605,7 +1624,7 @@ class GeneralAI
}
//일반장 행동
protected function do일반내정(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do일반내정(): ?GeneralCommand
{
$leadership = $this->leadership;
$strength = $this->strength;
@@ -1691,7 +1710,7 @@ class GeneralAI
return Util::choiceRandomUsingWeightPair($cmdList);
}
protected function do긴급내정(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do긴급내정(): ?GeneralCommand
{
if($this->dipState === self::d평화){
return null;
@@ -1724,7 +1743,7 @@ class GeneralAI
return null;
}
protected function do전쟁내정(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do전쟁내정(): ?GeneralCommand
{
if($this->dipState === self::d평화){
@@ -1830,7 +1849,7 @@ class GeneralAI
}
protected function do금쌀구매(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do금쌀구매(): ?GeneralCommand
{
$general = $this->general;
$avgAmount = ($general->getVar('gold') + $general->getVar('rice'))/2;
@@ -1920,7 +1939,7 @@ class GeneralAI
return null;
}
protected function do징병(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do징병(): ?GeneralCommand
{
if (in_array($this->dipState, [self::d평화, self::d선포])) {
return null;
@@ -2072,7 +2091,7 @@ class GeneralAI
return $cmd;
}
protected function do전투준비(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do전투준비(): ?GeneralCommand
{
if (in_array($this->dipState, [self::d평화, self::d선포])) {
return null;
@@ -2103,7 +2122,7 @@ class GeneralAI
return Util::choiceRandomUsingWeightPair($cmdList);
}
public function do소집해제(GeneralCommand $reservedCommand): ?GeneralCommand
public function do소집해제(): ?GeneralCommand
{
if ($this->attackable){
return null;
@@ -2125,7 +2144,7 @@ class GeneralAI
}
protected function do출병(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do출병(): ?GeneralCommand
{
if (!$this->attackable) {
return null;
@@ -2171,13 +2190,13 @@ class GeneralAI
/*
protected function doNPC증여(GeneralCommand $reservedCommand): ?GeneralCommand
protected function doNPC증여(): ?GeneralCommand
{
return null;
}
*/
protected function doNPC헌납(GeneralCommand $reservedCommand): ?GeneralCommand
protected function doNPC헌납(): ?GeneralCommand
{
$policy = $this->nationPolicy;
$general = $this->general;
@@ -2241,7 +2260,7 @@ class GeneralAI
}
protected function do후방워프(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do후방워프(): ?GeneralCommand
{
if (in_array($this->dipState, [self::d평화, self::d선포])) {
return null;
@@ -2318,7 +2337,7 @@ class GeneralAI
return $cmd;
}
protected function do전방워프(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do전방워프(): ?GeneralCommand
{
if(!$this->attackable){
return null;
@@ -2365,7 +2384,7 @@ class GeneralAI
return $cmd;
}
protected function do내정워프(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do내정워프(): ?GeneralCommand
{
$city = $this->city;
@@ -2399,6 +2418,7 @@ class GeneralAI
if($city['city'] === $candidate['city']){
continue;
}
$realDevelRate = 0;
foreach($this->calcCityDevelRate($city) as $develKey => [$develVal, $develType]){
if(!($this->genType & $develType)){
@@ -2411,7 +2431,7 @@ class GeneralAI
continue;
}
$candidateCities[$city['city']] = $realDevelRate / \sqrt(count($city['generals']) + 1);
$candidateCities[$city['city']] = $realDevelRate / \sqrt(count($city['generals']??[]) + 1);
}
if(!$candidateCities){
@@ -2429,7 +2449,7 @@ class GeneralAI
}
protected function do귀환(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do귀환(): ?GeneralCommand
{
$general = $this->general;
$city = $this->city;
@@ -2444,9 +2464,8 @@ class GeneralAI
return $cmd;
}
protected function do집합(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do집합(): ?GeneralCommand
{
$cmd = $reservedCommand;
$general = $this->general;
$cmd = buildGeneralCommandClass('che_집합', $general, $this->env);
@@ -2455,7 +2474,7 @@ class GeneralAI
return $cmd;
}
protected function do방랑군이동(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do방랑군이동(): ?GeneralCommand
{
$db = DB::db();
@@ -2510,7 +2529,7 @@ class GeneralAI
return $cmd;
}
protected function do거병(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do거병(): ?GeneralCommand
{
$general = $this->general;
// 초반이면서 능력이 좋은놈 위주로 1.4%확률로 거병
@@ -2540,7 +2559,7 @@ class GeneralAI
return $cmd;
}
protected function do해산(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do해산(): ?GeneralCommand
{
$cmd = buildGeneralCommandClass('che_해산', $this->general, $this->env, null);
if(!$cmd->isRunnable()){
@@ -2549,7 +2568,7 @@ class GeneralAI
return $cmd;
}
protected function do건국(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do건국(): ?GeneralCommand
{
$nationType = Util::choiceRandom(GameConst::$availableNationType);
$nationColor = Util::choiceRandom(array_keys(GetNationColors()));
@@ -2564,7 +2583,7 @@ class GeneralAI
return $cmd;
}
protected function do선양(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do선양(): ?GeneralCommand
{
$db = DB::db();
$cmd = buildGeneralCommandClass('che_선양', $this->general, $this->env, [
@@ -2577,7 +2596,7 @@ class GeneralAI
return $cmd;
}
protected function do국가선택(GeneralCommand $reservedCommand): ?GeneralCommand
protected function do국가선택(): ?GeneralCommand
{
$general = $this->getGeneralObj();
$city = $this->city;
@@ -2621,7 +2640,7 @@ class GeneralAI
}
//랜임 커맨드 입력.
$cmd = buildGeneralCommandClass('che_랜덤임관', $general, $env, ['destNationID' => $rulerNation]);
$cmd = buildGeneralCommandClass('che_랜덤임관', $general, $env);
if(!$cmd->isRunnable()){
return null;
}
@@ -2672,7 +2691,7 @@ class GeneralAI
return null;
}
protected function do중립(GeneralCommand $reservedCommand): GeneralCommand
protected function do중립(): GeneralCommand
{
$general = $this->general;
if($general->getNationID() == 0){
@@ -2870,7 +2889,7 @@ class GeneralAI
$this->chooseNonLordPromotion();
}
if(!($reservedCommand instanceof Command\NationCommand\휴식) && $reservedCommand->isRunnable()){
if(!($reservedCommand instanceof Command\Nation\휴식) && $reservedCommand->isRunnable()){
return $reservedCommand;
}
@@ -2945,17 +2964,17 @@ class GeneralAI
}
if($general->getVar('officer_level') === 12 && $this->generalPolicy->can선양){
$result = $this->do선양($reservedCommand);
$result = $this->do선양();
if($result !== null){
return $result;
}
}
if($npcType == 5){
return $this->do집합($reservedCommand);
return $this->do집합();
}
if(!($reservedCommand instanceof Command\General\휴식) && $reservedCommand->isRunnable()){
if(!($reservedCommand instanceof Command\General\휴식)){
return $reservedCommand;
}
@@ -2964,32 +2983,32 @@ class GeneralAI
}
if($npcType == 2 && $nationID == 0){
$result = $this->do거병($reservedCommand);
$result = $this->do거병();
if($result !== null){
return $result;
}
}
if($nationID === 0 && $this->generalPolicy->can국가선택){
$result = $this->do국가선택($reservedCommand);
$result = $this->do국가선택();
if($result !== null){
return $result;
}
return $this->do중립($reservedCommand);
return $this->do중립();
}
if($npcType >= 2 && $general->getVar('officer_level') == 12 && !$this->nation['capital']){
//방랑군 건국
$result = $this->do건국($reservedCommand);
$result = $this->do건국();
if($result !== null){
return $result;
}
$result = $this->do방랑군이동($reservedCommand);
$result = $this->do방랑군이동();
if($result !== null){
return $result;
}
$result = $this->do해산($reservedCommand);
$result = $this->do해산();
if($result !== null){
return $result;
}
@@ -3000,13 +3019,13 @@ class GeneralAI
continue;
}
/** @var ?GeneralCommand */
$result = $this->{'do'.$actionName}($reservedCommand);
$result = $this->{'do'.$actionName}();
if($result !== null){
return $result;
}
}
return $this->do중립($reservedCommand);
return $this->do중립();
}
protected function calcNationDevelopedRate()
+1 -1
View File
@@ -21,7 +21,7 @@ class WarUnitCity extends WarUnit{
$this->cityRate = $cityRate;
$this->logger = $general->getLogger();
$this->crewType = GameUnitConst::byID(GameUnitConst::T_CASTLE);
$this->crewType = GameUnitConst::byID(GameUnitConst::CREWTYPE_CASTLE);
$this->hp = $this->getVar('def') * 10;
+1 -1
View File
@@ -46,7 +46,7 @@ class WarUnitGeneral extends WarUnit{
function setOppose(?WarUnit $oppose){
parent::setOppose($oppose);
$general = $this->general;
$this->general->increaseVar('warnum', 1);
$this->general->increaseRankVar('warnum', 1);
if($this->isAttacker){
$general->updateVar('recent_war', $general->getTurnTime());