#!/bin/sh
# SPDX-License-Identifier: ACSL
# SPDX-FileCopyrightText: © 2023 Fabien Givors <captnfab@debian-facile.org>
# SPDX-FileCopyrightText: © 2025 Antoine Le Gonidec <vv221@dotslashplay.it>
set -o errexit

###
# Kingdom Come: Deliverance expansions:
# - Treasures of the Past
# - From the Ashes
# - The Amorous Adventures of Bold Sir Hans Capon
# - Band of Bastards
# - HD Sound Pack
# - HD Texture Pack
# - HD Voice Pack - French
# - A Woman's Lot
# send your bug reports to bugs@dotslashplay.it
###

script_version=20260526.1

PLAYIT_COMPATIBILITY_LEVEL='2.35'

GAME_ID='kingdom-come-deliverance'
GAME_NAME='Kingdom Come: Deliverance'

CONTENT_PATH_DEFAULT='.'
CONTENT_GAME_MAIN_FILES='
data
goggame-*'

PKG_PARENT_ID="$GAME_ID"
PKG_MAIN_DEPENDENCIES_SIBLINGS='
PKG_PARENT'

# Treasures of the Past

EXPANSION_ID_TREASURES_OF_THE_PAST='treasures-of-the-past'
EXPANSION_NAME_TREASURES_OF_THE_PAST='Treasures of the Past'

ARCHIVE_BASE_TREASURES_OF_THE_PAST_0_NAME='setup_kingdom_come_deliverance_treasures_of_the_past_dlc_1.9.6-404-504czj3_(62297).exe'
ARCHIVE_BASE_TREASURES_OF_THE_PAST_0_MD5='4e3bd284e3dc4573690bed957ba78cbe'
ARCHIVE_BASE_TREASURES_OF_THE_PAST_0_TYPE='innosetup'
ARCHIVE_BASE_TREASURES_OF_THE_PAST_0_SIZE='100'
ARCHIVE_BASE_TREASURES_OF_THE_PAST_0_VERSION='1.9.6-404-504czj3'

# From the ashes

EXPANSION_ID_FROM_THE_ASHES='from-the-ashes'
EXPANSION_NAME_FROM_THE_ASHES='From the Ashes'

ARCHIVE_BASE_FROM_THE_ASHES_0_NAME='setup_kingdom_come_deliverance__from_the_ashes_1.9.6-404-504czj3_(62297).exe'
ARCHIVE_BASE_FROM_THE_ASHES_0_MD5='141360d56c9ba17c72fcac2f50685a7f'
ARCHIVE_BASE_FROM_THE_ASHES_0_TYPE='innosetup'
ARCHIVE_BASE_FROM_THE_ASHES_0_SIZE='100'
ARCHIVE_BASE_FROM_THE_ASHES_0_VERSION='1.9.6-404-504czj3'

# The Amorous Adventures of Bold Sir Hans Capon

EXPANSION_ID_HANS_CAPON='amorous-adventures-sir-capon'
EXPANSION_NAME_HANS_CAPON='The Amorous Adventures of Bold Sir Hans Capon'

ARCHIVE_BASE_HANS_CAPON_0_NAME='setup_kingdom_come_deliverance__the_amorous_adventures_of_bold_sir_hans_capon_1.9.6-404-504czj3_(62297).exe'
ARCHIVE_BASE_HANS_CAPON_0_MD5='2b41e8147c8046b7b01cfdd3e8079b10'
ARCHIVE_BASE_HANS_CAPON_0_TYPE='innosetup'
ARCHIVE_BASE_HANS_CAPON_0_SIZE='2000000'
ARCHIVE_BASE_HANS_CAPON_0_VERSION='1.9.6-404-504czj3'

# Band of Bastards

EXPANSION_ID_BAND_OF_BASTARDS='band-of-bastards'
EXPANSION_NAME_BAND_OF_BASTARDS='Band of Bastards'

ARCHIVE_BASE_BAND_OF_BASTARDS_0_NAME='setup_kingdom_come_deliverance__band_of_bastards_1.9.6-404-504czj3_(62297).exe'
ARCHIVE_BASE_BAND_OF_BASTARDS_0_MD5='cce9e163f07e2e9fa8be5b6b113fe866'
ARCHIVE_BASE_BAND_OF_BASTARDS_0_TYPE='innosetup'
ARCHIVE_BASE_BAND_OF_BASTARDS_0_SIZE='500000'
ARCHIVE_BASE_BAND_OF_BASTARDS_0_VERSION='1.9.6-404-504czj3'

# A Woman's Lot

EXPANSION_ID_A_WOMANS_LOT='a-woman-s-lot'
EXPANSION_NAME_A_WOMANS_LOT='A Woman’s Lot'

