package com.pixelized.shared.lwa.model.campaign.factory

import com.pixelized.shared.lwa.model.campaign.Campaign
import com.pixelized.shared.lwa.model.campaign.CampaignJsonV1

class CampaignJsonV1Factory {

    fun convertFromJson(
        campaignJson: CampaignJsonV1,
    ): Campaign {
        // Characters & npcs were previously a map of a CharacterInstanceID ( Char + instance number + Character Sheet Id)
        // Map to an instance object with data related to said instance (HP / PP / alterations etc.)
        // This have been deleted and moved to the CharacterSheet.
        return Campaign(
            characters = emptySet(),
            npcs = emptySet(),
            map = null,
            scene = campaignJson.scene
                ?.let { convertFromJson(it) }
                ?: Campaign.Scene.empty(),
            options = campaignJson.options
                ?.let { convertFromJson(it) }
                ?: Campaign.Options.empty()
        )
    }

    fun convertFromJson(
        sceneJson: CampaignJsonV1.SceneJsonV1,
    ): Campaign.Scene {
        return Campaign.Scene(
            name = sceneJson.name
        )
    }

    fun convertFromJson(
        optionsJson: CampaignJsonV1.OptionsJsonV1,
    ): Campaign.Options {
        return Campaign.Options(
            showParty = optionsJson.showPlayer,
            showNpcs = optionsJson.showNpcs
        )
    }
}