game,feat: 전투력보정 관련 유니크 도구 추가
- 직접 전투력보정을 위한 WarUnitTrigger 추가
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\ActionItem;
|
||||
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use sammo\Util;
|
||||
use sammo\WarUnit;
|
||||
use sammo\WarUnitTrigger\전투력보정;
|
||||
use sammo\WarUnitTriggerCaller;
|
||||
|
||||
class che_광기_상편 extends \sammo\BaseItem
|
||||
{
|
||||
|
||||
protected $rawName = '상편';
|
||||
protected $name = '상편(광기)';
|
||||
protected $info = '[전투] 남은 병력에 따라 공격력 증가. 최대 +50%';
|
||||
protected $cost = 200;
|
||||
protected $consumable = false;
|
||||
|
||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit): ?WarUnitTriggerCaller
|
||||
{
|
||||
$leadership = $unit->getGeneral()->getLeadership();
|
||||
$crew = $unit->getGeneral()->getVar('crew');
|
||||
|
||||
$crewRatio = Util::valueFit($crew / ($leadership * 100), 0, 1);
|
||||
return new WarUnitTriggerCaller(
|
||||
new 전투력보정(1 + 0.5 * (1 - $crewRatio))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace sammo\ActionItem;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use sammo\WarUnit;
|
||||
use sammo\WarUnitTrigger\전투력보정;
|
||||
use sammo\WarUnitTriggerCaller;
|
||||
|
||||
class che_상성보정_과실주 extends \sammo\BaseItem{
|
||||
|
||||
protected $rawName = '과실주';
|
||||
protected $name = '과실주(상성)';
|
||||
protected $info = '[전투] 유리한 병종 전투시 공격력 +10%, 피해 -10%';
|
||||
protected $cost = 200;
|
||||
protected $consumable = false;
|
||||
|
||||
public function getBattlePhaseSkillTriggerList(WarUnit $unit): ?WarUnitTriggerCaller
|
||||
{
|
||||
$oppose = $unit->getOppose();
|
||||
if($oppose === null){
|
||||
return null;
|
||||
}
|
||||
$attackCoef = $unit->getCrewType()->getAttackCoef($oppose->getCrewType());
|
||||
if($attackCoef <= 1){
|
||||
return null;
|
||||
}
|
||||
return new WarUnitTriggerCaller(
|
||||
new 전투력보정(1.1, 0.9)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -17,4 +17,6 @@ class che_훈련_과실주 extends \sammo\BaseItem{
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//NOTE: 구버전
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace sammo\WarUnitTrigger;
|
||||
use sammo\BaseWarUnitTrigger;
|
||||
use sammo\WarUnitGeneral;
|
||||
use sammo\WarUnitCity;
|
||||
use sammo\WarUnit;
|
||||
use sammo\GameUnitDetail;
|
||||
use sammo\ObjectTrigger;
|
||||
|
||||
class 전투력보정 extends BaseWarUnitTrigger{
|
||||
protected $priority = ObjectTrigger::PRIORITY_BEGIN;
|
||||
|
||||
public function __construct(protected int|float $attackerWarPowerMultiplier, protected int|float $defenderWarPowerMultiplier = 1){
|
||||
}
|
||||
|
||||
protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):bool{
|
||||
$self->multiplyWarPowerMultiply($this->attackerWarPowerMultiplier);
|
||||
$oppose->multiplyWarPowerMultiply($this->defenderWarPowerMultiplier);
|
||||
|
||||
$this->processConsumableItem();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user