diff --git a/app/Resources/views/Builder/initbuild.html.twig b/app/Resources/views/Builder/initbuild.html.twig
index d6123513..9d45825a 100755
--- a/app/Resources/views/Builder/initbuild.html.twig
+++ b/app/Resources/views/Builder/initbuild.html.twig
@@ -3,7 +3,7 @@
{% block head %}
{% endblock %}
@@ -32,7 +36,11 @@
-
Choose your identity
+
-
-
-
+
diff --git a/src/AppBundle/Controller/BuilderController.php b/src/AppBundle/Controller/BuilderController.php
index 0810848d..134da914 100755
--- a/src/AppBundle/Controller/BuilderController.php
+++ b/src/AppBundle/Controller/BuilderController.php
@@ -45,20 +45,36 @@ public function buildformAction(string $side_text, EntityManagerInterface $entit
]);
$identities = $entityManager->getRepository('AppBundle:Card')->findBy([
- "side" => $side,
"type" => $type,
], [
"faction" => "ASC",
"title" => "ASC",
]);
+ $identities = $cardsData->select_only_latest_cards($identities);
+ // Sorting minifactions and neutrals like this because whatever PHP version this is can't do stable sorting
+ // Resulting array is [ normal factions ... mini factions ... neutral ]
+ $identities = array_merge(
+ array_filter($identities, function($identity) {
+ return !$identity->getFaction()->getIsNeutral() && !$identity->getFaction()->getIsMini();
+ }),
+ array_filter($identities, function($identity) {
+ return $identity->getFaction()->getIsMini();
+ }),
+ array_filter($identities, function($identity) {
+ return $identity->getFaction()->getIsNeutral();
+ }),
+ );
- $factions = $entityManager->getRepository('AppBundle:Faction')->findBy([
- "side" => $side,
- ], [
+ $factions = $entityManager->getRepository('AppBundle:Faction')->findBy([], [
"name" => "ASC",
]);
+ $corp_factions = array_filter($factions, function($faction) {
+ return $faction->getSide()->getCode() == "corp" && !$faction->getIsNeutral();
+ });
+ $runner_factions = array_filter($factions, function($faction) {
+ return $faction->getSide()->getCode() == "runner" && !$faction->getIsNeutral() && !$faction->getIsMini();
+ });
- $identities = $cardsData->select_only_latest_cards($identities);
$banned_cards = array();
foreach ($identities as $id) {
$i = $cardsData->get_mwl_info([$id], true /* active_only */);
@@ -75,7 +91,9 @@ public function buildformAction(string $side_text, EntityManagerInterface $entit
'pagedescription' => "Choose your identity to start building a custom deck.",
"identities" => $identities,
"banned_cards" => $banned_cards,
- "factions" => $factions
+ "corp_factions" => $corp_factions,
+ "runner_factions" => $runner_factions,
+ "side" => $side,
],
$response
diff --git a/src/AppBundle/Entity/Faction.php b/src/AppBundle/Entity/Faction.php
index c0808e2b..68a2899c 100755
--- a/src/AppBundle/Entity/Faction.php
+++ b/src/AppBundle/Entity/Faction.php
@@ -83,6 +83,7 @@ public function normalize()
'code' => $this->code,
'color' => $this->color,
'is_mini' => $this->isMini,
+ 'is_neutral' => $this->getIsNeutral(),
'name' => $this->name,
'side_code' => $this->side ? $this->side->getCode() : null
];
@@ -153,6 +154,14 @@ public function setIsMini(bool $isMini)
return $this;
}
+ /**
+ * @return bool
+ */
+ public function getIsNeutral()
+ {
+ return str_contains($this->code, 'neutral');
+ }
+
/**
* @return Side
*/
diff --git a/web/css/style.css b/web/css/style.css
index 6c5c0b12..ddf11f40 100644
--- a/web/css/style.css
+++ b/web/css/style.css
@@ -2062,10 +2062,6 @@ code {
color: var(--nrdb-color--btn);
}
-#deck-builder #faction-filter.form-control {
- background-color: var(--nrdb-color--card) !important;
-}
-
.table-hover > tbody > tr:hover {
background-color: var(--nrdb-color--border);
}
diff --git a/web/js/initbuild.js b/web/js/initbuild.js
index fb691f99..c8ad8b47 100644
--- a/web/js/initbuild.js
+++ b/web/js/initbuild.js
@@ -11,7 +11,7 @@ $(function() {
// Check if the preview is showing a card that is currently visible
function checkPreview() {
let id = $(`.identity[data-code="${$('#cardimg').attr('data-code')}"]`);
- if (id.hasClass('hidden-format') || id.hasClass('hidden-misc')) {
+ if (id.hasClass('hidden-side') || id.hasClass('hidden-faction') || id.hasClass('hidden-format') || id.hasClass('hidden-misc')) {
$('#cardimg').hide();
}
}
@@ -30,59 +30,117 @@ $(function() {
}
});
- // Update the ID list when the format is changed
- function updateFormat(format) {
+ // Sets the faction selection to the appropriate side and refreshes the list of cards
+ function updateSide(side) {
+ // Update menu
+ if (side === 'corp') {
+ $('#corp-faction-options').show();
+ $('#runner-faction-options').hide();
+ $('#switch-side').attr('value', 'runner');
+ $('#switch-side').text($('#switch-side').text().replace("corp", "runner"));
+ } else {
+ $('#corp-faction-options').hide();
+ $('#runner-faction-options').show();
+ $('#switch-side').attr('value', 'corp');
+ $('#switch-side').text($('#switch-side').text().replace("runner", "corp"));
+ }
+ // Filter cards
+ $('.identity').each(function(id, i) {
+ if ($(this).hasClass('side-' + side)) {
+ $(this).removeClass('hidden-side');
+ } else {
+ $(this).addClass('hidden-side');
+ }
+ });
+ // Reset faction
+ updateFaction('all');
+ }
+
+ // Update the ID list when the faction is changed
+ function updateFaction(faction) {
+ // Update settings
+ $(`.option-faction[value!="${faction}"]`).removeClass('active-setting');
+ $(`.option-faction[value="${faction}"]`).addClass('active-setting');
+ // Filter cards
+ if (faction === 'all') {
$('.identity').each(function(id, i) {
- // All (only show legality indicators on all)
- if (format === 'all') {
- $(this).removeClass('hidden-format');
- $(this).find('.legality-indicator').show ();
- return;
+ $(this).removeClass('hidden-faction');
+ });
+ } else if (faction === 'mini') {
+ $('.identity').each(function(id, i) {
+ if ($(this).hasClass('mini-faction')) {
+ $(this).removeClass('hidden-faction');
+ } else {
+ $(this).addClass('hidden-faction');
+ }
+ });
+ } else {
+ $('.identity').each(function(id, i) {
+ if ($(this).hasClass('faction-' + faction)) {
+ $(this).removeClass('hidden-faction');
} else {
- $(this).find('.legality-indicator').hide ();
- }
- // Other formats
- let visible = true;
- // Startup
- if (format === 'startup') {
- visible = ['sg', 'su21', 'tai', 'rwr'].some(p => $(this).hasClass('pack-' + p)); // Hardcoded Startup Codes
- }
- // Standard
- else if (format === 'standard') {
- visible = !($(this).hasClass('banned') || $(this).hasClass('rotated'));
- }
- // Eternal
- else if (format === 'eternal') {
- visible = true
- }
- // Draft
- if ($(this).hasClass('pack-draft')) {
- visible = format === 'draft';
- }
- else if (format === 'draft') {
- visible = false
- }
- // Other (neutral Gateway IDs and the multiplayer NAPD ID)
- if (['24001', '30076', '30077'].includes($(this).attr('data-code'))) {
- visible = format === 'other';
- }
- else if (format === 'other') {
- visible = false
+ $(this).addClass('hidden-faction');
}
- // Apply effect
- if (visible)
- $(this).removeClass('hidden-format');
- else
- $(this).addClass('hidden-format');
});
+ }
+ }
+
+ // Update the ID list when the format is changed
+ function updateFormat(format) {
+ // Update settings
+ $(`.option-format[value!="${format}"]`).removeClass('active-setting');
+ $(`.option-format[value="${format}"]`).addClass('active-setting');
+ // Filter cards
+ $('.identity').each(function(id, i) {
+ // All (only show legality indicators on all)
+ if (format === 'all') {
+ $(this).removeClass('hidden-format');
+ $(this).find('.legality-indicator').show ();
+ return;
+ } else {
+ $(this).find('.legality-indicator').hide ();
+ }
+ // Other formats
+ let visible = true;
+ // Startup
+ if (format === 'startup') {
+ visible = ['sg', 'su21', 'tai', 'rwr'].some(p => $(this).hasClass('pack-' + p)); // Hardcoded Startup Codes
+ }
+ // Standard
+ else if (format === 'standard') {
+ visible = !($(this).hasClass('banned') || $(this).hasClass('rotated'));
+ }
+ // Eternal
+ else if (format === 'eternal') {
+ visible = true
+ }
+ // Draft
+ if ($(this).hasClass('pack-draft')) {
+ visible = format === 'draft';
+ }
+ else if (format === 'draft') {
+ visible = false
+ }
+ // Other (neutral Gateway IDs and the multiplayer NAPD ID)
+ if (['24001', '30076', '30077'].includes($(this).attr('data-code'))) {
+ visible = format === 'other';
+ }
+ else if (format === 'other') {
+ visible = false
+ }
+ // Apply effect
+ if (visible)
+ $(this).removeClass('hidden-format');
+ else
+ $(this).addClass('hidden-format');
+ });
}
// Update the ID list when any other parameter is changed
function updateMisc() {
- let faction = $('#faction-filter').val();
let search = $('#title-filter').val().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
$('.identity').each(function(id, i) {
- if (faction !== 'all' && !$(this).hasClass('faction-' + faction) || !$(this).find('.name').html().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").includes(search)) {
+ if (search && !$(this).find('.name').html().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").includes(search)) {
$(this).addClass('hidden-misc');
return;
}
@@ -90,17 +148,25 @@ $(function() {
});
}
- // Filter on format selected
- $('.option-format').on('click', function(event) {
- updateFormat($(this).attr('value'));
+ // Changing side
+ $('#switch-side').on('click', function(event) {
+ updateSide($(this).attr('value'));
checkPreview();
event.preventDefault();
});
// Filter on faction selected
- $('#faction-filter').change(function() {
- updateMisc();
+ $('.option-faction').on('click', function(event) {
+ updateFaction($(this).attr('value'));
checkPreview();
+ event.preventDefault();
+ });
+
+ // Filter on format selected
+ $('.option-format').on('click', function(event) {
+ updateFormat($(this).attr('value'));
+ checkPreview();
+ event.preventDefault();
});
// Filter on search updated
@@ -110,5 +176,7 @@ $(function() {
});
// Filter on page refresh
+ updateSide($('#switch-side').attr('value') == 'runner' ? 'corp' : 'runner');
+ updateFormat('standard');
updateMisc();
});