Search in sources :

Example 1 with MastermindMatchData

use of gg.projecteden.nexus.features.minigames.models.matchdata.MastermindMatchData in project Nexus by ProjectEdenGG.

the class Mastermind method onJoin.

@Override
public void onJoin(@NotNull MatchJoinEvent event) {
    super.onJoin(event);
    Match match = event.getMatch();
    MastermindMatchData matchData = match.getMatchData();
    matchData.giveLoadout(event.getMinigamer());
    matchData.resetResultsSign();
}
Also used : IMastermindMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.IMastermindMatchData) MastermindMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.MastermindMatchData) Match(gg.projecteden.nexus.features.minigames.models.Match)

Example 2 with MastermindMatchData

use of gg.projecteden.nexus.features.minigames.models.matchdata.MastermindMatchData in project Nexus by ProjectEdenGG.

the class Mastermind method onTick.

@EventHandler
public void onTick(MatchTimerTickEvent event) {
    if (!event.getMatch().isMechanic(this))
        return;
    Match match = event.getMatch();
    MastermindMatchData matchData = match.getMatchData();
    Minigamer minigamer = match.getAliveMinigamers().iterator().next();
    if (matchData.getGuess(minigamer) > 1 && matchData.getGuess(minigamer) <= 10)
        event.getMatch().getMinigamers().forEach(Minigamer::scored);
}
Also used : IMastermindMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.IMastermindMatchData) MastermindMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.MastermindMatchData) Minigamer(gg.projecteden.nexus.features.minigames.models.Minigamer) Match(gg.projecteden.nexus.features.minigames.models.Match) EventHandler(org.bukkit.event.EventHandler)

Example 3 with MastermindMatchData

use of gg.projecteden.nexus.features.minigames.models.matchdata.MastermindMatchData in project Nexus by ProjectEdenGG.

the class Mastermind method onInteract.

@EventHandler
public void onInteract(PlayerInteractEvent event) {
    Block block = event.getClickedBlock();
    if (EquipmentSlot.HAND != event.getHand() || block == null)
        return;
    Minigamer minigamer = PlayerManager.get(event.getPlayer());
    if (!minigamer.isPlaying(this))
        return;
    if (Action.LEFT_CLICK_BLOCK.equals(event.getAction())) {
        event.setCancelled(true);
        removeBlock(minigamer, block);
        return;
    }
    if (Action.RIGHT_CLICK_BLOCK.equals(event.getAction())) {
        Match match = minigamer.getMatch();
        MastermindMatchData matchData = match.getMatchData();
        if (isInRegion(match, block, "button")) {
            if (!MaterialTag.BUTTONS.isTagged(block.getType()))
                return;
            // TODO Cleanup
            try {
                matchData.guess(minigamer);
            } catch (MinigameException ex) {
                minigamer.tell("&cError: " + ex.getMessage());
            } catch (Exception ex) {
                minigamer.tell("&cUnknown error occurred");
                ex.printStackTrace();
            }
            return;
        }
        if (MaterialTag.SIGNS.isTagged(block.getType())) {
            int guess = matchData.getGuess(minigamer);
            if (isInRegion(match, block, "colorblind")) {
                if (guess != 1) {
                    minigamer.tell("You cannot change colorblind mode in the middle of the game");
                    return;
                }
                matchData.toggleColorblind(minigamer);
                matchData.giveLoadout(minigamer);
                matchData.createAnswer();
                match.getArena().regenerate();
                return;
            }
            if (isInRegion(match, block, "repeats_off")) {
                if (guess != 1) {
                    minigamer.tell("You cannot change the difficulty mode in the middle of the game");
                    return;
                }
                matchData.setRepeats(false);
                matchData.createAnswer();
                match.getArena().regenerate();
                minigamer.tell("Difficulty mode updated");
                return;
            }
            if (isInRegion(match, block, "repeats_on")) {
                if (guess != 1) {
                    minigamer.tell("You cannot change the difficulty mode in the middle of the game");
                    return;
                }
                matchData.setRepeats(true);
                matchData.createAnswer();
                match.getArena().regenerate();
                minigamer.tell("Difficulty mode updated");
                return;
            }
        }
        Block placed = event.getClickedBlock().getRelative(event.getBlockFace());
        if (!isNullOrAir(event.getItem()) && !canBuild(minigamer, placed))
            event.setCancelled(true);
    }
}
Also used : MinigameException(gg.projecteden.nexus.features.minigames.models.exceptions.MinigameException) Block(org.bukkit.block.Block) IMastermindMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.IMastermindMatchData) MastermindMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.MastermindMatchData) Minigamer(gg.projecteden.nexus.features.minigames.models.Minigamer) MinigameException(gg.projecteden.nexus.features.minigames.models.exceptions.MinigameException) Match(gg.projecteden.nexus.features.minigames.models.Match) EventHandler(org.bukkit.event.EventHandler)

Example 4 with MastermindMatchData

use of gg.projecteden.nexus.features.minigames.models.matchdata.MastermindMatchData in project Nexus by ProjectEdenGG.

the class MinigamesCommand method mastermindShowAnswer.

@Path("mastermind showAnswer")
@Permission(Group.ADMIN)
void mastermindShowAnswer() {
    if (!minigamer.isPlaying(Mastermind.class))
        error("You must be playing Mastermind to use this command");
    MastermindMatchData matchData = minigamer.getMatch().getMatchData();
    send(matchData.getAnswer().toString());
}
Also used : Mastermind(gg.projecteden.nexus.features.minigames.mechanics.Mastermind) MastermindMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.MastermindMatchData) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 5 with MastermindMatchData

use of gg.projecteden.nexus.features.minigames.models.matchdata.MastermindMatchData in project Nexus by ProjectEdenGG.

the class MinigamesCommand method mastermindPlayAgain.

@HideFromHelp
@TabCompleteIgnore
@Path("mastermind playAgain")
void mastermindPlayAgain() {
    if (!minigamer.isPlaying(Mastermind.class))
        error("You must be playing Mastermind to use this command");
    MastermindMatchData matchData = minigamer.getMatch().getMatchData();
    matchData.reset(minigamer);
}
Also used : Mastermind(gg.projecteden.nexus.features.minigames.mechanics.Mastermind) MastermindMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.MastermindMatchData) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) HideFromHelp(gg.projecteden.nexus.framework.commands.models.annotations.HideFromHelp) TabCompleteIgnore(gg.projecteden.nexus.framework.commands.models.annotations.TabCompleteIgnore)

Aggregations

MastermindMatchData (gg.projecteden.nexus.features.minigames.models.matchdata.MastermindMatchData)5 Match (gg.projecteden.nexus.features.minigames.models.Match)3 IMastermindMatchData (gg.projecteden.nexus.features.minigames.models.matchdata.IMastermindMatchData)3 Mastermind (gg.projecteden.nexus.features.minigames.mechanics.Mastermind)2 Minigamer (gg.projecteden.nexus.features.minigames.models.Minigamer)2 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)2 EventHandler (org.bukkit.event.EventHandler)2 MinigameException (gg.projecteden.nexus.features.minigames.models.exceptions.MinigameException)1 HideFromHelp (gg.projecteden.nexus.framework.commands.models.annotations.HideFromHelp)1 Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)1 TabCompleteIgnore (gg.projecteden.nexus.framework.commands.models.annotations.TabCompleteIgnore)1 Block (org.bukkit.block.Block)1