package com.sakurarealm.playerrisk.api;

import com.sakurarealm.playerrisk.PlayerRisk;
import com.sakurarealm.playerrisk.hook.PlaceHolderAPIHook;
import org.apache.commons.lang.NotImplementedException;
import org.bukkit.OfflinePlayer;

import java.util.UUID;

/**
 * 危机度区间为0~level_max级，每次离开安全区（城镇），重置危险等级：每待n秒会使危机等级（变量）提升1点，
 * 但开始计算时玩家在的每一个每种生物群系最多使危机等级提升10 (如上限level_max是50的话, 玩家至少进入5个不同的生物群系才能达到上限)，
 * 玩家每次死亡重生或回到安全区，会重置当前危机等级。
 * 所有变量见config.yml
 * <a href="https://drawrealm.feishu.cn/wiki/ZqTQwSQNyiZUIWkHCRgcuAcYn3f?chunked=false">...</a>
 */
public class PlayerRiskManager {

    private final PlayerRisk plugin;

    public final PlayerRiskSettings settings;

    // TODO: Add any data structures needed to manage player risk.

    public PlayerRiskManager(PlayerRisk plugin, PlayerRiskSettings settings) {
        this.plugin = plugin;
        // Register the event listener.
//        plugin.getServer().getPluginManager().registerEvents(new Listener(), plugin);
        //注入settings
        this.settings = settings;
        new PlaceHolderAPIHook(this).register();
    }

    public int getPlayerRiskLevel(String playerName) {
        // Get offline player by name.
        OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
        return getPlayerRiskLevel(player);
    }

    public int getPlayerRiskLevel(UUID playerId) {
        // Get offline player by UUID.
        OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerId);
        return getPlayerRiskLevel(player);
    }

    /**
     * TODO: 获取玩家的危险度等级
     *
     * @param player 玩家
     * @return 危险度等级
     */
    public int getPlayerRiskLevel(OfflinePlayer player) {
        throw new NotImplementedException("Not implemented yet.");
    }

    public void setPlayerRiskLevel(String playerName, int level) {
        // Get offline player by name.
        OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
        setPlayerRiskLevel(player, level);
    }

    public void setPlayerRiskLevel(UUID playerId, int level) {
        // Get offline player by UUID.
        OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerId);
        setPlayerRiskLevel(player, level);
    }

    /**
     * TODO: 设置玩家的危险度等级
     */
    public void setPlayerRiskLevel(OfflinePlayer player, int level) {
        throw new NotImplementedException("Not implemented yet.");
    }

    // TODO Add any other methods needed to manage player risk.

}
