전투 스킬 세팅 중

This commit is contained in:
2019-05-31 02:28:08 +09:00
parent 17654633dc
commit 7fd8bfbe4e
14 changed files with 280 additions and 0 deletions
@@ -0,0 +1,34 @@
<?php
namespace sammo\WarUnitTrigger;
use sammo\BaseWarUnitTrigger;
use sammo\WarUnitGeneral;
use sammo\WarUnitCity;
use sammo\WarUnit;
use sammo\GameUnitDetail;
use sammo\Util;
use sammo\ObjectTrigger;
class WarActivateSkills extends BaseWarUnitTrigger{
static protected $priority = ObjectTrigger::PRIORITY_INIT;
protected $isSelf;
protected $activeSkills;
public function __construct(WarUnit $unit, int $raiseType, bool $isSelf, string ...$activeSkills){
$this->object = $unit;
$this->raiseType = $raiseType;
$this->isSelf = $isSelf;
$this->activeSkills = $activeSkills;
}
protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):bool{
if($this->isSelf){
$self->activateSkill(...$this->activeSkills);
}
else{
$oppose->activateSkill(...$this->activeSkills);
}
return true;
}
}
@@ -0,0 +1,38 @@
<?php
namespace sammo\WarUnitTrigger;
use sammo\BaseWarUnitTrigger;
use sammo\WarUnitGeneral;
use sammo\WarUnitCity;
use sammo\WarUnit;
use sammo\GameUnitDetail;
use sammo\Util;
use sammo\ObjectTrigger;
class che_계략발동 extends BaseWarUnitTrigger{
static protected $priority = ObjectTrigger::PRIORITY_POST + 100;
protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):bool{
if(!$self->hasActivatedSkill('계략')){
return true;
}
if($selfEnv['계략발동']??false){
return true;
}
$selfEnv['계략발동'] = true;
$general = $self->getGeneral();
[$magic, $damage] = $selfEnv['magic'];
$damage = $general->onCalcStat($general, 'warMagicFailDamage', $damage, $magic);
$josaUl = \sammo\JosaUtil::pick($magic, '을');
$general->pushGeneralBattleDetailLog("<D>{$magic}</>{$josaUl} <C>성공</>했다!", ActionLogger::PLAIN);
$oppose->getLogger()->pushGeneralBattleDetailLog("<D>{$magic}</>에 당했다!", ActionLogger::PLAIN);
$self->multiplyWarPowerMultiply($damage);
return true;
}
}
@@ -0,0 +1,77 @@
<?php
namespace sammo\WarUnitTrigger;
use sammo\BaseWarUnitTrigger;
use sammo\WarUnitGeneral;
use sammo\WarUnitCity;
use sammo\WarUnit;
use sammo\GameUnitDetail;
use sammo\ObjectTrigger;
class che_계략시도 extends BaseWarUnitTrigger{
static protected $priority = ObjectTrigger::PRIORITY_PRE + 300; //최 우선 순위
static protected $tableToGeneral = [
'위보'=>[1.2, 1.1],
'매복'=>[1.4, 1.2],
'반목'=>[1.6, 1.3],
'화계'=>[1.8, 1.4],
'혼란'=>[2.0, 1.5]
];
static protected $tableToCity = [
'급습'=>[1.2, 1.1],
'위보'=>[1.4, 1.2],
'혼란'=>[1.6, 1.3]
];
protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):bool{
assert($self instanceof WarUnitGeneral, 'General만 발동 가능');
$general = $self->getGeneral();
$crewType = $general->getCrewTypeObj();
if($crewType->magicCoef <= 0){
//NOTE: -인 경우를 고려해야하나? 계략 맞을 확률 증가?
return true;
}
if($self->hasActivatedSkill('계략불가')){
return true;
}
$magicTrialProb = $general->getIntel(true, true, true, false) / 100;
$magicTrialProb *= $crewType->magicCoef;
$magicTrialProb = $general->onCalcStat($general, 'warMagicTrialProb', $magicTrialProb);
if(!Util::randBool($magicTrialProb)){
return true;
}
$magicSuccessProb = 0.7;
$magicSuccessProb = $general->onCalcStat($general, 'warMagicSuccessProb', $magicSuccessProb);
if($this->hasActivatedSkill('계략약화')){
$magicSuccessProb -= 0.1; //NOTE: 앞으로 이건 oppose의 onCalcStat에 들어가야하지 않을까?
}
if($oppose instanceof WarUnitCity){
$magic = Util::choiceRandom(array_keys(static::$tableToCity));
[$successDamage, $failDamage] = static::$tableToCity[$magic];
}
else{
$magic = Util::choiceRandom(array_keys(static::$tableToGeneral));
[$successDamage, $failDamage] = static::$tableToGeneral[$magic];
}
$self->activateSkill('계략시도', $magic);
if(Util::randBool($magicSuccessProb)){
$self->activateSkill('계략');
$selfEnv['magic'] = [$magic, $successDamage];
}
else{
$self->activateSkill('계략실패');
$selfEnv['magic'] = [$magic, $failDamage];
}
return true;
}
}
@@ -0,0 +1,39 @@
<?php
namespace sammo\WarUnitTrigger;
use sammo\BaseWarUnitTrigger;
use sammo\WarUnitGeneral;
use sammo\WarUnitCity;
use sammo\WarUnit;
use sammo\GameUnitDetail;
use sammo\Util;
use sammo\ObjectTrigger;
class che_계략실패 extends BaseWarUnitTrigger{
static protected $priority = ObjectTrigger::PRIORITY_POST + 300;
protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):bool{
if(!$self->hasActivatedSkill('계략실패')){
return true;
}
if($selfEnv['계략실패']??false){
return true;
}
$selfEnv['계략실패'] = true;
$general = $self->getGeneral();
[$magic, $damage] = $selfEnv['magic'];
$damage = $general->onCalcStat($general, 'warMagicFailDamage', $damage, $magic);
$josaUl = \sammo\JosaUtil::pick($magic, '을');
$general->pushGeneralBattleDetailLog("<D>{$magic}</>{$josaUl} <R>실패</>했다!", ActionLogger::PLAIN);
$oppose->getLogger()->pushGeneralBattleDetailLog("<D>{$magic}</>{$josaUl} 간파했다!", ActionLogger::PLAIN);
$self->multiplyWarPowerMultiply(1/$damage);
$oppose->multiplyWarPowerMultiply($damage);
return true;
}
}