Skip to content

Commit 669a4e3

Browse files
authored
Merge pull request #611 from distributive/search-improvements
Fixed decklist search crashing when a faction is specified
2 parents 83e444d + 4958afa commit 669a4e3

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

app/Resources/views/Search/form.html.twig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
<option value="jinteki"{{ faction_j|default('') }}>Jinteki</option>
1212
<option value="nbn"{{ faction_n|default('') }}>NBN</option>
1313
<option value="weyland-consortium"{{ faction_w|default('') }}>Weyland</option>
14+
<option value="neutral-corp"{{ faction_w|default('') }}>Neutral Corp</option>
1415
<option value="runner"{{ faction_R|default('') }}>any Runner</option>
1516
<option value="anarch"{{ faction_a|default('') }}>Anarch</option>
1617
<option value="criminal"{{ faction_c|default('') }}>Criminal</option>
1718
<option value="shaper"{{ faction_s|default('') }}>Shaper</option>
1819
<option value="adam"{{ faction_d|default('') }}>Adam</option>
1920
<option value="apex"{{ faction_p|default('') }}>Apex</option>
2021
<option value="sunny-lebeau"{{ faction_u|default('') }}>Sunny Lebeau</option>
22+
<option value="neutral-runner"{{ faction_w|default('') }}>Neutral Corp</option>
2123
</select>
2224
</div>
2325
<div class="form-group">

src/AppBundle/Controller/DecklistsController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,8 @@ private function searchForm(Request $request, EntityManagerInterface $entityMana
259259
$params['faction_C'] = ' selected="selected"';
260260
} elseif ($faction_code == 'runner') {
261261
$params['faction_R'] = ' selected="selected"';
262-
263262
} else {
264-
$params['faction_' . CardsData::$faction_letters[$faction_code]] = ' selected="selected"';
263+
$params['faction_' . $faction_code] = ' selected="selected"';
265264
}
266265
}
267266

src/AppBundle/Service/CardsData.php

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,27 @@ class CardsData
2222
public static $faction_shortcuts = [
2323
'neutral' => ['neutral-runner', 'neutral-corp'],
2424
'-' => ['neutral-runner', 'neutral-corp'],
25-
'nc' => 'neutral-corp',
26-
'nr' => 'neutral-runner',
25+
'nc' => ['neutral-corp'],
26+
'nr' => ['neutral-runner'],
2727

28-
'h' => 'haas-bioroid',
29-
'hb' => 'haas-bioroid',
30-
'j' => 'jinteki',
31-
'n' => 'nbn',
32-
'w' => 'weyland-consortium',
33-
'weyland' => 'weyland-consortium',
28+
'h' => ['haas-bioroid'],
29+
'hb' => ['haas-bioroid'],
30+
'j' => ['jinteki'],
31+
'n' => ['nbn'],
32+
'w' => ['weyland-consortium'],
33+
'weyland' => ['weyland-consortium'],
3434

35-
'a' => 'anarch',
36-
'c' => 'criminal',
37-
's' => 'shaper',
35+
'a' => ['anarch'],
36+
'c' => ['criminal'],
37+
's' => ['shaper'],
3838

3939
'mini' => ['apex', 'adam', 'sunny-lebeau'],
40-
'p' => 'apex',
41-
'ap' => 'apex',
42-
'd' => 'adam',
43-
'ad' => 'adam',
44-
'u' => 'sunny-lebeau',
45-
'su' => 'sunny-lebeau',
40+
'p' => ['apex'],
41+
'ap' => ['apex'],
42+
'd' => ['adam'],
43+
'ad' => ['adam'],
44+
'u' => ['sunny-lebeau'],
45+
'su' => ['sunny-lebeau'],
4646
];
4747

4848
/** @var EntityManagerInterface $entityManager */
@@ -936,11 +936,7 @@ public function validateConditions(array &$conditions)
936936
$factions = [];
937937
for ($j = 2; $j < count($l); ++$j) {
938938
if (array_key_exists($l[$j], self::$faction_shortcuts)) {
939-
if (is_array(self::$faction_shortcuts[$l[$j]])) {
940-
array_push($factions, ...self::$faction_shortcuts[$l[$j]]);
941-
} else {
942-
array_push($factions, self::$faction_shortcuts[$l[$j]]);
943-
}
939+
array_push($factions, ...self::$faction_shortcuts[$l[$j]]);
944940
} else {
945941
array_push($factions, $l[$j]);
946942
}

0 commit comments

Comments
 (0)