전투 엔진 중간 반영
This commit is contained in:
+25
-15
@@ -8,7 +8,7 @@ class WarUnit{
|
||||
protected $crewType;
|
||||
|
||||
protected $killed = 0;
|
||||
protected $death = 0;
|
||||
protected $dead = 0;
|
||||
|
||||
protected $isAttacker = false;
|
||||
|
||||
@@ -55,6 +55,14 @@ class WarUnit{
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
function getKilled():int{
|
||||
return $this->killed;
|
||||
}
|
||||
|
||||
function getDead():int{
|
||||
return $this->dead;
|
||||
}
|
||||
|
||||
function getSpecialDomestic():int{
|
||||
return 0;
|
||||
}
|
||||
@@ -146,21 +154,23 @@ class WarUnit{
|
||||
}
|
||||
|
||||
function getComputedTrain(){
|
||||
//TODO: 나머지에 구현
|
||||
return 100;
|
||||
return GameConst::$maxTrainByCommand;
|
||||
}
|
||||
|
||||
function getComputeAtmos(){
|
||||
//TODO: 나머지에 구현
|
||||
return 100;
|
||||
return GameConst::$maxAtmosByCommand;
|
||||
}
|
||||
|
||||
function addWin(){
|
||||
//TODO: 1승 로그 추가
|
||||
throw new NotInheritedMethodException();
|
||||
}
|
||||
|
||||
function addLose(){
|
||||
//TODO: 1패 로그 추가
|
||||
throw new NotInheritedMethodException();
|
||||
}
|
||||
|
||||
function finishBattle(){
|
||||
throw new NotInheritedMethodException();
|
||||
}
|
||||
|
||||
function getCharacter(){
|
||||
@@ -188,24 +198,24 @@ class WarUnit{
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkActiveItem():bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
function applyActiveSkillAndItem():bool{
|
||||
function applyActiveSkill():bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
function getHP():int{
|
||||
return 1;
|
||||
throw new NotInheritedMethodException();
|
||||
}
|
||||
|
||||
function decreaseHP(int $damage):int{
|
||||
return false;
|
||||
throw new NotInheritedMethodException();
|
||||
}
|
||||
|
||||
function increaseKilled(int $damage):int{
|
||||
throw new NotInheritedMethodException();
|
||||
}
|
||||
|
||||
function tryAttackInPhase():int{
|
||||
return 0;
|
||||
return $this->getWarPower();
|
||||
}
|
||||
|
||||
function tryWound():bool{
|
||||
|
||||
@@ -7,8 +7,6 @@ class WarUnitCity extends WarUnit{
|
||||
protected $logger;
|
||||
protected $crewType;
|
||||
|
||||
protected $killed = 0;
|
||||
protected $death = 0;
|
||||
protected $rice = 0;
|
||||
|
||||
protected $updatedVar = [];
|
||||
@@ -20,6 +18,7 @@ class WarUnitCity extends WarUnit{
|
||||
function __construct($raw, $rawNation, $year, $month){
|
||||
$this->raw = $raw;
|
||||
$this->rawNation = $rawNation;
|
||||
|
||||
$this->isAttacker = false;
|
||||
|
||||
$this->logger = new ActionLogger(0, $raw['nation'], $year, $month);
|
||||
@@ -27,7 +26,7 @@ class WarUnitCity extends WarUnit{
|
||||
|
||||
$this->def = $raw['def'] * 10;
|
||||
$this->wall = $raw['wall'] * 10;
|
||||
$this->rice = $rawNation['rice'];
|
||||
$this->rice = $this->rawNation['rice'];
|
||||
|
||||
$this->crewType = GameUnitConst::byID(GameUnitConst::T_CASTLE);
|
||||
}
|
||||
@@ -40,6 +39,11 @@ class WarUnitCity extends WarUnit{
|
||||
return $this->raw['name'];
|
||||
}
|
||||
|
||||
function tryAttackInPhase():int{
|
||||
$warPower = $this->getWarPower();
|
||||
$warPower *= Util::randRange(0.9, 1.1);
|
||||
}
|
||||
|
||||
function continueWar(&$noRice):bool{
|
||||
//전투가 가능하면 true
|
||||
$noRice = false;
|
||||
|
||||
@@ -9,8 +9,6 @@ class WarUnitGeneral extends WarUnit{
|
||||
protected $logger;
|
||||
protected $crewType;
|
||||
|
||||
protected $killed = 0;
|
||||
protected $death = 0;
|
||||
protected $win = 0;
|
||||
|
||||
protected $updatedVar = [];
|
||||
@@ -92,6 +90,55 @@ class WarUnitGeneral extends WarUnit{
|
||||
$this->updatedVar['atmos'] = true;
|
||||
}
|
||||
|
||||
function addWin(){
|
||||
$this->win += 1;
|
||||
|
||||
$this->raw['atmos'] = min($this->raw['atmos'] * 1.1, GameConst::$maxAtmosByWar);
|
||||
$this->updatedVar['atmos'] = true;
|
||||
|
||||
$this->addStatExp(1);
|
||||
}
|
||||
|
||||
function addStatExp(int $value = 1){
|
||||
if($this->crewType->armType == GameUnitConst::T_WIZARD) { // 귀병
|
||||
$this->raw['intel2'] += $value;
|
||||
$this->updatedVar['intel2'] = true;
|
||||
} elseif($this->crewType->armType == GameUnitConst::T_SIEGE) { // 차병
|
||||
$this->raw['leader2'] += $value;
|
||||
$this->updatedVar['leader2'] = true;
|
||||
} else {
|
||||
$this->raw['power2'] += $value;
|
||||
$this->updatedVar['power2'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
function addLevelExp(float $value){
|
||||
$value *= getCharExpMultiplier($this->getCharacter());
|
||||
$this->raw['experience'] += $value;
|
||||
$this->updatedVar['experience'] = true;
|
||||
}
|
||||
|
||||
function addDedication(float $value){
|
||||
$value *= getCharDedMultiplier($this->getCharacter());
|
||||
$this->raw['dedication'] += $value;
|
||||
$this->updatedVar['dedication'] = true;
|
||||
}
|
||||
|
||||
function addLose(){
|
||||
|
||||
$this->addStatExp(1);
|
||||
//TODO: 1패 로그 추가
|
||||
}
|
||||
|
||||
function finishBattle(){
|
||||
//TODO: 전투 종료 처리. 경험치 등
|
||||
|
||||
|
||||
Util::setRound($this->raw['rice']);
|
||||
Util::setRound($this->raw['experience']);
|
||||
Util::setRound($this->raw['dedication']);
|
||||
}
|
||||
|
||||
protected function getWarPowerMultiplyBySpecialWar():array{
|
||||
//TODO: 장기적으로 if문이 아니라 객체를 이용하여 처리해야함
|
||||
$myWarPowerMultiply = 1.0;
|
||||
@@ -270,6 +317,47 @@ class WarUnitGeneral extends WarUnit{
|
||||
return $itemActivated;
|
||||
}
|
||||
|
||||
function getHP():int{
|
||||
return $this->raw['crew'];
|
||||
}
|
||||
|
||||
function decreaseHP(int $damage):int{
|
||||
$damage = min($damage, $this->raw['crew']);
|
||||
$this->raw['crew'] -= $damage;
|
||||
|
||||
//TODO: 죽은 만큼 숙련도 변경
|
||||
|
||||
return $this->raw['crew'];
|
||||
}
|
||||
|
||||
function increaseKilled(int $damage):int{
|
||||
|
||||
$this->addLevelExp($damage / 50);
|
||||
|
||||
$rice = $damage / 100;
|
||||
if(!$this->isAttacker){
|
||||
$rice *= 0.8;
|
||||
}
|
||||
|
||||
$rice *= getCharExpMultiplier($this->getCharacter());
|
||||
$rice *= $this->crewType->rice;
|
||||
$rice *= getTechCost($this->rawNation['tech']);
|
||||
|
||||
$rice = min($this->raw['rice'], $rice);
|
||||
$this->raw['rice'] -= $rice;
|
||||
$this->updatedVar['rice'] = true;
|
||||
//TODO: 죽인 만큼 숙련도 변경
|
||||
//TODO: 죽인 만큼 쌀 소모
|
||||
|
||||
$this->killed += $damage;
|
||||
return $this->killed;
|
||||
}
|
||||
|
||||
function tryAttackInPhase():int{
|
||||
//TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
function tryWound():bool{
|
||||
if(Util::randBool(0.95)){
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user