Check the all-elimination clause in the create bracket
This commit is contained in:
parent
3eb482e313
commit
cdc5ed5cf6
2 changed files with 8 additions and 9 deletions
|
|
@ -30,7 +30,11 @@ export default {
|
||||||
// Calculate the winners from the previous bracket
|
// Calculate the winners from the previous bracket
|
||||||
let r = await request.server.inject(`/bracket/winners`);
|
let r = await request.server.inject(`/bracket/winners`);
|
||||||
var quotes: string[] = JSON.parse(r.payload).winners;
|
var quotes: string[] = JSON.parse(r.payload).winners;
|
||||||
var winner_count = quotes.length;
|
|
||||||
|
// Ensure that the all elimination limit didn't get hit
|
||||||
|
if (quotes.length > Math.floor(config.discord.quote_max / 2)) {
|
||||||
|
quotes = [];
|
||||||
|
};
|
||||||
|
|
||||||
// Get any new quotes for the bracket
|
// Get any new quotes for the bracket
|
||||||
quotes.push(...(await getQuote(config.discord.quote_max - quotes.length)));
|
quotes.push(...(await getQuote(config.discord.quote_max - quotes.length)));
|
||||||
|
|
@ -49,7 +53,7 @@ export default {
|
||||||
{
|
{
|
||||||
description: `Note: If **more than ${Math.floor(config.discord.quote_max / 2)}** of the quotes tie, they will all be eliminated, otherwise, the ones that tie will move on to the next bracket.`,
|
description: `Note: If **more than ${Math.floor(config.discord.quote_max / 2)}** of the quotes tie, they will all be eliminated, otherwise, the ones that tie will move on to the next bracket.`,
|
||||||
fields: quotes.map((quote, i) => { return {
|
fields: quotes.map((quote, i) => { return {
|
||||||
name: `${i < winner_count ? '👑 ' : ''}Quote: ${i + 1}`,
|
name: `${i < quotes.length ? '👑 ' : ''}Quote: ${i + 1}`,
|
||||||
value: quote,
|
value: quote,
|
||||||
}}),
|
}}),
|
||||||
}
|
}
|
||||||
|
|
@ -66,7 +70,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
label: `Quote ${i + 1}`,
|
label: `Quote ${i + 1}`,
|
||||||
value: i,
|
value: i,
|
||||||
emoji: i < winner_count ? {
|
emoji: i < quotes.length ? {
|
||||||
name: `👑`
|
name: `👑`
|
||||||
} : null
|
} : null
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { config, db } from "@/main"
|
import { db } from "@/main"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
method: `GET`, path: `/bracket/winners`,
|
method: `GET`, path: `/bracket/winners`,
|
||||||
|
|
@ -16,11 +16,6 @@ export default {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Ensure that the all elimination limit didn't get hit
|
|
||||||
if (winners.length > Math.floor(config.discord.quote_max / 2)) {
|
|
||||||
return { winners: [] };
|
|
||||||
};
|
|
||||||
|
|
||||||
return { winners };
|
return { winners };
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue