Skip to content

Commit

Permalink
Merge pull request #486 from plural/basic-startup-support
Browse files Browse the repository at this point in the history
Basic startup support
  • Loading branch information
plural authored Mar 14, 2021
2 parents 57e1e83 + f72b9b1 commit d62e3a3
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
3 changes: 2 additions & 1 deletion app/Resources/views/Builder/deck.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ var Filters = {},
<div role="tabpanel" class="tab-pane" id="tab-pane-collection">
<div class="panel panel-default">
<div class="panel-heading">Select your packs |
<a href="#" id="collection_current">Current Cardpool</a> |
<a href="#" id="collection_startup">Startup</a> |
<a href="#" id="collection_standard">Standard</a> |
<a href="#" id="collection_all">All</a> |
<a href="#" id="collection_none">None</a></div>
<div class="panel-body filter" id="pack_code"></div>
Expand Down
3 changes: 3 additions & 0 deletions app/Resources/views/Search/display-zoom.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
<div class="panel-body">
<table>
<thead>
<tr>
<th class="legality-{{ card.startup_legality }}"> Startup Card Pool</th>
</tr>
<tr>
<th class="legality-{{ card.standard_legality }}"> Standard Card Pool</th>
</tr>
Expand Down
10 changes: 10 additions & 0 deletions src/AppBundle/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@ public function displayAction(
$cardinfo['versions'] = [];
$standard_legal = true;
$all_versions_rotated = true;

// Startup legality is currently hard-coded since the DB doesn't know anything about it.
$startupCycles = ['ashes' => true, 'system-gateway' => true, 'system-update-2021' => true];
$startup_legal = false;

foreach ($cardVersions as $version) {
$v = $cardsData->getCardInfo($version, $locale);
$cardinfo['versions'][] = $v;
Expand All @@ -491,11 +496,16 @@ public function displayAction(
if (array_key_exists($v['cycle_code'], $currentRotationCycles)) {
$all_versions_rotated = false;
}
// Any printing of this card in a valid Startup cycle means the card is Startup legal.
if (array_key_exists($v['cycle_code'], $startupCycles)) {
$startup_legal = true;
}
}

$cardinfo['reviews'] = $cardsData->get_reviews($cardVersions);
$cardinfo['rulings'] = $cardsData->get_rulings($cardVersions);
$cardinfo['mwl_info'] = $cardsData->get_mwl_info($cardVersions);
$cardinfo['startup_legality'] = $startup_legal ? 'legal' : 'banned';

if ($standard_legal) {
$cardinfo['standard_legality'] = $all_versions_rotated ? 'rotated' : 'legal';
Expand Down
27 changes: 22 additions & 5 deletions web/js/deck.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,35 @@ function select_only_latest_cards(matchingCards) {
}

function create_collection_tab(initialPackSelection) {
var rotated_cycles = Array();
var rotated_cycles = Array();
rotated_cycles['draft'] = 1;
rotated_cycles['napd'] = 1;
NRDB.data.cycles.find( { "rotated": true } ).forEach(function(cycle) { rotated_cycles[cycle.code] = 1; });

var rotated_packs = Array();
NRDB.data.packs.find().forEach(function(pack) { if (rotated_cycles[pack.cycle.code]) { rotated_packs[pack.code] = 1; } });

$('#collection_current').on('click', function(event) {
$('#collection_startup').on('click', function(event) {
let startup_cycles = Array();
startup_cycles['ashes'] = 1;
startup_cycles['system-gateway'] = 1;
startup_cycles['system-update-2021'] = 1;
let startup_packs = Array();
startup_packs['df'] = 1;
startup_packs['urbp'] = 1;
startup_packs['ur'] = 1;
startup_packs['sg'] = 1;
startup_packs['su21'] = 1;
event.preventDefault();
$('#pack_code').find(':checkbox').each(function() {
$(this).prop('checked', !(rotated_cycles[$(this).prop('name')] || rotated_packs[$(this).prop('name')]));
$(this).prop('checked', Boolean(startup_cycles[$(this).prop('name')] || startup_packs[$(this).prop('name')]));
});
update_collection_packs();
});
$('#collection_standard').on('click', function(event) {
event.preventDefault();
$('#pack_code').find(':checkbox').each(function() {
$(this).prop('checked', !Boolean(rotated_cycles[$(this).prop('name')] || rotated_packs[$(this).prop('name')]));
});
update_collection_packs();
});
Expand Down Expand Up @@ -217,8 +234,8 @@ function create_collection_tab(initialPackSelection) {
var is_checked = released || sets_in_deck[pack.code] || initialPackSelection[pack.code] !== false;
return $container.addClass("checkbox").append('<label><input type="checkbox" name="' + pack.code + '"' + (is_checked ? ' checked="checked"' : '')+ '>' + pack.name + '</label>');
};
_.sortBy(NRDB.data.cycles.find(), 'position').forEach(function (cycle) {
var packs = _.sortBy(NRDB.data.packs.find({cycle_code:cycle.code}), 'position');
_.sortBy(NRDB.data.cycles.find(), 'position').reverse().forEach(function (cycle) {
var packs = _.sortBy(NRDB.data.packs.find({cycle_code:cycle.code}), 'position').reverse();
if(cycle.size === 1) {
if(packs.length) {
var $div = f(packs[0], $('<div></div>'));
Expand Down

0 comments on commit d62e3a3

Please sign in to comment.