feat: g65_병사연회 구현

This commit is contained in:
2023-12-25 13:43:46 +00:00
parent 1fe55b83bd
commit 53474ab3d2
10 changed files with 204 additions and 19 deletions
+22 -12
View File
@@ -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());
}
};
};