#!/bin/sh
# SPDX-License-Identifier: ACSL
# SPDX-FileCopyrightText: © 2025 Christian Stalp
# SPDX-FileCopyrightText: © 2026 Antoine Le Gonidec <vv221@dotslashplay.it>
set -o errexit

###
# Pathfinder: Kingmaker expansions:
# - Bloody Mess
# - The Wildcards
# - Varnhold's Lot
# - Arcane Unleashed
# - Beneath The Stolen Lands
# - Pet Red Panda
# - Players Portraits
# send your bug reports to bugs@dotslashplay.it
###

script_version=20260510.1

PLAYIT_COMPATIBILITY_LEVEL='2.31'

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

EXPANSION_ID_BLOODY_MESS='bloody-mess'
EXPANSION_NAME_BLOODY_MESS='Bloody Mess'

EXPANSION_ID_THE_WILDCARDS='the-wildcards'
EXPANSION_NAME_THE_WILDCARDS='The Wildcards'

EXPANSION_ID_VARNHOLDS_LOT='varnholds-lot'
EXPANSION_NAME_VARNHOLDS_LOT='Varnhold’s Lot'

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_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'

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_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_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_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_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_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'
# "ascention" with a T is an error in the store URL, not a typo in this game script.

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.

if [ -z "$PLAYIT_LIB2" ]; then
	for playit_lib_dir in \
		"$PWD" \
		"${HOME}/.local/lib/play.it" \
		'/usr/local/lib/play.it' \
		'/usr/lib/play.it'
	do
		playit_lib_path="${playit_lib_dir}/libplayit.sh.2"
		if [ -e "$playit_lib_path" ]; then
			PLAYIT_LIB2="$playit_lib_path"
			break
		fi
	done
fi
if [ -z "$PLAYIT_LIB2" ]; then
	printf '\n\033[1;31mError:\033[0m\n'
	printf 'libplayit.sh.2 not found.\n'
	exit 1
fi
# shellcheck source=libplayit.sh.2
. "$PLAYIT_LIB2"

# Run default initialisation 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
