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
8 changes: 6 additions & 2 deletions locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@
"dont-use-drawn": "Nicht verwenden",
"win": "%u hat das Spiel gewonnen! Es wurden %turns Karten gespielt.",
"win-you": "Du hast das Spiel gewonnen!",
"missing-uno": ":warning: Du musst den Uno!-Button nutzen, bevor du die vorletzte Karte legst!",
"missing-uno": "⚠️ Du musst den Uno!-Button nutzen, bevor du die vorletzte Karte legst!",
"choose-color": "Wähle eine Farbe aus:",
"pending-draws": "Lege eine Ziehe 2/4-Karte, sonst musst du %count Karten ziehen!",
"not-ingame": "Du bist nicht in dem Uno-Spiel!",
Expand All @@ -925,7 +925,11 @@
"start-game": "Spiel sofort starten",
"not-host": "Du bist nicht der Ersteller des Spiels!",
"max-players": "Das Spiel ist voll!",
"previous-cards": "Vorherige Karten: "
"previous-cards": "Vorherige Karten: ",
"used-card": "Du hast die Karte %c bereits verwendet! Nutze den Aktualisieren-Button und spiele eine zulässige Karte.",
"invalid-card": "Du kannst die Karte %c momentan nicht spielen! Bitte spiele eine zulässige Karte.",
"inactive-warn": "%u, du bist bei Uno am Zug!",
"inactive-win": "Das Uno-Spiel wurde beendet. %u hat gewonnen, da alle anderen ausgeschieden sind!"
},
"quiz": {
"what-have-i-voted": "Was habe ich gewählt?",
Expand Down
8 changes: 6 additions & 2 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@
"dont-use-drawn": "Dont use",
"win": "%u won the game! %turns cards were played.",
"win-you": "You've won the game!",
"missing-uno": ":warning: You must use the Uno! button before you use your second last card!",
"missing-uno": "⚠️ You must use the Uno! button before you use your second last card!",
"choose-color": "Select a color:",
"pending-draws": "Use a Draw 2/4 card, otherwise you have to draw %count cards!",
"not-ingame": "You're not in this game!",
Expand All @@ -909,7 +909,11 @@
"start-game": "Start game now",
"not-host": "You're not the host of the game!",
"max-players": "The game is full!",
"previous-cards": "Previous cards: "
"previous-cards": "Previous cards: ",
"used-card": "You've already used the card %c! Use the Update button and play a valid card.",
"invalid-card": "You cannot play the card %c right now! Please select a valid card.",
"inactive-warn": "%u, it's your turn in the uno game!",
"inactive-win": "The uno game has ended. %u won as all others have been eliminated!"
},
"quiz": {
"what-have-i-voted": "What have I voted?",
Expand Down
6 changes: 3 additions & 3 deletions modules/connect-four/commands/connect-four.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {localize} = require('../../../src/functions/localize');
const {MessageActionRow, MessageButton} = require('discord.js');
const footer = [':one:', ':two:', ':three:', ':four:', ':five:', ':six:', ':seven:', ':eight:', ':nine:', ':keycap_ten:'];
const footer = ['1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣', '6️⃣', '7️⃣', '8️⃣', '9️⃣', '🔟'];

/**
* Builds the game message
Expand Down Expand Up @@ -183,7 +183,7 @@ module.exports.run = async function (interaction) {
const fieldSize = interaction.options.getInteger('field_size') || 7;

const grid = new Array(fieldSize - 1).fill();
for (const i in grid) grid[i] = new Array(fieldSize).fill(':white_large_square:');
for (const i in grid) grid[i] = new Array(fieldSize).fill('');

const row1 = new MessageActionRow();
const row2 = new MessageActionRow();
Expand Down Expand Up @@ -212,7 +212,7 @@ module.exports.run = async function (interaction) {
const position = parseInt(i.customId.replace('c4_', '')) - 1;

for (let j = grid.length - 1; j >= 0; j--) {
if (grid[j][position] === ':white_large_square:') {
if (grid[j][position] === '') {
grid[j][position] = ':' + color + '_circle:';
const winner = checkWin(grid, color, position, j);
if (winner) {
Expand Down
2 changes: 1 addition & 1 deletion modules/rock-paper-scissors/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"description": {
"en": "Let your users play Rock Paper Scissors against the bot and each other!",
"de": "Lasse Nutzer auf deinem Server Schere Stein Paper gegen den Bot und gegeneinander spielen"
"de": "Lasse Nutzer auf deinem Server Schere Stein Papier gegen den Bot und gegeneinander spielen"
},
"commands-dir": "/commands",
"noConfig": true,
Expand Down
59 changes: 46 additions & 13 deletions modules/uno/commands/uno.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ const publicrow = new MessageActionRow()
* Build a deck for a player
* @param {Object} player
* @param {Object} game
* @param {Boolean} neutral
* @return {MessageActionRow}
*/
function buildDeck(player, game) {
function buildDeck(player, game, neutral = false) {
const controlrow = new MessageActionRow();
if (player.turn && !player.blockRedraw) controlrow.addComponents(
new MessageButton()
Expand Down Expand Up @@ -63,8 +64,8 @@ function buildDeck(player, game) {
.setCustomId('uno-card-' + c.name + '-' + c.color + '-' + i)
.setLabel(c.name)
.setEmoji(colorEmojis[c.color])
.setStyle(canUseCard(game, c, player.cards) ? 'PRIMARY' : 'SECONDARY')
.setDisabled(player.turn ? !canUseCard(game, c, player.cards) : true)
.setStyle(!neutral && canUseCard(game, c, player.cards) ? 'PRIMARY' : 'SECONDARY')
.setDisabled(neutral || (player.turn ? !canUseCard(game, c, player.cards) : true))
);
});

Expand All @@ -83,6 +84,7 @@ function buildDeck(player, game) {
* @returns {Boolean}
*/
function canUseCard(game, card, playerCards) {
if (game.pendingDraws > 0 && card.name !== localize('uno', 'draw2') && card.name !== localize('uno', 'colordraw4')) return false;
if (card.name === localize('uno', 'color') || (card.name === localize('uno', 'colordraw4') && game.lastCard.name !== localize('uno', 'draw2') && !playerCards.some(c => c.color === game.lastCard.color))) return true;
return game.lastCard.name === card.name || game.lastCard.color === card.color;
}
Expand All @@ -100,6 +102,22 @@ function nextPlayer(game, player, moves = 1, revSkip = false) {
if (game.players.length === 2 && revSkip) next = player;
next.turn = true;
next.uno = false;

if (game.inactiveTimeout[0]) clearTimeout(game.inactiveTimeout[0]);
if (game.inactiveTimeout[1]) clearTimeout(game.inactiveTimeout[1]);
game.inactiveTimeout[0] = setTimeout(() => {
game.msg.channel.send({content: localize('uno', 'inactive-warn', {u: '<@' + next.id + '>'}), reference: {messageId: game.msg.id, channelId: game.msg.channel.id}});
}, 1000 * 60);
game.inactiveTimeout[1] = setTimeout(() => {
nextPlayer(game, next);
game.players = game.players.filter(p => p.id !== next.id);
if (game.players.length <= 1) {
clearTimeout(game.inactiveTimeout[0]);
clearTimeout(game.inactiveTimeout[1]);
return game.msg.edit({content: localize('uno', 'inactive-win', {u: '<@' + game.players[0]?.id + '>'}), components: []});
}
game.msg.edit(gameMsg(game));
}, 1000 * 60 * 2);
}

/**
Expand All @@ -109,8 +127,9 @@ function nextPlayer(game, player, moves = 1, revSkip = false) {
* @param {Object} game
*/
function perPlayerHandler(i, player, game) {
if (i.customId === 'uno-update') {
if (player.turn && game.pendingDraws > 0 && !player.cards.some(c => (c.name === localize('uno', 'draw2') && canUseCard(game, c, player.cards)) || (c.name === localize('uno', 'colordraw4') && canUseCard(game, c, player.cards)))) {
if (player.turn && game.pendingDraws > 0 && !player.cards.some(c => (c.name === localize('uno', 'draw2') && canUseCard(game, c, player.cards)) || (c.name === localize('uno', 'colordraw4') && canUseCard(game, c, player.cards)))) {
if (game.justChoosingColor) game.justChoosingColor = false;
else {
game.turns++;
if (game.pendingDraws > 0) {
for (let j = 0; j < game.pendingDraws; j++) player.cards.push({name: cards[Math.floor(Math.random() * cards.length)], color: colors[Math.floor(Math.random() * colors.length)]});
Expand All @@ -121,9 +140,15 @@ function perPlayerHandler(i, player, game) {
game.players[player.n] = player;
i.update({content: localize('uno', 'auto-drawn-skip'), components: buildDeck(player, game)});
return game.msg.edit(gameMsg(game));
} else return i.update({content: null, components: buildDeck(player, game)});
}
}
if (i.customId === 'uno-update') return i.update({content: null, components: buildDeck(player, game)});

if (!player.turn) return i.reply({content: localize('connect-four', 'not-turn'), ephemeral: true});
game.justChoosingColor = false;

if (game.inactiveTimeout[0]) clearTimeout(game.inactiveTimeout[0]);
if (game.inactiveTimeout[1]) clearTimeout(game.inactiveTimeout[1]);

game.turns++;
if (game.pendingDraws > 0 && i.customId !== 'uno-dont-use-drawn' && !i.customId.startsWith('uno-color-') && i.customId.startsWith('uno-card-' + localize('uno', 'draw2') + '-') && i.customId.startsWith('uno-card-' + localize('uno', 'colordraw4') + '-')) {
Expand Down Expand Up @@ -169,8 +194,11 @@ function perPlayerHandler(i, player, game) {
}
const name = i.customId.split('-')[2];
const color = i.customId.split('-')[3];
if (!canUseCard(game, {name, color}, player.cards)) return i.update({content: localize('uno', 'invalid-card', {c: colorEmojis[color] + ' **' + name + '**'}), components: buildDeck(player, game)});

const toremove = player.cards.find(c => c.name === name && c.color === color);
if (!toremove) return i.update({content: localize('uno', 'used-card', {c: colorEmojis[color] + ' **' + name + '**'}), components: buildDeck(player, game)});

player.cards.splice(player.cards.indexOf(toremove), 1);

if (player.cards.length === 0) {
Expand All @@ -181,7 +209,10 @@ function perPlayerHandler(i, player, game) {

if (name === localize('uno', 'skip')) nextPlayer(game, player, 2, true);
else if (name === localize('uno', 'color') || name === localize('uno', 'colordraw4')) {
if (name === localize('uno', 'colordraw4')) game.pendingDraws = game.pendingDraws + 4;
if (name === localize('uno', 'colordraw4')) {
game.pendingDraws = game.pendingDraws + 4;
game.justChoosingColor = true;
}
return i.update({content: localize('uno', 'choose-color'), components: [
new MessageActionRow()
.addComponents(
Expand All @@ -202,12 +233,12 @@ function perPlayerHandler(i, player, game) {
.setEmoji(colorEmojis.yellow)
.setStyle('PRIMARY')
),
...buildDeck(player, game).slice(1, 3)
...buildDeck(player, game, true).slice(1)
]});
} else nextPlayer(game, player, 1, name === localize('uno', 'reverse'));
if (name === localize('uno', 'draw2')) game.pendingDraws = game.pendingDraws + 2;

game.previousCards = [game.previousCards[1], colorEmojis[game.lastCard.color] + ' ' + game.lastCard.name];
game.previousCards = [game.previousCards[1], game.previousCards[2], colorEmojis[game.lastCard.color] + ' ' + game.lastCard.name];
game.lastCard = {name, color};
i.update({content: null, components: buildDeck(player, game)});
game.msg.edit(gameMsg(game));
Expand All @@ -230,10 +261,10 @@ function gameMsg(game) {
return {
content: game.players.map(u => localize('uno', 'user-cards', {u: '<@' + u.id + '>', cards: '**' + (u.cards.length === 0 ? 7 : u.cards.length) + '**'})).join(', ') + '\n' +
localize('uno', 'turn', {u: '<@' + game.players.find(p => p.turn).id + '>'}) + '\n' +
localize('uno', 'previous-cards') + game.previousCards.filter(c => c).join(' → ') + '\n\n' +
(game.previousCards.length > 0 ? localize('uno', 'previous-cards') + game.previousCards.filter(c => c).join(' → ') + '\n' : '') + '\n' +
colorEmojis[game.lastCard.color] + ' **' + game.lastCard.name + '**' +
(game.players.some(p => p.uno) ? '\nUno: ' + game.players.filter(p => p.uno).map(p => '<@' + p.id + '>').join(' ') : '') +
(game.pendingDraws > 0 ? '\n\n:warning: ' + localize('uno', 'pending-draws', {count: '**' + game.pendingDraws + '**'}) : ''),
(game.pendingDraws > 0 ? '\n\n⚠️ ' + localize('uno', 'pending-draws', {count: '**' + game.pendingDraws + '**'}) : ''),
allowedMentions: {
users: [game.players.find(p => p.turn).id]
},
Expand All @@ -242,7 +273,7 @@ function gameMsg(game) {
}

module.exports.run = async function (interaction) {
const timestamp = '<t:' + Math.floor(Date.now() / 1000 + 90) + ':R>';
const timestamp = '<t:' + Math.round(Date.now() / 1000 + 180) + ':R>';
const msg = await interaction.reply({
content: localize('uno', 'challenge-message', {u: interaction.user.toString(), count: '**1**', timestamp}),
allowedMentions: {
Expand Down Expand Up @@ -282,9 +313,11 @@ module.exports.run = async function (interaction) {
}],
lastCard: {name: cards[Math.floor(Math.random() * cards.length)], color: colors[Math.floor(Math.random() * colors.length)]},
previousCards: [],
inactiveTimeout: [],
msg,
turns: 0,
reversed: false,
justChoosingColor: false,
pendingDraws: 0
};

Expand All @@ -306,7 +339,7 @@ module.exports.run = async function (interaction) {
m.createMessageComponentCollector({componentType: 'BUTTON'}).on('collect', i => perPlayerHandler(i, p, game));
});
}
const timeout = setTimeout(startGame, 89000);
const timeout = setTimeout(startGame, 179000);

const collector = msg.createMessageComponentCollector({componentType: 'BUTTON'});
collector.on('collect', async i => {
Expand Down
Loading