ARCHIVE_BASE_A_WOMANS_LOT_0_NAME='setup_kingdom_come_deliverance_-_a_womans_lot_1.9.6-404-504czj3_(62297).exe'
ARCHIVE_BASE_A_WOMANS_LOT_0_MD5='08ec99ec6bf0a08bc04004579641da81'
ARCHIVE_BASE_A_WOMANS_LOT_0_TYPE='innosetup'
ARCHIVE_BASE_A_WOMANS_LOT_0_PART1_NAME='setup_kingdom_come_deliverance_-_a_womans_lot_1.9.6-404-504czj3_(62297)-1.bin'
ARCHIVE_BASE_A_WOMANS_LOT_0_PART1_MD5='7cf9ac8abb8e304b756c98a36d6fbc2a'
ARCHIVE_BASE_A_WOMANS_LOT_0_PART2_NAME='setup_kingdom_come_deliverance_-_a_womans_lot_1.9.6-404-504czj3_(62297)-2.bin'
ARCHIVE_BASE_A_WOMANS_LOT_0_PART2_MD5='e671d0cfaceb8f5cac910d0e93f2b19f'
ARCHIVE_BASE_A_WOMANS_LOT_0_SIZE='8000000'
ARCHIVE_BASE_A_WOMANS_LOT_0_VERSION='1.9.6-404-504czj3'

# HD Sound Pack

EXPANSION_ID_HD_SOUND='hd-sound'
EXPANSION_NAME_HD_SOUND='HD Sound Pack'

ARCHIVE_BASE_HD_SOUND_0_NAME='setup_kingdom_come_deliverance_-_hd_sound_pack_1.9.6-404-504czj3_(62297).exe'
ARCHIVE_BASE_HD_SOUND_0_MD5='2148cf5d68e477f5c4fb32fde94a2cb8'
ARCHIVE_BASE_HD_SOUND_0_TYPE='innosetup'
ARCHIVE_BASE_HD_SOUND_0_SIZE='974736'
ARCHIVE_BASE_HD_SOUND_0_VERSION='1.9.6-404-504czj3'

# HD Texture Pack

EXPANSION_ID_HD_TEXTURE='hd-texture'
EXPANSION_NAME_HD_TEXTURE='HD Texture Pack'

ARCHIVE_BASE_HD_TEXTURE_0_NAME='setup_kingdom_come_deliverance_-_hd_texture_pack_1.9.6-404-504czj3_(62297).exe'
ARCHIVE_BASE_HD_TEXTURE_0_MD5='599a26fd112d65bd0c6bcaeccd47e3c2'
ARCHIVE_BASE_HD_TEXTURE_0_TYPE='innosetup'
ARCHIVE_BASE_HD_TEXTURE_0_PART1_NAME='setup_kingdom_come_deliverance_-_hd_texture_pack_1.9.6-404-504czj3_(62297)-1.bin'
ARCHIVE_BASE_HD_TEXTURE_0_PART1_MD5='257a19297a6e1ffc202ca9af584dbc17'
ARCHIVE_BASE_HD_TEXTURE_0_PART2_NAME='setup_kingdom_come_deliverance_-_hd_texture_pack_1.9.6-404-504czj3_(62297)-2.bin'
ARCHIVE_BASE_HD_TEXTURE_0_PART2_MD5='c3271df85b819e5ed5016e318544fcc5'
ARCHIVE_BASE_HD_TEXTURE_0_SIZE='7089775'
ARCHIVE_BASE_HD_TEXTURE_0_VERSION='1.9.6-404-504czj3'

# HD Voice Pack - French

EXPANSION_ID_HD_VOICE_FR='hd-voice-fr'
EXPANSION_NAME_HD_VOICE_FR='HD Voice Pack - French'

ARCHIVE_BASE_HD_VOICE_FR_0_NAME='setup_kingdom_come_deliverance_-_hd_voice_pack_-_french_1.9.6-404-504czj3_(62297).exe'
ARCHIVE_BASE_HD_VOICE_FR_0_MD5='16178699acfc1ca2b94c385f7e6dc206'
ARCHIVE_BASE_HD_VOICE_FR_0_TYPE='innosetup'
ARCHIVE_BASE_HD_VOICE_FR_0_PART1_NAME='setup_kingdom_come_deliverance_-_hd_voice_pack_-_french_1.9.6-404-504czj3_(62297)-1.bin'
ARCHIVE_BASE_HD_VOICE_FR_0_PART1_MD5='85279184e0e52c810cea55efa9440efc'
ARCHIVE_BASE_HD_VOICE_FR_0_SIZE='3832027'
ARCHIVE_BASE_HD_VOICE_FR_0_VERSION='1.9.6-404-504czj3'

# 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
. "$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
