forked from devsam/core
contraint 일괄 체크 함수 추가
This commit is contained in:
+31
-1
@@ -191,7 +191,37 @@ function CriticalScore($score, $type) {
|
||||
return Util::round($score * $ratio);
|
||||
}
|
||||
|
||||
function process_1(&$general, $type) {
|
||||
function process_1(array $general, int $type){
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
[$startYear, $year, $month, $develCost] = $gameStor->getValuesAsArray(['startyear', 'year', 'month', 'develcost']);
|
||||
|
||||
if($type == 1){
|
||||
$cityKey = 'agri';
|
||||
$keyName = '농지 개간';
|
||||
}
|
||||
else{
|
||||
$cityKey = 'comm';
|
||||
$keyName = '상업 투자';
|
||||
}
|
||||
|
||||
$city = $db->queryFirstRow('SELECT * FROM city WHERE city = %i', $general['city']);
|
||||
$nation = getNationStaticInfo($general['nation']);
|
||||
$lbonus = setLeadershipBonus($general, $nation['level']);
|
||||
|
||||
$constraints = [
|
||||
['NoNeutral'],
|
||||
['NoWanderingNation'],
|
||||
['OccupiedCity'],
|
||||
['SuppliedCity'],
|
||||
['ReqGeneralGold', $develCost],
|
||||
['RemainCityCapacity', [$cityKey, $keyName]]
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
function process_1_old(&$general, $type) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$connect=$db->get();
|
||||
|
||||
@@ -172,4 +172,29 @@ abstract class Constraint{
|
||||
return $this->reason;
|
||||
}
|
||||
|
||||
public static function testAll(array $contraintPacks, array $input):?string{
|
||||
foreach($contraintPacks as $constraintArgs){
|
||||
if (!$constraintArgs){
|
||||
continue;
|
||||
}
|
||||
|
||||
$method = $constraintArgs[0].'::build';
|
||||
|
||||
/** @var \sammo\Constraint\Constraint $contraint */
|
||||
$constraint = call_user_func($method,$input);
|
||||
|
||||
if(count($constraintArgs) > 1){
|
||||
$arg = $constraintArgs[1];
|
||||
$constraint->arg($arg);
|
||||
}
|
||||
|
||||
|
||||
if(!$constraint->test()){
|
||||
return $constraint->reason();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ namespace sammo\Constraint;
|
||||
|
||||
use \sammo\JosaUtil;
|
||||
|
||||
class NoFullCityCapacity extends Constraint{
|
||||
class RemainCityCapacity extends Constraint{
|
||||
const REQ_VALUES = Constraint::REQ_CITY|Constraint::REQ_ARRAY_ARG;
|
||||
|
||||
protected $key;
|
||||
Reference in New Issue
Block a user