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

###
# Neverwinter Nights: Enhanced Edition localisations:
# - French
# - Polish
# - German
# send your bug reports to bugs@dotslashplay.it
###

script_version=20260710.2

PLAYIT_COMPATIBILITY_LEVEL=2.35

GAME_ID='neverwinter-nights-1-enhanced-edition'
GAME_NAME='Neverwinter Nights: Enhanced Edition'

EXPANSION_ID_FR=l10n-fr
EXPANSION_ID_PL=l10n-pl
EXPANSION_ID_DE=l10n-de

EXPANSION_NAME_FR='French localisation'
EXPANSION_NAME_PL='Polish localisation'
EXPANSION_NAME_DE='German localisation'

ARCHIVE_BASE_FR_7_NAME='neverwinter_nights_enhanced_edition_french_extras_89_8193_37_17_85648.sh'
ARCHIVE_BASE_FR_7_MD5=c1681fef83e9f97fcea232393b476ab4
ARCHIVE_BASE_FR_7_SIZE=833009
ARCHIVE_BASE_FR_7_VERSION=89.8193.37.17-1

ARCHIVE_BASE_PL_7_NAME='neverwinter_nights_enhanced_edition_polish_extras_89_8193_37_17_85648.sh'
ARCHIVE_BASE_PL_7_MD5=e5750ccc89ae65570f662e9eeed1b4dc
ARCHIVE_BASE_PL_7_SIZE=820818
ARCHIVE_BASE_PL_7_VERSION=89.8193.37.17-1

ARCHIVE_BASE_DE_7_NAME='neverwinter_nights_enhanced_edition_german_extras_89_8193_37_17_85648.sh'
ARCHIVE_BASE_DE_7_MD5=75c86bf3eec708d0c20ea261b2cef01c
ARCHIVE_BASE_DE_7_SIZE=892427
ARCHIVE_BASE_DE_7_VERSION=89.8193.37.17-1

ARCHIVE_BASE_FR_6_NAME='neverwinter_nights_enhanced_edition_french_extras_88_8193_36_13_72824.sh'
ARCHIVE_BASE_FR_6_MD5=088b8c890ecbf09b86a7c75e07ef43f1
ARCHIVE_BASE_FR_6_SIZE=833009
ARCHIVE_BASE_FR_6_VERSION=88.8193.36.13-1

ARCHIVE_BASE_PL_6_NAME='neverwinter_nights_enhanced_edition_polish_extras_88_8193_36_13_72824.sh'
ARCHIVE_BASE_PL_6_MD5=89e2dced24b885c04e1c45bc71e9960f
ARCHIVE_BASE_PL_6_SIZE=820818
ARCHIVE_BASE_PL_6_VERSION=88.8193.36.13-1

ARCHIVE_BASE_DE_6_NAME='neverwinter_nights_enhanced_edition_german_extras_88_8193_36_13_72824.sh'
ARCHIVE_BASE_DE_6_MD5=082281faf84fc9be25e1aaf21a99a1ce
ARCHIVE_BASE_DE_6_SIZE=892427
ARCHIVE_BASE_DE_6_VERSION=88.8193.36.13-1

ARCHIVE_BASE_FR_5_NAME='neverwinter_nights_enhanced_edition_french_extras_87_8193_35_40_65678.sh'
ARCHIVE_BASE_FR_5_MD5=88b889d8eefadfde33d0fad8bac1b9be
ARCHIVE_BASE_FR_5_SIZE=833404
ARCHIVE_BASE_FR_5_VERSION=87.8193.35.40-1

ARCHIVE_BASE_PL_5_NAME='neverwinter_nights_enhanced_edition_polish_extras_87_8193_35_40_65678.sh'
ARCHIVE_BASE_PL_5_MD5=c78a405c135ffad7e126bd44113ecc86
ARCHIVE_BASE_PL_5_SIZE=833404
ARCHIVE_BASE_PL_5_VERSION=87.8193.35.40-1

ARCHIVE_BASE_DE_5_NAME='neverwinter_nights_enhanced_edition_german_extras_87_8193_35_40_65678.sh'
ARCHIVE_BASE_DE_5_MD5=596b075b63b8f9f76bbf1eeaa8150cfb
ARCHIVE_BASE_DE_5_SIZE=892816
ARCHIVE_BASE_DE_5_VERSION=87.8193.35.40-1

ARCHIVE_BASE_FR_4_NAME='neverwinter_nights_enhanced_edition_french_extras_85_8193_33_50393.sh'
ARCHIVE_BASE_FR_4_MD5=f39ecc55b15740322d8ae860ccfecbc5
ARCHIVE_BASE_FR_4_SIZE=840000
ARCHIVE_BASE_FR_4_VERSION=85.8193.33-1

ARCHIVE_BASE_DE_4_NAME='neverwinter_nights_enhanced_edition_german_extras_85_8193_33_50393.sh'
ARCHIVE_BASE_DE_4_MD5=d20a22fc2dfdeca4bb71bb7fd7e13a82
ARCHIVE_BASE_DE_4_SIZE=900000
ARCHIVE_BASE_DE_4_VERSION=85.8193.33-1

ARCHIVE_BASE_FR_1_NAME='neverwinter_nights_enhanced_edition_french_extras_81_8193_16_41300.sh'
ARCHIVE_BASE_FR_1_MD5=1fe0cc196c146834ff186935ae2d3d66
ARCHIVE_BASE_FR_1_SIZE=832881
ARCHIVE_BASE_FR_1_VERSION=81.8193.16-1

ARCHIVE_BASE_PL_1_NAME='neverwinter_nights_enhanced_edition_polish_extras_81_8193_16_41300.sh'
ARCHIVE_BASE_PL_1_MD5=8ff3b7d282b9a3822425823e9efd545f
ARCHIVE_BASE_PL_1_SIZE=820690
ARCHIVE_BASE_PL_1_VERSION=81.8193.16-1

ARCHIVE_BASE_DE_1_NAME='neverwinter_nights_enhanced_edition_german_extras_81_8193_16_41300.sh'
ARCHIVE_BASE_DE_1_MD5=1e81fcf9d40bcf23dec0a77069222a52
ARCHIVE_BASE_DE_1_SIZE=892298
ARCHIVE_BASE_DE_1_VERSION=81.8193.16-1

ARCHIVE_BASE_FR_0_NAME='neverwinter_nights_enhanced_edition_french_extras_80_8193_9_37029.sh'
ARCHIVE_BASE_FR_0_MD5=5e0564a161259b003c7dc0f8d8aa743f
ARCHIVE_BASE_FR_0_SIZE=840000
ARCHIVE_BASE_FR_0_VERSION=80.8193.9-1

CONTENT_PATH_DEFAULT='data/noarch/game'
CONTENT_GAME_MAIN_FILES='
lang/??/data'

PKG_MAIN_PROVIDES=${GAME_ID}-l10n

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

# Run default initialisation actions.

initialization_default "$@"

# Extract archive contents.

archive_extraction_default

# Include game data.

content_inclusion_default

# Build packages.

packages_generation
print_instructions

# Clean up.

working_directory_cleanup

exit 0
