전투 구현 반영

This commit is contained in:
2018-08-19 02:57:25 +09:00
parent 5a8ab2d29c
commit 79d2b04721
4 changed files with 106 additions and 36 deletions
+1 -1
View File
@@ -156,7 +156,7 @@ class GameUnitDetail{
$ratio = max($mainstat - 65, 0);
$ratio *= $coef;
return min(50, $ratio);
return min(50, $ratio) / 100;
}
public function isValid($ownCities, $ownRegions, $relativeYear, $tech){
+5 -1
View File
@@ -260,7 +260,11 @@ class WarUnit{
return GameConst::$maxAtmosByCommand;
}
function getComputedAvoidRatio(){
function getComputedCriticalRatio():float{
return $this->getCrewType()->getCriticalRatio($this->getRaw());
}
function getComputedAvoidRatio():float{
return $this->getCrewType()->avoid / 100;
}
+15 -20
View File
@@ -2,43 +2,33 @@
namespace sammo;
class WarUnitCity extends WarUnit{
protected $logger;
protected $crewType;
protected $hp;
protected $rice = 0;
public $cityRate;
protected $updatedVar = [];
protected $year;
protected $month;
protected $cityRate;
function __construct($raw, $rawNation, $year, $month, $cityRate){
$this->raw = $raw;
$this->rawNation = $rawNation;
$this->year = $year;
$this->month = $month;
$this->isAttacker = false;
$this->cityRate = $cityRate;
$this->logger = new ActionLogger(0, $raw['nation'], $year, $month, false);
$this->crewType = GameUnitConst::byID($raw['crewtype']);
$this->rice = $this->getNationVar('rice');
$this->logger = new ActionLogger(
0,
$this->getVar('nation'),
$year,
$month,
false
);
$this->crewType = GameUnitConst::byID(GameUnitConst::T_CASTLE);
$this->hp = $this->getVar('def') * 10;
//수비자 보정
if($raw['level'] == 1){
if($this->getCityVar('level') == 1){
$this->trainBonus += 5;
}
else if($raw['level'] == 3){
else if($this->getCityVar('level') == 3){
$this->trainBonus += 5;
}
}
@@ -47,6 +37,10 @@ class WarUnitCity extends WarUnit{
return $this->getVar('name');
}
function getCityVar(string $key){
return $this->raw[$key];
}
function calcDamage():int{
$warPower = $this->getWarPower();
$warPower *= Util::randRange(0.9, 1.1);
@@ -94,6 +88,7 @@ class WarUnitCity extends WarUnit{
}
function addLose(){
//NOTE: 도시 정복은 외부에서 처리함
}
function heavyDecreseWealth(){
+85 -14
View File
@@ -4,13 +4,6 @@ namespace sammo;
class WarUnitGeneral extends WarUnit{
protected $rawCity;
protected $logger;
protected $crewType;
protected $win = 0;
protected $updatedVar = [];
function __construct($raw, $rawCity, $rawNation, $isAttacker, $year, $month){
setLeadershipBonus($raw, $rawNation['level']);
@@ -107,17 +100,49 @@ class WarUnitGeneral extends WarUnit{
}
function getComputedAtmos(){
return GameConst::$maxAtmosByCommand;
$train = $this->getVar('atmos');
$train += $this->trainBonus;
return $train;
}
function getComputedAvoidRatio(){
function getComputedCriticalRatio():float{
$critialRatio = $this->getCrewType()->getCriticalRatio($this->getRaw());
$specialWar = $this->getSpecialWar();
$item = $this->getItem();
if($this->isAttacker && $specialWar == 61){
$critialRatio += 0.1;
}
if($specialWar == 71){
$critialRatio += 0.2;
}
return $critialRatio;
}
function getComputedAvoidRatio():float{
$specialWar = $this->getSpecialWar();
$item = $this->getItem();
$avoidRatio = $this->getCrewType()->avoid / 100;
$avoidRatio *= $this->getComputedTrain() / 100;
//특기보정 : 궁병
if($specialWar == 51){
$avoidRatio += 0.2;
}
//도구 보정 : 둔갑천서, 태평요술
if($item == 26 || $item == 25){
$avoidRatio += 0.2;
}
return $avoidRatio;
}
function addWin(){
$this->win += 1;
$this->increaseVar('killnum', 1);
$this->multiplyVarWithLimit('atmos', 1.1, null, GameConst::$maxAtmosByWar);
$this->addStatExp(1);
@@ -425,15 +450,61 @@ class WarUnitGeneral extends WarUnit{
}
function checkPreActiveSkill():bool{
return false;
$activated = false;
$oppose = $this->getOppose();
$specialWar = $this->getSpecialWar();
$item = $this->getItem();
return $activated;
}
function checkActiveSkill():bool{
return false;
$activated = false;
$oppose = $this->getOppose();
$specialWar = $this->getSpecialWar();
$item = $this->getItem();
return $activated;
}
function checkPostActiveSkill():bool{
return false;
$activated = false;
$oppose = $this->getOppose();
$specialWar = $this->getSpecialWar();
$item = $this->getItem();
if(
!$this->hasActivatedSkill('특수') &&
Util::randBool($this->getComputedCriticalRatio())
){
$this->activateSkill('특수');
$this->activateSkill('필살');
}
if(
!$this->hasActivatedSkill('특수') &&
Util::randBool($this->getComputedAvoidRatio())
){
$this->activateSkill('특수');
$this->activateSkill('회피');
}
if(
$specialWar == 63 &&
$this->getPhase() == 0 &&
$this->getHP() >= 1000 &&
$this->getComputedAtmos() >= 90 &&
$this->getComputedTrain() >= 90
){
$this->activateSkill('위압');
$activated = true;
}
return $activated;
}
function applyActiveSkill():bool{