Search in sources :

Example 6 with Game

use of tel.discord.rtab.board.Game in project RtaB6 by Telnaior.

the class LuckySpace method execute.

@Override
public void execute(GameController game, int player) {
    this.game = game;
    this.player = player;
    // Generate the wheel
    ArrayList<LuckyEvent> wheel = new ArrayList<LuckyEvent>();
    wheel.addAll(Arrays.asList(LuckyEvent.values()));
    if (game.players.size() < 4)
        wheel.remove(LuckyEvent.JOKER);
    else
        wheel.remove(LuckyEvent.DOUBLE_DEAL);
    Collections.shuffle(wheel);
    game.channel.sendMessage("You found the **Lucky Space**! Step right up and claim your prize!").queue();
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    switch(spinWheel(wheel)) {
        case BIG_BUCKS:
            // Mystery money but with a much more limited range
            int cashWon = (int) Math.pow((Math.random() * 14) + 20, 4);
            // and boost it by the playercount
            cashWon *= Math.sqrt(game.players.size());
            // Round it off
            cashWon -= cashWon % 10_000;
            // Then base multiplier
            cashWon = game.applyBaseMultiplier(cashWon);
            game.channel.sendMessage(String.format("It's **Big Bucks**! You're taking home **$%,d**!", cashWon)).queue();
            StringBuilder extraResult = game.players.get(player).addMoney(game.applyBaseMultiplier(cashWon), MoneyMultipliersToUse.BOOSTER_ONLY);
            if (extraResult != null) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                game.channel.sendMessage(extraResult.toString()).queue();
            }
            break;
        case CASH_FOR_ALL:
            game.awardEvent(player, EventType.CASH_FOR_ALL);
            break;
        case DOUBLE_DEAL:
            game.awardEvent(player, EventType.DOUBLE_DEAL);
            break;
        case JOKER:
            game.awardEvent(player, EventType.JOKER);
            break;
        case MINIGAME:
            Game minigame = game.generateEventMinigame(player);
            game.awardGame(player, minigame);
            if (game.players.size() >= 9) {
                game.channel.sendMessage("And you can have two copies of it!").queue();
                game.players.get(player).games.add(minigame);
            }
            game.players.get(player).games.sort(null);
            break;
    }
}
Also used : Game(tel.discord.rtab.board.Game) ArrayList(java.util.ArrayList)

Example 7 with Game

use of tel.discord.rtab.board.Game in project RtaB6 by Telnaior.

the class GameController method prepareNextMiniGame.

private void prepareNextMiniGame(ListIterator<Game> gamesToPlay) {
    if (gamesToPlay.hasNext()) {
        // Get the minigame
        Game nextGame = gamesToPlay.next();
        currentGame = nextGame.getGame();
        // Count the number of copies
        int multiplier = 1;
        while (gamesToPlay.hasNext()) {
            // Move the iterator back one, to the first instance of the game
            gamesToPlay.previous();
            // If it matches (ie multiple copies), remove one and add it to the multiplier
            if (gamesToPlay.next() == gamesToPlay.next()) {
                multiplier++;
                gamesToPlay.remove();
            } else // Otherwise we'd better put it back where it belongs
            {
                gamesToPlay.previous();
                break;
            }
        }
        // Pass to the game
        boolean sendMessages = !(players.get(currentTurn).isBot) || verboseBotGames;
        // Set up the thread we'll send to the game
        Thread postGame = new Thread() {

            public void run() {
                // Recurse to get to the next minigame
                currentGame = null;
                if (players.get(currentTurn).games.size() > 0)
                    prepareNextMiniGame(players.get(currentTurn).games.listIterator(gamesToPlay.nextIndex()));
                else
                    runNextEndGamePlayer();
            }
        };
        postGame.setName(String.format("%s - %s - %s", channel.getName(), players.get(currentTurn).getName(), currentGame.getName()));
        currentGame.initialiseGame(channel, sendMessages, baseNumerator, baseDenominator, multiplier, players, currentTurn, postGame, players.get(currentTurn).enhancedGames.contains(nextGame));
    } else {
        // Check for winning the game
        if (players.get(currentTurn).money >= 1000000000 && players.get(currentTurn).status == PlayerStatus.DONE) {
            winners.add(players.get(currentTurn));
        }
        runNextEndGamePlayer();
    }
}
Also used : Game(tel.discord.rtab.board.Game) MiniGame(tel.discord.rtab.games.MiniGame)

Example 8 with Game

use of tel.discord.rtab.board.Game in project RtaB6 by Telnaior.

the class TestMinigameCommand method execute.

@Override
protected void execute(CommandEvent event) {
    if (event.getChannel().getType() != ChannelType.PRIVATE) {
        event.reply("This command must be used in a private message.");
        return;
    }
    String gameName = event.getArgs();
    boolean enhance = false;
    if (gameName.startsWith("-e ")) {
        enhance = true;
        gameName = gameName.replaceFirst("-e ", "");
    }
    // Run through the list of games to find the one they asked for
    boolean gameFound = false;
    for (Game game : Game.values()) {
        if ((!game.isBonus() || event.isOwner()) && (gameName.equalsIgnoreCase(game.getShortName()) || gameName.equalsIgnoreCase(game.getName()))) {
            runGame(event.getAuthor(), game, event.getChannel(), enhance);
            gameFound = true;
            break;
        }
    }
    // If they supplied an invalid game (or nothing at all), give them the list
    if (!gameFound) {
        StringBuilder output = new StringBuilder().append("Games available for practice:\n");
        for (Game game : Game.values()) if (!game.isBonus())
            output.append(game.getShortName() + " - " + game.getName() + "\n");
        event.reply(output.toString());
    }
}
Also used : Game(tel.discord.rtab.board.Game)

Example 9 with Game

use of tel.discord.rtab.board.Game in project RtaB6 by Telnaior.

the class EnhanceCommand method sendEnhanceList.

void sendEnhanceList(CommandEvent event) {
    StringBuilder output = new StringBuilder();
    output.append("```\nENHANCEABLE MINIGAMES:\n");
    for (Game next : Game.values()) {
        if (next.getWeight(4) > 0) {
            output.append("\n" + next.getShortName() + " - " + next.getName() + "\n" + next.getEnhanceText() + "\n");
        }
    }
    output.append("```");
    event.replyInDm(output.toString());
}
Also used : Game(tel.discord.rtab.board.Game)

Aggregations

Game (tel.discord.rtab.board.Game)9 Player (tel.discord.rtab.Player)3 MiniGame (tel.discord.rtab.games.MiniGame)3 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 GameController (tel.discord.rtab.GameController)2 LinkedList (java.util.LinkedList)1 Guild (net.dv8tion.jda.api.entities.Guild)1 Role (net.dv8tion.jda.api.entities.Role)1