diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 00000000..504cd9a5
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,4 @@
+**/__pycache__/
+**/.idea/
+/.git/
+/playsound/libplaysound*
diff --git a/.editorconfig b/.editorconfig
index 24448d86..01e14208 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -19,7 +19,10 @@ max_line_length = 80
max_line_length = off
-[*.md]
+[*.md,*.yaml,*.yml,*.sh]
indent_size = 2
tab_width = 2
+[packages/deb/assets/debian/rules]
+indent_style = tab
+tab_width = 4
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index dd5dc7ca..8f5149f4 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -13,14 +13,9 @@ on:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
- # This workflow contains a single job called "build"
- build:
- # The type of runner that the job will run on
+ release:
runs-on: ubuntu-latest
-
- # Steps represent a sequence of tasks that will be executed as part of the job
steps:
- # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Get tag
@@ -29,25 +24,7 @@ jobs:
with:
# Optionally strip `v` prefix
strip_v: true
-
- - name: path
- run: echo "::set-output name=path::Pokete-${{ steps.tag.outputs.tag }}-x86_64.AppImage"
- id: path
-
- # Runs a set of commands using the runners shell
- - name: Prepare
- run: |
- echo ${{ steps.tag.outputs.tag }}
- echo ${{ steps.path.outputs.path }}
- sudo apt install -y python3-pip python3-setuptools patchelf desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace fuse
- sudo wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O /usr/local/bin/appimagetool
- sudo chmod +x /usr/local/bin/appimagetool
- sudo pip3 install git+https://github.com/AppImageCrafters/appimage-builder.git
- sed -i '/app_info:/{n;n;n;n;s/\(version\).*/\1: '"${{ steps.tag.outputs.tag }}"'/}' assets/AppImageBuilder.yml
-
- - name: Build Appimage
- run: appimage-builder --skip-test --recipe assets/AppImageBuilder.yml
-
+
- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
@@ -55,8 +32,9 @@ jobs:
validation_depth: 10
version: ${{ steps.tag.outputs.tag }}
path: ./Changelog.md
-
- - name: release
+
+
+ - name: Create release
uses: actions/create-release@v1
id: create_release
with:
@@ -67,13 +45,133 @@ jobs:
body: ${{ steps.changelog_reader.outputs.changes }}
env:
GITHUB_TOKEN: ${{ github.token }}
-
- - name: upload linux artifact
+
+ debianpkg:
+ runs-on: ubuntu-latest
+ needs: "release"
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Get tag
+ id: tag
+ uses: dawidd6/action-get-tag@v1
+ with:
+ # Optionally strip `v` prefix
+ strip_v: true
+
+ - name: Build Debian package
+ run: tools/debbuild.sh
+
+ - name: Get release release url
+ run: |
+ url=$(gh api 'https://api.github.com/repos/lxgr-linux/pokete/releases/latest' | jq -r '.upload_url')
+ echo "Url: ${url}"
+ echo "::set-output name=url::${url}"
+ id: url
+
+ - name: Get Debian package path
+ run: |
+ p=ls build/pokete_${{ steps.tag.outputs.tag }}-1_amd64.deb
+ echo "Path: ${p}"
+ echo "::set-output name=path::${p}"
+ id: path
+
+ - name: Upload debian package
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ github.token }}
+ with:
+ upload_url: ${{ steps.url.outputs.url }}
+ asset_path: ${{ steps.path.outputs.path }}
+ asset_name: pokete_${{ steps.tag.outputs.tag }}-1_amd64.deb
+ asset_content_type: application/x-deb
+
+
+ appimage:
+ runs-on: ubuntu-latest
+ needs: "release"
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Get tag
+ id: tag
+ uses: dawidd6/action-get-tag@v1
+ with:
+ # Optionally strip `v` prefix
+ strip_v: true
+
+ - name: path
+ run: echo "::set-output name=path::Pokete-${{ steps.tag.outputs.tag }}-x86_64.AppImage"
+ id: path
+
+ - name: Get release url
+ run: |
+ url=$(gh api 'https://api.github.com/repos/lxgr-linux/pokete/releases/latest' | jq -r '.upload_url')
+ echo "Url: ${url}"
+ echo "::set-output name=url::${url}"
+ id: url
+
+ - name: Prepare
+ run: |
+ echo ${{ steps.tag.outputs.tag }}
+ echo ${{ steps.path.outputs.path }}
+ sudo apt install -y python3-pip python3-setuptools patchelf desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace fuse
+ sudo wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O /usr/local/bin/appimagetool
+ sudo chmod +x /usr/local/bin/appimagetool
+ sudo pip3 install git+https://github.com/AppImageCrafters/appimage-builder.git
+ sed -i '/app_info:/{n;n;n;n;s/\(version\).*/\1: '"${{ steps.tag.outputs.tag }}"'/}' assets/AppImageBuilder.yml
+
+ - name: Build Appimage
+ run: appimage-builder --skip-test --recipe assets/AppImageBuilder.yml
+
+ - name: Upload AppImage
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
- upload_url: ${{ steps.create_release.outputs.upload_url }}
+ upload_url: ${{ steps.url.outputs.url }}
asset_path: ${{ steps.path.outputs.path }}
asset_name: ${{ steps.path.outputs.path }}
asset_content_type: application/appimage
+
+ # Build and push the docker images
+ docker:
+ runs-on: ubuntu-latest
+ needs: "release"
+ permissions:
+ packages: write
+ contents: read
+ steps:
+ - name: Checkout the code
+ uses: actions/checkout@v3
+
+ - name: Log in to Docker Hub
+ uses: docker/login-action@v2
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_PASSWORD }}
+
+ - name: Log in to the Container registry
+ uses: docker/login-action@v2
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Extract metadata (tags, labels) for Docker
+ id: meta
+ uses: docker/metadata-action@v4
+ with:
+ images: |
+ hub.docker.com/${{ github.repository }}
+ ghcr.io/${{ github.repository }}
+
+ - name: Build and push Docker images
+ uses: docker/build-push-action@v3
+ with:
+ context: .
+ push: true
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
diff --git a/.gitignore b/.gitignore
index 371e9168..db4e9f23 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,7 @@ templates
.idea
scrap_engine.py
+
+# flatpak build directories
+.flatpak-builder
+build
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..d93e9603
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,38 @@
+FROM ubuntu:22.04 AS compile-image
+
+WORKDIR /build
+
+RUN apt-get update && \
+ DEBIAN_FRONTEND=non-interactive apt-get install -y \
+ libasound-dev \
+ libpulse-dev \
+ pkg-config \
+ golang \
+ curl
+
+COPY playsound /build/playsound/
+
+RUN curl -o scrap_engine.py "https://raw.githubusercontent.com/lxgr-linux/scrap_engine/master/scrap_engine.py" && \
+ cd playsound && \
+ go build -ldflags "-s -w" -buildmode=c-shared -buildvcs=false -o ./libplaysound.so && \
+ rm -v go.mod go.sum main.go README.md
+
+FROM ubuntu:22.04
+
+WORKDIR /app
+
+RUN apt-get update && \
+ DEBIAN_FRONTEND=non-interactive apt-get install -y \
+ alsa-base \
+ pulseaudio \
+ python3
+
+RUN mkdir -p /root/.local/share/pokete && \
+ ln -s /root/.local/share/pokete /data
+
+COPY . .
+COPY --from=compile-image /build /app
+
+VOLUME ["/data"]
+
+CMD [ "python3", "./pokete.py" ]
diff --git a/assets/Bildschirmfoto_2021-06-04_09-04-44 (Kopie 1).kra b/assets/Bildschirmfoto_2021-06-04_09-04-44 (Kopie 1).kra
deleted file mode 100644
index ea8717f8..00000000
Binary files a/assets/Bildschirmfoto_2021-06-04_09-04-44 (Kopie 1).kra and /dev/null differ
diff --git a/assets/Bildschirmfoto_2021-06-04_09-04-44 (Kopie 1).kra~ b/assets/Bildschirmfoto_2021-06-04_09-04-44 (Kopie 1).kra~
deleted file mode 100644
index ce561d15..00000000
Binary files a/assets/Bildschirmfoto_2021-06-04_09-04-44 (Kopie 1).kra~ and /dev/null differ
diff --git a/assets/Bildschirmfoto_2021-06-04_09-04-44.kra b/assets/Bildschirmfoto_2021-06-04_09-04-44.kra
deleted file mode 100644
index cc181222..00000000
Binary files a/assets/Bildschirmfoto_2021-06-04_09-04-44.kra and /dev/null differ
diff --git a/assets/Bildschirmfoto_2021-06-04_09-04-44.png b/assets/Bildschirmfoto_2021-06-04_09-04-44.png
deleted file mode 100644
index 7365beed..00000000
Binary files a/assets/Bildschirmfoto_2021-06-04_09-04-44.png and /dev/null differ
diff --git a/assets/banner.png.kra b/assets/banner.png.kra
deleted file mode 100644
index e7cacb86..00000000
Binary files a/assets/banner.png.kra and /dev/null differ
diff --git a/assets/com.github.lxgr_linux.pokete.yaml b/assets/com.github.lxgr_linux.pokete.yaml
new file mode 100644
index 00000000..f4e9ccd1
--- /dev/null
+++ b/assets/com.github.lxgr_linux.pokete.yaml
@@ -0,0 +1,69 @@
+app-id: com.github.lxgr_linux.pokete
+runtime: org.freedesktop.Platform
+runtime-version: '21.08'
+sdk: org.freedesktop.Sdk
+command: /app/bin/pokete
+
+finish-args:
+ # Store save files and logs
+ - "--filesystem=xdg-cache/pokete:create"
+ # Trading and update checking
+ - "--share=network"
+
+modules:
+ # Dependency of scrap engine; generated with flatpak-pip-generator
+ - name: python3-setuptools_scm
+ buildsystem: simple
+ build-commands:
+ - pip3 install --verbose --exists-action=i --no-index --find-links="file://${PWD}" --prefix=${FLATPAK_DEST} "setuptools_scm>=6.4.2" --no-build-isolation
+ sources:
+ - type: file
+ url: https://files.pythonhosted.org/packages/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9/tomli-2.0.1-py3-none-any.whl
+ sha256: 939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc
+ - type: file
+ url: https://files.pythonhosted.org/packages/6c/10/a7d0fa5baea8fe7b50f448ab742f26f52b80bfca85ac2be9d35cdd9a3246/pyparsing-3.0.9-py3-none-any.whl
+ sha256: 5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc
+ - type: file
+ url: https://files.pythonhosted.org/packages/05/8e/8de486cbd03baba4deef4142bd643a3e7bbe954a784dc1bb17142572d127/packaging-21.3-py3-none-any.whl
+ sha256: ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522
+ - type: file
+ url: https://files.pythonhosted.org/packages/e3/e5/c28b544051340e63e0d507eb893c9513d3a300e5e9183e2990518acbfe36/setuptools_scm-6.4.2-py3-none-any.whl
+ sha256: acea13255093849de7ccb11af9e1fb8bde7067783450cee9ef7a93139bddf6d4
+
+ # Dependency of pokete; generated with flatpak-pip-generator
+ - name: python3-scrap_engine
+ buildsystem: simple
+ build-commands:
+ - "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"scrap_engine>=1.2.0\" --no-build-isolation"
+ sources:
+ - type: "file"
+ url: "https://files.pythonhosted.org/packages/3e/d6/b51ae9c311603c76e952a39baabca3c81887e4609f7bf7308c2e19ac8c9f/scrap_engine-1.2.0.tar.gz"
+ sha256: "767ffdc312b550777771cdc9a350a9f6dca73855259dd1fe7197c8736e38cac1"
+
+ # The actual game files
+ - name: pokete
+ buildsystem: simple
+ build-commands:
+ # Copy Files
+ - "cp -r . /app"
+ # Create the desktop entry
+ - "sed -i 's#Icon=/usr/share/pokete/assets/pokete.png#Icon=com.github.lxgr_linux.pokete#g' assets/pokete.desktop"
+ - "sed -i 's#Exec=/usr/bin/pokete.py#Exec=/app/bin/pokete#g' assets/pokete.desktop"
+ - "install -D assets/pokete.desktop /app/share/applications/com.github.lxgr_linux.pokete.desktop"
+ - "install -D assets/pokete.svg /app/share/icons/hicolor/296x256/apps/com.github.lxgr_linux.pokete.png"
+ # Set Environment
+ - "echo 'environment=\"flatpak\"' >> /app/release.py"
+ # Generate shell wrapper script
+ - "mkdir -p /app/bin"
+ - "echo 'cd /app && python3 pokete.py --log' >> /app/bin/pokete"
+ - "chmod +x /app/bin/pokete"
+ sources:
+ - type: archive
+ url: "https://github.com/lxgr-linux/pokete/archive/refs/tags/0.7.2.tar.gz"
+ sha256: "7410b2043a53e636bfb8c9ede4c24f933f2bd3f5685ff0b2b3031206d7cbd5f4"
+
+cleanup:
+ - "/.github"
+ - "/*.md"
+ - "/.*"
+ - "/Pipfile*"
diff --git a/assets/pokete.desktop b/assets/pokete.desktop
index f01bc27b..8b4b39a6 100755
--- a/assets/pokete.desktop
+++ b/assets/pokete.desktop
@@ -3,8 +3,8 @@ Version=1.0
Type=Application
Name=Pokete
Comment=A terminal based Pokemon clone, based on the scrap engine.
-Exec=/usr/bin/pokete.py
-Icon=/usr/share/pokete/assets/pokete.png
+Exec=/usr/bin/pokete.py --log
+Icon=/usr/share/pokete/assets/pokete.svg
Terminal=true
StartupNotify=false
Categories=Game;
diff --git a/assets/pokete_old.png b/assets/pokete_old.png
deleted file mode 100644
index 49e03219..00000000
Binary files a/assets/pokete_old.png and /dev/null differ
diff --git a/installation.md b/installation.md
new file mode 100644
index 00000000..f913bf73
--- /dev/null
+++ b/installation.md
@@ -0,0 +1,96 @@
+# Installation
+- [Installation](#installation)
+ - [From source](#from-source)
+ - [On windows:](#on-windows)
+ - [On macOS:](#on-macos)
+ - [On linux:](#on-linux)
+ - [Flatpak](#flatpak)
+ - [AppImage](#appimage)
+ - [Snap](#snap)
+ - [Docker](#docker)
+
+## From source
+1. Make sure [Python](https://www.python.org/) is installed.
+2. Get the latest `.tar.gz` or `.zip` archive from the [releases page](https://github.com/lxgr-linux/pokete/releases/latest/) and unpack it.
+3. Run the following command, depending on your operating system
+4. Start pokete by navigating to the folder, where pokete is extracted, then run `python3 pokete.py` to start the game.
+
+### On windows:
+Use `powershell.exe` or `cmd.exe`:
+
+```cmd
+pip3 install scrap_engine playsound pynput
+```
+
+### On macOS:
+Open the `Terminal`:
+
+```bash
+pip3 install scrap_engine playsound pynput
+```
+
+### On linux:
+Use your shell of choice:
+
+```bash
+pip3 install scrap_engine playsound
+```
+
+## Flatpak
+
+
+Use GNOME software or KDE Discover to install this flatpak or use the following command:
+
+```bash
+flatpak install flathub com.github.lxgr_linux.pokete
+```
+
+You can then run this app via the app launcher or by running the following command:
+
+```bash
+flatpak run com.github.lxgr_linux.pokete
+```
+
+## AppImage
+![](https://docs.appimage.org/_images/appimage.svg)
+
+1. Download the latest AppImage from the [releases page](https://github.com/lxgr-linux/pokete/releases/latest/)
+2. Run the following commands in the folder, in which the downloaded file from step 1 is:
+
+```bash
+chmod +x Pokete-*.AppImage
+mkdir -p "$HOME/.local/share/pokete"
+./Pokete-*.AppImage
+```
+
+## Snap
+[![Get it from the Snap Store](https://snapcraft.io/static/images/badges/en/snap-store-black.svg)](https://snapcraft.io/pokete)
+
+1. Make sure [snap](https://snapcraft.io/) is installed on your system
+2. Run the following command in your terminal:
+
+```bash
+sudo snap install pokete
+```
+
+## Docker
+1. Pull the latest docker image from either or :
+
+```bash
+# From ghcr.io:
+docker pull ghcr.io/lxgr-linux/pokete:latest
+
+# From docker hub:
+docker pull lxgr-linux/pokete:latest
+```
+
+2. Run the docker container:
+
+```bash
+docker run -it \
+ -v "${HOME}/.local/share/pokete:/data" \
+ --device /dev/snd \
+ -e "PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native" \
+ -v "${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native" \
+ lxgr-linux/pokete
+```
diff --git a/packages/deb/assets/debian/changelog b/packages/deb/assets/debian/changelog
new file mode 100644
index 00000000..d392449a
--- /dev/null
+++ b/packages/deb/assets/debian/changelog
@@ -0,0 +1,6 @@
+pokete (0.8.2-1) UNRELEASED; urgency=low
+
+ * Fixes a small bug in the representation of pokete on flathub
+ * Closes #195: Publish formats
+
+ -- MaFeLP Fri, 05 Aug 2022 04:19:00 +0200
diff --git a/packages/deb/assets/debian/control b/packages/deb/assets/debian/control
new file mode 100644
index 00000000..8431a446
--- /dev/null
+++ b/packages/deb/assets/debian/control
@@ -0,0 +1,20 @@
+Source: pokete
+Section: cli-mono
+Priority: optional
+Maintainer: MaFeLP
+Build-Depends: debhelper-compat (= 12),
+ dh-python,
+ python3-all,
+ python3-setuptools
+Standards-Version: 4.5.0
+Homepage: https://github.com/lxgr-linux/pokete/
+X-Python3-Version: >= 3.8
+
+Package: pokete
+Architecture: amd64
+Depends: ${misc:Depends},
+ ${python3:Depends},
+ libc6 (>= 2.34),
+ libasound2,
+ pulseaudio
+Description: A terminal based Pokemon like game
diff --git a/packages/deb/assets/debian/copyright b/packages/deb/assets/debian/copyright
new file mode 100644
index 00000000..49ffd4c7
--- /dev/null
+++ b/packages/deb/assets/debian/copyright
@@ -0,0 +1,27 @@
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: pokete
+Upstream-Contact: lxgr
+Source: https://github.com/lxgr-linux/pokete
+
+Files: *
+Copyright: 2021-2022 lxgr
+License: GPL-3+
+
+License: GPL-3+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+ .
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ .
+ On Debian systems, the full text of the GNU General Public
+ License version 3 can be found in the file
+ '/usr/share/common-licenses/GPL-3'.
diff --git a/packages/deb/assets/debian/rules b/packages/deb/assets/debian/rules
new file mode 100644
index 00000000..e064f26c
--- /dev/null
+++ b/packages/deb/assets/debian/rules
@@ -0,0 +1,6 @@
+#!/usr/bin/make -f
+
+%:
+ dh $@ --with python3 --buildsystem=pybuild
+
+override_dh_auto_test:
diff --git a/packages/deb/assets/debian/watch b/packages/deb/assets/debian/watch
new file mode 100644
index 00000000..9e7c0dae
--- /dev/null
+++ b/packages/deb/assets/debian/watch
@@ -0,0 +1 @@
+version=3
diff --git a/packages/deb/playsound_lib.patch b/packages/deb/playsound_lib.patch
new file mode 100644
index 00000000..c2a02dc8
--- /dev/null
+++ b/packages/deb/playsound_lib.patch
@@ -0,0 +1,36 @@
+--- playsound/__init__.py 2022-08-05 16:52:07.648610000 +0200
++++ playsound/__init__.py.patched 2022-08-07 20:42:05.805025300 +0200
+@@ -1,6 +1,6 @@
+ import ctypes
+ import logging
+-import sys
++import os
+ from pathlib import Path
+
+
+@@ -12,15 +12,13 @@
+ _playsound.playsound(file.encode("utf-8"))
+
+
+-_playsound = ctypes.cdll.LoadLibrary(
+- str(
+- Path(__file__).parent / (
+- "libplaysound." +
+- {
+- sys.platform: "so",
+- "win32": "dll",
+- "darwin": "osx.so"
+- }[sys.platform]
+- )
+- )
+-)
++def _get_libpath():
++ dirpath = Path(__file__).parent
++ contents = os.listdir(dirpath)
++ for file in contents:
++ if file.startswith("libplaysound") and file.endswith(".so") and not file.endswith(".osx.so"):
++ return str(dirpath / file)
++
++_playsound = ctypes.cdll.LoadLibrary(_get_libpath())
++
++del _get_libpath
diff --git a/packages/deb/setup.py b/packages/deb/setup.py
new file mode 100644
index 00000000..aca56f0a
--- /dev/null
+++ b/packages/deb/setup.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+
+from setuptools import setup
+
+setup(
+ name="pokete",
+ version="0.8.2",
+ description="A terminal based Pokemon like game",
+ author="lxgr-linux",
+ author_email="lxgr@protonmail.com",
+ license="GPL-3.0",
+ packages=["pokete", "pokete.pokete_data", "pokete.pokete_classes", "pokete.playsound", "scrap_engine"],
+ entry_points={
+ 'console_scripts': [
+ 'pokete = pokete:run_pokete'
+ ]
+ },
+ install_requires=[],
+ package_data={"pokete": ["assets/music/*", "playsound/libplaysound.so"]},
+ include_package_data=True
+)
diff --git a/pokete_classes/animations.py b/pokete_classes/animations.py
index c2c23585..29f78a18 100644
--- a/pokete_classes/animations.py
+++ b/pokete_classes/animations.py
@@ -2,7 +2,7 @@
import time
import scrap_engine as se
-import pokete_classes.game_map as gm
+from . import game_map as gm
from release import SPEED_OF_TIME
diff --git a/pokete_classes/audio.py b/pokete_classes/audio.py
index 8efc64f9..ac90334c 100644
--- a/pokete_classes/audio.py
+++ b/pokete_classes/audio.py
@@ -10,11 +10,11 @@
def audio_fn(song, play_audio):
"""plays a song in loop"""
- import playsound
+ from playsound import playsound
while play_audio:
- playsound.playsound(str(MUSIC_PATH / song))
+ playsound(str(MUSIC_PATH / song))
class Audio:
diff --git a/pokete_classes/classes.py b/pokete_classes/classes.py
index d0ff8605..5f95cfba 100644
--- a/pokete_classes/classes.py
+++ b/pokete_classes/classes.py
@@ -1,7 +1,7 @@
"""Contains just some small classes"""
import scrap_engine as se
-import pokete_classes.game_map as gm
+from . import game_map as gm
from .weather import Weather
diff --git a/pokete_classes/deck.py b/pokete_classes/deck.py
index bbf4b566..d000de52 100644
--- a/pokete_classes/deck.py
+++ b/pokete_classes/deck.py
@@ -2,12 +2,8 @@
import logging
import scrap_engine as se
-from pokete_classes import detail
-import pokete_classes.game_map as gm
-from pokete_classes.hotkeys import (
- ACTION_DIRECTIONS, Action, get_action
-)
-import pokete_classes.movemap as mvp
+from . import detail, game_map as gm, movemap as mvp
+from .hotkeys import ACTION_DIRECTIONS, Action, get_action
from .event import _ev
from .input import ask_bool, ask_ok
from .loops import std_loop
diff --git a/pokete_classes/detail.py b/pokete_classes/detail.py
index 44c2e280..497f2ed8 100644
--- a/pokete_classes/detail.py
+++ b/pokete_classes/detail.py
@@ -1,8 +1,8 @@
"""Contains classes needed for the detail-view of a Pokete"""
import scrap_engine as se
-import pokete_classes.game_map as gm
-from pokete_classes.hotkeys import Action, get_action
+from . import game_map as gm
+from .hotkeys import Action, get_action
from .loops import std_loop
from .event import _ev
from .ui_elements import StdFrame2, ChooseBox
diff --git a/pokete_classes/dex.py b/pokete_classes/dex.py
index 551d475b..a6420bd9 100644
--- a/pokete_classes/dex.py
+++ b/pokete_classes/dex.py
@@ -3,8 +3,8 @@
import scrap_engine as se
from pokete_classes.hotkeys import Action, ACTION_UP_DOWN, get_action
import pokete_data as p_data
-import pokete_classes.movemap as mvp
from pokete_general_use_fns import liner
+from . import movemap as mvp
from .loops import std_loop, easy_exit_loop
from .poke import Poke
from .color import Color
diff --git a/pokete_classes/doors.py b/pokete_classes/doors.py
index 8505687a..860df86f 100644
--- a/pokete_classes/doors.py
+++ b/pokete_classes/doors.py
@@ -2,7 +2,7 @@
import random
import scrap_engine as se
-from pokete_classes import game, ob_maps as obmp
+from . import game, ob_maps as obmp
class CenterDoor(se.Object):
diff --git a/pokete_classes/evomap.py b/pokete_classes/evomap.py
index 24c40f01..667e9837 100644
--- a/pokete_classes/evomap.py
+++ b/pokete_classes/evomap.py
@@ -1,7 +1,7 @@
"""Contains the map used for evolving"""
import scrap_engine as se
-import pokete_classes.game_map as gm
+from . import game_map as gm
from .classes import OutP
diff --git a/pokete_classes/fightmap.py b/pokete_classes/fightmap.py
index 9692679d..31b9aa9f 100644
--- a/pokete_classes/fightmap.py
+++ b/pokete_classes/fightmap.py
@@ -6,7 +6,7 @@
import scrap_engine as se
import pokete_data as p_data
from pokete_general_use_fns import liner
-from pokete_classes import animations, ob_maps as obmp, movemap as mvp, \
+from . import animations, ob_maps as obmp, movemap as mvp, \
deck, game_map as gm
from release import SPEED_OF_TIME
from .hotkeys import ACTION_UP_DOWN, Action, get_action
diff --git a/pokete_classes/general.py b/pokete_classes/general.py
index 93cfe151..f879f7ce 100644
--- a/pokete_classes/general.py
+++ b/pokete_classes/general.py
@@ -1,7 +1,7 @@
"""Contains some stuff that's used in this module"""
import logging
-from pokete_classes import movemap as mvp
+from . import movemap as mvp
from .doors import DoorToCenter
from .input import ask_ok
diff --git a/pokete_classes/landscape.py b/pokete_classes/landscape.py
index 54ee810a..dfad4d8b 100644
--- a/pokete_classes/landscape.py
+++ b/pokete_classes/landscape.py
@@ -3,7 +3,7 @@
import random
import scrap_engine as se
import pokete_data as p_data
-from pokete_classes import timer, movemap as mvp, fightmap as fm
+from . import timer, movemap as mvp, fightmap as fm
from .providers import NatureProvider
from .color import Color
from .general import check_walk_back
diff --git a/pokete_classes/loops.py b/pokete_classes/loops.py
index 6bcfe596..2a6c0357 100644
--- a/pokete_classes/loops.py
+++ b/pokete_classes/loops.py
@@ -1,8 +1,8 @@
"""Standardized loops components"""
import time
-from pokete_classes.hotkeys import Action, get_action
-import release
+from release import FRAMETIME
+from .hotkeys import Action, get_action
from .notify import notifier
@@ -26,4 +26,4 @@ def std_loop(on_mvmp=True, pevm=None):
notifier.next()
if pevm is not None:
pevm.event()
- time.sleep(release.FRAMETIME)
+ time.sleep(FRAMETIME)
diff --git a/pokete_classes/movemap.py b/pokete_classes/movemap.py
index 0f119a49..0548487e 100644
--- a/pokete_classes/movemap.py
+++ b/pokete_classes/movemap.py
@@ -3,8 +3,7 @@
import time
import scrap_engine as se
from pokete_general_use_fns import liner
-import pokete_classes.ob_maps as obmp
-import pokete_classes.game_map as gm
+from . import ob_maps as obmp, game_map as gm
from release import SPEED_OF_TIME
from .loops import std_loop
from .classes import OutP
diff --git a/pokete_classes/npcs.py b/pokete_classes/npcs.py
index 6beb1f0d..9eb5071f 100644
--- a/pokete_classes/npcs.py
+++ b/pokete_classes/npcs.py
@@ -4,10 +4,9 @@
import logging
import random
import scrap_engine as se
-import pokete_classes.fightmap as fm
+from . import fightmap as fm, movemap as mvp
from release import SPEED_OF_TIME
-from pokete_classes.hotkeys import ACTION_UP_DOWN, Action, get_action
-from . import movemap as mvp
+from .hotkeys import ACTION_UP_DOWN, Action, get_action
from .providers import Provider
from .loops import std_loop
from .input import ask_bool
diff --git a/pokete_classes/periodic_event_manager.py b/pokete_classes/periodic_event_manager.py
index 786ae093..ee9ee3d4 100644
--- a/pokete_classes/periodic_event_manager.py
+++ b/pokete_classes/periodic_event_manager.py
@@ -1,6 +1,6 @@
"""Contains the pevm"""
-from pokete_classes import timer
+from . import timer
from .settings import settings
from .landscape import Meadow
from .npcs import NPC
diff --git a/pokete_classes/roadmap.py b/pokete_classes/roadmap.py
index aedef3e1..38e2fc2a 100644
--- a/pokete_classes/roadmap.py
+++ b/pokete_classes/roadmap.py
@@ -2,8 +2,8 @@
import scrap_engine as se
import pokete_data as p_data
-import pokete_classes.ob_maps as obmp
from pokete_general_use_fns import liner
+from . import ob_maps as obmp
from .hotkeys import ACTION_DIRECTIONS, Action, ActionList, get_action
from .loops import std_loop, easy_exit_loop
from .color import Color
diff --git a/pokete_classes/side_loops.py b/pokete_classes/side_loops.py
index 08b208f4..3ad905af 100644
--- a/pokete_classes/side_loops.py
+++ b/pokete_classes/side_loops.py
@@ -2,8 +2,8 @@
import os
import scrap_engine as se
-import pokete_classes.game_map as gm
from pokete_general_use_fns import liner
+from . import game_map as gm
from .loops import easy_exit_loop
from .ui_elements import InfoBox, StdFrame
diff --git a/pokete_general_use_fns.py b/pokete_general_use_fns.py
index 74cb9825..ed6829d5 100644
--- a/pokete_general_use_fns.py
+++ b/pokete_general_use_fns.py
@@ -1,7 +1,7 @@
"""General use functions for Pokete"""
import sys
-import release
+from release import CODENAME, SAVEPATH, VERSION
def liner(text, width, pre=""):
@@ -56,7 +56,7 @@ def print_help(path):
"""Shows help message
ARGS:
path: The game's path"""
- print(f"""Pokete {release.CODENAME} v{release.VERSION}
+ print(f"""Pokete {CODENAME} v{VERSION}
Usage: {path} ()
Options:
--log : Enables logging
@@ -65,7 +65,7 @@ def print_help(path):
Homepage: https://github.com/lxgr-linux/pokete
-All save and logfiles are located in ~{release.SAVEPATH}/
+All save and logfiles are located in ~{SAVEPATH}/
Feel free to contribute.
See README.md for more information.
This software is licensed under the GPLv3, you should have gotten a
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 00000000..fa45aca7
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,31 @@
+[build-system]
+requires = ["setuptools", "setuptools-scm"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "pokete"
+version = "0.8.2"
+description = "A terminal based Pokemon like game"
+readme = "README.md"
+requires-python = ">=3.8"
+license = {text = "GPL-3.0"}
+dependencies = ["scrap_engine"]
+
+[tool.setuptools]
+packages = ["pokete", "pokete.pokete_data", "pokete.pokete_classes", "pokete.assets.music", "pokete.playsound"]
+
+[tool.setuptools.package-dir]
+"pokete" = "pokete"
+"pokete.assets.music" = "pokete/assets/music"
+"pokete.pokete_data" = "pokete/pokete_data"
+"pokete.pokete_classes" = "pokete/pokete_classes"
+"pokete.playsound" = "pokete/playsound"
+
+[tool.setuptools.package-data]
+"pokete.assets.music" = ["*.mp3"]
+"pokete.playsound" = ["libplaysound*"]
+
+[project.optional-dependencies]
+
+[project.scripts]
+pokete = "pokete:run_pokete"
diff --git a/release.py b/release.py
index fc716a7b..e3dbe1cf 100644
--- a/release.py
+++ b/release.py
@@ -3,7 +3,7 @@
from pathlib import Path
-VERSION = "0.8.1"
+VERSION = "0.8.2"
CODENAME = "Grey Edition"
SAVEPATH = Path(
os.environ.get(
diff --git a/setup.py b/setup.py
new file mode 100644
index 00000000..ae22aacb
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,156 @@
+#!/usr/bin/env python3
+"""
+This file prepares and handles installs of the pokete game.
+
+It prepares the python (sub-)modules in a way that they can be installed via pip.
+"""
+
+import os
+from pathlib import Path
+import shutil
+import sys
+from setuptools import setup
+import subprocess
+
+
+PACKAGE_PATH = Path(__file__).parent / "pokete"
+
+def package_file_to_pokete(file: str) -> None:
+ """Packages a file into the 'pokete' module.
+
+ Receives a filename and then uses this filename to locate the file from the
+ directory structure. It then copies the file into the 'pokete' folder
+ and renames all imports of all other pokete files and modules to submodules
+ of 'pokete'.
+
+ Arguments:
+ ---------
+ - file: The file to package into the module
+
+ Returns:
+ -------
+ None
+ """
+ print(f" Packaging {file} ...")
+ replace_paths = [
+ ("import pokete_data as p_data", "import pokete.pokete_data as p_data"),
+ ("from pokete_data", "from pokete.pokete_data"),
+ ("import pokete_classes", "import pokete.pokete_classes"),
+ ("from pokete_classes", "from pokete.pokete_classes"),
+ ("from pokete_general_use_fns import",
+ "from pokete.pokete_general_use_fns import"),
+ ("from release import", "from pokete.release import"),
+ ("from playsound import", "from pokete.playsound import")
+ ]
+
+ with open(file, 'r') as f:
+ data = f.read()
+
+ for text, replace in replace_paths:
+ data = data.replace(text, replace)
+
+ if file == "pokete.py":
+ data = data.replace('if __name__ == "__main__":', 'if True:')
+
+ with open(Path('pokete') / file, 'w') as f:
+ f.write(data)
+
+
+def compile_playsound():
+ print(" Rebuilding go library...")
+ command = ["go", "build", "-ldflags", "-s -w", "-buildvcs=false", "-buildmode=c-shared", "-o",
+ {
+ sys.platform: "./libplaysound.so",
+ "win32": "./libplaysound.dll",
+ "darwin": "./libplaysound.osx.so"
+ }[sys.platform]
+ ]
+
+ result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=Path(__file__).parent / 'playsound')
+ print(f"Playsound compilation finished with stdout: {result.stdout} / stderr: {result.stderr}")
+
+
+def main():
+ """The main function of the setup process.
+
+ This function prepares the modules directory structure in a way, so that
+ setuptools can easily install pokete:
+
+ 1. Create all needed directories
+ 2. Package the modules 'pokete_data' and 'pokete_classes'
+ 3. Package the python files 'pokete.py', 'pokete_general_use_fns.py' and
+ 'release.py'
+ 4. Creates a '__init__.py' run pokete on module import.
+ 5. Packages some needed assets.
+ 6. Calls 'setup()', which uses 'setuptools' and the 'pyproject.toml' to
+ build the wheel.
+ """
+ for directory in ["pokete_data", "pokete_classes"]:
+ print(f"Processing directory '{directory}'...")
+ os.makedirs(PACKAGE_PATH / directory, exist_ok=True)
+ for file in os.listdir(directory):
+ file = Path(directory) / file
+ if os.path.isfile(file):
+ package_file_to_pokete(file)
+
+ print("Packaging directory 'playsound'...")
+ compile_playsound()
+ os.makedirs(PACKAGE_PATH / "playsound", exist_ok=True)
+ libpath = ("libplaysound." +
+ {
+ sys.platform: "so",
+ "win32": "dll",
+ "darwin": "osx.so"
+ }[sys.platform]
+ )
+ for file in ["__init__.py", libpath]:
+ file = Path("playsound") / file
+ print(f" Packaging '{file}'...")
+ shutil.copyfile(file, PACKAGE_PATH / file)
+
+
+ print("Packaging root file scripts...")
+ for file in ["pokete.py", "pokete_general_use_fns.py", "release.py"]:
+ package_file_to_pokete(file)
+
+ print("Packaging new '__init__.py' file...")
+ with open(PACKAGE_PATH / "__init__.py", 'w') as f:
+ f.write("""def run_pokete():
+ import pokete.pokete
+
+if __name__ == "__main__":
+ run_pokete()
+""")
+
+ print("Packaging assets...")
+ asset_path = Path("assets") / "music"
+ os.makedirs(PACKAGE_PATH / asset_path, exist_ok=True)
+ for file in os.listdir(asset_path):
+ file = asset_path / file
+ if os.path.isfile(file):
+ print(f" Packaging '{file}'...")
+ shutil.copyfile(file, PACKAGE_PATH / file)
+
+
+if __name__ == "__main__":
+ main()
+
+ setup()
+ # For setuptools<61.0 uncomment the following lines instead
+ #setup(
+ # name="pokete",
+ # version="0.8.2",
+ # description="A terminal based Pokemon like game",
+ # author="lxgr-linux",
+ # author_email="lxgr@protonmail.com",
+ # license="GPL-3.0",
+ # packages=["pokete", "pokete.pokete_data", "pokete.pokete_classes", "pokete.playsound", "scrap_engine"],
+ # entry_points={
+ # 'console_scripts': [
+ # 'pokete = pokete:run_pokete'
+ # ]
+ # },
+ # install_requires=[],
+ # package_data={"pokete": ["assets/music/*", "playsound/libplaysound.so"]},
+ # include_package_data=True
+ #)
diff --git a/snap/gui/pokete.desktop b/snap/gui/pokete.desktop
new file mode 100644
index 00000000..42de73e9
--- /dev/null
+++ b/snap/gui/pokete.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Version=1.0
+Type=Application
+Name=Pokete
+Comment=A terminal based Pokemon clone, based on the scrap engine.
+Exec=pokete
+Icon=${SNAP}/meta/gui/icon.svg
+Terminal=true
+StartupNotify=false
+Categories=Game;
diff --git a/snap/gui/pokete.svg b/snap/gui/pokete.svg
new file mode 120000
index 00000000..a141260f
--- /dev/null
+++ b/snap/gui/pokete.svg
@@ -0,0 +1 @@
+../../assets/pokete.svg
\ No newline at end of file
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
new file mode 100644
index 00000000..c2382fb9
--- /dev/null
+++ b/snap/snapcraft.yaml
@@ -0,0 +1,51 @@
+---
+name: "pokete"
+title: "Pokete"
+base: "core22"
+version: "0.8.2"
+summary: "A terminal based Pokemon like game"
+description: |
+ Pokete is a small terminal based game in the style of a very popular and old
+ game by Gamefreak. Imagine you're a Pokete-Trainer and your goal is it to run
+ around in the world and catch/train as many Poketes as possible and to get
+ the best trainer.
+license: "GPL-3.0"
+contact: "mafelp@proton.me"
+icon: "assets/pokete.svg"
+source-code: "https://github.com/lxgr-linux/pokete/"
+website: "https://github.com/lxgr-linux/pokete/"
+type: "app"
+
+grade: "stable"
+confinement: "strict"
+
+architectures:
+ - build-on: ["amd64"]
+
+parts:
+ pokete:
+ plugin: "python"
+ python-packages:
+ - "scrap_engine"
+ source: "."
+ build-packages:
+ - "libasound2-dev"
+ - "libpulse-dev"
+ - "pkg-config"
+ - "golang"
+ stage-packages:
+ - "libasound2"
+
+layout:
+ /usr/share/alsa:
+ bind: "$SNAP/usr/share/alsa"
+ /etc/alsa:
+ bind: "$SNAP/etc/alsa"
+
+apps:
+ pokete:
+ command: "bin/pokete"
+ plugs:
+ - "home" # Stores the save files
+ - "network" # For trading with other players
+ - "audio-playback" # Used to play music
diff --git a/tools/debbuild.sh b/tools/debbuild.sh
new file mode 100755
index 00000000..98878958
--- /dev/null
+++ b/tools/debbuild.sh
@@ -0,0 +1,127 @@
+#!/usr/bin/env bash
+
+set -e
+
+# Change directory to the script directory
+cd "$(dirname $0)/.."
+BUILDDIR=$(pwd)
+
+function heading() {
+ local width=$(tput cols 2> /dev/null)
+ [ -z $width ] && width=50
+
+ local text=$1
+ # prints '#' for a whole line
+ python3 -c "print('#' * ${width})"
+
+ # centers the text
+ python3 -c "print(' ' * ((${width} - ${#text}) // 2), end='')"
+ echo "$text"
+
+ # prints '#' for a whole line
+ python3 -c "print('#' * ${width})"
+}
+
+VERSION=$(python3 -c "print(__import__('release').VERSION)")
+cat << EOF
+ _____ _ _
+ | __ \ | | | |
+ | |__) |__ | | _____| |_ ___
+ | ___/ _ \| |/ / _ \ __/ _ \\
+ | | | (_) | < __/ || __/
+ |_| \___/|_|\_\___|\__\___|
+
+ debian-package builder
+
+Pokete Version: $VERSION
+Project url: https://github.com/lxgr-linux/pokete
+
+This software is licensed under the GPLv3.
+You should have gotten an copy of the GPLv3 license anlonside this software.
+If not, the license text is available at https://www.gnu.org/licenses/gpl-3.0.txt
+
+EOF
+
+if [ "$1" = "-h" -o "$1" = "--help" ];then
+ heading "Help"
+ cat << EOF
+
+Use this script if packaging the debian package.
+It is a complete automated installation process, after the first run.
+This script tries the following things:
+
+ * Installs build dependencies with apt-get
+ * Downloads the latest version of the scrap engine
+ * Builds the source tar ball with python-setuptools
+ * Prepares and builds the actual debian package
+
+A useful routine, when developing this script or the debian package might look
+like this:
+
+ $ git restore pyproject.toml setup.py
+ $ rm -rf build dist pokete pokete.egg-info scrap_engine
+ $ tools/debbuild.sh
+
+If you need more help about this script, please contact
+MaFeLP .
+
+EOF
+fi
+
+if [ -d 'build' ];then
+ heading "ERROR"
+ echo "Please clean and remove the 'build' directory before running this script!"
+ exit 1
+fi
+
+heading "Installing prerequirements..."
+sudo apt-get install -y \
+ build-essential \
+ devscripts \
+ debhelper \
+ debmake \
+ golang \
+ pkg-config \
+ pulseaudio \
+ libasound2-dev \
+ python3-pip \
+ dh-python \
+ python3-all \
+ curl
+
+#heading "Installing python setuptools>=61..."
+#pip3 install 'setuptools>=61'
+
+heading "Preparing pokete build..."
+patch "playsound/__init__.py" < "packages/deb/playsound_lib.patch"
+rm -v playsound/libplaysound*
+python3 -c "__import__('setup').main()"
+cp -v packages/deb/setup.py ./setup.py
+rm -v pyproject.toml
+
+heading "Downloading scrap_engine..."
+mkdir scrap_engine
+curl -o "scrap_engine/__init__.py" "https://raw.githubusercontent.com/lxgr-linux/scrap_engine/master/scrap_engine.py"
+
+heading "Building sdist of pokete with setuptools..."
+python3 setup.py sdist
+
+heading "Preparing debian build environment..."
+
+mkdir build
+mv "dist/pokete-${VERSION}.tar.gz" build
+cd build
+tar xmvf "pokete-${VERSION}.tar.gz"
+cd "pokete-${VERSION}"
+
+heading "Preparing the debian source package..."
+mkdir debian
+cp -vr ../../packages/deb/assets/* .
+debmake -b":python3"
+
+heading "Building actual debian package..."
+debuild -uc
+
+heading "Finished"
+cd "${BUILDDIR}"
+echo "Built debian package at $(pwd)/$(ls build/pokete_${VERSION}-*.deb)"