수극을 통한 저격 예시
This commit is contained in:
@@ -294,6 +294,13 @@ function processWar_NG(
|
|||||||
$attacker->setOppose($defender);
|
$attacker->setOppose($defender);
|
||||||
$defender->setOppose($attacker);
|
$defender->setOppose($attacker);
|
||||||
|
|
||||||
|
$initCaller = $attacker->getGeneral()->getBattleInitSkillTriggerList($attacker);
|
||||||
|
$initCaller->merge($defender->getGeneral()->getBattleInitSkillTriggerList($defender));
|
||||||
|
|
||||||
|
$initCaller->fire([], [$attacker, $defender]);
|
||||||
|
//스킬류, 아이템, 스킬 및 아이템 적용 순이어야 할 것
|
||||||
|
|
||||||
|
/*
|
||||||
foreach(Util::zip(
|
foreach(Util::zip(
|
||||||
$attacker->checkBattleBeginSkill(),
|
$attacker->checkBattleBeginSkill(),
|
||||||
$defender->checkBattleBeginSkill()
|
$defender->checkBattleBeginSkill()
|
||||||
@@ -306,6 +313,7 @@ function processWar_NG(
|
|||||||
|
|
||||||
$attacker->applyBattleBeginSkillAndItem();
|
$attacker->applyBattleBeginSkillAndItem();
|
||||||
$defender->applyBattleBeginSkillAndItem();
|
$defender->applyBattleBeginSkillAndItem();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
$attacker->beginPhase();
|
$attacker->beginPhase();
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo\ActionNationType;
|
||||||
|
use \sammo\iAction;
|
||||||
|
use \sammo\General;
|
||||||
|
use \sammo\WarUnitTriggerCaller;
|
||||||
|
use \sammo\WarUnit;
|
||||||
|
use \sammo\WarInitTrigger\che_저격시도;
|
||||||
|
use \sammo\WarInitTrigger\che_저격발동;
|
||||||
|
|
||||||
|
class che_저격_수극 extends \sammo\BaseItem{
|
||||||
|
|
||||||
|
protected static $id = 2;
|
||||||
|
protected static $name = '수극(저격)';
|
||||||
|
protected static $info = '[전투] 전투 개시 전 20% 확률로 저격 시도. 1회용';
|
||||||
|
protected static $cost = 1000;
|
||||||
|
protected static $consumable = true;
|
||||||
|
|
||||||
|
public function getBattleInitSkillTriggerList(WarUnit $unit):?WarUnitTriggerCaller{
|
||||||
|
return new WarUnitTriggerCaller([
|
||||||
|
new che_저격시도($unit, che_저격시도::TYPE_CONSUMABLE_ITEM, 20, 40),
|
||||||
|
new che_저격발동($unit)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,49 @@ namespace sammo;
|
|||||||
|
|
||||||
abstract class BaseWarUnitTrigger extends ObjectTrigger{
|
abstract class BaseWarUnitTrigger extends ObjectTrigger{
|
||||||
/** @var WarUnit $object */
|
/** @var WarUnit $object */
|
||||||
public function __construct(WarUnit $unit){
|
|
||||||
|
const TYPE_NONE = 0;
|
||||||
|
const TYPE_ITEM = 1;
|
||||||
|
const TYPE_CONSUMABLE_ITEM = 2;
|
||||||
|
|
||||||
|
protected $raiseType;
|
||||||
|
|
||||||
|
public function __construct(WarUnit $unit, int $raiseType = 0){
|
||||||
$this->object = $unit;
|
$this->object = $unit;
|
||||||
|
$this->raiseType = $raiseType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function action(?array $env=null, $arg=null):?array{
|
||||||
|
/** @var WarUnitGeneral $attacker */
|
||||||
|
/** @var WarUnit $defender */
|
||||||
|
[$attacker, $defender] = $arg;
|
||||||
|
|
||||||
|
|
||||||
|
/** @var WarUnit $self */
|
||||||
|
$self = $this->object;
|
||||||
|
$isAttacker = $self->isAttacker();
|
||||||
|
$oppose = $isAttacker?$defender:$attacker;
|
||||||
|
|
||||||
|
if($env === null){
|
||||||
|
$env = [];
|
||||||
|
}
|
||||||
|
if(!key_exists('e_attacker', $env)){
|
||||||
|
$env['e_attacker'] = [];
|
||||||
|
}
|
||||||
|
if(!key_exists('e_defender', $env)){
|
||||||
|
$env['e_defender'] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$selfEnv = $isAttacker?$env['e_attacker']:$env['e_defender'];
|
||||||
|
$opposeEnv = $isAttacker?$env['e_defender']:$env['e_attacker'];
|
||||||
|
|
||||||
|
$this->actionWar($self, $oppose, $selfEnv, $opposeEnv);
|
||||||
|
|
||||||
|
$env['e_attacker'] = $isAttacker?$selfEnv:$opposeEnv;
|
||||||
|
$env['e_defender'] = $isAttacker?$opposeEnv:$selfEnv;
|
||||||
|
|
||||||
|
return $env;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):void;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
class GameUnitInitTriggerBase extends ObjectTrigger{
|
class GameUnitInitTriggerBase extends BaseWarUnitTrigger{
|
||||||
static protected $priority = 10000;
|
static protected $priority = 10000;
|
||||||
|
|
||||||
public function __construct(WarUnit $unit){
|
protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):void{
|
||||||
$this->object = $unit;
|
|
||||||
$this->unitType = $unit->getCrewType();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function action(?array $env=null, $arg=null):?array{
|
|
||||||
/** @var WarUnitGeneral $attacker */
|
|
||||||
/** @var WarUnit $defender */
|
|
||||||
[$attacker, $defender] = $arg;
|
|
||||||
|
|
||||||
$attackerCrewType = $attacker->getCrewType();
|
|
||||||
$defenderCrewType = $defender->getCrewType();
|
|
||||||
|
|
||||||
//TODO: 충차는 성벽 상대로 부상입지 않음
|
//TODO: 충차는 성벽 상대로 부상입지 않음
|
||||||
|
|
||||||
return $env;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,23 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo;
|
namespace sammo;
|
||||||
|
|
||||||
class GameUnitPhaseTriggerBase extends ObjectTrigger{
|
class GameUnitPhaseTriggerBase extends BaseWarUnitTrigger{
|
||||||
static protected $priority = 10000;
|
static protected $priority = 10000;
|
||||||
|
|
||||||
public function __construct(WarUnit $unit){
|
protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):void{
|
||||||
$this->object = $unit;
|
//TODO: 목우 목우
|
||||||
$this->unitType = $unit->getCrewType();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function action(?array $env=null, $arg=null):?array{
|
|
||||||
/** @var WarUnitGeneral $attacker */
|
|
||||||
/** @var WarUnit $defender */
|
|
||||||
[$attacker, $defender] = $arg;
|
|
||||||
|
|
||||||
$attackerCrewType = $attacker->getCrewType();
|
|
||||||
$defenderCrewType = $defender->getCrewType();
|
|
||||||
|
|
||||||
//TODO: 목우
|
|
||||||
return $env;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,6 +81,8 @@ abstract class TriggerCaller{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//NOTE: array_merge로 계속 가야하는가? merge가 많으면 SPL의 LinkedList가 낫지 않나?
|
||||||
|
|
||||||
$newTriggerList = [];
|
$newTriggerList = [];
|
||||||
$iterLhs = new \ArrayIterator($this->triggerListByPriority);
|
$iterLhs = new \ArrayIterator($this->triggerListByPriority);
|
||||||
$iterRhs = new \ArrayIterator($other->triggerListByPriority);
|
$iterRhs = new \ArrayIterator($other->triggerListByPriority);
|
||||||
@@ -96,7 +98,7 @@ abstract class TriggerCaller{
|
|||||||
$iterRhs->next();
|
$iterRhs->next();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$newTriggerList[$iterLhs->key()] = $iterLhs->current() + $iterRhs->current();
|
$newTriggerList[$iterLhs->key()] = array_merge($iterLhs->current(), $iterRhs->current());
|
||||||
$iterLhs->next();
|
$iterLhs->next();
|
||||||
$iterRhs->next();
|
$iterRhs->next();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo\WarInitTrigger;
|
||||||
|
use sammo\BaseWarUnitTrigger;
|
||||||
|
use sammo\WarUnitGeneral;
|
||||||
|
use sammo\WarUnitCity;
|
||||||
|
use sammo\WarUnit;
|
||||||
|
use sammo\GameUnitDetail;
|
||||||
|
use sammo\Util;
|
||||||
|
|
||||||
|
class che_저격발동 extends BaseWarUnitTrigger{
|
||||||
|
static protected $priority = 20000;
|
||||||
|
|
||||||
|
protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):void{
|
||||||
|
if(!$oppose->hasActivatedSkill('저격')){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($selfEnv['저격발동']){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$selfEnv['저격발동'] = true;
|
||||||
|
|
||||||
|
$general = $self->general;
|
||||||
|
|
||||||
|
$oppose->getLogger()->pushGeneralActionLog("상대를 <C>저격</>했다!", ActionLogger::PLAIN);
|
||||||
|
$oppose->getLogger()->pushGeneralBattleDetailLog("상대를 <C>저격</>했다!", ActionLogger::PLAIN);
|
||||||
|
$self->getLogger()->pushGeneralActionLog("상대에게 <R>저격</>당했다!", ActionLogger::PLAIN);
|
||||||
|
$self->getLogger()->pushGeneralBattleDetailLog("상대에게 <R>저격</>당했다!", ActionLogger::PLAIN);
|
||||||
|
|
||||||
|
$general->increaseVarWithLimit('injury', Util::randRangeInt($opposeEnv['woundMin'], $opposeEnv['woundMax']), null, 80);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo\WarInitTrigger;
|
||||||
|
use sammo\BaseWarUnitTrigger;
|
||||||
|
use sammo\WarUnitGeneral;
|
||||||
|
use sammo\WarUnitCity;
|
||||||
|
use sammo\WarUnit;
|
||||||
|
use sammo\GameUnitDetail;
|
||||||
|
|
||||||
|
class che_저격시도 extends BaseWarUnitTrigger{
|
||||||
|
static protected $priority = 20000;
|
||||||
|
|
||||||
|
protected $woundMin;
|
||||||
|
protected $woundMax;
|
||||||
|
|
||||||
|
public function __construct(WarUnit $unit, int $raiseType, float $woundMin, float $woundMax){
|
||||||
|
$this->object = $unit;
|
||||||
|
$this->raiseType = $raiseType;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):void{
|
||||||
|
assert($self instanceof WarUnitGeneral, 'General만 발동 가능');
|
||||||
|
if(!$oppose instanceof WarUnitGeneral){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if($self->hasActivatedSkill('저격')){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if($self->hasActivatedSkill('저격불가')){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!Util::randBool(1/5)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->activateSkill('저격');
|
||||||
|
$selfEnv['woundMin'] = $this->woundMin;
|
||||||
|
$selfEnv['woundMax'] = $this->woundMax;
|
||||||
|
|
||||||
|
if(!($this->raiseType & static::TYPE_ITEM)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->activateSkill('아이템사용');
|
||||||
|
$item = $self->getGeneral()->getItem();
|
||||||
|
$itemName = $item->getName();
|
||||||
|
$self->activateSkill($itemName);
|
||||||
|
|
||||||
|
if (!($this->raiseType & static::TYPE_CONSUMABLE_ITEM)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->activateSkill('아이템소모');
|
||||||
|
$josaUl = JosaUtil::pick($itemName, '을');
|
||||||
|
$self->getLogger()->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 사용!", ActionLogger::PLAIN);
|
||||||
|
$self->general->deleteItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user