feat: g65_병사연회 구현
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace sammo\Command\UserAction;
|
||||
|
||||
use sammo\ActionBuff\g65_사기40;
|
||||
use \sammo\Command;
|
||||
use \sammo\Util;
|
||||
use \sammo\JosaUtil;
|
||||
use sammo\LastTurn;
|
||||
|
||||
class g65_병사연회 extends Command\UserActionCommand{
|
||||
static protected $actionName = '병사연회';
|
||||
|
||||
protected function argTest():bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getBrief(): string
|
||||
{
|
||||
return '병사 연회';
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$postReqTurn = $this->getPostReqTurn();
|
||||
return "3턴간 사기 +40(재사용 대기 {$postReqTurn})";
|
||||
}
|
||||
|
||||
protected function init(){
|
||||
//아무것도 하지 않음
|
||||
$this->fullConditionConstraints=[];
|
||||
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
return 60;
|
||||
}
|
||||
|
||||
public function getCost():array{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
|
||||
$this->generalObj->addInstantBuff(new g65_사기40(), 3);
|
||||
$logger = $this->generalObj->getLogger();
|
||||
$logger->pushGeneralActionLog("병사에게 연회를 열어 3턴간 사기가 40 상승합니다.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command;
|
||||
|
||||
use \sammo\Util;
|
||||
|
||||
abstract class UserActionCommand extends BaseCommand{
|
||||
abstract class UserActionCommand extends BaseCommand
|
||||
{
|
||||
const USER_ACTION_KEY = 'user_action';
|
||||
|
||||
public function getNextExecuteKey():string{
|
||||
public function getNextExecuteKey(): string
|
||||
{
|
||||
//NOTE: 일반 턴 체계와 다르므로 쓸 일은 없음
|
||||
$turnKey = static::$actionName;
|
||||
$userActionKey = static::USER_ACTION_KEY;
|
||||
@@ -14,38 +18,44 @@ abstract class UserActionCommand extends BaseCommand{
|
||||
return $executeKey;
|
||||
}
|
||||
|
||||
public function getNextAvailableTurn():?int{
|
||||
if($this->isArgValid && !$this->getPostReqTurn()){
|
||||
public function getNextAvailableTurn(): ?int
|
||||
{
|
||||
if ($this->isArgValid && !$this->getPostReqTurn()) {
|
||||
return null;
|
||||
}
|
||||
$rawUserAction = $this->generalObj->getAuxVar(static::USER_ACTION_KEY);
|
||||
if($rawUserAction === null){
|
||||
if ($rawUserAction === null) {
|
||||
return null;
|
||||
}
|
||||
$userAction = \sammo\DTO\UserAction::fromArray($rawUserAction);
|
||||
$nextAvailableTurn = $userAction->nextAvailableTurn;
|
||||
if($nextAvailableTurn === null){
|
||||
if ($nextAvailableTurn === null) {
|
||||
return null;
|
||||
}
|
||||
$nextAvailableTurn = $nextAvailableTurn[static::$actionName] ?? null;
|
||||
return $nextAvailableTurn;
|
||||
}
|
||||
|
||||
public function setNextAvailable(?int $yearMonth=null){
|
||||
if(!$this->getPostReqTurn()){
|
||||
public function setNextAvailable(?int $yearMonth = null)
|
||||
{
|
||||
if (!$this->getPostReqTurn()) {
|
||||
return;
|
||||
}
|
||||
$rawUserAction = $this->generalObj->getAuxVar(static::USER_ACTION_KEY);
|
||||
if($rawUserAction === null){
|
||||
if ($rawUserAction === null) {
|
||||
$rawUserAction = [];
|
||||
}
|
||||
$userAction = \sammo\DTO\UserAction::fromArray($rawUserAction);
|
||||
|
||||
if($userAction->nextAvailableTurn === null){
|
||||
if ($userAction->nextAvailableTurn === null) {
|
||||
$userAction->nextAvailableTurn = [];
|
||||
}
|
||||
|
||||
if ($yearMonth === null) {
|
||||
$yearMonth = Util::joinYearMonth($this->env['year'], $this->env['month'])
|
||||
+ $this->getPostReqTurn() - $this->getPreReqTurn();
|
||||
}
|
||||
$userAction->nextAvailableTurn[static::$actionName] = $yearMonth;
|
||||
$this->generalObj->setAuxVar(static::USER_ACTION_KEY, $userAction->toArray());
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user