package ca.recrown.islandsurvivalcraft.world;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.Random;

import org.bukkit.block.Biome;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;

@TestInstance(Lifecycle.PER_CLASS)
public class BiomeMapTest {
    private final Random random = new Random(10320452);
    BiomeMap biomeSelector;

    @BeforeAll
    public void setUp() {
        biomeSelector = new BiomeMap(random);
    }

    @Test
    public void testGetBiomeTemperatureBirchHill() {
        assertEquals(0.6f, biomeSelector.getBiomeTemperature(Biome.BIRCH_FOREST_HILLS));
    }

    @Test
    public void testGetBiomeTemperatureSwampHill() {
        assertEquals(0.8f, biomeSelector.getBiomeTemperature(Biome.SWAMP_HILLS));
    }

    @Test
    public void testGetBiomeTemperatureTaigaHill() {
        assertEquals(0.25f, biomeSelector.getBiomeTemperature(Biome.TAIGA_HILLS));
    }

    @Test
    public void testGetBiomeTemperatureSnowyTaigaHill() {
        assertEquals(-0.5f, biomeSelector.getBiomeTemperature(Biome.SNOWY_TAIGA_HILLS));
    }

    @Test
    public void testGetBiomeTemperatureSnowyTaigaMountain() {
        assertEquals(-0.5f, biomeSelector.getBiomeTemperature(Biome.SNOWY_TAIGA_MOUNTAINS));
    }

    @Test
    public void testGetTransitionalBiomeFromModifiedJungle() {
        assertEquals(Biome.MODIFIED_JUNGLE_EDGE, biomeSelector.getTransitionalBiome(Biome.MODIFIED_JUNGLE));
    }

    @Test
    public void testGetTransitionalBiomeFromOcean() {
        assertEquals(null, biomeSelector.getTransitionalBiome(Biome.OCEAN));
    }

    @Test
    public void testGetTransitionalBiomeFromMountain() {
        assertEquals(null, biomeSelector.getTransitionalBiome(Biome.MOUNTAINS));
    }

    @Test
    public void testGetTransitionalBiomeFromJungle() {
        assertEquals(Biome.JUNGLE_EDGE, biomeSelector.getTransitionalBiome(Biome.JUNGLE));
    }

    @Test
    public void testGetShoreBiomeFromMountain() {
        assertEquals(Biome.STONE_SHORE, biomeSelector.getShoreBiome(Biome.MOUNTAINS, 0.2f));
    }

    @Test
    public void testGetShoreBiomeFromMushroomIsland() {
        assertEquals(Biome.MUSHROOM_FIELD_SHORE, biomeSelector.getShoreBiome(Biome.MUSHROOM_FIELDS, 1.2f));
    }

    @Test
    public void testGetShoreBiomeFromPlains() {
        assertEquals(Biome.BEACH, biomeSelector.getShoreBiome(Biome.PLAINS, 0.8f));
    }

    @Test
    public void testGetShoreBiomeFromSnowyTaiga() {
        assertEquals(Biome.SNOWY_BEACH, biomeSelector.getShoreBiome(Biome.SNOWY_TAIGA, -0.5f));
    }
}