#!/bin/sh
# SPDX-License-Identifier: BSD-2-Clause
# SPDX-FileCopyrightText: © 2025 Christian Stalp
set -o errexit

###
# Pillars of Eternity 2 expansions:
# - forgotten sanctum
# - beast of winter
# - seeker slayer survivor
# - rum runners-pack
# - deck of many things
# - critical role
# - scalawags pack
# - beard and hair pack
###

script_version=20241201.1

PLAYIT_COMPATIBILITY_LEVEL='2.31'

GAME_ID='pathfinder-kingmaker' 
GAME_NAME='Pathfinder Kingmaker' 


EXPANSION_ID_ARCANE_UNLEASHED='arcane-unleashed'
EXPANSION_NAME_ARCANE_UNLEASHED='arcane unleashed'

EXPANSION_ID_BENEATH_THE_STOLEN_LANDS='beneath-the-stolen-lands'
EXPANSION_NAME_BENEATH_THE_STOLEN_LANDS='beneath the stolen lands'

EXPANSION_ID_BLOODY_MESS='bloody-mess'
EXPANSION_NAME_BLOODY_MESS='bloody mess'

EXPANSION_ID_THE_WILDCARDS='the-wildcards'
EXPANSION_NAME_THE_WILDCARDS='the wildcarts'

EXPANSION_ID_PET_RED_PANDA='pet-red-panda'
EXPANSION_NAME_PET_RED_PANDA='pet red panda'

EXPANSION_ID_PLAYERS_PORTRAITS='players-portraits'
EXPANSION_NAME_PLAYERS_PORTRAITS='players portraits'

EXPANSION_ID_VARNHOLDS_LOT='varnholds-lot'
EXPANSION_NAME_VARNHOLDS_LOT='varnholds lot'

# Archives

## Kickstarter item

ARCHIVE_BASE_ARCANE_UNLEASHED_0_NAME='pathfinder_kingmaker_arcane_unleashed_2_1_5d_41987.sh'
ARCHIVE_BASE_ARCANE_UNLEASHED_0_MD5='c2c6e7862b9d33e92db51380e06b3a90'
ARCHIVE_BASE_ARCANE_UNLEASHED_0_SIZE='2000'
ARCHIVE_BASE_ARCANE_UNLEASHED_0_VERSION='2.1.5d-gog41097'
ARCHIVE_BASE_ARCANE_UNLEASHED_0_URL='https://www.gog.com/de/game/pathfinder_kingmaker_arcane_unleashed'

ARCHIVE_BASE_BENEATH_THE_STOLEN_LANDS_0_NAME='pathfinder_kingmaker_beneath_the_stolen_lands_2_1_5d_41987.sh'
ARCHIVE_BASE_BENEATH_THE_STOLEN_LANDS_0_MD5='72d4b40ff5fbd4162ff0fde494c25323'
ARCHIVE_BASE_BENEATH_THE_STOLEN_LANDS_0_SIZE='350000'
ARCHIVE_BASE_BENEATH_THE_STOLEN_LANDS_0_VERSION='2.1.5d-gog41097'
ARCHIVE_BASE_BENEATH_THE_STOLEN_LANDS_0_URL='https://www.gog.com/de/game/pathfinder_kingmaker_beneath_the_stolen_lands'

ARCHIVE_BASE_BLOODY_MESS_0_NAME='pathfinder_kingmaker_bloody_mess_2_1_5d_41987.sh'
ARCHIVE_BASE_BLOODY_MESS_0_MD5='fadac08c9ede4f5167901330c8d08764'
ARCHIVE_BASE_BLOODY_MESS_0_SIZE='2000'
ARCHIVE_BASE_BLOODY_MESS_0_VERSION='2.1.5d-gog41097'
ARCHIVE_BASE_BLOODY_MESS_0_URL='https://www.gog.com/de/game/pathfinder_kingmaker_bloody_mess'

ARCHIVE_BASE_THE_WILDCARDS_0_NAME='pathfinder_kingmaker_the_wildcards_2_1_5d_41987.sh'
ARCHIVE_BASE_THE_WILDCARDS_0_MD5='934c97675f6156fb96dfe4f38038691c'
ARCHIVE_BASE_THE_WILDCARDS_0_SIZE='2000'
ARCHIVE_BASE_THE_WILDCARDS_0_VERSION='2.1.5d-gog41097'
ARCHIVE_BASE_THE_WILDCARDS_0_URL='https://www.gog.com/de/game/pathfinder_kingmaker_the_wildcards'

ARCHIVE_BASE_PET_RED_PANDA_0_NAME='pathfinder_kingmaker_in_game_pet_red_panda_2_1_5d_41987.sh'
ARCHIVE_BASE_PET_RED_PANDA_0_MD5='d30e0b240c9ebaaba172be9c5fb97b30'
ARCHIVE_BASE_PET_RED_PANDA_0_SIZE='2000'
ARCHIVE_BASE_PET_RED_PANDA_0_VERSION='2.1.5d-gog41097'

ARCHIVE_BASE_VARNHOLDS_LOT_0_NAME='pathfinder_kingmaker_varnhold_s_lot_2_1_5d_41987.sh'
ARCHIVE_BASE_VARNHOLDS_LOT_0_MD5='05fc3268fdcc29214ad380e7d5e6b267'
ARCHIVE_BASE_VARNHOLDS_LOT_0_SIZE='2000'
ARCHIVE_BASE_VARNHOLDS_LOT_0_VERSION='2.1.5d-gog41097'
ARCHIVE_BASE_VARNHOLDS_LOT_0_URL='https://www.gog.com/de/game/pathfinder_kingmaker_varnholds_lot'

ARCHIVE_BASE_PLAYERS_PORTRAITS_0_NAME='pathfinder_kingmaker_in_game_player_s_portraits_2_1_5d_41987.sh'
ARCHIVE_BASE_PLAYERS_PORTRAITS_0_MD5='5a63db6cfdb05fa17af4460ca4ace4c7'
ARCHIVE_BASE_PLAYERS_PORTRAITS_0_SIZE='2000'
ARCHIVE_BASE_PLAYERS_PORTRAITS_0_VERSION='2.1.5d-gog41097'

CONTENT_PATH_DEFAULT='data/noarch/game'
CONTENT_GAME_MAIN_FILES='
Kingmaker_Data'


PKG_PARENT_ID="$GAME_ID"

PKG_MAIN_DEPENDENCIES_SIBLINGS='
PKG_PARENT'

# Load common functions

PLAYIT_LIB_PATHS="
$PWD
${XDG_DATA_HOME:="${HOME}/.local/share"}/play.it
/usr/local/share/games/play.it
/usr/local/share/play.it
/usr/share/games/play.it
/usr/share/play.it"

if [ -z "$PLAYIT_LIB2" ]; then
	for playit_lib_path in $PLAYIT_LIB_PATHS; do
		if [ -e "${playit_lib_path}/libplayit2.sh" ]; then
			PLAYIT_LIB2="${playit_lib_path}/libplayit2.sh"
			break
		fi
	done
fi
if [ -z "$PLAYIT_LIB2" ]; then
	printf '\n\033[1;31mError:\033[0m\n'
	printf 'libplayit2.sh not found.\n'
	exit 1
fi
# shellcheck source=libplayit2.sh
. "$PLAYIT_LIB2"

# Run the default initialization actions

initialization_default "$@"

# Extract game data

archive_extraction_default

# Include game data

content_inclusion_default

# Build packages

packages_generation
print_instructions

# Clean up

working_directory_cleanup

exit 0
