001package com.ericlam.mc.minigames.core.manager;
002
003import com.ericlam.mc.minigames.core.arena.Arena;
004import com.ericlam.mc.minigames.core.character.GamePlayer;
005import com.ericlam.mc.minigames.core.exception.AlreadyVotedException;
006import com.ericlam.mc.minigames.core.exception.arena.NoFinalArenaException;
007import com.google.common.collect.ImmutableList;
008import com.google.common.collect.ImmutableMap;
009import org.bukkit.entity.Player;
010
011import java.util.Optional;
012
013/**
014 * 等候大堂管理器
015 */
016public interface LobbyManager {
017
018    /**
019     * 傳送到大堂位置
020     *
021     * @param player 玩家
022     */
023    void tpLobbySpawn(Player player);
024
025    /**
026     * 獲取可投票場地
027     *
028     * @return 可投票場地
029     */
030    ImmutableList<Arena> getCandidate();
031
032    /**
033     * 獲取該玩家投票的場地
034     *
035     * @param player 玩家
036     * @return 可能為 null 的 投票場地
037     */
038    Optional<Arena> getVoted(GamePlayer player);
039
040    /**
041     * 玩家投票
042     *
043     * @param player 玩家
044     * @param arena  投票場地
045     * @throws AlreadyVotedException 已經投票了相同場地時
046     */
047    void vote(GamePlayer player, Arena arena) throws AlreadyVotedException;
048
049    /**
050     * 取消玩家投票
051     *
052     * @param player 玩家
053     */
054    void unVote(GamePlayer player);
055
056    /**
057     * 獲取目前投票結果
058     *
059     * @return 投票結果
060     */
061    ImmutableMap<Arena, ImmutableList<GamePlayer>> getResult();
062
063    /**
064     * 運行投票結果計算出最終場地
065     *
066     * @throws NoFinalArenaException 找不到最終場地時
067     */
068    void runFinalResult() throws NoFinalArenaException;
069
070}