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; } }