From 7bab771555faff3d63582e0d29d36e86b2f89dbf Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 2 Sep 2018 14:18:59 +0900 Subject: [PATCH] =?UTF-8?q?contraint=20=EC=9D=BC=EA=B4=84=20=EC=B2=B4?= =?UTF-8?q?=ED=81=AC=20=ED=95=A8=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func_process.php | 32 ++++++++++++++++++- hwe/sammo/Constraint/Constraint.php | 25 +++++++++++++++ ...ityCapacity.php => RemainCityCapacity.php} | 2 +- 3 files changed, 57 insertions(+), 2 deletions(-) rename hwe/sammo/Constraint/{NoFullCityCapacity.php => RemainCityCapacity.php} (96%) 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;