아이템 전량 구현, 말, 무기, 책 준비

This commit is contained in:
2019-05-13 02:44:01 +09:00
parent 91b5a1e44a
commit 85409263c8
24 changed files with 340 additions and 50 deletions
@@ -0,0 +1,20 @@
<?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_BEGIN + 200;
protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):bool{
assert($self instanceof WarUnitGeneral, 'General만 발동 가능');
$oppose->activateSkill('저격불가');
$self->activateSkill('부상무효');
return true;
}
}
@@ -8,7 +8,7 @@ use sammo\GameUnitDetail;
use sammo\ObjectTrigger;
class che_성벽부상무효 extends BaseWarUnitTrigger{
static protected $priority = ObjectTrigger::PRIORITY_BEGIN;
static protected $priority = ObjectTrigger::PRIORITY_BEGIN + 100;
protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):bool{
assert($self instanceof WarUnitGeneral, 'General만 발동 가능');
@@ -0,0 +1,60 @@
<?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{
static protected $priority = ObjectTrigger::PRIORITY_BEGIN;
protected $variable;
protected $operator;
protected $value;
protected $limitMin;
protected $limitMax;
public function __construct(WarUnit $unit, int $raiseType, string $variable, string $operator, $value, $limitMin=null, $limitMax=null){
$this->object = $unit;
$this->raiseType = $raiseType;
$this->variable = $variable;
$this->operator = $operator;
$this->value = $value;
$this->limitMin = $limitMin;
$this->limitMax = $limitMax;
if(!in_array($this->operator, ['=', '+', '-', '*', '/'])){
throw new \InvalidArgumentException("올바르지 않은 operator : {$operator}");
}
}
protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):bool{
assert($self instanceof WarUnitGeneral, 'General만 발동 가능');
$general = $self->getGeneral();
if($this->operator === '='){
$general->setVar($this->variable, $this->value);
}
else if($this->operator === '+'){
$general->increaseVarWithLimit($this->variable, $this->value, $this->limitMin, $this->limitMax);
}
else if($this->operator === '-'){
$general->increaseVarWithLimit($this->variable, -$this->value, $this->limitMin, $this->limitMax);
}
else if($this->operator === '*'){
$general->multiplyVarWithLimit($this->variable, $this->value, $this->limitMin, $this->limitMax);
}
else if($this->operator === '/'){
$general->multiplyVarWithLimit($this->variable, 1/$this->value, $this->limitMin, $this->limitMax);
}
else{
throw new \sammo\MustNotBeReachedException();
}
$this->processConsumableItem();
return true;
}
}