특성에 '랜덤', '랜덤전특', '랜점내특' 가능. 0으로 지정 가능

This commit is contained in:
2018-04-29 00:28:06 +09:00
parent e97e702c2e
commit 63e888c9b1
2 changed files with 97 additions and 50 deletions
+4 -4
View File
@@ -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{
+93 -46
View File
@@ -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);
}
}