Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 72 additions & 32 deletions assets/js/app.deck.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@
var map = {};

_.each(pods_list, function (pod) {
if (! map.hasOwnProperty(pod.restricted)) {
map[pod.restricted] = [];
if (pod.restricted) {
if (! map.hasOwnProperty(pod.restricted)) {
map[pod.restricted] = [];
}
map[pod.restricted].push(pod);
}
map[pod.restricted].push(pod);
_.each(pod.cards, function (card) {
if (! map.hasOwnProperty(card)) {
map[card] = [];
Expand Down Expand Up @@ -129,10 +131,17 @@


for (i = 0, n = pods.length; i < n; i++) {
if (-1 !== codes.indexOf(pods[i].restricted)
&& _.intersection(pods[i].cards, codes).length) {
is_valid = false;
break;
if (pods[i].restricted) {
if (-1 !== codes.indexOf(pods[i].restricted)
&& _.intersection(pods[i].cards, codes).length) {
is_valid = false;
break;
}
} else {
if (1 < _.intersection(pods[i].cards, codes).length) {
is_valid = false;
break;
}
}
}
return is_valid;
Expand Down Expand Up @@ -1190,11 +1199,11 @@
var cards;
var formatCardTitle = function (card) {
var rhett = '';
rhett += '&quot;' + card.name.replace(/"/g, '') + '&quot;';
rhett += card.name.replace(/"/g, '');
if (card.is_multiple) {
rhett += ' (' + card.pack_code +')';
}
return rhett;
return '&quot;' + rhett + '&quot;';
}
var isBannedInJoust = (-1 !== app.data.joust_banned_list.indexOf(card.code));
var isBannedInMelee = (-1 !== app.data.melee_banned_list.indexOf(card.code));
Expand All @@ -1215,31 +1224,62 @@
if (joust_pods_map.hasOwnProperty(card.code)) {
pods = joust_pods_map[card.code];
_.each(pods, function (pod) {
restricted = app.data.cards.findById(pod.restricted);
cards = app.data.cards.find({ code: { $in: pod.cards }});

if (1 === pod.cards.length) {
labels.push({
name: '[' + pod.name + ']',
class: 'rl-pod',
title: Translator.trans('card.podinfo_single', {
restricted: formatCardTitle(restricted),
card: formatCardTitle(cards[0]),
format: Translator.trans('tournamentLegality.joust').toUpperCase()
})
});
if (pod.restricted) {
restricted = app.data.cards.findById(pod.restricted);
if (1 === pod.cards.length) {
labels.push({
name: '[' + pod.name + ']',
class: 'rl-pod',
title: Translator.trans('card.restricted_podinfo_single', {
restricted: formatCardTitle(restricted),
card: formatCardTitle(cards[0]),
format: Translator.trans('tournamentLegality.joust').toUpperCase()
})
});
} else {
labels.push({
name: '[' + pod.name + ']',
class: 'rl-pod',
title: Translator.trans('card.restricted_podinfo_multiple', {
restricted: formatCardTitle(restricted),
cards: _.map(cards, function (card) {
return formatCardTitle(card);
}).join(', '),
format: Translator.trans('tournamentLegality.joust').toUpperCase()
}),
});
}
} else {
labels.push({
name: '[' + pod.name + ']',
class: 'rl-pod',
title: Translator.trans('card.podinfo_multiple', {
restricted: formatCardTitle(restricted),
cards: _.map(cards, function (card) {
return formatCardTitle(card);
}).join(', '),
format: Translator.trans('tournamentLegality.joust').toUpperCase()
}),
});
if (2 === pod.cards.length) {
labels.push({
name: '[' + pod.name + ']',
class: 'rl-pod',
title: Translator.trans('card.podinfo_single', {
card: formatCardTitle(card),
other_card: _.map(_.filter(cards, function(c) {
return card.code !== c.code;
}), function (card) {
return formatCardTitle(card);
}).join(', '),
format: Translator.trans('tournamentLegality.joust').toUpperCase()
}),
});
} else {
labels.push({
name: '[' + pod.name + ']',
class: 'rl-pod',
title: Translator.trans('card.podinfo_multiple', {
card: formatCardTitle(card),
other_cards: _.map(_.filter(cards, function(c) {
return card.code !== c.code;
}), function (card) {
return formatCardTitle(card);
}).join(', '),
format: Translator.trans('tournamentLegality.joust').toUpperCase()
}),
});
}
}
});
}
Expand Down
29 changes: 19 additions & 10 deletions src/Services/RestrictionsChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,28 @@ protected function isRestricted(array $restrictedCards, array $pods, array $card
return true;
}

// a deck cannot include cards from pods if the pod's restricted card is part of the deck.
$isRestrictedInPod = false;

foreach ($pods as $pod) {
$restricted = $pod['restricted'];
if (! in_array($restricted, $cardsInDeck)) {
continue;
}
if (array_intersect($pod['cards'], $cardsInDeck)) {
$isRestrictedInPod = true;
break;
if (array_key_exists('restricted', $pod)) {
// if a pod has a restricted card, then the deck cannot include cards
// from pods if the restricted-pod's restricted card is part of the deck.
$restricted = $pod['restricted'];
if (! in_array($restricted, $cardsInDeck)) {
continue;
}
if (array_intersect($pod['cards'], $cardsInDeck)) {
return true;
}
} else {
// a deck cannot include more than one card from each pod.
$podCardsInDeck = array_intersect($pod['cards'], $cardsInDeck);
if (1 < count($podCardsInDeck)) {
return true;
}
}
}
return $isRestrictedInPod;

return false;
}

/**
Expand Down
12 changes: 7 additions & 5 deletions templates/Restrictions/poddescription.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
@file
Partial template for rendering a description for pods.
#}
<p>Some restricted cards are so powerful that their inclusion in a deck comes with
additional deckbuilding restrictions.
If a player selects one of these cards as their restricted card
(shown in <strong>bold text</strong> below), they may not include any of the
cards listed following them.</p>
<p>Some cards interactions are so powerful that the inclusion of these cards in a deck comes with
additional restrictions. Those cards are grouped together in pods.</p>
<p>No more than one card from each pod may be included in a deck.</p>
<p>However, if a pod contains a card from the restricted list (indicated in <strong>bold text</strong> if applicable)
and you choose that card as your restricted card, then the other cards from that pod cannot
be included in your deck. If you choose a different restricted card, you may include any number of
unrestricted cards from that pod in your deck.</p>
26 changes: 22 additions & 4 deletions tests/Services/RestrictionsCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,15 @@ protected function setUp(): void
'title' => 'P2',
'restricted' => '01005',
'cards' => ['01003', '01004']
]
],
[
'title' => 'P3',
'cards' => ['01006', '01007']
],
[
'title' => 'P4',
'cards' => ['01008', '01009']
],
]
],
'melee' => [
Expand All @@ -62,15 +70,23 @@ protected function setUp(): void
],
'restricted_pods' => [
[
'title' => 'P1',
'title' => 'MP1',
'restricted' => '01000',
'cards' => ['01001', '01002']
],
[
'title' => 'P2',
'title' => 'MP2',
'restricted' => '01005',
'cards' => ['01003', '01004']
]
],
[
'title' => 'MP3',
'cards' => ['01006', '01007']
],
[
'title' => 'MP4',
'cards' => ['01008', '01009']
],
]
],
];
Expand All @@ -90,6 +106,7 @@ public function isLegalProvider(): array
[['04001', '04002', '01000'], 'contains one restricted card'],
[['01000', '01003', '01004'], 'contains one restricted card and cards from a different restricted-pod.'],
[['01001', '01002'], 'contains cards in restricted-pod but not the restricted card itself.'],
[['01006', '01008'], 'contains cards in pods but only one from each pod max.'],
[[], 'empty list']
];
}
Expand Down Expand Up @@ -125,6 +142,7 @@ public function isNotLegalProvider(): array
[['04001', '04002', '01900'], 'contains banned card'],
[['04001', '04002', '01000', '01005'], 'contains more than one restricted card'],
[['01000', '01001'], 'contains restricted card and a card in its restricted-pod.'],
[['01006', '01007'], 'contains more than one card from a pod.'],
];
}

Expand Down
6 changes: 4 additions & 2 deletions translations/messages.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,10 @@ pag:
cardscount: "{0} Keine Karten | {1} Eine Karte | ]1,Inf] %count% Karten"

card:
podinfo_single: "%format% - Falls %restricted% Deine Eingeschränkte Karte ist, dann kannst Du %card% nicht in Dein Deck aufnehmen."
podinfo_multiple: '%format% - Falls %restricted% Deine Eingeschränkte Karte ist, dann kannst Du die folgenden Karten nicht in Dein Deck aufnehmen: %cards%.'
podinfo_single: '%format% - Wenn Dein Deck %card% enthält, dann kann es nicht %other_card% enthalten.'
podinfo_multiple: '%format% - Wenn Dein Deck %card% enthält, dann kann es keine der folgenden Karten enthalten: %other_cards%.'
restricted_podinfo_single: "%format% - Falls %restricted% Deine Eingeschränkte Karte ist, dann kannst Du %card% nicht in Dein Deck aufnehmen."
restricted_podinfo_multiple: '%format% - Falls %restricted% Deine Eingeschränkte Karte ist, dann kannst Du die folgenden Karten nicht in Dein Deck aufnehmen: %cards%.'
rl-joust:
title: "Diese Karte ist auf der Liste Eingeschränkter Karten für Tjost."
rl-melee:
Expand Down
6 changes: 4 additions & 2 deletions translations/messages.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,10 @@ pag:
cardscount: "{0} There is no cards | {1} One card | ]1,Inf] %count% cards"

card:
podinfo_single: '%format% - If %restricted% is your chosen restricted card, you cannot include %card% in your deck.'
podinfo_multiple: '%format% - If %restricted% is your chosen restricted card, you cannot include the following cards in your deck: %cards%.'
podinfo_single: '%format% - If you deck includes %card% then it cannot include %other_card%.'
podinfo_multiple: '%format% - If you deck includes %card% then it cannot include any of the following cards: %other_cards%.'
restricted_podinfo_single: '%format% - If %restricted% is your chosen restricted card, you cannot include %card% in your deck.'
restricted_podinfo_multiple: '%format% - If %restricted% is your chosen restricted card, you cannot include the following cards in your deck: %cards%.'
rl-joust:
title: "This card is on the Joust Restricted List."
rl-melee:
Expand Down
6 changes: 4 additions & 2 deletions translations/messages.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,10 @@ pag:
cardscount: "{0} No hay cartas | {1} Una carta | ]1,Inf] %count% cartas"

card:
podinfo_single: '%format% - Si %restricted% es tu carta restringida elegida, no puedes incluir %card% en tu mazo.'
podinfo_multiple: '%format% - Si %restricted% es tu carta restringida elegida, no puedes incluir las siguientes cartas en tu mazo: %cards%.'
podinfo_single: '%format% - Si tu mazo incluye %card%, entonces no puede incluir %other_card%.'
podinfo_multiple: '%format% - Si tu mazo incluye %card%, entonces no puede incluir ninguna de las siguientes cartas: %other_cards%.'
restricted_podinfo_single: '%format% - Si %restricted% es tu carta restringida elegida, no puedes incluir %card% en tu mazo.'
restricted_podinfo_multiple: '%format% - Si %restricted% es tu carta restringida elegida, no puedes incluir las siguientes cartas en tu mazo: %cards%.'
rl-joust:
title: "Su carta está en la la Lista Restringida Justa."
rl-melee:
Expand Down