전투 구현 반영
This commit is contained in:
+20
-52
@@ -35,7 +35,8 @@ function processWar_NG(
|
|||||||
$defender = $city;
|
$defender = $city;
|
||||||
|
|
||||||
if($city->getRawNation()['rice'] <= 0 && $city->getRaw()['supply'] == 1){
|
if($city->getRawNation()['rice'] <= 0 && $city->getRaw()['supply'] == 1){
|
||||||
$attacker->setOppose(null);
|
$attacker->setOppose($defender);
|
||||||
|
$defender->setOppose($attacker);
|
||||||
$attacker->addTrain(1);
|
$attacker->addTrain(1);
|
||||||
$attacker->addWin();
|
$attacker->addWin();
|
||||||
$conquerCity = true;
|
$conquerCity = true;
|
||||||
@@ -80,21 +81,25 @@ function processWar_NG(
|
|||||||
$defender->applyBattleBeginSkillAndItem();
|
$defender->applyBattleBeginSkillAndItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
$attacker->computeWarPower();
|
$attacker->beginPhase();
|
||||||
$defender->computeWarPower();
|
$defender->beginPhase();
|
||||||
|
|
||||||
|
$attacker->checkPreActiveSkill();
|
||||||
|
$defender->checkPreActiveSkill();
|
||||||
|
|
||||||
$attacker->checkActiveSkill();
|
$attacker->checkActiveSkill();
|
||||||
$defender->checkActiveSkill();
|
$defender->checkActiveSkill();
|
||||||
|
//NOTE: 마법은 checkActiveSkill, checkPostActiveSkill 내에서 반영
|
||||||
|
|
||||||
$attacker->checkPostActiveSkill();
|
$attacker->checkPostActiveSkill();
|
||||||
$defender->checkPostActiveSkill();
|
$defender->checkPostActiveSkill();
|
||||||
|
//NOTE: 반계류 등의 스킬을 post에서 반영
|
||||||
|
|
||||||
$attacker->applyActiveSkill();
|
$attacker->applyActiveSkill();
|
||||||
$defender->applyActiveSkill();
|
$defender->applyActiveSkill();
|
||||||
|
|
||||||
$deadDefender = $attacker->tryAttackInPhase();
|
$deadDefender = $attacker->calcDamage();
|
||||||
$deadAttacker = $defender->tryAttackInPhase();
|
$deadAttacker = $defender->calcDamage();
|
||||||
//NOTE: 마법은 tryAttackInPhase 내에서 반영
|
|
||||||
|
|
||||||
$attackerHP = $attacker->getHP();
|
$attackerHP = $attacker->getHP();
|
||||||
$defenderHP = $defender->getHP();
|
$defenderHP = $defender->getHP();
|
||||||
@@ -189,10 +194,18 @@ function processWar_NG(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: 전투 종료
|
|
||||||
$attacker->finishBattle();
|
$attacker->finishBattle();
|
||||||
$defender->finishBattle();
|
$defender->finishBattle();
|
||||||
|
|
||||||
|
if($defender instanceof WarUnitCity){
|
||||||
|
$newConflict = $defender->addConflict();
|
||||||
|
if($newConflict){
|
||||||
|
$nationName = $attacker->getRawNation()['name'];
|
||||||
|
$josaYi = JosaUtil::pick($nationName, '이');
|
||||||
|
$logger->pushGlobalHistoryLog("<M><b>【분쟁】</b></><D><b>{$nationName}</b></>{$josaYi} <G><b>{$defender->getName()}</b></> 공략에 가담하여 분쟁이 발생하고 있습니다.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
($getNextDefender)($defender, false);
|
($getNextDefender)($defender, false);
|
||||||
//NOTE: 공격자의 applyDB는 함수 호출자가 실행
|
//NOTE: 공격자의 applyDB는 함수 호출자가 실행
|
||||||
|
|
||||||
@@ -204,51 +217,6 @@ function processWar_NG(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
|
||||||
// 표준 공 / 수 반환 수치는 약 0이 되게 (100~550)
|
|
||||||
//////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
function addConflict($city, $nationID, $mykillnum) {
|
|
||||||
$db = DB::db();
|
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
|
||||||
|
|
||||||
$nationlist = [];
|
|
||||||
$killnum = [0];
|
|
||||||
|
|
||||||
list($year, $month) = $gameStor->getValuesAsArray(['year', 'month']);
|
|
||||||
|
|
||||||
$conflict = Json::decode($city['conflict']);
|
|
||||||
|
|
||||||
if(!$conflict || $city['def'] == 0){ // 선타, 막타 보너스
|
|
||||||
$mykillnum *= 1.05;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$conflict) {
|
|
||||||
$conflict[$nationID] = $mykillnum;
|
|
||||||
}
|
|
||||||
else if(key_exists($nationID, $conflict)){
|
|
||||||
$conflict[$nationID] += $mykillnum;
|
|
||||||
arsort($conflict);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$conflict[$nationID] = $mykillnum;
|
|
||||||
arsort($conflict);
|
|
||||||
|
|
||||||
$nation = getNationStaticInfo($nationID);
|
|
||||||
$josaYi = JosaUtil::pick($nation['name'], '이');
|
|
||||||
pushWorldHistory(["<C>●</>{$year}년 {$month}월:<M><b>【분쟁】</b></><D><b>{$nation['name']}</b></>{$josaYi} <G><b>{$city['name']}</b></> 공략에 가담하여 분쟁이 발생하고 있습니다."]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$rawConflict = Json::encode($conflict);
|
|
||||||
$city['conflict'] = $rawConflict;
|
|
||||||
|
|
||||||
$db->update('city', [
|
|
||||||
'conflict'=>$rawConflict
|
|
||||||
], 'city=%i',$city['city']);
|
|
||||||
|
|
||||||
return $city;
|
|
||||||
}
|
|
||||||
|
|
||||||
function DeleteConflict($nation) {
|
function DeleteConflict($nation) {
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
|
|||||||
+43
-6
@@ -24,6 +24,8 @@ class WarUnit{
|
|||||||
protected $warPower;
|
protected $warPower;
|
||||||
protected $warPowerMultiply = 1.0;
|
protected $warPowerMultiply = 1.0;
|
||||||
|
|
||||||
|
protected $activatedSkill = [];
|
||||||
|
|
||||||
private function __construct(){
|
private function __construct(){
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +101,10 @@ class WarUnit{
|
|||||||
$this->oppose = $oppose;
|
$this->oppose = $oppose;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getOppose():?WarUnit{
|
||||||
|
return $this->oppose;
|
||||||
|
}
|
||||||
|
|
||||||
function getWarPower(){
|
function getWarPower(){
|
||||||
return $this->warPower * $this->warPowerMultiply;
|
return $this->warPower * $this->warPowerMultiply;
|
||||||
}
|
}
|
||||||
@@ -124,9 +130,11 @@ class WarUnit{
|
|||||||
$warPower = GameConst::$armperphase + $myAtt - $opDef;
|
$warPower = GameConst::$armperphase + $myAtt - $opDef;
|
||||||
$opposeWarPowerMultiply = 1.0;
|
$opposeWarPowerMultiply = 1.0;
|
||||||
|
|
||||||
if($warPower <= 0){
|
if($warPower < 100){
|
||||||
//FIXME: 0으로 잡을때 90~100이면, 1은 너무 억울하지 않나?
|
//최소 전투력 50 보장
|
||||||
$warPower = rand(90, 100);
|
$warPower = max(0, $warPower);
|
||||||
|
$warPower = ($warPower + 100) / 2;
|
||||||
|
$warPower = rand($warPower, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
$warPower *= CharAtmos(
|
$warPower *= CharAtmos(
|
||||||
@@ -139,8 +147,20 @@ class WarUnit{
|
|||||||
$oppose->getCharacter()
|
$oppose->getCharacter()
|
||||||
);
|
);
|
||||||
|
|
||||||
$genDexAtt = getGenDex($this->getRaw(), $this->getCrewType()->id);
|
if($this instanceof WarUnitGeneral){
|
||||||
$oppDexDef = getGenDex($oppose->getRaw(), $this->getCrewType()->id);
|
$genDexAtt = getGenDex($this->getRaw(), $this->getCrewType()->id);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$genDexAtt = ($this->cityRate - 60) * 7200;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this instanceof WarUnitGeneral){
|
||||||
|
$oppDexDef = getGenDex($oppose->getRaw(), $this->getCrewType()->id);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$oppDexDef = ($this->cityRate - 60) * 7200;
|
||||||
|
}
|
||||||
|
|
||||||
$warPower *= getDexLog($genDexAtt, $oppDexDef);
|
$warPower *= getDexLog($genDexAtt, $oppDexDef);
|
||||||
|
|
||||||
$warPower *= $this->getCrewType()->getAttackCoef($oppose->getCrewType());
|
$warPower *= $this->getCrewType()->getAttackCoef($oppose->getCrewType());
|
||||||
@@ -189,6 +209,11 @@ class WarUnit{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function beginPhase():void{
|
||||||
|
$this->activatedSkill = [];
|
||||||
|
$this->computeWarPower();
|
||||||
|
}
|
||||||
|
|
||||||
function checkBattleBeginSkill():bool{
|
function checkBattleBeginSkill():bool{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -201,6 +226,18 @@ class WarUnit{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasActivatedSkill(string $skillName):bool{
|
||||||
|
return $this->activatedSkill[$skillName] ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function deactivateSkill(string $skillName):bool{
|
||||||
|
$this->activatedSkill[$skillName] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkPreActiveSkill():bool{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function checkActiveSkill():bool{
|
function checkActiveSkill():bool{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -227,7 +264,7 @@ class WarUnit{
|
|||||||
throw new NotInheritedMethodException();
|
throw new NotInheritedMethodException();
|
||||||
}
|
}
|
||||||
|
|
||||||
function tryAttackInPhase():int{
|
function calcDamage():int{
|
||||||
return $this->getWarPower();
|
return $this->getWarPower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,14 +11,22 @@ class WarUnitCity extends WarUnit{
|
|||||||
protected $trainAtmos;
|
protected $trainAtmos;
|
||||||
|
|
||||||
protected $rice = 0;
|
protected $rice = 0;
|
||||||
|
public $cityRate;
|
||||||
|
|
||||||
protected $updatedVar = [];
|
protected $updatedVar = [];
|
||||||
|
|
||||||
function __construct($raw, $rawNation, $year, $month){
|
protected $year;
|
||||||
|
protected $month;
|
||||||
|
|
||||||
|
function __construct($raw, $rawNation, $year, $month, $cityRate){
|
||||||
$this->raw = $raw;
|
$this->raw = $raw;
|
||||||
$this->rawNation = $rawNation;
|
$this->rawNation = $rawNation;
|
||||||
|
|
||||||
|
$this->year = $year;
|
||||||
|
$this->month = $month;
|
||||||
|
|
||||||
$this->isAttacker = false;
|
$this->isAttacker = false;
|
||||||
|
$this->cityRate = $cityRate;
|
||||||
|
|
||||||
$this->logger = new ActionLogger(0, $raw['nation'], $year, $month);
|
$this->logger = new ActionLogger(0, $raw['nation'], $year, $month);
|
||||||
$this->crewType = GameUnitConst::byID($raw['crewtype']);
|
$this->crewType = GameUnitConst::byID($raw['crewtype']);
|
||||||
@@ -39,7 +47,7 @@ class WarUnitCity extends WarUnit{
|
|||||||
return $this->raw['name'];
|
return $this->raw['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function tryAttackInPhase():int{
|
function calcDamage():int{
|
||||||
$warPower = $this->getWarPower();
|
$warPower = $this->getWarPower();
|
||||||
$warPower *= Util::randRange(0.9, 1.1);
|
$warPower *= Util::randRange(0.9, 1.1);
|
||||||
}
|
}
|
||||||
@@ -89,6 +97,37 @@ class WarUnitCity extends WarUnit{
|
|||||||
$this->updatedVar['secu'] = true;
|
$this->updatedVar['secu'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addConflict():bool{
|
||||||
|
$conflict = Json::decode($this->raw['conflict']);
|
||||||
|
$opposeNation = $this->getOppose()->getRawNation();
|
||||||
|
|
||||||
|
$nationID = $opposeNation['nation'];
|
||||||
|
$newConflict = false;
|
||||||
|
|
||||||
|
$dead = $this->dead;
|
||||||
|
|
||||||
|
if(!$conflict || $this->getHP() == 0){ // 선타, 막타 보너스
|
||||||
|
$dead *= 1.05;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$conflict){
|
||||||
|
$conflict = [$nationID => $dead];
|
||||||
|
}
|
||||||
|
else if(key_exists($nationID, $conflict)){
|
||||||
|
$conflict[$nationID] += $dead;
|
||||||
|
arsort($conflict);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$conflict[$nationID] = $dead;
|
||||||
|
arsort($conflict);
|
||||||
|
$newConflict = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->raw['conflict'] = Json::encode($conflict);
|
||||||
|
$this->updatedVar['conflict'] = true;
|
||||||
|
|
||||||
|
return $newConflict;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function applyDB($db):bool{
|
function applyDB($db):bool{
|
||||||
|
|||||||
@@ -355,7 +355,11 @@ class WarUnitGeneral extends WarUnit{
|
|||||||
$this->dead += $damage;
|
$this->dead += $damage;
|
||||||
$this->raw['crew'] -= $damage;
|
$this->raw['crew'] -= $damage;
|
||||||
|
|
||||||
|
$addDex = $damage;
|
||||||
|
if(!$this->isAttacker){
|
||||||
|
$addDex *= 0.9;
|
||||||
|
}
|
||||||
|
$this->addDex($this->oppose->getCrewType(), $addDex);
|
||||||
|
|
||||||
return $this->raw['crew'];
|
return $this->raw['crew'];
|
||||||
}
|
}
|
||||||
@@ -375,14 +379,18 @@ class WarUnitGeneral extends WarUnit{
|
|||||||
$rice = min($this->raw['rice'], $rice);
|
$rice = min($this->raw['rice'], $rice);
|
||||||
$this->raw['rice'] -= $rice;
|
$this->raw['rice'] -= $rice;
|
||||||
$this->updatedVar['rice'] = true;
|
$this->updatedVar['rice'] = true;
|
||||||
//TODO: 죽인 만큼 숙련도 변경
|
|
||||||
//TODO: 죽인 만큼 쌀 소모
|
$addDex = $damage;
|
||||||
|
if(!$this->isAttacker){
|
||||||
|
$addDex *= 0.9;
|
||||||
|
}
|
||||||
|
$this->addDex($this->oppose->getCrewType(), $addDex);
|
||||||
|
|
||||||
$this->killed += $damage;
|
$this->killed += $damage;
|
||||||
return $this->killed;
|
return $this->killed;
|
||||||
}
|
}
|
||||||
|
|
||||||
function tryAttackInPhase():int{
|
function calcDamage():int{
|
||||||
//TODO
|
//TODO
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -416,9 +424,45 @@ class WarUnitGeneral extends WarUnit{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function finishBattle(){
|
///checkAbility의 method 버전
|
||||||
//TODO: 전투 종료 처리. 경험치 등
|
function checkStatChange():bool{
|
||||||
|
//FIXME: 장기적으로는 General 클래스가 별도로 있어야 함
|
||||||
|
$logger = $this->getLogger();
|
||||||
|
$limit = GameConst::$upgradeLimit;
|
||||||
|
|
||||||
|
$table = [
|
||||||
|
['통솔', 'leader'],
|
||||||
|
['무력', 'power'],
|
||||||
|
['지력', 'intel'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$result = false;
|
||||||
|
|
||||||
|
foreach($table as [$statNickName, $statName]){
|
||||||
|
$statExpName = $statName.'2';
|
||||||
|
|
||||||
|
if($this->raw[$statExpName] < 0){
|
||||||
|
$logger->pushGeneralActionLog("<R>{$statNickName}</>이 <C>1</> 떨어졌습니다!", ActionLogger::PLAIN);
|
||||||
|
$this->raw[$statExpName] += $limit;
|
||||||
|
$this->updatedVar[$statExpName] = true;
|
||||||
|
$this->raw[$statName] -= 1;
|
||||||
|
$this->updatedVar[$statName] = true;
|
||||||
|
$result = true;
|
||||||
|
}
|
||||||
|
else if($this->raw[$statExpName] >= $limit){
|
||||||
|
$logger->pushGeneralActionLog("<R>{$statNickName}</>이 <C>1</> 올랐습니다!", ActionLogger::PLAIN);
|
||||||
|
$this->raw[$statExpName] -= $limit;
|
||||||
|
$this->updatedVar[$statExpName] = true;
|
||||||
|
$this->raw[$statName] += 1;
|
||||||
|
$this->updatedVar[$statName] = true;
|
||||||
|
$result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function finishBattle(){
|
||||||
if($this->isAttacker){
|
if($this->isAttacker){
|
||||||
$this->raw['recwar'] = $this->raw['turntime'];
|
$this->raw['recwar'] = $this->raw['turntime'];
|
||||||
}
|
}
|
||||||
@@ -436,6 +480,8 @@ class WarUnitGeneral extends WarUnit{
|
|||||||
Util::setRound($this->raw['rice']);
|
Util::setRound($this->raw['rice']);
|
||||||
Util::setRound($this->raw['experience']);
|
Util::setRound($this->raw['experience']);
|
||||||
Util::setRound($this->raw['dedication']);
|
Util::setRound($this->raw['dedication']);
|
||||||
|
|
||||||
|
$this->checkStatChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user