diff --git a/hwe/func_process.php b/hwe/func_process.php index fe531577..f12b3669 100644 --- a/hwe/func_process.php +++ b/hwe/func_process.php @@ -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(); diff --git a/hwe/sammo/Constraint/Constraint.php b/hwe/sammo/Constraint/Constraint.php index 9852b5f6..09b1aac2 100644 --- a/hwe/sammo/Constraint/Constraint.php +++ b/hwe/sammo/Constraint/Constraint.php @@ -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; + } + } \ No newline at end of file diff --git a/hwe/sammo/Constraint/NoFullCityCapacity.php b/hwe/sammo/Constraint/RemainCityCapacity.php similarity index 96% rename from hwe/sammo/Constraint/NoFullCityCapacity.php rename to hwe/sammo/Constraint/RemainCityCapacity.php index c565a9aa..d4617208 100644 --- a/hwe/sammo/Constraint/NoFullCityCapacity.php +++ b/hwe/sammo/Constraint/RemainCityCapacity.php @@ -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;