저격시 아이템이 무조건 소모되는 버그 수정

This commit is contained in:
2020-06-09 01:45:52 +09:00
parent 6565fdbe7e
commit 75a704c196
+104 -104
View File
@@ -1,104 +1,104 @@
<?php <?php
namespace sammo; namespace sammo;
abstract class BaseWarUnitTrigger extends ObjectTrigger{ abstract class BaseWarUnitTrigger extends ObjectTrigger{
/** @var WarUnit $object */ /** @var WarUnit $object */
const TYPE_NONE = 0; const TYPE_NONE = 0;
const TYPE_ITEM = 1; const TYPE_ITEM = 1;
const TYPE_CONSUMABLE_ITEM = 1 | 2; const TYPE_CONSUMABLE_ITEM = 1 | 2;
protected $raiseType = self::TYPE_NONE; protected $raiseType = self::TYPE_NONE;
public function __construct(WarUnit $unit, int $raiseType = 0){ public function __construct(WarUnit $unit, int $raiseType = 0){
$this->object = $unit; $this->object = $unit;
$this->raiseType = $raiseType; $this->raiseType = $raiseType;
} }
public function getUniqueID():string{ public function getUniqueID():string{
$priority = $this->priority; $priority = $this->priority;
$fqn = static::class; $fqn = static::class;
if($this->object === null){ if($this->object === null){
$objID = ''; $objID = '';
} }
else{ else{
$objID = spl_object_id($this->object); $objID = spl_object_id($this->object);
} }
return "{$priority}_{$fqn}_{$objID}_{$this->raiseType}"; return "{$priority}_{$fqn}_{$objID}_{$this->raiseType}";
} }
public function action(?array $env=null, $arg=null):?array{ public function action(?array $env=null, $arg=null):?array{
if($env === null){ if($env === null){
$env = []; $env = [];
} }
if(!key_exists('e_attacker', $env)){ if(!key_exists('e_attacker', $env)){
$env['e_attacker'] = []; $env['e_attacker'] = [];
} }
if(!key_exists('e_defender', $env)){ if(!key_exists('e_defender', $env)){
$env['e_defender'] = []; $env['e_defender'] = [];
} }
if($env['stopNextAction']??false){ if($env['stopNextAction']??false){
return $env; return $env;
} }
/** @var WarUnitGeneral $attacker */ /** @var WarUnitGeneral $attacker */
/** @var WarUnit $defender */ /** @var WarUnit $defender */
[$attacker, $defender] = $arg; [$attacker, $defender] = $arg;
/** @var WarUnit $self */ /** @var WarUnit $self */
$self = $this->object; $self = $this->object;
$isAttacker = $self->isAttacker(); $isAttacker = $self->isAttacker();
$oppose = $isAttacker?$defender:$attacker; $oppose = $isAttacker?$defender:$attacker;
$selfEnv = $isAttacker?$env['e_attacker']:$env['e_defender']; $selfEnv = $isAttacker?$env['e_attacker']:$env['e_defender'];
$opposeEnv = $isAttacker?$env['e_defender']:$env['e_attacker']; $opposeEnv = $isAttacker?$env['e_defender']:$env['e_attacker'];
$callNextAction = $this->actionWar($self, $oppose, $selfEnv, $opposeEnv); $callNextAction = $this->actionWar($self, $oppose, $selfEnv, $opposeEnv);
$env['e_attacker'] = $isAttacker?$selfEnv:$opposeEnv; $env['e_attacker'] = $isAttacker?$selfEnv:$opposeEnv;
$env['e_defender'] = $isAttacker?$opposeEnv:$selfEnv; $env['e_defender'] = $isAttacker?$opposeEnv:$selfEnv;
if(!$callNextAction){ if(!$callNextAction){
$env['stopNextAction'] = true; $env['stopNextAction'] = true;
} }
return $env; return $env;
} }
abstract protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):bool; abstract protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):bool;
public function processConsumableItem():bool{ public function processConsumableItem():bool{
if(!($this->raiseType & static::TYPE_ITEM)){ if(!($this->raiseType & static::TYPE_ITEM)){
return false; return false;
} }
/** @var WarUnit $self */ /** @var WarUnit $self */
$self = $this->object; $self = $this->object;
if($self->hasActivatedSkill('아이템사용')){ if($self->hasActivatedSkill('아이템사용')){
return false; return false;
} }
$self->activateSkill('아이템사용'); $self->activateSkill('아이템사용');
$item = $self->getGeneral()->getItem(); $item = $self->getGeneral()->getItem();
$itemName = $item->getName(); $itemName = $item->getName();
$itemRawName = $item->getRawName(); $itemRawName = $item->getRawName();
$self->activateSkill($itemName); $self->activateSkill($itemName);
if (!($this->raiseType & static::TYPE_CONSUMABLE_ITEM)) { if ($this->raiseType != static::TYPE_CONSUMABLE_ITEM) {
return false; return false;
} }
if($self->hasActivatedSkill('아이템소모')){ if($self->hasActivatedSkill('아이템소모')){
return false; return false;
} }
$self->activateSkill('아이템소모'); $self->activateSkill('아이템소모');
$josaUl = JosaUtil::pick($itemRawName, '을'); $josaUl = JosaUtil::pick($itemRawName, '을');
$self->getLogger()->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 사용!", ActionLogger::PLAIN); $self->getLogger()->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 사용!", ActionLogger::PLAIN);
$self->getGeneral()->deleteItem(); $self->getGeneral()->deleteItem();
return true; return true;
} }
} }