WarUnit의 일부 요소를 General과 ActionSpecialWar 등으로 분리
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace sammo\ActionNationType;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
|
||||
class che_회피_둔갑천서 extends \sammo\BaseItem{
|
||||
|
||||
protected static $id = 26;
|
||||
protected static $name = '둔갑천서(회피)';
|
||||
protected static $info = '[전투] 회피 확률 +20%p';
|
||||
protected static $cost = 200;
|
||||
protected static $consumable = false;
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'warAvoidRatio'){
|
||||
return $value += 0.2;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace sammo\ActionNationType;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
|
||||
class che_회피_태평요술 extends \sammo\BaseItem{
|
||||
|
||||
protected static $id = 25;
|
||||
protected static $name = '둔갑천서(회피)';
|
||||
protected static $info = '[전투] 회피 확률 +20%p';
|
||||
protected static $cost = 200;
|
||||
protected static $consumable = false;
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'warAvoidRatio'){
|
||||
return $value += 0.2;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_격노 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_견고 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
|
||||
@@ -4,6 +4,8 @@ use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\GameUnitConst;
|
||||
use \sammo\WarUnit;
|
||||
use \sammo\WarUnitCity;
|
||||
|
||||
class che_공성 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
@@ -27,4 +29,11 @@ class che_공성 implements iAction{
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getWarPowerMultiplier(WarUnit $unit):array{
|
||||
if($unit->getOppose() instanceof WarUnitCity){
|
||||
return [2, 1];
|
||||
}
|
||||
return [1, 1];
|
||||
}
|
||||
}
|
||||
@@ -27,4 +27,11 @@ class che_궁병 implements iAction{
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'warAvoidRatio'){
|
||||
return $value += 0.2;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\GameUnitConst;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_귀병 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
|
||||
@@ -4,6 +4,7 @@ use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\GameUnitConst;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_기병 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
@@ -26,4 +27,11 @@ class che_기병 implements iAction{
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getWarPowerMultiplier(WarUnit $unit):array{
|
||||
if($unit->isAttacker()){
|
||||
return [1.2, 1];
|
||||
}
|
||||
return [1.1, 1];
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_돌격 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
@@ -24,4 +25,11 @@ class che_돌격 implements iAction{
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getWarPowerMultiplier(WarUnit $unit):array{
|
||||
if($unit->isAttacker()){
|
||||
return [1.1, 1];
|
||||
}
|
||||
return [1, 1];
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_무쌍 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
@@ -24,4 +25,8 @@ class che_무쌍 implements iAction{
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getWarPowerMultiplier(WarUnit $unit):array{
|
||||
return [1.1, 1];
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_반계 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
|
||||
@@ -4,6 +4,7 @@ use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\GameUnitConst;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_보병 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
@@ -26,4 +27,11 @@ class che_보병 implements iAction{
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getWarPowerMultiplier(WarUnit $unit):array{
|
||||
if($unit->isAttacker()){
|
||||
return [0, 0.9];
|
||||
}
|
||||
return [0, 0.8];
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_신산 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_신중 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_위압 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
|
||||
@@ -6,6 +6,7 @@ use sammo\SpecialityConst;
|
||||
use \sammo\General;
|
||||
use \sammo\GeneralTrigger;
|
||||
use \sammo\GeneralTriggerCaller;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_의술 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_저격 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_집중 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_징병 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_척사 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
@@ -18,4 +19,12 @@ class che_척사 implements iAction{
|
||||
SpecialityConst::STAT_POWER,
|
||||
SpecialityConst::STAT_INTEL
|
||||
];
|
||||
|
||||
public function getWarPowerMultiplier(WarUnit $unit):array{
|
||||
$opposeCrewType = $unit->getOppose()->getCrewType();
|
||||
if($opposeCrewType->reqCities || $opposeCrewType->reqRegions){
|
||||
return [1.1, 0.9];
|
||||
}
|
||||
return [1, 1];
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_필살 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace sammo\ActionSpecialWar;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\SpecialityConst;
|
||||
use \sammo\WarUnit;
|
||||
|
||||
class che_환술 implements iAction{
|
||||
use \sammo\DefaultAction;
|
||||
|
||||
@@ -16,13 +16,7 @@ class DummyGeneral extends General{
|
||||
$this->resultTurn = new LastTurn();
|
||||
|
||||
if($initLogger){
|
||||
$this->logger = new ActionLogger(
|
||||
$this->getVar('no'),
|
||||
$this->getVar('nation'),
|
||||
1,
|
||||
1,
|
||||
false
|
||||
);
|
||||
$this->initLogger(1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,26 +82,21 @@ class GameUnitDetail{
|
||||
return $this->defenceCoef[$armType]??1;
|
||||
}
|
||||
|
||||
public function getComputedAttack(array $general, int $tech){
|
||||
if($this->armType == GameUnitConst::T_CASTLE){
|
||||
assert(isset($general['def']) && isset($general['wall']), '도시 정보가 입력되어야 함');
|
||||
return ($general['def'] + $general['wall']*9) / 500 + 200;
|
||||
}
|
||||
|
||||
public function getComputedAttack(General $general, int $tech){
|
||||
if($this->armType == GameUnitConst::T_WIZARD){
|
||||
$ratio = getGeneralIntel($general, true, true, true)*2 - 40;
|
||||
$ratio = $general->getIntel(true, true, true)*2 - 40;
|
||||
}
|
||||
else if($this->armType == GameUnitConst::T_SIEGE){
|
||||
$ratio = getGeneralLeadership($general, true, true, true)*2 - 40;
|
||||
$ratio = $general->getLeadership(true, true, true)*2 - 40;
|
||||
}
|
||||
else if($this->armType == GameUnitConst::T_MISC){
|
||||
$ratio = getGeneralIntel($general, true, true, true) +
|
||||
getGeneralLeadership($general, true, true, true) +
|
||||
getGeneralPower($general, true, true, true);
|
||||
$ratio = $general->getIntel(true, true, true) +
|
||||
$general->getLeadership(true, true, true) +
|
||||
$general->getPower(true, true, true);
|
||||
$ratio = $ratio*2/3 - 40;
|
||||
}
|
||||
else{
|
||||
$ratio = getGeneralPower($general, true, true, true)*2 - 40;
|
||||
$ratio = $general->getPower(true, true, true)*2 - 40;
|
||||
}
|
||||
if($ratio < 10){
|
||||
$ratio = 10;
|
||||
@@ -114,13 +109,9 @@ class GameUnitDetail{
|
||||
return $att * $ratio / 100;
|
||||
}
|
||||
|
||||
public function getComputedDefence(array $general, int $tech){
|
||||
if($this->armType == GameUnitConst::T_CASTLE){
|
||||
assert(isset($general['def']) && isset($general['wall']), '도시 정보가 입력되어야 함');
|
||||
return ($general['def'] + $general['wall']*9) / 500 + 200;
|
||||
}
|
||||
public function getComputedDefence(General $general, int $tech){
|
||||
$def = $this->defence + getTechAbil($tech);
|
||||
$crew = ($general['crew'] / (7000 / 30)) + 70;
|
||||
$crew = ($general->getVar('crew') / (7000 / 30)) + 70;
|
||||
return $def * $crew / 100;
|
||||
}
|
||||
|
||||
|
||||
+11
-7
@@ -52,13 +52,7 @@ class General implements iAction{
|
||||
$this->resultTurn = new LastTurn();
|
||||
|
||||
if($year !== null || $month !== null){
|
||||
$this->logger = new ActionLogger(
|
||||
$this->getVar('no'),
|
||||
$this->getVar('nation'),
|
||||
$year,
|
||||
$month,
|
||||
false
|
||||
);
|
||||
$this->initLogger($year, $month);
|
||||
}
|
||||
|
||||
if(!$fullConstruct){
|
||||
@@ -90,6 +84,16 @@ class General implements iAction{
|
||||
//TODO: $specialItemClass 설정
|
||||
}
|
||||
|
||||
function initLogger(int $year, int $month){
|
||||
$this->logger = new ActionLogger(
|
||||
$this->getVar('no'),
|
||||
$this->getVar('nation'),
|
||||
$year,
|
||||
$month,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
function deleteItem(){
|
||||
$this->setVar('item', 0);
|
||||
$this->itemObjs['item'] = new ActionItem\che_Dummy(0);
|
||||
|
||||
+64
-22
@@ -33,6 +33,53 @@ class WarUnit{
|
||||
private function __construct(General $general){
|
||||
$this->general = $general;
|
||||
}
|
||||
|
||||
/* XXX:Dirty wrapper */
|
||||
function getRaw():array{
|
||||
return $this->general->getRaw();
|
||||
}
|
||||
|
||||
function getVar(string $key){
|
||||
return $this->general->getVar($key);
|
||||
}
|
||||
|
||||
function touchVar(string $key):bool{
|
||||
return $this->general->touchVar($key);
|
||||
}
|
||||
|
||||
function setVar(string $key, $value){
|
||||
return $this->general->setVar($key, $value);
|
||||
}
|
||||
|
||||
function updateVar(string $key, $value){
|
||||
return $this->general->updateVar($key, $value);
|
||||
}
|
||||
|
||||
function updateVarWithLimit(string $key, $value, $min = null, $max = null){
|
||||
return $this->general->updateVarWithLimit($key, $value, $min, $max);
|
||||
}
|
||||
|
||||
function increaseVar(string $key, $value)
|
||||
{
|
||||
return $this->general->increaseVar($key, $value);
|
||||
}
|
||||
|
||||
function increaseVarWithLimit(string $key, $value, $min = null, $max = null){
|
||||
return $this->general->increaseVarWithLimit($key, $value, $min, $max);
|
||||
}
|
||||
|
||||
function multiplyVar(string $key, $value)
|
||||
{
|
||||
return $this->general->multiplyVar($key, $value);
|
||||
}
|
||||
|
||||
function multiplyVarWithLimit(string $key, $value, $min = null, $max = null){
|
||||
return $this->general->multiplyVarWithLimit($key, $value, $min, $max);
|
||||
}
|
||||
|
||||
function getUpdatedValues():array {
|
||||
return $this->general->getUpdatedValues();
|
||||
}
|
||||
|
||||
protected function clearActivatedSkill(){
|
||||
foreach($this->activatedSkill as $skillName=>$state){
|
||||
@@ -91,7 +138,7 @@ class WarUnit{
|
||||
}
|
||||
|
||||
function getLogger():ActionLogger{
|
||||
return $this->logger;
|
||||
return $this->general->logger;
|
||||
}
|
||||
|
||||
function getKilled():int{
|
||||
@@ -114,10 +161,6 @@ class WarUnit{
|
||||
return $this->general;
|
||||
}
|
||||
|
||||
function getVar(string $key){
|
||||
return $this->general->getVar($key);
|
||||
}
|
||||
|
||||
function getMaxPhase():int{
|
||||
return $this->getCrewType()->speed;
|
||||
}
|
||||
@@ -161,11 +204,21 @@ class WarUnit{
|
||||
$this->warPowerMultiply *= $multiply;
|
||||
}
|
||||
|
||||
function computeWarPower(){
|
||||
$oppose = $this->oppose;
|
||||
function getComputedAttack(){
|
||||
return $this->getCrewType()->getComputedAttack($this->general, $this->getNationVar('tech'));
|
||||
}
|
||||
|
||||
$myAtt = $this->getCrewType()->getComputedAttack($this->getRaw(), $this->getNationVar('tech'));
|
||||
$opDef = $oppose->getCrewType()->getComputedDefence($oppose->getRaw(), $oppose->getNationVar('tech'));
|
||||
function getComputedDefence(){
|
||||
return $this->getCrewType()->getComputedDefence($this->general, $this->getNationVar('tech'));
|
||||
}
|
||||
|
||||
function computeWarPower(){
|
||||
$oppose = $this->getOppose();
|
||||
$general = $this->general;
|
||||
$opposeGeneral = $oppose->getGeneral();
|
||||
|
||||
$myAtt = $this->getComputedAttack();
|
||||
$opDef = $oppose->getComputedDefence();
|
||||
// 감소할 병사 수
|
||||
$warPower = GameConst::$armperphase + $myAtt - $opDef;
|
||||
$opposeWarPowerMultiply = 1.0;
|
||||
@@ -177,15 +230,8 @@ class WarUnit{
|
||||
$warPower = rand($warPower, 100);
|
||||
}
|
||||
|
||||
$warPower *= CharAtmos(
|
||||
$this->getComputedAtmos(),
|
||||
$this->getCharacter()
|
||||
);
|
||||
|
||||
$warPower /= CharTrain(
|
||||
$oppose->getComputedTrain(),
|
||||
$oppose->getCharacter()
|
||||
);
|
||||
$warPower *= $this->getComputedAtmos();
|
||||
$warPower /= $oppose->getComputedTrain();
|
||||
|
||||
if($this instanceof WarUnitGeneral){
|
||||
$genDexAtt = getGenDex($this->getRaw(), $this->getCrewType()->id);
|
||||
@@ -254,10 +300,6 @@ class WarUnit{
|
||||
throw new NotInheritedMethodException();
|
||||
}
|
||||
|
||||
function getCharacter():int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
function useBattleInitItem():bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2,24 +2,24 @@
|
||||
namespace sammo;
|
||||
|
||||
class WarUnitCity extends WarUnit{
|
||||
use LazyVarUpdater;
|
||||
|
||||
protected $hp;
|
||||
|
||||
protected $cityRate;
|
||||
|
||||
function __construct($raw, $rawNation, $year, $month, $cityRate){
|
||||
function __construct($raw, $rawNation, int $year, int $month, $cityRate){
|
||||
$general = new DummyGeneral(false);
|
||||
$general->setVar('city', $raw['city']);
|
||||
$general->setVar('nation', $raw['nation']);
|
||||
$general->initLogger($year, $month);
|
||||
$this->raw = $raw;
|
||||
$this->rawNation = $rawNation;
|
||||
|
||||
$this->isAttacker = false;
|
||||
$this->cityRate = $cityRate;
|
||||
|
||||
$this->logger = new ActionLogger(
|
||||
0,
|
||||
$this->getVar('nation'),
|
||||
$year,
|
||||
$month,
|
||||
false
|
||||
);
|
||||
$this->logger = $general->getLogger();
|
||||
$this->crewType = GameUnitConst::byID(GameUnitConst::T_CASTLE);
|
||||
|
||||
$this->hp = $this->getVar('def') * 10;
|
||||
@@ -41,6 +41,14 @@ class WarUnitCity extends WarUnit{
|
||||
return $this->raw[$key];
|
||||
}
|
||||
|
||||
function getComputedAttack(){
|
||||
return ($this->raw['def'] + $this->raw['wall'] * 9) / 500 + 200;
|
||||
}
|
||||
|
||||
function getComputedDefence(){
|
||||
return ($this->raw['def'] + $this->raw['wall'] * 9) / 500 + 200;
|
||||
}
|
||||
|
||||
function increaseKilled(int $damage):int{
|
||||
$this->killed += $damage;
|
||||
$this->killedCurr += $damage;
|
||||
@@ -138,13 +146,13 @@ class WarUnitCity extends WarUnit{
|
||||
|
||||
function applyDB($db):bool{
|
||||
$updateVals = $this->getUpdatedValues();
|
||||
$this->getLogger()->rollback(); //수비 도시의 로그는 기록하지 않음
|
||||
|
||||
if(!$updateVals){
|
||||
return false;
|
||||
}
|
||||
|
||||
$db->update('city', $updateVals, 'city=%i', $this->raw['city']);
|
||||
$this->getLogger()->rollback(); //수비 도시의 로그는 기록하지 않음
|
||||
return $db->affectedRows() > 0;
|
||||
}
|
||||
|
||||
|
||||
+47
-128
@@ -95,21 +95,11 @@ class WarUnitGeneral extends WarUnit{
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
$avoidRatio = $general->onCalcStat($general, 'warAvoidRatio', $avoidRatio, ['isAttacker'=>$this->isAttacker]);
|
||||
|
||||
if($this->getOppose()->getCrewType()->armType == GameUnitConst::T_FOOTMAN){
|
||||
$avoidRatio *= 0.75;
|
||||
@@ -119,100 +109,51 @@ class WarUnitGeneral extends WarUnit{
|
||||
}
|
||||
|
||||
function addWin(){
|
||||
$this->increaseVar('killnum', 1);
|
||||
$this->multiplyVarWithLimit('atmos', 1.1, null, GameConst::$maxAtmosByWar);
|
||||
$general = $this->general;
|
||||
$general->increaseVar('killnum', 1);
|
||||
$general->multiplyVarWithLimit('atmos', 1.1, null, GameConst::$maxAtmosByWar);
|
||||
|
||||
$this->addStatExp(1);
|
||||
}
|
||||
|
||||
function addStatExp(int $value = 1){
|
||||
$general = $this->general;
|
||||
if($this->crewType->armType == GameUnitConst::T_WIZARD) { // 귀병
|
||||
$this->increaseVar('intel2', $value);
|
||||
$general->increaseVar('intel2', $value);
|
||||
} elseif($this->crewType->armType == GameUnitConst::T_SIEGE) { // 차병
|
||||
$this->increaseVar('leader2', $value);
|
||||
$general->increaseVar('leader2', $value);
|
||||
} else {
|
||||
$this->increaseVar('power2', $value);
|
||||
$general->increaseVar('power2', $value);
|
||||
}
|
||||
}
|
||||
|
||||
function addLevelExp(float $value){
|
||||
$general = $this->general;
|
||||
if(!$this->isAttacker){
|
||||
$value *= 0.8;
|
||||
}
|
||||
$value *= getCharExpMultiplier($this->getCharacter());
|
||||
$this->increaseVar('experience', $value);
|
||||
$value = $general->onCalcStat($general, 'experience', $value);
|
||||
$general->increaseVar('experience', $value);
|
||||
}
|
||||
|
||||
function addDedication(float $value){
|
||||
$value *= getCharDedMultiplier($this->getCharacter());
|
||||
$this->increaseVar('dedication', $value);
|
||||
$general = $this->general;
|
||||
$value = $general->onCalcStat($general, 'dedication', $value);
|
||||
$general->increaseVar('dedication', $value);
|
||||
}
|
||||
|
||||
function addLose(){
|
||||
$this->increaseVar('deathnum', 1);
|
||||
$general = $this->general;
|
||||
$general->increaseVar('deathnum', 1);
|
||||
$this->addStatExp(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function getWarPowerMultiplyBySpecialWar():array{
|
||||
//TODO: 장기적으로 if문이 아니라 객체를 이용하여 처리해야함
|
||||
$myWarPowerMultiply = 1.0;
|
||||
$opposeWarPowerMultiply = 1.0;
|
||||
|
||||
$specialWar = $this->getSpecialWar();
|
||||
|
||||
if($specialWar == 53){
|
||||
if($this->getOppose() instanceof WarUnitCity){
|
||||
$myWarPowerMultiply *= 2;
|
||||
}
|
||||
}
|
||||
else if($specialWar == 52){
|
||||
if($this->isAttacker){
|
||||
$myWarPowerMultiply *= 1.20;
|
||||
}
|
||||
else{
|
||||
$myWarPowerMultiply *= 1.10;
|
||||
}
|
||||
|
||||
}
|
||||
else if($specialWar == 60){
|
||||
if($this->isAttacker){
|
||||
$myWarPowerMultiply *= 1.10;
|
||||
}
|
||||
|
||||
}
|
||||
else if($specialWar == 61){
|
||||
$myWarPowerMultiply *= 1.10;
|
||||
}
|
||||
else if($specialWar == 62){
|
||||
$opposeWarPowerMultiply *= 0.95;
|
||||
}
|
||||
else if($specialWar == 50){
|
||||
if($this->isAttacker){
|
||||
$opposeWarPowerMultiply *= 0.9;
|
||||
}
|
||||
else{
|
||||
$opposeWarPowerMultiply *= 0.8;
|
||||
}
|
||||
}
|
||||
else if($specialWar == 75){
|
||||
$opposeCrewType = $this->oppose->getCrewType();
|
||||
if($opposeCrewType->reqCities || $opposeCrewType->reqRegions){
|
||||
$myWarPowerMultiply *= 1.1;
|
||||
$opposeWarPowerMultiply *= 0.9;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return [$myWarPowerMultiply, $opposeWarPowerMultiply];
|
||||
}
|
||||
|
||||
function computeWarPower(){
|
||||
[$warPower,$opposeWarPowerMultiply] = parent::computeWarPower();
|
||||
|
||||
$generalNo = $this->getVar('no');
|
||||
$genLevel = $this->getVar('level');
|
||||
$general = $this->general;
|
||||
$generalNo = $general->getVar('no');
|
||||
$genLevel = $general->getVar('level');
|
||||
|
||||
if($this->isAttacker){
|
||||
if($genLevel == 12){
|
||||
@@ -240,7 +181,7 @@ class WarUnitGeneral extends WarUnit{
|
||||
}
|
||||
}
|
||||
|
||||
$expLevel = $this->getVar('explevel');
|
||||
$expLevel = $general->getVar('explevel');
|
||||
|
||||
if($this->getOppose() instanceof WarUnitCity){
|
||||
$warPower *= 1 + $expLevel / 600;
|
||||
@@ -251,7 +192,7 @@ class WarUnitGeneral extends WarUnit{
|
||||
}
|
||||
|
||||
|
||||
[$specialMyWarPowerMultiply, $specialOpposeWarPowerMultiply] = $this->getWarPowerMultiplyBySpecialWar();
|
||||
[$specialMyWarPowerMultiply, $specialOpposeWarPowerMultiply] = $this->general->getWarPowerMultiplier($this);
|
||||
$warPower *= $specialMyWarPowerMultiply;
|
||||
$opposeWarPowerMultiply *= $specialOpposeWarPowerMultiply;
|
||||
|
||||
@@ -271,6 +212,7 @@ class WarUnitGeneral extends WarUnit{
|
||||
$itemActivated = false;
|
||||
$itemConsumed = false;
|
||||
$itemName = getItemName($item);
|
||||
$general = $this->general;
|
||||
|
||||
if($item == 3){
|
||||
//탁주 사용
|
||||
@@ -306,7 +248,7 @@ class WarUnitGeneral extends WarUnit{
|
||||
}
|
||||
|
||||
if($itemConsumed){
|
||||
$this->updateVar('item', 0);
|
||||
$general->updateVar('item', 0);
|
||||
$josaUl = JosaUtil::pick($itemName, '을');
|
||||
$this->getLogger()->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 사용!", ActionLogger::PLAIN);
|
||||
}
|
||||
@@ -373,7 +315,7 @@ class WarUnitGeneral extends WarUnit{
|
||||
|
||||
if($itemConsumed){
|
||||
//NOTE: 소비 아이템은 하나인가?, 1회용인가?
|
||||
$this->updateVar('item', 0);
|
||||
$this->general->updateVar('item', 0);
|
||||
$josaUl = JosaUtil::pick($itemName, '을');
|
||||
$this->getLogger()->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 사용!", ActionLogger::PLAIN);
|
||||
}
|
||||
@@ -384,6 +326,7 @@ class WarUnitGeneral extends WarUnit{
|
||||
function applyBattleBeginSkillAndItem():bool{
|
||||
$result = false;
|
||||
$oppose = $this->getOppose();
|
||||
$general = $this->general;
|
||||
|
||||
if($oppose->hasActivatedSkill('저격')){
|
||||
$result = true;
|
||||
@@ -394,10 +337,10 @@ class WarUnitGeneral extends WarUnit{
|
||||
$this->getLogger()->pushGeneralBattleDetailLog("상대에게 <R>저격</>당했다!", ActionLogger::PLAIN);
|
||||
|
||||
if($oppose->hasActivatedSkill('수극')){
|
||||
$this->increaseVarWithLimit('injury', Util::randRangeInt(20, 40), null, 80);
|
||||
$general->increaseVarWithLimit('injury', Util::randRangeInt(20, 40), null, 80);
|
||||
}
|
||||
else{
|
||||
$this->increaseVarWithLimit('injury', Util::randRangeInt(20, 60), null, 80);
|
||||
$general->increaseVarWithLimit('injury', Util::randRangeInt(20, 60), null, 80);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -406,10 +349,11 @@ class WarUnitGeneral extends WarUnit{
|
||||
}
|
||||
|
||||
function getHP():int{
|
||||
return $this->getVar('crew');
|
||||
return $this->general->getVar('crew');
|
||||
}
|
||||
|
||||
function addDex(GameUnitDetail $crewType, float $exp){
|
||||
$general = $this->general;
|
||||
$armType = $crewType->armType;
|
||||
|
||||
if($armType == GameUnitConst::T_CASTLE){
|
||||
@@ -431,15 +375,16 @@ class WarUnitGeneral extends WarUnit{
|
||||
$ntype = $armType*10;
|
||||
$dexType = "dex{$ntype}";
|
||||
|
||||
$this->increaseVar($dexType, $exp);
|
||||
$general->increaseVar($dexType, $exp);
|
||||
}
|
||||
|
||||
function decreaseHP(int $damage):int{
|
||||
$damage = min($damage, $this->getVar('crew'));
|
||||
$general = $this->general;
|
||||
$damage = min($damage, $general->getVar('crew'));
|
||||
|
||||
$this->dead += $damage;
|
||||
$this->deadCurr += $damage;
|
||||
$this->increaseVar('crew', -$damage);
|
||||
$general->increaseVar('crew', -$damage);
|
||||
|
||||
$addDex = $damage;
|
||||
if(!$this->isAttacker){
|
||||
@@ -447,10 +392,11 @@ class WarUnitGeneral extends WarUnit{
|
||||
}
|
||||
$this->addDex($this->oppose->getCrewType(), $addDex);
|
||||
|
||||
return $this->getVar('crew');
|
||||
return $general->getVar('crew');
|
||||
}
|
||||
|
||||
function increaseKilled(int $damage):int{
|
||||
$general = $this->general;
|
||||
$this->addLevelExp($damage / 50);
|
||||
|
||||
$rice = $damage / 100;
|
||||
@@ -461,7 +407,7 @@ class WarUnitGeneral extends WarUnit{
|
||||
$rice *= $this->crewType->rice;
|
||||
$rice *= getTechCost($this->getNationVar('tech'));
|
||||
|
||||
$this->increaseVarWithLimit('rice', -$rice, 0);
|
||||
$general->increaseVarWithLimit('rice', -$rice, 0);
|
||||
|
||||
$addDex = $damage;
|
||||
if(!$this->isAttacker){
|
||||
@@ -889,6 +835,7 @@ class WarUnitGeneral extends WarUnit{
|
||||
}
|
||||
|
||||
function tryWound():bool{
|
||||
$general = $this->general;
|
||||
if($this->hasActivatedSkillOnLog('부상무효')){
|
||||
return false;
|
||||
}
|
||||
@@ -896,56 +843,27 @@ class WarUnitGeneral extends WarUnit{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->increaseVarWithLimit('injury', Util::randRangeInt(10, 80), null, 80);
|
||||
$general->increaseVarWithLimit('injury', Util::randRangeInt(10, 80), null, 80);
|
||||
$this->getLogger()->pushGeneralActionLog("전투중 <R>부상</>당했다!", ActionLogger::PLAIN);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function continueWar(&$noRice):bool{
|
||||
$general = $this->general;
|
||||
if($this->getHP() <= 0){
|
||||
$noRice = false;
|
||||
return false;
|
||||
}
|
||||
if($this->getVar('rice') <= $this->getHP() / 100){
|
||||
if($general->getVar('rice') <= $this->getHP() / 100){
|
||||
$noRice = true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
///checkAbility의 method 버전
|
||||
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->getVar($statExpName) < 0){
|
||||
$logger->pushGeneralActionLog("<R>{$statNickName}</>이 <C>1</> 떨어졌습니다!", ActionLogger::PLAIN);
|
||||
$this->increaseVar($statExpName, $limit);
|
||||
$this->increaseVar($statName, -1);
|
||||
$result = true;
|
||||
}
|
||||
else if($this->getVar($statExpName) >= $limit){
|
||||
$logger->pushGeneralActionLog("<S>{$statNickName}</>이 <C>1</> 올랐습니다!", ActionLogger::PLAIN);
|
||||
$this->increaseVar($statExpName, -$limit);
|
||||
$this->increaseVar($statName, 1);
|
||||
$result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->general->checkStatChange();
|
||||
}
|
||||
|
||||
function finishBattle(){
|
||||
@@ -954,13 +872,14 @@ class WarUnitGeneral extends WarUnit{
|
||||
}
|
||||
$this->clearActivatedSkill();
|
||||
$this->isFinished = true;
|
||||
$general = $this->general;
|
||||
|
||||
$this->increaseVar('killcrew', $this->killed);
|
||||
$this->increaseVar('deathcrew', $this->dead);
|
||||
$general->increaseVar('killcrew', $this->killed);
|
||||
$general->increaseVar('deathcrew', $this->dead);
|
||||
|
||||
$this->updateVar('rice', Util::round($this->getVar('rice')));
|
||||
$this->updateVar('experience', Util::round($this->getVar('experience')));
|
||||
$this->updateVar('dedication', Util::round($this->getVar('dedication')));
|
||||
$general->updateVar('rice', Util::round($general->getVar('rice')));
|
||||
$general->updateVar('experience', Util::round($general->getVar('experience')));
|
||||
$general->updateVar('dedication', Util::round($general->getVar('dedication')));
|
||||
|
||||
$this->checkStatChange();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user