본격 전투전 boiler plate 정리, atmos/train이랑 atmosBonus/trainBonus 통합
This commit is contained in:
Regular → Executable
+120
-78
@@ -1,12 +1,111 @@
|
|||||||
<?
|
<?
|
||||||
|
|
||||||
|
function getGame($connect) {
|
||||||
|
$query = "select * from game where no='1'";
|
||||||
|
return MYDB_fetch_array(MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""));
|
||||||
|
}
|
||||||
|
function getOriginCity($connect, $general) {
|
||||||
|
$query = "select city, level from city where city='$general[city]'";
|
||||||
|
return MYDB_fetch_array(MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""));
|
||||||
|
}
|
||||||
|
|
||||||
|
function getNation($connect, $general) {
|
||||||
|
$query = "select nation,level,name,history,capital,tech,type from nation where nation='$general[nation]'";
|
||||||
|
return MYDB_fetch_array(MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""));
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDestination($connect, $city) {
|
||||||
|
$query = "select nation,level,name,history,rice,capital,tech,type from nation where nation='$city[nation]'";
|
||||||
|
return MYDB_fetch_array(MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""));
|
||||||
|
}
|
||||||
|
|
||||||
|
function getGeneralCount($connect, $nation) {
|
||||||
|
$query = "select no from general where nation='$nation'";
|
||||||
|
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||||
|
$generalCount = MYDB_num_rows($result);
|
||||||
|
if($generalCount < 10) {
|
||||||
|
$generalCount = 10;
|
||||||
|
}
|
||||||
|
return $generalCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOpposeCount($connect, $city) {
|
||||||
|
// 목표 도시내에 목표 국가 소속 장수 중, 병사가 있는 능력치합+병사수 순으로 훈,사 60, 80 이상
|
||||||
|
$query = "select no,name,turntime,personal,special2,crew,crewtype,atmos,train,intel,intel2,book,power,power2,weap,injury,leader,leader2,horse,item,explevel,level,rice,leader+power+intel+weap+horse+book+crew/100 as sum,dex0,dex10,dex20,dex30,dex40 from general where city='$city[city]' and nation='$city[nation]' and nation!=0 and crew>'0' and rice>round(crew/100) and ((train>=60 and atmos>=60 and mode=1) or (train>=80 and atmos>=80 and mode=2)) order by sum desc";
|
||||||
|
return MYDB_num_rows(MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""));
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBonusAtmosBasedOnItem($connect, $general) {
|
||||||
|
$bonusAtmos = 0;
|
||||||
|
if($general[item] == 3) {
|
||||||
|
//탁주 사용
|
||||||
|
$bonusAtmos += 3;
|
||||||
|
$query = "update general set item=0 where no='$general[no]'";
|
||||||
|
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||||
|
$log[count($log)] = "<C>●</><C>".getItemName($general[item])."</>(을)를 사용!";
|
||||||
|
$general[item] = 0;
|
||||||
|
} elseif($general[item] >= 14 && $general[item] <= 16) {
|
||||||
|
//의적주, 두강주, 보령압주 사용
|
||||||
|
$bonusAtmos += 5;
|
||||||
|
} elseif($general[item] >= 19 && $general[item] <= 20) {
|
||||||
|
//춘화첩, 초선화 사용
|
||||||
|
$bonusAtmos += 7;
|
||||||
|
}
|
||||||
|
return $bonusAtmos;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBonusTrainBasedOnItem($connect, $general) {
|
||||||
|
$bonusTrain = 0;
|
||||||
|
if($general[item] == 4) {
|
||||||
|
//청주 사용
|
||||||
|
$bonusTrain += 3;
|
||||||
|
$query = "update general set item=0 where no='$general[no]'";
|
||||||
|
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||||
|
$log[count($log)] = "<C>●</><C>".getItemName($general[item])."</>(을)를 사용!";
|
||||||
|
$general[item] = 0;
|
||||||
|
} elseif($general[item] >= 12 && $general[item] <= 13) {
|
||||||
|
//과실주, 이강주 사용
|
||||||
|
$bonusTrain += 5;
|
||||||
|
} elseif($general[item] >= 17 && $general[item] <= 18) {
|
||||||
|
//철벽서, 단결도 사용
|
||||||
|
$bonusTrain += 7;
|
||||||
|
}
|
||||||
|
return $bonusTrain;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBonusAtmosBasedOnCity($connect, $city, $nation) {
|
||||||
|
$bonusAtmos = 0;
|
||||||
|
// 수도 보정
|
||||||
|
if($nation[capital] == $city[city]) {
|
||||||
|
$bonusAtmos += 5;
|
||||||
|
}
|
||||||
|
// 출병도시가 진이면 공격자 공격보정
|
||||||
|
if($city[level] == 2) {
|
||||||
|
$bonusAtmos += 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bonusAtmos;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBonusTrainBasedOnCity($connect, $city) {
|
||||||
|
$bonusTrain = 0;
|
||||||
|
// 방어도시가 수진이면 방어자 방어보정
|
||||||
|
if($city[level] == 1) {
|
||||||
|
$bonusTrain += 5;
|
||||||
|
}
|
||||||
|
// 방어도시가 관이면 방어자 방어보정
|
||||||
|
if($city[level] == 3) {
|
||||||
|
$bonusTrain += 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bonusTrain;
|
||||||
|
}
|
||||||
|
|
||||||
function processWar($connect, $general, $city) {
|
function processWar($connect, $general, $city) {
|
||||||
global $_armperphase, $_maximumatmos, $_maximumtrain, $_dexLimit, $_basegold, $_baserice;
|
global $_armperphase, $_maximumatmos, $_maximumtrain, $_dexLimit, $_basegold, $_baserice;
|
||||||
$date = substr($general[turntime],11,5);
|
$date = substr($general[turntime],11,5);
|
||||||
|
|
||||||
$query = "select * from game where no='1'";
|
$game = getGame($connect);
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$game = MYDB_fetch_array($result);
|
|
||||||
|
|
||||||
$deadAmount[att] = 0;
|
$deadAmount[att] = 0;
|
||||||
$deadAmount[def] = 0;
|
$deadAmount[def] = 0;
|
||||||
@@ -16,83 +115,25 @@ function processWar($connect, $general, $city) {
|
|||||||
// 특기보정 : 돌격
|
// 특기보정 : 돌격
|
||||||
if($general[special2] == 60) { $warphase += 1; }
|
if($general[special2] == 60) { $warphase += 1; }
|
||||||
|
|
||||||
$genAtmos = 0;
|
$genAtmos = getBonusAtmosBasedOnItem($connect, $general);
|
||||||
if($general[item] == 3) {
|
$genAtmos += getBonusAtmosBasedOnCity($connect, $originCity, $nation);
|
||||||
//탁주 사용
|
|
||||||
$genAtmos += 3;
|
$genTrain = getBonusTrainBasedOnItem($connect, $general);
|
||||||
$query = "update general set item=0 where no='$general[no]'";
|
$oppTrain = getBonusTrainBasedOnCity($connect, $city);
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$log[count($log)] = "<C>●</><C>".getItemName($general[item])."</>(을)를 사용!";
|
|
||||||
$general[item] = 0;
|
|
||||||
} elseif($general[item] >= 14 && $general[item] <= 16) {
|
|
||||||
//의적주, 두강주, 보령압주 사용
|
|
||||||
$genAtmos += 5;
|
|
||||||
} elseif($general[item] >= 19 && $general[item] <= 20) {
|
|
||||||
//춘화첩, 초선화 사용
|
|
||||||
$genAtmos += 7;
|
|
||||||
}
|
|
||||||
$genTrain = 0;
|
|
||||||
if($general[item] == 4) {
|
|
||||||
//청주 사용
|
|
||||||
$genTrain += 3;
|
|
||||||
$query = "update general set item=0 where no='$general[no]'";
|
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$log[count($log)] = "<C>●</><C>".getItemName($general[item])."</>(을)를 사용!";
|
|
||||||
$general[item] = 0;
|
|
||||||
} elseif($general[item] >= 12 && $general[item] <= 13) {
|
|
||||||
//과실주, 이강주 사용
|
|
||||||
$genTrain += 5;
|
|
||||||
} elseif($general[item] >= 17 && $general[item] <= 18) {
|
|
||||||
//철벽서, 단결도 사용
|
|
||||||
$genTrain += 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 우선 스케일링
|
// 우선 스케일링
|
||||||
$city[def] *= 10;
|
$city[def] *= 10;
|
||||||
$city[wall] *= 10;
|
$city[wall] *= 10;
|
||||||
|
|
||||||
$query = "select level from city where city='$general[city]'";
|
$originCity = getOriginCity($connect, $general);
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
$nation = getNation($connect, $general);
|
||||||
$originCity = MYDB_fetch_array($result);
|
$destnation = getDestination($connect, $city);
|
||||||
|
$gencount = getGeneralCount($connect, $nation[nation]);
|
||||||
$query = "select nation,level,name,history,capital,tech,type from nation where nation='$general[nation]'";
|
$destgencount = getGeneralCount($connect, $destnation[nation]);
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
$opposecount = getOpposeCount($connect, $city);
|
||||||
$nation = MYDB_fetch_array($result);
|
|
||||||
|
|
||||||
$query = "select nation,level,name,history,rice,capital,tech,type from nation where nation='$city[nation]'";
|
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$destnation = MYDB_fetch_array($result);
|
|
||||||
|
|
||||||
//장수수 구함
|
|
||||||
$query = "select no from general where nation='$general[nation]'";
|
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$gencount = MYDB_num_rows($result);
|
|
||||||
if($gencount < 10) $gencount = 10;
|
|
||||||
//장수수 구함
|
|
||||||
$query = "select no from general where nation='$destnation[nation]'";
|
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$destgencount = MYDB_num_rows($result);
|
|
||||||
if($destgencount < 10) $destgencount = 10;
|
|
||||||
|
|
||||||
$genAtmosBonus = 0; $genTrainBonus = 0;
|
|
||||||
$oppAtmosBonus = 0; $oppTrainBonus = 0;
|
|
||||||
//공격자 수도보정
|
|
||||||
if($nation[capital] == $general[city]) { $genAtmosBonus += 5; }
|
|
||||||
//방어자 수도보정
|
|
||||||
//if($destnation[capital] == $city[city]) { $oppTrainBonus += 5; }
|
|
||||||
//관,진,수진 보정
|
|
||||||
if($city[level] == 1) { $oppTrainBonus += 5; } // 방어도시가 수진이면 방어자 방어보정
|
|
||||||
if($originCity[level] == 2) { $genAtmosBonus += 5; } // 출병도시가 진이면 공격자 공격보정
|
|
||||||
if($city[level] == 3) { $oppTrainBonus += 5; } // 방어도시가 관이면 방어자 방어보정
|
|
||||||
|
|
||||||
$alllog[count($alllog)] = "<C>●</>{$game[month]}월:<D><b>$nation[name]</b></>의 <Y>$general[name]</>(이)가 <G><b>$city[name]</b></>(으)로 진격합니다.";
|
$alllog[count($alllog)] = "<C>●</>{$game[month]}월:<D><b>$nation[name]</b></>의 <Y>$general[name]</>(이)가 <G><b>$city[name]</b></>(으)로 진격합니다.";
|
||||||
$log[count($log)] = "<C>●</>{$game[month]}월:<G><b>$city[name]</b></>(으)로 <M>진격</>합니다. <1>$date</>";
|
$log[count($log)] = "<C>●</>{$game[month]}월:<G><b>$city[name]</b></>(으)로 <M>진격</>합니다. <1>$date</>";
|
||||||
// $history[count($history)] = "<C>●</>{$game[year]}년 {$game[month]}월:<O><b>【전투】</b></><D><b>$nation[name]</b></>(이)가 <D><b>$destnation[name]</b></>의 <G><b>$city[name]</b></>(으)로 <M>진격</>합니다.";
|
|
||||||
|
|
||||||
// 목표 도시내에 목표 국가 소속 장수 중, 병사가 있는 능력치합+병사수 순으로 훈,사 60, 80 이상
|
|
||||||
$query = "select no,name,turntime,personal,special2,crew,crewtype,atmos,train,intel,intel2,book,power,power2,weap,injury,leader,leader2,horse,item,explevel,level,rice,leader+power+intel+weap+horse+book+crew/100 as sum,dex0,dex10,dex20,dex30,dex40 from general where city='$city[city]' and nation='$city[nation]' and nation!=0 and crew>'0' and rice>round(crew/100) and ((train>=60 and atmos>=60 and mode=1) or (train>=80 and atmos>=80 and mode=2)) order by sum desc";
|
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$opposecount = MYDB_num_rows($result);
|
|
||||||
|
|
||||||
$exp = 0; //병사 소진 시킨 만큼
|
$exp = 0; //병사 소진 시킨 만큼
|
||||||
$opexp = 0;
|
$opexp = 0;
|
||||||
@@ -160,8 +201,8 @@ function processWar($connect, $general, $city) {
|
|||||||
if($myCrew <= 0) { $myCrew = rand() % 90 + 10; }
|
if($myCrew <= 0) { $myCrew = rand() % 90 + 10; }
|
||||||
|
|
||||||
//훈련 사기따라
|
//훈련 사기따라
|
||||||
$myCrew = getCrew($myCrew, $game[city_rate]+$oppAtmosBonus, CharTrain($general[train]+$genTrain+$genTrainBonus, $general[personal]));
|
$myCrew = getCrew($myCrew, $game[city_rate], CharTrain($general[train]+$genTrain, $general[personal]));
|
||||||
$cityCrew = getCrew($cityCrew, CharAtmos($general[atmos]+$genAtmos+$genAtmosBonus, $general[personal]), $game[city_rate]+$oppTrainBonus);
|
$cityCrew = getCrew($cityCrew, CharAtmos($general[atmos]+$genAtmos, $general[personal]), $game[city_rate]+$oppTrain);
|
||||||
//숙련도 따라
|
//숙련도 따라
|
||||||
$genDexAtt = getGenDex($general, $general[crewtype]);
|
$genDexAtt = getGenDex($general, $general[crewtype]);
|
||||||
$genDexDef = getGenDex($general, 40);
|
$genDexDef = getGenDex($general, 40);
|
||||||
@@ -501,6 +542,7 @@ function processWar($connect, $general, $city) {
|
|||||||
//춘화첩, 초선화 사용
|
//춘화첩, 초선화 사용
|
||||||
$oppAtmos += 7;
|
$oppAtmos += 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
$oppTrain = 0;
|
$oppTrain = 0;
|
||||||
if($oppose[item] == 4) {
|
if($oppose[item] == 4) {
|
||||||
//청주 사용
|
//청주 사용
|
||||||
@@ -608,8 +650,8 @@ function processWar($connect, $general, $city) {
|
|||||||
if($myCrew <= 0) { $myCrew = rand() % 90 + 10; }
|
if($myCrew <= 0) { $myCrew = rand() % 90 + 10; }
|
||||||
if($opCrew <= 0) { $opCrew = rand() % 90 + 10; }
|
if($opCrew <= 0) { $opCrew = rand() % 90 + 10; }
|
||||||
//훈련 사기따라
|
//훈련 사기따라
|
||||||
$myCrew = getCrew($myCrew, CharAtmos($oppose[atmos]+$oppAtmos+$oppAtmosBonus, $oppose[personal]), CharTrain($general[train]+$genTrain+$genTrainBonus, $general[personal]));
|
$myCrew = getCrew($myCrew, CharAtmos($oppose[atmos]+$oppAtmos, $oppose[personal]), CharTrain($general[train]+$genTrain, $general[personal]));
|
||||||
$opCrew = getCrew($opCrew, CharAtmos($general[atmos]+$genAtmos+$genAtmosBonus, $general[personal]), CharTrain($oppose[train]+$oppTrain+$oppTrainBonus, $oppose[personal]));
|
$opCrew = getCrew($opCrew, CharAtmos($general[atmos]+$genAtmos, $general[personal]), CharTrain($oppose[train]+$oppTrain, $oppose[personal]));
|
||||||
//숙련도 따라
|
//숙련도 따라
|
||||||
$genDexAtt = getGenDex($general, $general[crewtype]);
|
$genDexAtt = getGenDex($general, $general[crewtype]);
|
||||||
$genDexDef = getGenDex($general, $oppose[crewtype]);
|
$genDexDef = getGenDex($general, $oppose[crewtype]);
|
||||||
@@ -905,8 +947,8 @@ function processWar($connect, $general, $city) {
|
|||||||
// 특기보정: 돌격
|
// 특기보정: 돌격
|
||||||
if($oppose[crewtype] == 43 && $general[special2] != 60) { // 목우
|
if($oppose[crewtype] == 43 && $general[special2] != 60) { // 목우
|
||||||
$r = 0;
|
$r = 0;
|
||||||
$r += $oppose[atmos] + $oppAtmos + $oppAtmosBonus;
|
$r += $oppose[atmos] + $oppAtmos;
|
||||||
$r += $oppose[train] + $oppTrain + $oppTrainBonus;
|
$r += $oppose[train] + $oppTrain;
|
||||||
$ratio = rand() % 400; // 최대 50% 저지
|
$ratio = rand() % 400; // 최대 50% 저지
|
||||||
if($ratio < $r && $opAvoid == 1) {
|
if($ratio < $r && $opAvoid == 1) {
|
||||||
$batlog[count($batlog)] = "<C>●</><R>저지</>당했다!</>";
|
$batlog[count($batlog)] = "<C>●</><R>저지</>당했다!</>";
|
||||||
|
|||||||
Reference in New Issue
Block a user