game: 토너먼터 자동 참가 시, 능력치에 기반

This commit is contained in:
2021-12-16 01:05:59 +09:00
parent 786306e32a
commit 8da0e685c8
2 changed files with 59 additions and 42 deletions
+1 -1
View File
@@ -202,7 +202,7 @@ if($btn == "자동개최설정") {
$gameStor->tournament = 2; $gameStor->tournament = 2;
$gameStor->phase = 0; $gameStor->phase = 0;
} elseif($btn == "무명전부투입") { } elseif($btn == "무명전부투입") {
fillLowGenAll(); fillLowGenAll($admin['tnmt_type']);
} elseif($btn == "예선") { } elseif($btn == "예선") {
qualify($admin['tnmt_type'], $admin['tournament'], $admin['phase']); qualify($admin['tnmt_type'], $admin['tournament'], $admin['phase']);
} elseif($btn == "예선전부") { } elseif($btn == "예선전부") {
+35 -18
View File
@@ -58,7 +58,7 @@ function processTournament()
for ($i = 0; $i < $iter; $i++) { for ($i = 0; $i < $iter; $i++) {
switch ($tnmt) { switch ($tnmt) {
case 1: //신청 마감 case 1: //신청 마감
fillLowGenAll(); fillLowGenAll($type);
$tnmt = 2; $tnmt = 2;
$phase = 0; $phase = 0;
break; break;
@@ -452,7 +452,7 @@ function startBetting()
} }
} }
function fillLowGenAll() function fillLowGenAll($tnmt_type)
{ {
$db = DB::db(); $db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env'); $gameStor = KVStorage::getStorage($db, 'game_env');
@@ -466,17 +466,7 @@ function fillLowGenAll()
'leadership' => 10, 'leadership' => 10,
'strength' => 10, 'strength' => 10,
'intel' => 10, 'intel' => 10,
'explevel' => 10 'lvl' => 10,
];
$dummyGeneral = [
'no' => 0,
'npc' => 2,
'name' => '무명장수',
'leadership' => 10,
'strength' => 10,
'intel' => 10,
'lvl' => 0,
'h' => 'None', 'h' => 'None',
'w' => 'None', 'w' => 'None',
'b' => 'None' 'b' => 'None'
@@ -500,16 +490,43 @@ function fillLowGenAll()
$toBeFilledCnt = 8 * 8 - $currentJoinerCnt; $toBeFilledCnt = 8 * 8 - $currentJoinerCnt;
$scoringCandFunction = match ($tnmt_type) {
0 => function ($gen) {
return $gen['leadership'] + $gen['strength'] + $gen['intel'];
}, //전력전
1 => function ($gen) {
return $gen['leadership'];
}, //통솔전
2 => function ($gen) {
return $gen['strength'];
}, //통솔전
3 => function ($gen) {
return $gen['intel'];
}, //통솔전
default => throw new \ValueError('invalid tnmt_type' . $tnmt_type)
};
//자동신청하고, 돈 있고, 아직 참가 안한 장수 //자동신청하고, 돈 있고, 아직 참가 안한 장수
$freeJoiners = $db->query( $freeJoinerCandidate = [];
'SELECT no,npc,name,leadership,strength,intel,explevel,horse,weapon,book from general where tnmt=1 and tournament=0 order by rand() limit %d',
$toBeFilledCnt foreach($db->query(
); 'SELECT no,npc,name,leadership,strength,intel,explevel,horse,weapon,book from general where tnmt=1 and tournament=0',
) as $gen){
$score = $scoringCandFunction($gen);
$freeJoinerCandidate[$gen['no']] = [$gen, $score**2];
}
$joinersValues = []; $joinersValues = [];
$joinersIdx = []; $joinersIdx = [];
foreach ($freeJoiners as $general) { foreach(Util::range($toBeFilledCnt) as $_){
if(!$freeJoinerCandidate){
break;
}
$general = Util::choiceRandomUsingWeightPair($freeJoinerCandidate);
unset($freeJoinerCandidate[$general['no']]);
$grpIdx = array_keys($grpCount, min($grpCount))[0]; $grpIdx = array_keys($grpCount, min($grpCount))[0];
$grpCnt = $grpCount[$grpIdx]; $grpCnt = $grpCount[$grpIdx];
$joinersValues[] = [ $joinersValues[] = [