game: 충차 도구 추가

This commit is contained in:
2024-09-18 16:08:37 +00:00
parent 749e8f673b
commit cfd0a2d26f
3 changed files with 158 additions and 2 deletions
+52
View File
@@ -0,0 +1,52 @@
<?php
namespace sammo\ActionItem;
use \sammo\iAction;
use \sammo\General;
use \sammo\SpecialityHelper;
use \sammo\GameUnitConst;
use \sammo\WarUnit;
use \sammo\WarUnitCity;
use sammo\RandUtil;
use \sammo\WarUnitTriggerCaller;
use \sammo\BaseWarUnitTrigger;
use sammo\WarUnitTrigger\event_충차아이템소모;
class event_충차 extends \sammo\BaseItem{
protected $rawName = '충차';
protected $name = '충차';
protected $info = '[전투] 성벽 공격 시 대미지 +50%, 2회용';
protected $cost = 2000;
protected $consumable = true;
protected $buyable = true;
protected $reqSecu = 4000;
const REMAIN_KEY = 'remain충차';
function onArbitraryAction(General $general, RandUtil $rng, string $actionType, ?string $phase = null, $aux = null): ?array
{
if($actionType != '장비매매'){
return $aux;
}
if($phase != '구매'){
return $aux;
}
$general->setAuxVar(static::REMAIN_KEY, 2);
return $aux;
}
public function getWarPowerMultiplier(WarUnit $unit):array{
if($unit->getOppose() instanceof WarUnitCity){
return [1.5, 1];
}
return [1, 1];
}
public function getBattlePhaseSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
return new WarUnitTriggerCaller(
new event_충차아이템소모($unit, BaseWarUnitTrigger::TYPE_CONSUMABLE_ITEM)
);
}
}
@@ -0,0 +1,47 @@
<?php
namespace sammo\WarUnitTrigger;
use sammo\ActionItem\event_충차;
use sammo\BaseWarUnitTrigger;
use sammo\WarUnitGeneral;
use sammo\WarUnitCity;
use sammo\WarUnit;
use sammo\GameUnitDetail;
use sammo\ObjectTrigger;
use sammo\Util;
use sammo\ActionLogger;
class event_충차아이템소모 extends BaseWarUnitTrigger{
protected $priority = ObjectTrigger::PRIORITY_PRE + 200;
protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):bool{
if($self->hasActivatedSkillOnLog('충차공격') && $self->getPhase() == $self->getMaxPhase() - 1){
//TODO: 전투 종료시 소모를 예약하는 기능이 있으면 매우 좋을 것 같다.
$general = $self->getGeneral();
$remain = $general->getAuxVar(event_충차::REMAIN_KEY) ?? 0;
if($remain <= 0){
$this->processConsumableItem();
}
return true;
}
if(!($self instanceof WarUnitGeneral)){
return true;
}
if(!($oppose instanceof WarUnitCity)){
return true;
}
if($self->hasActivatedSkillOnLog('충차공격')){
return true;
}
$self->getLogger()->pushGeneralBattleDetailLog("<C>충차</>로 성벽을 공격합니다.", ActionLogger::PLAIN);
$general = $self->getGeneral();
$remain = $general->getAuxVar(event_충차::REMAIN_KEY) ?? 0;
$self->activateSkill('충차공격');
$general->setAuxVar(event_충차::REMAIN_KEY, $remain - 1);
return true;
}
}