임관 추가. 유니크 복권 추첨을 General 클래스 용으로 변경

This commit is contained in:
2018-10-21 15:20:27 +09:00
parent 6c5c2d40bc
commit ff87555eba
38 changed files with 467 additions and 165 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace sammo\Constraint;
use \sammo\GameConst;
class AllowJoinAction extends Constraint{
const REQ_VALUES = Constraint::REQ_GENERAL;
public function checkInputValues(bool $throwExeception=true){
if(!parent::checkInputValues($throwExeception) && !$throwException){
return false;
}
if(!key_exists('makelimit', $this->general)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require makelimit in general");
}
return true;
}
public function test():bool{
$this->checkInputValues();
$this->tested = true;
if($this->general['makelimit'] == 0){
return true;
}
$joinActionLimit = GameConst::$joinActionLimit;
$this->reason = "재야가 된지 {$joinActionLimit}턴이 지나야 합니다.";
return false;
}
}
@@ -0,0 +1,61 @@
<?php
namespace sammo\Constraint;
use \sammo\DB;
use \sammo\GameConst;
class AllowJoinDestNation extends Constraint{
const REQ_VALUES = Constraint::REQ_GENERAL|Constraint::REQ_DEST_NATION|Constraint::REQ_INT_ARG;
protected $relYear;
public function checkInputValues(bool $throwExeception=true){
if(!parent::checkInputValues($throwExeception) && !$throwException){
return false;
}
if(!key_exists('scout', $this->nation)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require scout in nation");
}
if(!key_exists('gennum', $this->nation)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require gennum in nation");
}
if(!key_exists('nations', $this->general)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require nations in nation");
}
$this->relYear = $this->arg;
return true;
}
public function test():bool{
$this->checkInputValues();
$this->tested = true;
$db = DB::db();
if($relYear < GameConst::$openingPartYear && $this->destNation['gennum'] >= GameConst::$initialNationGenLimit){
$this->reason = "임관이 제한되고 있습니다.";
return false;
}
if($this->destNation['scout'] == 0){
$this->reason = "임관이 금지되어 있습니다.";
return false;
}
$joinedNations = Json::decode($this->general['nations']);
if(in_array($this->destNation['nation'], $joinedNations)){
$this->reason = "이미 임관했었던 국가입니다.";
return false;
}
return true;
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
namespace sammo\Constraint;
class NotCapital extends Constraint{
class AllowWar extends Constraint{
const REQ_VALUES = Constraint::REQ_NATION;
public function checkInputValues(bool $throwExeception=true){
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace sammo\Constraint;
class BeNeutral extends Constraint{
const REQ_VALUES = Constraint::REQ_GENERAL;
public function checkInputValues(bool $throwExeception=true){
if(!parent::checkInputValues($throwExeception) && !$throwException){
return false;
}
if(!key_exists('nation', $this->general)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require nation in general");
}
return true;
}
public function test():bool{
$this->checkInputValues();
$this->tested = true;
if($this->general['nation'] == 0){
return true;
}
$this->reason = "재야가 아닙니다.";
return false;
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace sammo\Constraint;
class ExistsDestGeneral extends Constraint{
const REQ_VALUES = Constraint::REQ_DEST_NATION;
public function checkInputValues(bool $throwExeception=true){
if(!parent::checkInputValues($throwExeception) && !$throwException){
return false;
}
return true;
}
public function test():bool{
$this->checkInputValues();
$this->tested = true;
if($this->destNation['nation']){
return true;
}
$this->reason = "없는 국가입니다.";
return false;
}
}
@@ -2,7 +2,7 @@
namespace sammo\Constraint;
class NoOpeningPart extends Constraint{
class NotBeNeutral extends Constraint{
const REQ_VALUES = Constraint::REQ_GENERAL;
public function checkInputValues(bool $throwExeception=true){
@@ -10,9 +10,9 @@ class NoOpeningPart extends Constraint{
return false;
}
if(!key_exists('level', $this->general)){
if(!key_exists('nation', $this->general)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require level in general");
throw new \InvalidArgumentException("require nation in general");
}
return true;
@@ -22,7 +22,7 @@ class NoOpeningPart extends Constraint{
$this->checkInputValues();
$this->tested = true;
if($this->general['level'] != 0){
if($this->general['nation'] != 0){
return true;
}
@@ -2,7 +2,7 @@
namespace sammo\Constraint;
class NoOpeningPart extends Constraint{
class NotOpeningPart extends Constraint{
const REQ_VALUES = Constraint::REQ_INT_ARG;
protected $relYear;
@@ -2,7 +2,7 @@
namespace sammo\Constraint;
class NoWanderingNation extends Constraint{
class NotWanderingNation extends Constraint{
const REQ_VALUES = Constraint::REQ_NATION;
public function checkInputValues(bool $throwExeception=true){