아이템 전량 구현, 말, 무기, 책 준비
This commit is contained in:
+10
-26
@@ -272,41 +272,25 @@ function getPersonalityClass(?string $type){
|
||||
throw new \InvalidArgumentException("{$type}은 올바른 성격 클래스가 아님");
|
||||
}
|
||||
|
||||
function getItemClass(int $itemCode){
|
||||
//XXX: 임시 구현임
|
||||
|
||||
//iAction이 필요한 것만 반환
|
||||
|
||||
static $basePath = __NAMESPACE__.'\\ActionItem\\';
|
||||
|
||||
$itemPath = [
|
||||
1=>'che_환약_치료',
|
||||
5=>'che_이추_계략',
|
||||
6=>'che_향낭_계략',
|
||||
|
||||
7=>'che_오석산_치료',
|
||||
8=>'che_무후행군_치료',
|
||||
9=>'che_도소연명_치료',
|
||||
10=>'che_칠엽청점_치료',
|
||||
11=>'che_정력견혈_치료',
|
||||
21=>'che_육도_계략',
|
||||
22=>'che_삼략_계략',
|
||||
23=>'che_청낭서_의술',
|
||||
24=>'che_태평청령_의술',
|
||||
];
|
||||
|
||||
$itemClass = $itemPath[$itemCode]??null;
|
||||
function getItemClass(?string $itemClass){
|
||||
if($itemClass === null){
|
||||
return null;
|
||||
}
|
||||
|
||||
static $basePath = __NAMESPACE__.'\\ActionItem\\';
|
||||
|
||||
$classPath = ($basePath.$itemClass);
|
||||
|
||||
if(class_exists($classPath)){
|
||||
return $classPath;
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException("{$itemCode}, {$itemClass}는 올바른 성격 클래스가 아님");
|
||||
throw new \InvalidArgumentException("{$itemClass}는 올바른 성격 클래스가 아님");
|
||||
}
|
||||
|
||||
function buildItemClass(?string $itemClass):BaseItem{
|
||||
$class = getGeneralCommandClass($itemClass);
|
||||
return new $class();
|
||||
}
|
||||
|
||||
function getGeneralSpecialDomesticClass(?string $type){
|
||||
@@ -894,7 +878,7 @@ function getItemName($item) : ?string {
|
||||
return $itemname;
|
||||
}
|
||||
|
||||
function getItemInfo(?int $item):?string{
|
||||
function getItemInfo(?int $item):?array{
|
||||
$itemInfo = [
|
||||
1=>['환약(치료)', '[군사] 턴 실행 전 부상 회복. 1회용'],
|
||||
2=>['수극(저격)', '[전투] 전투 개시 전 20% 확률로 저격 시도. 1회용'],
|
||||
|
||||
@@ -34,7 +34,7 @@ class che_Dummy extends \sammo\BaseItem{
|
||||
|
||||
public function __construct(int $itemCode)
|
||||
{
|
||||
$this->_id = $itemCode = true;
|
||||
$this->_id = $itemCode;
|
||||
[$this->_name, $this->_info] = getItemInfo($itemCode);
|
||||
$this->_cost = getItemCost2($itemCode);
|
||||
$this->_consumable = isConsumable($itemCode);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace sammo\ActionItem;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
|
||||
class che_사기_의적주 extends \sammo\BaseItem{
|
||||
|
||||
protected static $id = 15;
|
||||
protected static $name = '두강주(사기)';
|
||||
protected static $info = '[전투] 사기 보정 +5';
|
||||
protected static $cost = 200;
|
||||
protected static $consumable = false;
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'bonusAtmos'){
|
||||
return $value + 5;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace sammo\ActionItem;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
|
||||
class che_사기_보령압주 extends \sammo\BaseItem{
|
||||
|
||||
protected static $id = 16;
|
||||
protected static $name = '보령압주(사기)';
|
||||
protected static $info = '[전투] 사기 보정 +5';
|
||||
protected static $cost = 200;
|
||||
protected static $consumable = false;
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'bonusAtmos'){
|
||||
return $value + 5;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace sammo\ActionItem;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
|
||||
class che_사기_의적주 extends \sammo\BaseItem{
|
||||
|
||||
protected static $id = 14;
|
||||
protected static $name = '의적주(사기)';
|
||||
protected static $info = '[전투] 사기 보정 +5';
|
||||
protected static $cost = 200;
|
||||
protected static $consumable = false;
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'bonusAtmos'){
|
||||
return $value + 5;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace sammo\ActionItem;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
|
||||
class che_사기_초선화 extends \sammo\BaseItem{
|
||||
|
||||
protected static $id = 20;
|
||||
protected static $name = '초선화(사기)';
|
||||
protected static $info = '[전투] 사기 보정 +7';
|
||||
protected static $cost = 200;
|
||||
protected static $consumable = false;
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'bonusAtmos'){
|
||||
return $value + 7;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace sammo\ActionItem;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
|
||||
class che_사기_춘화첩 extends \sammo\BaseItem{
|
||||
|
||||
protected static $id = 19;
|
||||
protected static $name = '춘화첩(사기)';
|
||||
protected static $info = '[전투] 사기 보정 +7';
|
||||
protected static $cost = 200;
|
||||
protected static $consumable = false;
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'bonusAtmos'){
|
||||
return $value + 7;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace sammo\ActionItem;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
use \sammo\BaseWarUnitTrigger;
|
||||
|
||||
class che_사기_탁주 extends \sammo\BaseItem{
|
||||
|
||||
protected static $id = 3;
|
||||
protected static $name = '탁주(사기)';
|
||||
protected static $info = '[전투] 사기 +3. 1회용';
|
||||
protected static $cost = 1000;
|
||||
protected static $consumable = true;
|
||||
|
||||
public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||
return new WarUnitTriggerCaller([
|
||||
new 능력치변경($unit, BaseWarUnitTrigger::TYPE_CONSUMABLE_ITEM, 'atmos', '+', 3),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ use \sammo\WarUnitTriggerCaller;
|
||||
use \sammo\WarUnit;
|
||||
use \sammo\WarUnitTrigger\che_저격시도;
|
||||
use \sammo\WarUnitTrigger\che_저격발동;
|
||||
use \sammo\BaseWarUnitTrigger;
|
||||
|
||||
class che_저격_수극 extends \sammo\BaseItem{
|
||||
|
||||
@@ -17,7 +18,7 @@ class che_저격_수극 extends \sammo\BaseItem{
|
||||
|
||||
public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||
return new WarUnitTriggerCaller([
|
||||
new che_저격시도($unit, che_저격시도::TYPE_CONSUMABLE_ITEM, 0.2, 20, 40),
|
||||
new che_저격시도($unit, BaseWarUnitTrigger::TYPE_CONSUMABLE_ITEM, 0.2, 20, 40),
|
||||
new che_저격발동($unit)
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class che_회피_둔갑천서 extends \sammo\BaseItem{
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'warAvoidRatio'){
|
||||
return $value += 0.2;
|
||||
return $value + 0.2;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class che_회피_태평요술 extends \sammo\BaseItem{
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'warAvoidRatio'){
|
||||
return $value += 0.2;
|
||||
return $value + 0.2;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace sammo\ActionItem;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
|
||||
class che_훈련_과실주 extends \sammo\BaseItem{
|
||||
|
||||
protected static $id = 12;
|
||||
protected static $name = '과실주(훈련)';
|
||||
protected static $info = '[전투] 훈련 보정 +5';
|
||||
protected static $cost = 200;
|
||||
protected static $consumable = false;
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'bonusTrain'){
|
||||
return $value + 5;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace sammo\ActionItem;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
|
||||
class che_훈련_단결도 extends \sammo\BaseItem{
|
||||
|
||||
protected static $id = 18;
|
||||
protected static $name = '단결도(훈련)';
|
||||
protected static $info = '[전투] 훈련 보정 +7';
|
||||
protected static $cost = 200;
|
||||
protected static $consumable = false;
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'bonusTrain'){
|
||||
return $value + 7;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace sammo\ActionItem;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
|
||||
class che_훈련_이강주 extends \sammo\BaseItem{
|
||||
|
||||
protected static $id = 13;
|
||||
protected static $name = '이강주(훈련)';
|
||||
protected static $info = '[전투] 훈련 보정 +5';
|
||||
protected static $cost = 200;
|
||||
protected static $consumable = false;
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'bonusTrain'){
|
||||
return $value + 5;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace sammo\ActionItem;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
|
||||
class che_훈련_철벽서 extends \sammo\BaseItem{
|
||||
|
||||
protected static $id = 17;
|
||||
protected static $name = '철벽서(훈련)';
|
||||
protected static $info = '[전투] 훈련 보정 +7';
|
||||
protected static $cost = 200;
|
||||
protected static $consumable = false;
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'bonusTrain'){
|
||||
return $value + 7;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace sammo\ActionItem;
|
||||
use \sammo\iAction;
|
||||
use \sammo\General;
|
||||
|
||||
class che_훈련_청주 extends \sammo\BaseItem{
|
||||
|
||||
protected static $id = 4;
|
||||
protected static $name = '청주(훈련)';
|
||||
protected static $info = '[전투] 훈련 +3. 1회용';
|
||||
protected static $cost = 1000;
|
||||
protected static $consumable = true;
|
||||
|
||||
public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||
return new WarUnitTriggerCaller([
|
||||
new 능력치변경($unit, BaseWarUnitTrigger::TYPE_CONSUMABLE_ITEM, 'train', '+', 3),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ class che_궁병 implements iAction{
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'warAvoidRatio'){
|
||||
return $value += 0.2;
|
||||
return $value + 0.2;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class che_돌격 implements iAction{
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'initWarPhase'){
|
||||
return $value += 1;
|
||||
return $value + 1;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class che_필살 implements iAction{
|
||||
|
||||
public function onCalcStat(General $general, string $statName, $value, $aux=null){
|
||||
if($statName === 'warCriticalRatio'){
|
||||
return $value += 0.2;
|
||||
return $value + 0.2;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
@@ -74,14 +74,10 @@ class General implements iAction{
|
||||
$personalityClass = getPersonalityClass($raw['personal']);
|
||||
$this->personalityObj = new $personalityClass;
|
||||
|
||||
$itemClass = getItemClass($raw['item']);
|
||||
if($itemClass !== null){
|
||||
$this->itemObjs['item'] = new $itemClass;
|
||||
}
|
||||
else{
|
||||
$this->itemObjs['item'] = new ActionItem\che_Dummy($raw['item']);
|
||||
}
|
||||
//TODO: $specialItemClass 설정
|
||||
$this->itemObjs['horse'] = buildItemClass($raw['horse']);
|
||||
$this->itemObjs['weapon'] = buildItemClass($raw['weap']);
|
||||
$this->itemObjs['book'] = buildItemClass($raw['book']);
|
||||
$this->itemObjs['item'] = buildItemClass($raw['item']);
|
||||
}
|
||||
|
||||
function initLogger(int $year, int $month){
|
||||
|
||||
@@ -204,14 +204,28 @@ class WarUnitGeneral extends WarUnit{
|
||||
return [$warPower,$opposeWarPowerMultiply];
|
||||
}
|
||||
|
||||
///전투 개시 시에 작동하여 1회에만 작동하는 아이템
|
||||
///전투 개시 시에 작동하여 1회에만 작동하는 아이템, 자체적인 Consumable을 처리하지 않는 경우에만
|
||||
function useBattleInitItem():bool{
|
||||
$item = $this->getItem();
|
||||
$general = $this->getGeneral();
|
||||
$item = $general->getItem();
|
||||
|
||||
if($item == 0){
|
||||
if($item === null){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$item->isConsumable()){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$item->isValidTurnItem('Battle', 'NonHandledConsumable')){
|
||||
return false;
|
||||
}
|
||||
|
||||
$itemName = $item->getName();
|
||||
$josaUl = JosaUtil::pick($itemName, '을');
|
||||
$this->getLogger()->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 사용!", ActionLogger::PLAIN);
|
||||
return true;
|
||||
|
||||
$itemActivated = false;
|
||||
$itemConsumed = false;
|
||||
$itemName = getItemName($item);
|
||||
@@ -250,11 +264,7 @@ class WarUnitGeneral extends WarUnit{
|
||||
$itemActivated = true;
|
||||
}
|
||||
|
||||
if($itemConsumed){
|
||||
$general->updateVar('item', 0);
|
||||
$josaUl = JosaUtil::pick($itemName, '을');
|
||||
$this->getLogger()->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 사용!", ActionLogger::PLAIN);
|
||||
}
|
||||
|
||||
|
||||
return $itemActivated;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user