import { ROOM_SHOP, ROOM_BREW, ROOM_MARKET, moveToRoom } from "../game.js"

export function navigationUI(game, stageData) {
    document.getElementById("prev").addEventListener("click", (event) => {
        previousRoom(game, stageData)
    })

    document.getElementById("next").addEventListener("click", (event) => {
        nextRoom(game, stageData)
    })
}

export function showNavigationUI(game, stageData) {
    document.getElementById("room-navigation").style.display = "block"
}

export function hideNavigationUI(game, stageData) {
    document.getElementById("room-navigation").style.display = "none"

    document.getElementById("prev").style.display = "block"
    document.getElementById("next").style.display = "block"
    document.getElementById("prev-text").innerHTML = "Shop"
    document.getElementById("next-text").innerHTML = "Market"
}

export function previousRoom(game, stageData) {
    switch(stageData.currentRoom) {
        case ROOM_BREW:
            moveToRoom(ROOM_SHOP)
            document.getElementById("prev").style.display = "none"
            document.getElementById("next-text").innerHTML = "Brew"
            break;
        case ROOM_MARKET:
            moveToRoom(ROOM_BREW)
            document.getElementById("next").style.display = "block"
            document.getElementById("prev-text").innerHTML = "Shop"
            break;
    }
}

export function nextRoom(game, stageData) {
    switch(stageData.currentRoom) {
        case ROOM_BREW:
            moveToRoom(ROOM_MARKET)
            document.getElementById("next").style.display = "none"
            document.getElementById("prev-text").innerHTML = "Brew"
            break;
        case ROOM_SHOP:
            moveToRoom(ROOM_BREW)
            document.getElementById("prev").style.display = "block"
            document.getElementById("next-text").innerHTML = "Market"
            break;
    }
}