feat,game: 전투 중 약탈 추가, 약탈 유니크 추가
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace sammo\ActionItem;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use sammo\WarUnit;
|
||||
use sammo\WarUnitTrigger\che_약탈발동;
|
||||
use sammo\WarUnitTrigger\che_약탈시도;
|
||||
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{
|
||||
return new WarUnitTriggerCaller(
|
||||
new che_약탈시도($unit, che_약탈시도::TYPE_ITEM, 0.1, 0.1),
|
||||
new che_약탈발동($unit, che_약탈발동::TYPE_ITEM)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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;
|
||||
use sammo\ActionLogger;
|
||||
use sammo\GameConst;
|
||||
|
||||
class che_약탈발동 extends BaseWarUnitTrigger
|
||||
{
|
||||
protected $priority = ObjectTrigger::PRIORITY_POST + 400;
|
||||
|
||||
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();
|
||||
|
||||
if (!($oppose instanceof WarUnitGeneral)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
$general->increaseVarWithLimit('atmos', $selfEnv['addAtmos'], 0, GameConst::$maxAtmosByWar);
|
||||
|
||||
$opposeGeneral = $oppose->getGeneral();
|
||||
|
||||
$theftGold = $opposeGeneral->getVar('gold') * $selfEnv['theftRatio'];
|
||||
$theftRice = $opposeGeneral->getVar('rice') * $selfEnv['theftRatio'];
|
||||
|
||||
$opposeGeneral->increaseVarWithLimit('gold', -$theftGold, 0);
|
||||
$opposeGeneral->increaseVarWithLimit('rice', -$theftRice, 0);
|
||||
|
||||
$general->increaseVar('gold', $theftGold);
|
||||
$general->increaseVar('rice', $theftRice);
|
||||
|
||||
$self->getLogger()->pushGeneralActionLog("상대를 <C>약탈</>했다!", ActionLogger::PLAIN);
|
||||
$self->getLogger()->pushGeneralBattleDetailLog("상대에게서 금 {$theftGold}, 쌀 {$theftRice} 만큼을 <C>약탈</>했다!", ActionLogger::PLAIN);
|
||||
$oppose->getLogger()->pushGeneralActionLog("상대에게 <R>약탈</>당했다!", ActionLogger::PLAIN);
|
||||
$oppose->getLogger()->pushGeneralBattleDetailLog("상대에게 금 {$theftGold}, 쌀 {$theftRice} 만큼을 <R>약탈</>당했다!", ActionLogger::PLAIN);
|
||||
|
||||
$this->processConsumableItem();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
namespace sammo\WarUnitTrigger;
|
||||
use sammo\BaseWarUnitTrigger;
|
||||
use sammo\WarUnitGeneral;
|
||||
use sammo\WarUnitCity;
|
||||
use sammo\WarUnit;
|
||||
use sammo\GameUnitDetail;
|
||||
use sammo\ObjectTrigger;
|
||||
use sammo\Util;
|
||||
|
||||
class che_약탈시도 extends BaseWarUnitTrigger{
|
||||
protected $priority = ObjectTrigger::PRIORITY_PRE + 400;
|
||||
|
||||
protected $ratio;
|
||||
protected $theftRatio;
|
||||
|
||||
public function __construct(WarUnit $unit, int $raiseType, float $ratio, float $theftRatio){
|
||||
$this->object = $unit;
|
||||
$this->raiseType = $raiseType;
|
||||
$this->ratio = $ratio;
|
||||
$this->theftRatio = $theftRatio;
|
||||
}
|
||||
|
||||
protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):bool{
|
||||
assert($self instanceof WarUnitGeneral, 'General만 발동 가능');
|
||||
if($self->getPhase() !== 0 && $oppose->getPhase() !== 0){
|
||||
return true;
|
||||
}
|
||||
if(!($oppose instanceof WarUnitGeneral)){
|
||||
return true;
|
||||
}
|
||||
if($self->hasActivatedSkill('약탈')){
|
||||
return true;
|
||||
}
|
||||
if($self->hasActivatedSkill('약탈불가')){
|
||||
return true;
|
||||
}
|
||||
if(!Util::randBool($this->ratio)){
|
||||
return true;
|
||||
}
|
||||
|
||||
$self->activateSkill('약탈');
|
||||
$selfEnv['theftRatio'] = $this->theftRatio;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user