From 63e888c9b1d2381a9981901b905c855041d91d8a Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 29 Apr 2018 00:28:06 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8A=B9=EC=84=B1=EC=97=90=20'=EB=9E=9C?= =?UTF-8?q?=EB=8D=A4',=20'=EB=9E=9C=EB=8D=A4=EC=A0=84=ED=8A=B9',=20'?= =?UTF-8?q?=EB=9E=9C=EC=A0=90=EB=82=B4=ED=8A=B9'=20=EA=B0=80=EB=8A=A5.=200?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=A7=80=EC=A0=95=20=EA=B0=80=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Scenario/NPC.php | 8 +- hwe/sammo/SpecialityConst.php | 139 +++++++++++++++++++++++----------- 2 files changed, 97 insertions(+), 50 deletions(-) diff --git a/hwe/sammo/Scenario/NPC.php b/hwe/sammo/Scenario/NPC.php index 1a587779..2508bd9a 100644 --- a/hwe/sammo/Scenario/NPC.php +++ b/hwe/sammo/Scenario/NPC.php @@ -60,17 +60,17 @@ class NPC{ ]; if($char === '랜덤전특'){ - $this->charWar = \sammo\Engine\SpecialityConst::pickSpecialWar($general); + $this->charWar = \sammo\SpecialityConst::pickSpecialWar($general); } else if($char === '랜덤내특'){ - $this->charDomestic = \sammo\Engine\SpecialityConst::pickSpecialDomestic($general); + $this->charDomestic = \sammo\SpecialityConst::pickSpecialDomestic($general); } else if($char === '랜덤'){ if(Util::randBool(2/3)){ - $this->charWar = \sammo\Engine\SpecialityConst::pickSpecialWar($general); + $this->charWar = \sammo\SpecialityConst::pickSpecialWar($general); } else{ - $this->charDomestic = \sammo\Engine\SpecialityConst::pickSpecialDomestic($general); + $this->charDomestic = \sammo\SpecialityConst::pickSpecialDomestic($general); } } else{ diff --git a/hwe/sammo/SpecialityConst.php b/hwe/sammo/SpecialityConst.php index 8d1913b7..6fea7a21 100644 --- a/hwe/sammo/SpecialityConst.php +++ b/hwe/sammo/SpecialityConst.php @@ -26,45 +26,58 @@ class SpecialityConst{ //음수 : 절대값 %, 양수 : 상대적 비중 const DOMESTIC = [ - 1 => ['경작', 1, self::STAT_INTEL], - 2 => ['상재', 1, self::STAT_INTEL], - 3 => ['발명', 1, self::STAT_INTEL], + 1 => ['경작', 1, [self::STAT_INTEL]], + 2 => ['상재', 1, [self::STAT_INTEL]], + 3 => ['발명', 1, [self::STAT_INTEL]], - 10 => ['축성', 1, self::STAT_POWER], - 11 => ['수비', 1, self::STAT_POWER], - 12 => ['통찰', 1, self::STAT_POWER], + 10 => ['축성', 1, [self::STAT_POWER]], + 11 => ['수비', 1, [self::STAT_POWER]], + 12 => ['통찰', 1, [self::STAT_POWER]], - 20 => ['인덕', 1, self::STAT_LEADERSHIP], + 20 => ['인덕', 1, [self::STAT_LEADERSHIP]], - 30 => ['거상', -2.5, self::DISABLED], - 31 => ['귀모', -2.5, self::STAT_LEADERSHIP | self::STAT_POWER | self::STAT_INTEL], + 30 => ['거상', -2.5, [self::DISABLED]], + 31 => ['귀모', -2.5, [self::STAT_LEADERSHIP, self::STAT_POWER, self::STAT_INTEL]], ]; const WAR = [ - 40 => ['귀병', 1, self::STAT_INTEL | self::ARMY_WIZARD | self::REQ_DEXTERITY], + 40 => ['귀병', 1, [self::STAT_INTEL | self::ARMY_WIZARD | self::REQ_DEXTERITY]], - 41 => ['신산', 1, self::STAT_INTEL | self::ARMY_WIZARD], - 42 => ['환술', -5, self::STAT_INTEL | self::ARMY_WIZARD], - 43 => ['집중', 1, self::STAT_INTEL | self::ARMY_WIZARD], - 44 => ['신중', 1, self::STAT_INTEL | self::ARMY_WIZARD], - 45 => ['반계', 1, self::STAT_INTEL | self::ARMY_WIZARD], + 41 => ['신산', 1, [self::STAT_INTEL]], + 42 => ['환술', -5, [self::STAT_INTEL]], + 43 => ['집중', 1, [self::STAT_INTEL]], + 44 => ['신중', 1, [self::STAT_INTEL]], + 45 => ['반계', 1, [self::STAT_INTEL]], - 50 => ['보병', 1, self::STAT_LEADERSHIP | self::STAT_POWER | self::REQ_DEXTERITY | self::ARMY_FOOTMAN], - 51 => ['궁병', 1, self::STAT_LEADERSHIP | self::STAT_POWER | self::REQ_DEXTERITY | self::ARMY_ARCHER], - 52 => ['기병', 1, self::STAT_LEADERSHIP | self::STAT_POWER | self::REQ_DEXTERITY | self::ARMY_CAVALRY], - 53 => ['공성', 1, self::STAT_LEADERSHIP | self::STAT_POWER | self::REQ_DEXTERITY | self::ARMY_SIEGE], + 50 => ['보병', 1, [ + self::STAT_LEADERSHIP | self::REQ_DEXTERITY | self::ARMY_FOOTMAN, + self::STAT_POWER | self::REQ_DEXTERITY | self::ARMY_FOOTMAN + ]], + 51 => ['궁병', 1, [ + self::STAT_LEADERSHIP | self::REQ_DEXTERITY | self::ARMY_ARCHER, + self::STAT_POWER | self::REQ_DEXTERITY | self::ARMY_ARCHER + ]], + 52 => ['기병', 1, [ + self::STAT_LEADERSHIP | self::REQ_DEXTERITY | self::ARMY_CAVALRY, + self::STAT_POWER | self::REQ_DEXTERITY | self::ARMY_CAVALRY + ]], + 53 => ['공성', 1, [ + self::STAT_LEADERSHIP | self::REQ_DEXTERITY | self::ARMY_SIEGE, + self::STAT_POWER | self::REQ_DEXTERITY | self::ARMY_SIEGE, + self::STAT_INTEL | self::REQ_DEXTERITY | self::ARMY_SIEGE + ]], - 60 => ['돌격', 1, self::STAT_LEADERSHIP | self::STAT_POWER], - 61 => ['무쌍', 1, self::STAT_LEADERSHIP | self::STAT_POWER], - 62 => ['견고', 1, self::STAT_LEADERSHIP | self::STAT_POWER], - 63 => ['위압', 1, self::STAT_LEADERSHIP | self::STAT_POWER], + 60 => ['돌격', 1, [self::STAT_LEADERSHIP, self::STAT_POWER]], + 61 => ['무쌍', 1, [self::STAT_LEADERSHIP, self::STAT_POWER]], + 62 => ['견고', 1, [self::STAT_LEADERSHIP, self::STAT_POWER]], + 63 => ['위압', 1, [self::STAT_LEADERSHIP, self::STAT_POWER]], - 70 => ['저격', 1, self::STAT_LEADERSHIP | self::STAT_POWER | self::STAT_INTEL], - 71 => ['필살', 1, self::STAT_LEADERSHIP | self::STAT_POWER | self::STAT_INTEL], - 72 => ['징병', 1, self::STAT_LEADERSHIP | self::STAT_POWER | self::STAT_INTEL], - 73 => ['의술', -2, self::STAT_LEADERSHIP | self::STAT_POWER | self::STAT_INTEL], - 74 => ['격노', 1, self::STAT_LEADERSHIP | self::STAT_POWER | self::STAT_INTEL], - 75 => ['척사', 1, self::STAT_LEADERSHIP | self::STAT_POWER | self::STAT_INTEL], + 70 => ['저격', 1, [self::STAT_LEADERSHIP, self::STAT_POWER, self::STAT_INTEL]], + 71 => ['필살', 1, [self::STAT_LEADERSHIP, self::STAT_POWER, self::STAT_INTEL]], + 72 => ['징병', 1, [self::STAT_LEADERSHIP, self::STAT_POWER, self::STAT_INTEL]], + 73 => ['의술', -2, [self::STAT_LEADERSHIP, self::STAT_POWER, self::STAT_INTEL]], + 74 => ['격노', 1, [self::STAT_LEADERSHIP, self::STAT_POWER, self::STAT_INTEL]], + 75 => ['척사', 1, [self::STAT_LEADERSHIP, self::STAT_POWER, self::STAT_INTEL]], ]; public static function getInvDomestic(string $name){ @@ -101,15 +114,19 @@ class SpecialityConst{ private static function calcCondGeneric(array $general) : int { $myCond = 0; + + $leader = $general['leader']??50; + $power = $general['power']??50; + $intel = $general['intel']??50; if ($leader * 0.95 > $power && $leader * 0.95 > $intel) { - $myCond |= STAT_LEADERSHIP; + $myCond |= self::STAT_LEADERSHIP; } else if($power >= $intel){ - $myCond |= STAT_POWER; + $myCond |= self::STAT_POWER; } else { - $myCond |= STAT_INTEL; + $myCond |= self::STAT_INTEL; } return $myCond; @@ -117,11 +134,11 @@ class SpecialityConst{ private static function calcCondDexterity(array $general) : int { $dex = [ - static::ARMY_FOOTMAN => $general['dex0'], - static::ARMY_ARCHER => $general['dex10'], - static::ARMY_CAVALRY => $general['dex20'], - static::ARMY_WIZARD => $general['dex30'], - static::ARMY_SIEGE => $general['dex40'], + static::ARMY_FOOTMAN => $general['dex0']??0, + static::ARMY_ARCHER => $general['dex10']??0, + static::ARMY_CAVALRY => $general['dex20']??0, + static::ARMY_WIZARD => $general['dex30']??0, + static::ARMY_SIEGE => $general['dex40']??0, ]; $dexSum = array_sum($dex); @@ -135,7 +152,7 @@ class SpecialityConst{ return 0; } - if($dexSum){ + if(!$dexSum){ return array_rand($dex); } @@ -148,10 +165,18 @@ class SpecialityConst{ $myCond = static::calcCondGeneric($general); - foreach(self::DOMESTIC as $id=>list($name, $weight, $cond)){ - if(!($cond & $myCond)){ + foreach(self::DOMESTIC as $id=>list($name, $weight, $conds)){ + $valid = false; + foreach($conds as $cond){ + if($cond === ($cond & $myCond)){ + $valid = true; + break; + } + } + if(!$valid){ continue; } + if($weight < 0){ $pAbs[$id] = -$weight; @@ -162,14 +187,21 @@ class SpecialityConst{ } if($pAbs){ - $pAbs[0] = max(0, 100 - array_sum($pAbs)); + if($pRel){ + $pAbs[0] = max(0, 100 - array_sum($pAbs)); + } $id = Util::choiceRandomUsingWeight($pAbs); if($id){ return $id; } } - return Util::choiceRandomUsingWeight($pRel); + $id = Util::choiceRandomUsingWeight($pRel); + if($id){ + return $id; + } + + return static::pickStatickWar($general); } public static function pickSpecialWar(array $general) : int{ @@ -180,8 +212,15 @@ class SpecialityConst{ $myCond = static::calcCondGeneric($general); $myCond |= static::calcCondDexterity($general); - foreach(self::WAR as $id=>list($name, $weight, $cond)){ - if(!($cond & $myCond)){ + foreach(self::WAR as $id=>list($name, $weight, $conds)){ + $valid = false; + foreach($conds as $cond){ + if($cond === ($cond & $myCond)){ + $valid = true; + break; + } + } + if(!$valid){ continue; } @@ -201,13 +240,21 @@ class SpecialityConst{ } if($pAbs){ - $pAbs[0] = max(0, 100 - array_sum($pAbs)); + if($pRel){ + $pAbs[0] = max(0, 100 - array_sum($pAbs)); + } + $id = Util::choiceRandomUsingWeight($pAbs); if($id){ return $id; } } - return Util::choiceRandomUsingWeight($pRel); + $id = Util::choiceRandomUsingWeight($pRel); + if($id){ + return $id; + } + + return static::pickStatickWar($general); } } \ No newline at end of file