Skip to content

Commit

Permalink
Merge pull request #433 from plural/faction-updates
Browse files Browse the repository at this point in the history
Sort faction page by ID card title. Add banned & rotated icons.
  • Loading branch information
plural authored May 27, 2020
2 parents 253166d + adaf249 commit 75d677e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
9 changes: 7 additions & 2 deletions app/Resources/views/Faction/faction.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

{% include '/Default/navbar-factions.html.twig' %}

<div class="page-header">
<span>🔄: rotated card 🚫: banned card</span>
</div>
{% for result in results %}
{% set faction = result.faction %}
{% set decklists = result.decklists %}
Expand All @@ -19,8 +22,10 @@
<div class="col-md-12">

{% for item in decklists %}
<h2>{{ item['identity'].title }}</h2>

<h2>{{ item['identity'].title }}
{% if item['identity'].pack.cycle.rotated %}<span>🔄</span>{% endif %}
{% if item['identity'].code in banned_cards|keys %}<span>🚫</span>{% endif %}
</h2>
<div class="row">
<div class="col-md-3">
<a href="{{ path('cards_zoom',{_locale:app.request.locale,card_code:item['identity'].code}) }}" class="no-popup"><img data-src="{{ asset('/card_image/'~item['identity'].largeImagePath) }}" class="img-responsive lazyload"></a>
Expand Down
15 changes: 10 additions & 5 deletions src/AppBundle/Controller/FactionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public function factionAction(string $faction_code, EntityManagerInterface $enti
$faction_name = $factions[0]->getName();
}


$result = [];
$banned_cards = array();

foreach ($factions as $faction) {

Expand Down Expand Up @@ -83,6 +83,10 @@ public function factionAction(string $faction_code, EntityManagerInterface $enti
}

$identity = $cardsData->select_only_latest_cards($identities);
$i = $cardsData->get_mwl_info([$identity[0]]);
if (count($i) > 0 && $i[0]['active']) {
$banned_cards[$identity[0]->getCode()] = true;
}

$decklists[] = [
'identity' => $identity[0],
Expand All @@ -91,9 +95,9 @@ public function factionAction(string $faction_code, EntityManagerInterface $enti
];
}

// sort the identities from most points to least
// Sort the identities alphabetically.
usort($decklists, function ($a, $b) {
return $b['points'] - $a['points'];
return strcasecmp($a['identity']->getTitle(), $b['identity']->getTitle());
});

$result[] = [
Expand All @@ -103,8 +107,9 @@ public function factionAction(string $faction_code, EntityManagerInterface $enti
}

return $this->render('/Faction/faction.html.twig', [
"pagetitle" => "Faction Page: $faction_name",
"results" => $result,
"pagetitle" => "Faction Page: $faction_name",
"results" => $result,
"banned_cards" => $banned_cards,
], $response);
}
}

0 comments on commit 75d677e

Please sign in to comment.