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

###
# Zodiacats
# send your bug reports to bugs@dotslashplay.it
###

script_version=20260419.4

PLAYIT_COMPATIBILITY_LEVEL='2.35'

GAME_ID='zodiacats'
GAME_NAME='Zodiacats'

ARCHIVE_BASE_1_NAME='setup_zodiacats_1.0006_-_gog_wrapper_ok_(64bit)_(63182).exe'
ARCHIVE_BASE_1_MD5='da18fffdef200b98f9d3a0bef1b87a49'
ARCHIVE_BASE_1_TYPE='innosetup'
ARCHIVE_BASE_1_SIZE='279914'
ARCHIVE_BASE_1_VERSION='1.0006-gog63182'
ARCHIVE_BASE_1_URL='https://www.gog.com/game/zodiacats'

ARCHIVE_BASE_0_NAME='setup_zodiacats_1.0003_(64bit)_(62419).exe'
ARCHIVE_BASE_0_MD5='ad9c318bba0464f6bcdf3079ebd8f1c9'
ARCHIVE_BASE_0_TYPE='innosetup'
ARCHIVE_BASE_0_SIZE='270000'
ARCHIVE_BASE_0_VERSION='1.0003-gog62419'

CONTENT_PATH_DEFAULT='.'
CONTENT_GAME_BIN_FILES='
zodiacats.exe
zodiacats_settings.cfg'
# TODO: Install libraries in a standard path.
# zodiacats.exe requirements
CONTENT_GAME0_BIN_FILES='
steam_api64.dll'
# steam_api64.dll requirements
CONTENT_GAME1_BIN_FILES='
Galaxy64.dll'
# Missing GalaxyConfig.json triggers a crash on launch.
CONTENT_GAME2_BIN_FILES='
GalaxyConfig.json'
CONTENT_GAME_DATA_FILES='
zodiacats.pck'

USER_PERSISTENT_FILES='
fortune.cfg'

# Loading this game with Linux native godot3-runner crashes right after the introduction video.
# We fall back on running the shipped binaries with WINE.
# (Godot 3.6.2)
APP_MAIN_EXE='zodiacats.exe'
# If the .exe file is too big, wrestool fails to handle it with:
# wrestool: (…)/gamedata/zodiacats.exe: premature end
APP_MAIN_ICON_0='app/goggame-1435098189.ico'

PACKAGES_LIST='
PKG_BIN
PKG_DATA'
PACKAGES_LIST_0='
PKG_BIN'

PKG_BIN_ARCH='64'
PKG_BIN_DEPENDENCIES_SIBLINGS='
PKG_DATA'

PKG_DATA_ID="${GAME_ID}-data"
PKG_DATA_DESCRIPTION='data'
PKG_BIN_PROVIDES_0="
$PKG_DATA_ID"

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

case "$(current_archive)" in
	('ARCHIVE_BASE_0')
		content_inclusion_icons
	;;
	(*)
		content_inclusion_icons 'PKG_DATA'
	;;
esac
content_inclusion_default

# Write launchers.

launchers_generation

# Build packages.

# Prevent a dependency loop when building a single package.
case "$(current_archive)" in
	('ARCHIVE_BASE_0')
		dependencies_siblings_list() { return 0; }
	;;
esac

packages_generation
print_instructions

# Clean up.

working_directory_cleanup

exit 0
