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

###
# Akalabeth: World of Doom
# send your bug reports to bugs@dotslashplay.it
###

script_version=20250826.1

PLAYIT_COMPATIBILITY_LEVEL='2.33'

GAME_ID='akalabeth'
GAME_NAME='Akalabeth: World of Doom'

ARCHIVE_BASE_0_NAME='gog_akalabeth_world_of_doom_2.0.0.3.sh'
ARCHIVE_BASE_0_MD5='11a770db592af2ac463e6cdc453b555b'
ARCHIVE_BASE_0_SIZE='13000'
ARCHIVE_BASE_0_VERSION='1.0-gog2.0.0.3'

CONTENT_PATH_DEFAULT='data/noarch/data'
CONTENT_GAME_MAIN_FILES='
aklabeth.bas
aklabeth.exe'
CONTENT_DOC_MAIN_PATH='data/noarch/docs'
CONTENT_DOC_MAIN_FILES='
*.pdf'

APP_MAIN_EXE='aklabeth.exe'
APP_MAIN_ICON='../support/icon.png'

## convmv is used to convert paths to lower case.
REQUIREMENTS_LIST='
convmv'

# 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
## Convert all paths to lowercase.
tolower "${PLAYIT_WORKDIR}/gamedata/$(content_path_default)"

# Include game data

content_inclusion_icons
content_inclusion_default

# Write launchers

launchers_generation

# Build packages

packages_generation
print_instructions

# Clean up

working_directory_cleanup

exit 0
