diff --git a/.editorconfig b/.editorconfig index 24448d86..f98fda1b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -15,6 +15,9 @@ indent_size = 4 tab_width = 4 max_line_length = 80 +[*.xml] +indent_style = tab + [pokete_data/{map_data,npcs}.py] max_line_length = off diff --git a/.gh-pages.json b/.gh-pages.json index a278a459..6e01ef77 100644 --- a/.gh-pages.json +++ b/.gh-pages.json @@ -49,16 +49,16 @@ "convert_with_pandoc": true, "new_name": "DevGuide.html" }, - "gen_wiki.py": { + "util.py": { "type": "documentation" }, "pokete.py": { "type": "documentation" }, - "prepare_pages.py": { + "pokete_general_use_fns.py": { "type": "documentation" }, - "pokete_general_use_fns.py": { + "util/": { "type": "documentation" }, "pokete_classes/": { diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 34c6f559..ebb22d39 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -42,9 +42,9 @@ jobs: - name: Preprocess page files run: | - python3 ./prepare_pages.py before + python3 util.py prepare-pages before cp -r ./assets/ /tmp/assets - cp ./prepare_pages.py /tmp/prepare_pages.py + cp ./* /tmp/pokete - name: Switch branch to gh-pages uses: actions/checkout/@v2 with: @@ -53,7 +53,7 @@ jobs: run: | rm -rf ./assets ./wiki-multi mv '/tmp/assets/' . - python3 /tmp/prepare_pages.py after + python3 /tmp/pokete/util.py prepare-pages after # Push to github_pages - name: Release documentation run: | @@ -98,7 +98,7 @@ jobs: - name: Make multipage wiki run: | - python3 gen_wiki.py verbose single multi pics + python3 util.py wiki --verbose --single --multi --pics mkdir /tmp/gen-wiki cp -r HowToPlay.md DevGuide.md wiki.md /tmp/gen-wiki - name: Switch to wiki repository diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8e7ff676..f958e4cc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,13 +14,13 @@ jobs: steps: - uses: actions/checkout@v2 - + - name: install deps run: pip3 install scrap_engine - name: gen-wiki - run: python3 ./gen_wiki.py - + run: python3 util.py wiki + - name: Commit files run: | git config --local user.name ${{ github.actor }} @@ -30,7 +30,7 @@ jobs: git add ./wiki.md git commit -m "Updated wiki" fi - + - name: Push changes # push the output folder to your repo uses: ad-m/github-push-action@master with: diff --git a/Changelog.md b/Changelog.md index 1ab5c418..7aa0961d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -141,7 +141,8 @@ What changed until this release? - Added multipage wiki - Completely rewrote gen_wiki.py - Reformated, moved, outsourced, chnages a lot of code - Again special thanks to MaFeLP + +Again special thanks to MaFeLP ## [0.5.1] - 2021-09-19 diff --git a/README.md b/README.md index b4ca15ee..11935a3f 100644 --- a/README.md +++ b/README.md @@ -163,8 +163,7 @@ On Windows `pynput` has to be installed too. - [Documentation for pokete_classes](https://lxgr-linux.github.io/pokete/doc/pokete_classes/index.html) - [Documentation for pokete_data](https://lxgr-linux.github.io/pokete/doc/pokete_data/index.html) -- [Documentation for the gen-wiki file](https://lxgr-linux.github.io/pokete/doc/gen_wiki.html "gen_wiki.py") -- [Documentation for the prepare_pages file](https://lxgr-linux.github.io/pokete/doc/prepare_pages.html "prepare_pages.py") +- [Documentation for the util file](https://lxgr-linux.github.io/pokete/doc/util.html) - [Documentation for the pokete_general_use_fns](https://lxgr-linux.github.io/pokete/doc/pokete_general_use_fns.html "pokete_general_use_fns.py") - [Documentation for the main file "pokete.py"](https://lxgr-linux.github.io/pokete/doc/pokete.html "pokete.py") @@ -182,7 +181,7 @@ To learn how to add more poketes/types/attacks to the game, see [the development After adding new Poketes and/or attacks you may want to run ```shell -$ ./gen_wiki.py +$ ./util.py wiki ``` to regenerate the wiki and adding them to it. diff --git a/assets/AppImageBuilder.yml b/assets/AppImageBuilder.yml index 17581adc..97075fcb 100644 --- a/assets/AppImageBuilder.yml +++ b/assets/AppImageBuilder.yml @@ -1,70 +1,53 @@ -# appimage-builder recipe see https://appimage-builder.readthedocs.io for details -version: 1 -script: - - rm -rf AppDir | true - - mkdir -p AppDir/usr/share/icons - - git clone --depth=1 https://github.com/lxgr-linux/pokete AppDir/usr/share/pokete - - git clone --depth=1 https://github.com/lxgr-linux/scrap_engine AppDir/usr/share/scrap_engine - - cp AppDir/usr/share/scrap_engine/scrap_engine.py AppDir/usr/share/pokete/ - - cp AppDir/usr/share/pokete/assets/pokete.svg AppDir/usr/share/icons/pokete.svg - AppDir: - path: AppDir app_info: - id: com.github.lxgr-linux.pokete - name: Pokete - icon: pokete - version: 0.8.0 exec: usr/bin/python3.10 - exec_args: $APPDIR/usr/share/pokete/pokete.py --log $@ - # pacman: - # include: - # - python - # exclude: [] + exec_args: $APPDIR/usr/bin/pokete.py --log $@ + icon: com.github.lxgr_linux.pokete + id: com.github.lxgr_linux.pokete + name: Pokete + version: 0.9.2 apt: arch: amd64 - sources: - - sourceline: 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse' - key_url: 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x871920d1991bc93c' - include: - - python3.10 exclude: - - perl - - gcc-12-base + - perl + - gcc-12-base + include: + - python3.10 + sources: + - key_url: https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x871920d1991bc93c + sourceline: deb [arch=amd64] https://archive.ubuntu.com/ubuntu/ jammy main restricted + universe multiverse files: - include: [] exclude: - - usr/share/man - - usr/share/pokete/bash - - usr/share/pokete/.git - - usr/share/pokete/prepare_pages.py - - usr/share/pokete/gen_wiki.py./ - - usr/share/pokete/*.md - - usr/share/scrap_engine - - usr/share/pokete/playsound/libplaysound.dll - - usr/share/pokete/playsound/libplaysound.osx.so - - usr/share/pokete/assets/ss - - usr/share/pokete/assets/*.png - - usr/share/pokete/assets/*.kra - - usr/share/pokete/assets/*.svg - - usr/share/doc + - pokete + - usr/share/scrap_engine + - usr/share/pokete/playsound/libplaysound.dll + - usr/share/pokete/playsound/libplaysound.osx.so + include: [] + path: AppDir test: - fedora-30: - image: appimagecrafters/tests-env:fedora-30 - command: ./AppRun - debian-stable: - image: appimagecrafters/tests-env:debian-stable - command: ./AppRun archlinux-latest: - image: appimagecrafters/tests-env:archlinux-latest command: ./AppRun + image: appimagecrafters/tests-env:archlinux-latest centos-7: + command: ./AppRun image: appimagecrafters/tests-env:centos-7 + debian-stable: command: ./AppRun + image: appimagecrafters/tests-env:debian-stable + fedora-30: + command: ./AppRun + image: appimagecrafters/tests-env:fedora-30 ubuntu-xenial: - image: appimagecrafters/tests-env:ubuntu-xenial command: ./AppRun + image: appimagecrafters/tests-env:ubuntu-xenial AppImage: arch: x86_64 comp: gzip update-information: guess +script: +- rm -rf AppDir | true +- git clone --depth=1 https://github.com/lxgr-linux/pokete +- git clone --depth=1 https://github.com/lxgr-linux/scrap_engine AppDir/usr/share/scrap_engine +- cd ./pokete && python3.10 ./util.py install AppDir/usr +version: 1 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.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/pokete.desktop b/assets/com.github.lxgr_linux.pokete.desktop similarity index 82% rename from assets/pokete.desktop rename to assets/com.github.lxgr_linux.pokete.desktop index f01bc27b..f3bc02d3 100755 --- a/assets/pokete.desktop +++ b/assets/com.github.lxgr_linux.pokete.desktop @@ -4,7 +4,7 @@ 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 +Icon=com.github.lxgr_linux.pokete Terminal=true StartupNotify=false Categories=Game; diff --git a/assets/pokete.svg b/assets/com.github.lxgr_linux.pokete.svg similarity index 100% rename from assets/pokete.svg rename to assets/com.github.lxgr_linux.pokete.svg diff --git a/assets/pokete.metainfo.xml b/assets/pokete.metainfo.xml index 75cb9a34..1584c2d2 100644 --- a/assets/pokete.metainfo.xml +++ b/assets/pokete.metainfo.xml @@ -1,88 +1,438 @@ - com.github.lxgr_linux.pokete - - lxgr-linux - - MIT - GPL-3.0 - Pokete - A terminal based Pokemon like game - -

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

-
- - Game - - - game - python - pokemon - console-game - - https://github.com/lxgr-linux/pokete/ - https://github.com/lxgr-linux/pokete/issues - - com.github.lxgr_linux.pokete - - com.github.lxgr_linux.pokete.desktop - - - Fight against other poketes - https://lxgr-linux.github.io/pokete/assets/ss/ss01.png - - - Conversation with a trainer on Map Route 2 - https://lxgr-linux.github.io/pokete/assets/ss/ss05.png - - - - - -

Quite a lot of bugs were fixed: Added more documentation. #278: Fixed random dor in flowytown arena. #279: Fixed warnings at startup due to new python versions. #281: Fixed trainer name conflicts

-
- https://github.com/lxgr-linux/pokete/releases/tag/0.9.2 -
- - -

Quite a lot happened until this release: Moved some NPCs out of the way. Fixed a small bug with `gen_wiki.py` on windows. Added new `first evolution` achievement. Added new Poketes (Pavous, Uberpavous, Kartmen, Kakraholt, Bablbam). Volume settings with a funky new volumeslider. A new `--no_audio` commandline option to supress all audio. Stats for Poketes. Infos about the effect an attack has. The complete game is now resizable. Reduced stack traces. This release now requires `scrap_engine` on v1.4.0. Many thanks to @ondrejmyska for your many contributions.

-
- https://github.com/lxgr-linux/pokete/releases/tag/0.9.0 -
- - -

Version 0.8.2 fixes a display bug of the release notes on flatpak. Version 0.8.1 on the other hand brought the following improvements: This version brings a new cross-platform implementation of how the audio is played, written in go. This makes the installation size of pokete significantly smaller, as less dependencies are required. The first map has been reworked, to make it easier for new players to understand the game.

-
- https://github.com/lxgr-linux/pokete/releases/tag/0.8.2 -
- - -

This version brings a new cross-platform implementation of how the audio is played, written in go. This makes the installation size of pokete significantly smaller, as less dependencies are required. The first map has been reworked, to make it easier for new players to understand the game.

-
- https://github.com/lxgr-linux/pokete/releases/tag/0.8.1 -
- - -

We are constantly developing pokete further and with version 0.8.0 added a low of improvements and new features, such as music and sound effects. Running away from wild poketes can now fail and trainers can now have more than one pokete. Controls and hotkeys can now be remapped for different keyboard layouts. The default safe-file location has been moved to .local/share and some minor bugs have been fixed as well!

-
- https://github.com/lxgr-linux/pokete/releases/tag/0.8.0 -
- - -

Preparation release for flatpaks. Includes: A svg image of the pokete logo, A metainfo.xml file for pokete -

-
- https://github.com/lxgr-linux/pokete/releases/tag/0.7.3 -
-
- - mild - mild - intense - moderate - -
- + com.github.lxgr_linux.pokete + + lxgr-linux + + MIT + GPL-3.0 + Pokete + Terminal based Pokemon like game + +

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.

+
+ + Game + + + game + python + pokemon + console-game + + https://github.com/lxgr-linux/pokete/ + https://github.com/lxgr-linux/pokete/issues + + com.github.lxgr_linux.pokete + + com.github.lxgr_linux.pokete.desktop + + + Fight against other poketes + https://lxgr-linux.github.io/pokete/assets/ss/ss01.png + + + Conversation with a trainer on Map Route 2 + https://lxgr-linux.github.io/pokete/assets/ss/ss05.png + + + + + +

Quite a lot of bugs were fixed:

+
    +
  • Added more documentation
  • +
  • #278: Fixed random dor in flowytown arena
  • +
  • #279: Fixed warnings at startup due to new python versions
  • +
  • #281: Fixed trainer name conflicts
  • +
+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.9.2 +
+ + +
    +
  • Fixed a bug with fightmap not resozing
  • +
  • Did some reformating
  • +
+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.9.1 +
+ + +

Quite a lot happened until this release:

+
    +
  • Moved some NPCs out of the way
  • +
  • + Fixed a small bug with + gen_wiki.py + on windows +
  • +
  • + Added new + first evolution + achievement +
  • +
  • Added new Poketes (Pavous, Uberpavous, Kartmen, Kakraholt, Bablbam)
  • +
  • Volume settings with a funky new volumeslider
  • +
  • + A new + --no_audio + commandline option to supress all audio +
  • +
  • Stats for Poketes
  • +
  • Infos about the effect an attack has
  • +
  • The complete game is now resizable
  • +
  • Reduced stack traces
  • +
+

+ This release now requires + scrap_engine + on v1.4.0 +

+

Many thanks to @ondrejmyska for your many contributions.

+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.9.0 +
+ + +

Fixes a small bug in the representation of pokete on flathub.

+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.8.2 +
+ + +

The distribution size was shrinked extremely compared to 0.8.0

+
    +
  • Made all wav files mp3s
  • +
  • Added new audio library and replaced playsound
  • +
  • Reduced the Appimage size
  • +
  • The first map got a bigger overhaul to make an entrance into the game easier
  • +
+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.8.1 +
+ + +
    +
  • Added audio
  • +
  • Removed pynput as a dependency on windows
  • +
  • A lot of spelling and grammar fixes
  • +
  • Fixed Poketes not beeing freeable
  • +
  • Added some game ballancing
  • +
  • Trainers can now obtain more than one Pokete
  • +
  • Made run away random
  • +
  • Added remappable controls
  • +
  • Save location is now based on XDG dirs, no intervention needed
  • +
  • + Added quick attacks using + yzcv + so the attackamenu can be skipped +
  • +
+

Many thanks to everybody who contributed to this release!

+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.8.0 +
+ + +

Preparation release for flatpaks. Includes:

+
    +
  • A svg image of the pokete logo
  • +
  • A metainfo.xml file for pokete
  • +
+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.7.3 +
+ + +

Crucial bugfix related to natures and pokete dex.

+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.7.2 +
+ + +

Just some small bugfixes.

+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.7.1 +
+ + +

Under the hood

+
    +
  • Massive code reorganisation
  • +
  • + Added + PeriodicEventManager + , introducing a centralized approach to handling periodically occurring events +
  • +
  • Enabled pipenv support
  • +
+

Game design and behaviour

+
    +
  • After all Poketes are dead, players are now transported back to the last visited Pokete center
  • +
  • Multiple Poketes in a fight are now automatically possible
  • +
  • NPCs are way smarter now and support multi-answer chats
  • +
  • Added achievements visible via a submenu
  • +
  • Added commandline options
  • +
  • Several new Poketes have been added:
  • +
  • Voglus
  • +
  • Ratatat
  • +
  • Crabbat
  • +
  • Rustacean
  • +
  • Saugh
  • +
  • Corcos day
  • +
  • Corcos night
  • +
  • Raupathor day
  • +
  • Raupathor night
  • +
  • Mothor
  • +
  • Also the maps "Agrawos" and "Sunny Beach" have been added
  • +
  • Weather influencing effectivities has been added
  • +
  • Added notifications
  • +
  • Ingame time was added:
  • +
  • Day and Night active Poketes
  • +
  • A clock
  • +
  • Time stops after a certain period of idling
  • +
  • Treats and the Pokete-Care where added to make leveling easier
  • +
  • The game is now available as an AppImage
  • +
  • The newly added natures now influence a Poketes stats on an individual basis
  • +
+

This article summarises the changes further.

+

Again very special thanks to @MaFeLP for supporting me!

+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.7.0 +
+ + +

What changed until this release?

+
    +
  • Added Diamondos, Dia stab,
  • +
  • Dazzle, Dia spikes
  • +
  • Added Megapois, Poison thorn
  • +
  • Added Dicko, Lil nut
  • +
  • Added Mowcow, Supercow power
  • +
  • Added Wheeto, Special smell
  • +
  • Added Flowy Town, Mowcow Meadow, The Fields of Agrawos
  • +
  • Reformated files
  • +
  • Added Github pages, special thanks to MaFeLP
  • +
  • Added validation action
  • +
  • Made the savefile json
  • +
  • Added subtypes to better organise generic attacks
  • +
  • Added Devguide
  • +
  • Added modloader
  • +
  • Added .editorconfig
  • +
  • Added Pipfile and Pipfile.lock
  • +
  • Overhauled Roadmap
  • +
  • Added multipage wiki
  • +
  • Completely rewrote gen_wiki.py
  • +
  • Reformated, moved, outsourced, chnages a lot of code
  • +
+

Again special thanks to MaFeLP

+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.6.0 +
+ + +

Some minor changes due to API changes in scrap_engine v1.0.0.

+

scrap_engine v1.0.0 is now required.

+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.5.1 +
+ + +

What changed until this release?

+
    +
  • Improve Help
  • +
  • Added CODENAME: Grey Edition
  • +
  • Now unvisited maps names are not displayed in Roadmap anymore
  • +
  • Added question when exiting
  • +
  • Added startuptime to savefile
  • +
  • Added Route 7
  • +
  • Added coloured Minimap
  • +
  • Added Spikes, Bubble gun,
  • +
  • Flame throw, Toe breaker, Wind blow, Storm gust, Rock smash
  • +
  • Added Dicki, Dick energy,
  • +
  • Ground hit, Hiding
  • +
  • Added Schmetterling, Schmetter
  • +
  • Added abbility to learn a new attack very fifth level
  • +
  • Added second type
  • +
  • Added savable attacks
  • +
  • Added Poison Type
  • +
  • Added Learn Discs that can be used to teach new attack to Poketes
  • +
  • Added abilities
  • +
  • Added flying
  • +
  • scrap_engine v0.3.3 is now needed
  • +
+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.5.0 +
+ + +

What changed until this release?

+
    +
  • Added EffectFreezing
  • +
  • Added ice Poketes (Cubl, Spikl) andattacks (freeze, Snow storm, Sword of ice)
  • +
  • Added some more new Poketes (Confuso, Poisopla) andattacks (Confusion, Posion spores, Root slap)
  • +
  • Added shiny Poketes
  • +
  • Outsourced all map information to maps.py
  • +
  • Added version checking to warn about data loss when downgrading
  • +
  • Sorted the Poketes and attacks in the wiki by types
  • +
  • Fixed the effectivity of EffectBurning
  • +
  • Fixed logic bug in most effects, so that some types are not affected by some effects
  • +
  • Added Pokete dex for the user to keep track of all Pokete 'races' they have ever caught regardless of wether or notthe Poketes are in the deck or not
  • +
  • Cleaned up save file to be more readable for humans
  • +
  • Changed development flow
  • +
+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.4.1 +
+ + +

What changed until this release?

+
    +
  • Added confirmation for running away
  • +
  • Made playmap_1 way easier
  • +
  • Changed attack list to start with 1 and not 0
  • +
  • Renamed attacs to attacks
  • +
  • Added several new attacks
  • +
  • Added several new moves (downgrade...)
  • +
  • Added Rock-ville
  • +
  • Added new mechanic that moves movemap to ensure all text fits on movemap
  • +
  • Fixed bug with exclamations out of movemap
  • +
  • Added support for more than one move per attack
  • +
  • Increased attack AP to avoid running back to the Pokete-center as often
  • +
  • Changed roadmap mechanism
  • +
  • Added effects
  • +
  • Added coloured output for OutP (scrap_engine >= v0.3.1 is now needed)
  • +
  • Fixed bug with saving in shops
  • +
  • Fixed bug with moves when confused
  • +
  • Outsourced general-use functions
  • +
  • Made some functions a class
  • +
  • Made some other quality of life changes
  • +
+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.4.0 +
+ + +

What changed until this release?

+
    +
  • Added coloured type tags and attack labels
  • +
  • Added ice type
  • +
  • Added about
  • +
  • Added a now Pokete
  • +
  • Made some minor fixes and changes
  • +
+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.3.8 +
+ + +

What changed until this release?

+
    +
  • Added trading with other players in the same network
  • +
  • Simplified some code
  • +
+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.3.7 +
+ + +

What changed until this release?

+
    +
  • scrap_engine 0.3.0 in now needed
  • +
  • Added initiative attribute for Poketes to determine which Pokete attacks first
  • +
  • Several minor fixed and additions
  • +
+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.3.6 +
+ + +

What changed until this release?

+
    +
  • Compatibility with scrap_engine 0.2.0
  • +
  • Added validation for pokete_data
  • +
  • Added Intro
  • +
+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.3.5 +
+ + +

What changed until this release?

+
    +
  • Added Changelog.md
  • +
  • Added Route 6, bigmountain see and bigmountain cave
  • +
  • Improved wiki.md
  • +
  • Added Wolfiro
  • +
  • Added saving Poketeballs
  • +
  • Added some new attacks
  • +
  • Fixed some bugs
  • +
+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.3.4 +
+ + +

What changed until this release?

+
    +
  • Trainers are now more likely to use effective attacks
  • +
  • Added autosave
  • +
  • Added a proper settings system
  • +
  • Added undead type
  • +
  • Added some new Poketes and attacks
  • +
  • Added HowToPlay.md
  • +
  • Added trainer saving
  • +
  • Added Route 5
  • +
  • Added confirmation texts when doing sensible stuff
  • +
  • Moved some stuff around
  • +
  • Fixed some bugs
  • +
+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.3.3 +
+ + +

What changed until this release?

+
    +
  • Added route 3
  • +
  • Added route 4
  • +
  • Added Deepest forest
  • +
  • minor fixes
  • +
  • Added pics
  • +
  • Fixed some values
  • +
  • Fixed some bugs with trainers
  • +
+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.3.2 +
+ + +

What changed until this release?

+
    +
  • Added Abandoned village
  • +
  • Added clampi
  • +
  • Added more NPCs
  • +
  • Added .desktop (MaFeLP) and logo
  • +
  • Made additions to the item system
  • +
+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.3.1 +
+ + +

This is the first real release of Pokete, because at this point most of the key game mechanics are implemented and most

+

stuff that's still missing is just game content.

+
+ https://github.com/lxgr-linux/pokete/releases/tag/0.3.0 +
+
+ + mild + mild + intense + moderate + + \ No newline at end of file diff --git a/assets/Bildschirmfoto_2021-06-04_09-04-44 (Kopie 1).kra b/assets/pokete.png.kra similarity index 100% rename from assets/Bildschirmfoto_2021-06-04_09-04-44 (Kopie 1).kra rename to assets/pokete.png.kra diff --git a/assets/Bildschirmfoto_2021-06-04_09-04-44.kra b/assets/pokete_old.kra similarity index 100% rename from assets/Bildschirmfoto_2021-06-04_09-04-44.kra rename to assets/pokete_old.kra diff --git a/pokete.py b/pokete.py index c6c8725c..fd647203 100755 --- a/pokete.py +++ b/pokete.py @@ -19,6 +19,7 @@ from datetime import datetime import scrap_engine as se import pokete_data as p_data +import release from pokete_classes import animations from pokete_classes.pokestats import PokeStats from pokete_classes.poke import Poke, upgrade_by_one_lvl @@ -55,10 +56,11 @@ from pokete_classes.dex import Dex from pokete_classes.loops import std_loop from pokete_classes.periodic_event_manager import PeriodicEventManager -from pokete_general_use_fns import liner, sort_vers, parse_args +from util import liner, sort_vers from release import SPEED_OF_TIME from release import VERSION, CODENAME, SAVEPATH +from util.command import RootCommand, Flag __t = time.time() @@ -1477,7 +1479,40 @@ def map_additions(): # Actual code execution ####################### if __name__ == "__main__": - do_logging, load_mods, audio.use_audio = parse_args(sys.argv) + log_flag = Flag(["--log"], "Enables logging") + mods_flag = Flag(["--no_mods"], "Disables mods") + audio_flag = Flag(["--no_audio"], "Disables audio") + + do_logging = False + load_mods = True + audio.use_audio = True + + + def root_fn(ex: str, options: list[str], + flags: dict[str, list[str]]): + global do_logging, load_mods + for flag in flags: + if log_flag.is_flag(flag): + do_logging = True + elif mods_flag.is_flag(flag): + load_mods = False + elif audio_flag.is_flag(flag): + audio.use_audio = False + + + c = RootCommand( + "Pokete", f"{release.CODENAME} v{release.VERSION}", root_fn, + flags=[log_flag, mods_flag, audio_flag], + additional_info=f"""All save and logfiles are located in ~{release.SAVEPATH}/ +Feel free to contribute. +See README.md for more information. +This software is licensed under the GPLv3, you should have gotten a +copy of it alongside this software.""", + usage="" + ) + + c.exec() + # deciding on wich input to use if sys.platform == "win32": import msvcrt diff --git a/pokete_classes/achievements.py b/pokete_classes/achievements.py index 7a02b9a2..fba893ce 100644 --- a/pokete_classes/achievements.py +++ b/pokete_classes/achievements.py @@ -3,7 +3,7 @@ import datetime import logging import scrap_engine as se -from pokete_general_use_fns import liner +from util import liner from .hotkeys import ACTION_DIRECTIONS, Action, get_action from .loops import std_loop, easy_exit_loop from .ui_elements import BetterChooseBox, LabelBox diff --git a/pokete_classes/buy.py b/pokete_classes/buy.py index 494c0423..630e7508 100644 --- a/pokete_classes/buy.py +++ b/pokete_classes/buy.py @@ -2,7 +2,7 @@ import scrap_engine as se from pokete_classes.hotkeys import ACTION_UP_DOWN, Action, get_action -from pokete_general_use_fns import liner +from util import liner from .loops import std_loop from .ui_elements import Box, ChooseBox from .inv_items import invitems diff --git a/pokete_classes/detail.py b/pokete_classes/detail.py index febd85a5..4389e499 100644 --- a/pokete_classes/detail.py +++ b/pokete_classes/detail.py @@ -2,7 +2,7 @@ import scrap_engine as se import pokete_classes.game_map as gm -from pokete_general_use_fns import liner +from util import liner from .hotkeys import Action, get_action from .pokestats import PokeStatsInfoBox from .loops import std_loop diff --git a/pokete_classes/dex.py b/pokete_classes/dex.py index 0504dd12..9e17e1d7 100644 --- a/pokete_classes/dex.py +++ b/pokete_classes/dex.py @@ -4,7 +4,7 @@ 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 util import liner from .loops import std_loop, easy_exit_loop from .poke import Poke from .color import Color diff --git a/pokete_classes/fightmap/attack.py b/pokete_classes/fightmap/attack.py index 4b533131..255026b3 100644 --- a/pokete_classes/fightmap/attack.py +++ b/pokete_classes/fightmap/attack.py @@ -1,7 +1,7 @@ """Contains stuff related to fight attack choosing""" import scrap_engine as se -from pokete_general_use_fns import liner +from util import liner from ..hotkeys import ACTION_UP_DOWN, Action, get_action from ..ui_elements import ChooseBox, LabelBox from ..loops import std_loop diff --git a/pokete_classes/hotkeys.py b/pokete_classes/hotkeys.py index 60a4acf7..2f4885bc 100644 --- a/pokete_classes/hotkeys.py +++ b/pokete_classes/hotkeys.py @@ -3,7 +3,7 @@ import sys from enum import Enum, auto from collections import defaultdict -from pokete_general_use_fns import liner +from util import liner from .event import _ev diff --git a/pokete_classes/input.py b/pokete_classes/input.py index 67ba3765..6e5c714b 100644 --- a/pokete_classes/input.py +++ b/pokete_classes/input.py @@ -1,7 +1,7 @@ """This file contains input wrappers for ui elements""" from pokete_classes.hotkeys import Action, get_action -from pokete_general_use_fns import hard_liner +from util import hard_liner from .loops import std_loop from .ui_elements import InfoBox, InputBox from .event import _ev diff --git a/pokete_classes/learnattack.py b/pokete_classes/learnattack.py index 138de688..bab1c521 100644 --- a/pokete_classes/learnattack.py +++ b/pokete_classes/learnattack.py @@ -3,7 +3,7 @@ import random import scrap_engine as se import pokete_data as p_data -from pokete_general_use_fns import liner +from util import liner from .hotkeys import Action, get_action from .loops import std_loop, easy_exit_loop from .input import ask_bool, ask_ok diff --git a/pokete_classes/movemap.py b/pokete_classes/movemap.py index 6172e991..0a099140 100644 --- a/pokete_classes/movemap.py +++ b/pokete_classes/movemap.py @@ -2,7 +2,7 @@ import time import scrap_engine as se -from pokete_general_use_fns import liner +from util import liner import pokete_classes.ob_maps as obmp import pokete_classes.game_map as gm from release import SPEED_OF_TIME diff --git a/pokete_classes/nature.py b/pokete_classes/nature.py index 11192526..83438068 100644 --- a/pokete_classes/nature.py +++ b/pokete_classes/nature.py @@ -4,7 +4,7 @@ import random import scrap_engine as se import pokete_data as p_data -from pokete_general_use_fns import liner +from util import liner from .hotkeys import Action from .ui_elements import LabelBox from .color import Color diff --git a/pokete_classes/notify.py b/pokete_classes/notify.py index 805c5b2b..751f67f2 100644 --- a/pokete_classes/notify.py +++ b/pokete_classes/notify.py @@ -1,7 +1,7 @@ """Contains classes for notifications""" import scrap_engine as se -from pokete_general_use_fns import liner +from util import liner from .ui_elements import LabelBox from .color import Color from .util.object_group import get_nested diff --git a/pokete_classes/poke.py b/pokete_classes/poke.py index 78dd3233..a3cc7219 100644 --- a/pokete_classes/poke.py +++ b/pokete_classes/poke.py @@ -7,7 +7,7 @@ from datetime import datetime import scrap_engine as se import pokete_data as p_data -from pokete_general_use_fns import liner +from util import liner from release import SPEED_OF_TIME from .attack_actions import AttackActions from .attack import Attack diff --git a/pokete_classes/roadmap.py b/pokete_classes/roadmap.py index a90cc96a..19f1ff58 100644 --- a/pokete_classes/roadmap.py +++ b/pokete_classes/roadmap.py @@ -3,7 +3,7 @@ import pokete_data as p_data import pokete_classes.ob_maps as obmp -from pokete_general_use_fns import liner +from util import liner 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 7925792e..05fcd829 100644 --- a/pokete_classes/side_loops.py +++ b/pokete_classes/side_loops.py @@ -3,7 +3,7 @@ import os import scrap_engine as se import pokete_classes.game_map as gm -from pokete_general_use_fns import liner +from util import liner from .loops import easy_exit_loop from .ui_elements import InfoBox from . import movemap as mvp diff --git a/pokete_general_use_fns.py b/pokete_general_use_fns.py deleted file mode 100644 index b4f084ce..00000000 --- a/pokete_general_use_fns.py +++ /dev/null @@ -1,104 +0,0 @@ -"""General use functions for Pokete""" - -import sys -import release - - -def liner(text, width, pre=""): - """Wraps a string after a certain length and respects word endings - ARGS: - text: The text that should be lined - width: The max width - pre: Prefix that will be added in the next line - RETURNS: - The lined string""" - lens = 0 - out = "" - for name in text.split(" "): - if "\n" in name: - lens = len(pre) - out += name + pre - elif lens+len(name) + 1 <= width: - out += name + " " - lens += len(name) + 1 - else: - lens = len(name) + 1 + len(pre) - out += "\n" + pre + name + " " - return out - - -def hard_liner(l_len, name): - """Wraps a string after a certain length - ARGS: - name: The String - l_len: The max length - RETURNS: - The lined string""" - ret = "" - for i in range(int(len(name) / l_len) + 1): - ret += name[i * l_len:(i + 1) * l_len] + ("\n" - if i != int(len(name) / l_len) - else "") - return ret - - -def sort_vers(vers): - """Sorts versions - ARGS: - vers: List of versions - RETURNS: - Sorted list""" - return [k[-1] for k in - sorted([([int(j) for j in i.split(".")], i) for i in vers])] - - -def print_help(path): - """Shows help message - ARGS: - path: The game's path""" - print(f"""Pokete {release.CODENAME} v{release.VERSION} -Usage: {path} () -Options: - --log : Enables logging - --help : Shows this help - --no_mods : Disables mods - --no_audio : Disables - -Homepage: https://github.com/lxgr-linux/pokete - -All save and logfiles are located in ~{release.SAVEPATH}/ -Feel free to contribute. -See README.md for more information. -This software is licensed under the GPLv3, you should have gotten a -copy of it alongside this software. -Copyright (c) lxgr-linux 2022""") - - -def parse_args(args): - """Parses command line args - ARGS: - args: Arguments given to the game - RETURNS: - Tuple of do_logging, load_mods and use_audio""" - do_logging = False - load_mods = True - use_audio = True - for arg in args[1:]: - if arg == "--log": - do_logging = True - elif arg == "--no_mods": - load_mods = False - elif arg == "--no_audio": - use_audio = False - elif arg == "--help": - print_help(args[0]) - sys.exit(0) - else: - print(f":: Error: '{arg}' is not a valid option! See '--help' for \ -options.") - sys.exit(1) - return do_logging, load_mods, use_audio - - -if __name__ == "__main__": - print("\033[31;1mDo not execute this!\033[0m") diff --git a/util.py b/util.py new file mode 100755 index 00000000..446bd3ee --- /dev/null +++ b/util.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 + +from util import gen_wiki, prepare_after, prepare_before, make_release, \ + install, wiki +from util.command import RootCommand, Command, not_enough_args, not_found + + +def fallback(ex: str, options: list[str], + flags: dict[str, list[str]]): + if not options: + not_enough_args(ex) + not_found(ex, options[0]) + + +def main(): + c = RootCommand( + "util", + "Pokete utility", + fallback, + commands=[ + Command( + "install", "Install pokete to a given directory", install, + usage="[dest]" + ), + Command( + "prepare-pages", "Prepares github pages", fallback, + commands=[ + Command("before", "Actions run pre branch switch", + prepare_before), + Command("after", "Actions run post branch switch", + prepare_after) + ] + ), + Command( + "release", "Prepare all relevant files for release", + make_release, + additional_info="Tags have to follow the `vMAJOR.MINOR.PATCH-RELEASE` semantic.", + usage="[tag]" + ), + Command( + "wiki", "Generate a markdown wiki", gen_wiki, flags=[ + wiki.silent_flag, wiki.quiet_flag, wiki.verbose_flag, + wiki.single_flag, wiki.multi_flag, wiki.pics_flag + ] + ) + ] + ) + + c.exec() + + +if __name__ == "__main__": + main() diff --git a/util/__init__.py b/util/__init__.py new file mode 100644 index 00000000..243fde78 --- /dev/null +++ b/util/__init__.py @@ -0,0 +1,6 @@ +from .wiki import gen as gen_wiki +from .pages import prepare_after, prepare_before +from .release import main as make_release +from .install import install +from .liner import liner, hard_liner +from .versions import sort_vers diff --git a/util/command/__init__.py b/util/command/__init__.py new file mode 100644 index 00000000..91526918 --- /dev/null +++ b/util/command/__init__.py @@ -0,0 +1,2 @@ +from .command import Command, RootCommand, Flag +from .helpers import not_enough_args, not_found diff --git a/util/command/command.py b/util/command/command.py new file mode 100644 index 00000000..825f576a --- /dev/null +++ b/util/command/command.py @@ -0,0 +1,94 @@ +import sys + +from .parse import parse + + +class Flag: + def __init__(self, aliases: list[str], desc: str): + self.aliases = aliases + self.desc = desc + + def is_flag(self, flag: str): + return flag in self.aliases + + +class Command: + def __init__( + self, + name: str, desc: str, + fn, + flags: list[Flag] | None = None, + commands: list["Command"] | None = None, + additional_info: str = "", + usage="[command] [options]..." + ): + self.name = name + self.desc = desc + self.fn = fn + self.flags = (flags if flags is not None else []) + [ + Flag(["-h", "--help"], "Shows help for a specific command")] + self.additional_info = additional_info + self.commands = commands if commands is not None else [] + self.usage = usage + + @staticmethod + def __line_setter(lines: list[tuple[str, str]], line_spaces: int): + return "\n".join( + f"\t{line[0]}{" " * (line_spaces - len(line[0]))}{line[1]}" for line + in lines + ) + + def __print_help(self, ex: str): + option_lines: list[tuple[str, str]] = [(command.name, command.desc) for + command in self.commands] + flag_lines: list[tuple[str, str]] = [ + ("|".join(flag.aliases), flag.desc) for flag in self.flags] + + line_spaces = sorted([ + len(i[0]) for i in option_lines + flag_lines + ])[-1] + 8 + + print(f"""{self.name} -- {self.desc} + +Usage: + {ex}{f" {self.usage}" if self.usage else ""} +{f""" +Options: +{self.__line_setter(option_lines, line_spaces)} +""" if self.commands else ""} +{f""" +Flags: +{self.__line_setter(flag_lines, line_spaces)} +""" if self.flags else ""} +{f"\n{self.additional_info}\n" if self.additional_info else ""} +Copyright (c) lxgr-linux 2024""") + + def run(self, ex: str, options: list[str], + flags: dict[str, list[str]]): + if options: + for c in self.commands: + if c.name == options[0]: + c.run(f"{ex} {options[0]}", + options[1:], + flags) + return + all_flags = [i for f in self.flags for i in f.aliases] + for flag in flags: + if flag not in all_flags: + print( + f":: Error: Unknown flag `{flag}`, " + f"try `{ex} --help`" + ) + sys.exit(2) + if "--help" in flags or "-h" in flags: + self.__print_help(ex) + sys.exit(0) + else: + self.fn(ex, options, flags) + + +class RootCommand(Command): + def exec(self): + args = sys.argv + options, flags = parse(args) + self.run(args[0], options, flags) diff --git a/util/command/helpers.py b/util/command/helpers.py new file mode 100644 index 00000000..7f673cc8 --- /dev/null +++ b/util/command/helpers.py @@ -0,0 +1,17 @@ +import sys + + +def not_found(ex, option): + print( + f":: Error: Command '{option}' not found, " + f"try `{ex} --help`" + ) + sys.exit(2) + + +def not_enough_args(ex): + print( + ":: Error: Not enough arguments, " + f"try `{ex} --help`" + ) + sys.exit(2) diff --git a/util/command/parse.py b/util/command/parse.py new file mode 100644 index 00000000..92eeeb02 --- /dev/null +++ b/util/command/parse.py @@ -0,0 +1,28 @@ +def parse(args) -> tuple[list[str], dict[str, list[str]]]: + if len(args) == 1: + return [], {} + options: list[str] = [] + flags: dict[str, list[str]] = {} + idx = 0 + for arg in args[1:]: + if arg.startswith("--"): + break + idx += 1 + options.append(arg) + __index_flags(0, args[1 + idx:], "", flags) + + return options, flags + + +def __index_flags( + idx: int, arr: list[str], flag: str, + flags: dict[str, list[str]] +): + if idx == len(arr): + return + if arr[idx].startswith("--"): + flag = arr[idx] + flags[flag] = flags.get(flag, []) + else: + flags[flag].append(arr[idx]) + __index_flags(idx + 1, arr, flag, flags) diff --git a/util/install.py b/util/install.py new file mode 100644 index 00000000..3755f049 --- /dev/null +++ b/util/install.py @@ -0,0 +1,15 @@ +import os +import sys + + +def install(ex: str, options: list[str], + flags: dict[str, list[str]]): + if len(options) == 0: + print( + ":: Error: Not enough arguments, a destination has to be given, " + f"try `{ex} {options} --help`" + ) + sys.exit(2) + else: + dest = options[0] + print(os.popen(f'sh -c "./util/install.sh {dest}"').read()) diff --git a/util/install.sh b/util/install.sh new file mode 100755 index 00000000..4712c40d --- /dev/null +++ b/util/install.sh @@ -0,0 +1,13 @@ +dest=$1 +app_id="com.github.lxgr_linux.pokete" + +install -Dv "assets/$app_id.desktop" "$dest/share/applications/$app_id.desktop" +install -Dvm644 "assets/$app_id.svg" "$dest/share/icons/hicolor/scalable/apps/$app_id.svg" +install -Dv assets/pokete.metainfo.xml "$dest/share/metainfo/$app_id.metainfo.xml" +install -Dv LICENSE "$dest/share/licenses/$app_id/LICENSE" +install -dv "$dest/bin/" +find . | grep -E "\.py$|\.so$|\.mp3$" | while read file +do + install -Dv "$file" "$dest/share/pokete/$file" +done +ln -s "../share/pokete/pokete.py" "$dest/bin/" diff --git a/util/liner.py b/util/liner.py new file mode 100644 index 00000000..2934472a --- /dev/null +++ b/util/liner.py @@ -0,0 +1,36 @@ +def liner(text, width, pre=""): + """Wraps a string after a certain length and respects word endings + ARGS: + text: The text that should be lined + width: The max width + pre: Prefix that will be added in the next line + RETURNS: + The lined string""" + lens = 0 + out = "" + for name in text.split(" "): + if "\n" in name: + lens = len(pre) + out += name + pre + elif lens + len(name) + 1 <= width: + out += name + " " + lens += len(name) + 1 + else: + lens = len(name) + 1 + len(pre) + out += "\n" + pre + name + " " + return out + + +def hard_liner(l_len, name): + """Wraps a string after a certain length + ARGS: + name: The String + l_len: The max length + RETURNS: + The lined string""" + ret = "" + for i in range(int(len(name) / l_len) + 1): + ret += name[i * l_len:(i + 1) * l_len] + ("\n" + if i != int(len(name) / l_len) + else "") + return ret diff --git a/prepare_pages.py b/util/pages.py similarity index 87% rename from prepare_pages.py rename to util/pages.py index e23064e4..98bccd91 100644 --- a/prepare_pages.py +++ b/util/pages.py @@ -1,7 +1,4 @@ -#!/usr/bin/env python """ -Prepare pages prepares all files in "files" for GitHub Pages - This script takes one argument, which specifies if the actions it should take are before the command "git switch gh-pages" or afterwards. "before" means that it will the pre-change actions and "after" the after-change actions. @@ -13,26 +10,14 @@ Afterwards this script will replace all the links specified in the list "replace_links". There the first argument of the Tuple specifies the old link and the second argument the new link. With "new_name" the file will be renamed on the website. - -Usage: ------ -- python3 prepare_pages.py before - - Invokes actions before the branch switch -- python3 prepare_pages.py after - - Invokes actions after the branch switch - -Exit Codes: ----------- -- 0: Everything is OK. -- 1: An internal error occurred -- 2: The user did not specify the right/enough arguments """ import os from os.path import exists -import sys import json from urllib import request +from util.wiki import Wiki + """ The files dictionary specifies how and which files should be processed. @@ -80,7 +65,8 @@ def replace_tables(_text: str) -> str: in_table = False with open('/tmp/pandoc_convert.md', 'w') as _f: _f.write(table) - os.system('pandoc /tmp/pandoc_convert.md -o /tmp/pandoc_convert.html') + os.system( + 'pandoc /tmp/pandoc_convert.md -o /tmp/pandoc_convert.html') with open('/tmp/pandoc_convert.html', 'r') as _f: md_text = _f.read() table = '' @@ -140,7 +126,8 @@ def create_documentation() -> None: for module in modules: print(f" -> {module}") - os.system(f"{pdoc_path} --html {module} --output-dir \"/tmp/doc/\" --force") + os.system( + f"{pdoc_path} --html {module} --output-dir \"/tmp/doc/\" --force") def add_folder(folder: str, add_tmp_folder: bool = False) -> None: @@ -172,7 +159,6 @@ def create_wiki() -> None: This function calls the multi-page and single-page methods from the gen_wiki file to add to the gh-pages. """ - from gen_wiki import Wiki Wiki.multi("./wiki-multi-md/") Wiki.single("./wiki-single.md") @@ -197,7 +183,8 @@ def add_wiki_folder(folder_name: str) -> list: for item in items: file = os.path.join(folder_name, item) if os.path.isdir(file): - add_folder(file.replace("./wiki-multi-md/", "./wiki-multi-html/"), True) + add_folder(file.replace("./wiki-multi-md/", "./wiki-multi-html/"), + True) for f in add_wiki_folder(file): out.append(f) elif os.path.isfile(file): @@ -224,14 +211,15 @@ def add_wiki_to_files() -> None: print(wiki_files) for wiki_file in wiki_files: files.update({ - wiki_file: { - "type": "page", - "replace_tables": False, - "convert_with_pandoc": True, - "replace_links": [], - "new_name": str(wiki_file.replace(".md", ".html")).replace("./wiki-multi-md/", "./wiki-multi-html/") - } - }) + wiki_file: { + "type": "page", + "replace_tables": False, + "convert_with_pandoc": True, + "replace_links": [], + "new_name": str(wiki_file.replace(".md", ".html")).replace( + "./wiki-multi-md/", "./wiki-multi-html/") + } + }) print(files) @@ -252,10 +240,12 @@ def before() -> None: print(f"==> Preparing {file}") properties = files[file] - if properties["type"] == "documentation" or properties["type"] == "folder": + if properties["type"] == "documentation" or properties[ + "type"] == "folder": continue - new_name = properties["new_name"] if properties["new_name"] is not None else file + new_name = properties["new_name"] if properties[ + "new_name"] is not None else file # Jekyll can not handle double open/closing brackets (e.g. {{) , so we # need to manually convert these pages. @@ -263,7 +253,8 @@ def before() -> None: # root page to the start and the end of the if properties["convert_with_pandoc"]: print(" -> Converting to html...") - os.system(f"pandoc --from gfm --to html5 -o \"{new_name}\" \"{file}\"") + os.system( + f"pandoc --from gfm --to html5 -o \"{new_name}\" \"{file}\"") # Tables only need to be replaced, if the file is not converted with # pandoc, as pandoc is converting the tables automatically. @@ -345,7 +336,8 @@ def after() -> None: elif properties["type"] == "folder": continue - new_name = properties["new_name"] if properties["new_name"] is not None else file + new_name = properties["new_name"] if properties[ + "new_name"] is not None else file print(f'==> After processing {new_name}') # If a file was converted with pandoc, it needs the stylesheet @@ -378,18 +370,19 @@ def after() -> None: print(':: Done!') -if __name__ == '__main__': - if len(sys.argv) == 1: - print('Error! Not enough arguments:') - print(f"Usage: '{sys.argv[0]}' ") - sys.exit(2) - if sys.argv[1] == 'before': - with open('.gh-pages.json', 'r') as config_file: - files = json.loads(config_file.read()) - before() - elif 'after' == sys.argv[1]: - after() - else: - print('Error! Unrecognised first argument:') - print(f"Usage: '{sys.argv[0]}' ") - sys.exit(2) +def prepare_before( + ex: str, options: list[str], + flags: dict[str, list[str]] +): + global files + with open('.gh-pages.json', 'r') as config_file: + files = json.loads(config_file.read()) + before() + + +def prepare_after( + ex: str, options: list[str], + flags: dict[str, list[str]] +): + global files + after() diff --git a/util/release/__init__.py b/util/release/__init__.py new file mode 100644 index 00000000..9a560ca2 --- /dev/null +++ b/util/release/__init__.py @@ -0,0 +1,39 @@ +import re +import sys + +from .changelog import write_changelog +from .appimage import write_appimage +from .release_py import write_release_py +from ..command import not_enough_args + +TAG_REGEX = r"^v([0-9]+)\.([0-9]+)\.([0-9]+)(-[0-9A-Za-z-]+)?$" + + +def __release(tag: str): + print(":: Writing appstream data...") + write_changelog(tag) + print(":: Writing appimage builder file...") + write_appimage(tag) + print(":: Writing release.py...") + write_release_py(tag) + + +def __is_tag_valid(tag: str) -> bool: + return re.fullmatch(TAG_REGEX, tag) is not None + + +def main( + ex: str, options: list[str], + flags: dict[str, list[str]] +): + if len(options) == 0: + not_enough_args(ex) + else: + tag = options[0] + if not __is_tag_valid(tag): + print( + ":: Error: Invalid tag, " + f"try `{ex} --help`" + ) + sys.exit(2) + __release(tag) diff --git a/util/release/appimage.py b/util/release/appimage.py new file mode 100644 index 00000000..10353cb3 --- /dev/null +++ b/util/release/appimage.py @@ -0,0 +1,13 @@ +import yaml + +FILE = "assets/AppImageBuilder.yml" + + +def write_appimage(tag: str): + with open(FILE, 'r') as f: + content = yaml.safe_load(f) + + content["AppDir"]["app_info"]["version"] = tag.lstrip("v") + + with open(FILE, 'w') as f: + yaml.dump(content, f) diff --git a/util/release/changelog.py b/util/release/changelog.py new file mode 100644 index 00000000..38df20ed --- /dev/null +++ b/util/release/changelog.py @@ -0,0 +1,154 @@ +import re +import xml.dom.minidom + +RawRelease = tuple[str, list[str]] +RawReleases = list[RawRelease] + +LIST_STARTERS = ("- ", "+ ") + + +def __get_raw_releases(content) -> RawReleases: + raw_releases: RawReleases = [] + for line in content.split("\n"): + if line.startswith("## "): + raw_releases.append((line, [])) + elif len(raw_releases) != 0: + raw_releases[-1][1].append(line) + return raw_releases + + +def __parse_line(line: str, idx=0, in_code_block=False, illegal_link="") -> str: + if idx == len(line): + return "" + this_segment = "" + segment = line[idx] + if segment == "`": + if in_code_block: + this_segment += "" + in_code_block = False + else: + this_segment += "" + in_code_block = True + elif segment == "[": + illegal_link += segment + elif illegal_link: + if segment == ")" and "]" in illegal_link: + this_segment += illegal_link.split("[")[1].split("]")[0] + illegal_link = "" + elif segment != "(" and illegal_link[-1] == "]": + this_segment += illegal_link + illegal_link = "" + else: + illegal_link += segment + else: + this_segment += segment + + return (this_segment + __parse_line( + line, idx + 1, in_code_block, illegal_link + )).replace("", "") + + +def __parse_markup( + lines: list[str], idx: int = 0, ul_depth: int = 0, + curr_ul_sep="", curr_line_depth=0 +) -> str: + if idx == len(lines): + return "" + parsed_line = "" + line = lines[idx].lstrip() + line_depth = len(lines[idx]) - len(line) + if line.startswith(LIST_STARTERS): + ul_sep = line[0:2] + if curr_ul_sep == "": + curr_ul_sep = ul_sep + ul_depth += 1 + parsed_line += "
    " + '''if ul_sep != curr_ul_sep: + curr_ul_sep = ul_sep + if line_depth >= curr_line_depth: + ul_depth += 1 + parsed_line += "
      " + else: + ul_depth -= 1 + parsed_line += "
    " + # Since Appstream does not support nested lists ind their standart, this is left out + ''' + parsed_line += f"
  • {__parse_line(line.lstrip(ul_sep))}
  • " + elif line_depth == curr_line_depth + 2 and curr_ul_sep != "": + parsed_line += f"{__parse_line(line)}" + else: + line = line.lstrip("#") + if ul_depth != 0: + parsed_line += "
" * ul_depth + ul_depth = 0 + curr_ul_sep = "" + if line.strip() != "": + parsed_line += f"

{__parse_line(line)}

" + + return ( + parsed_line + + __parse_markup( + lines, idx + 1, ul_depth, + curr_ul_sep, line_depth + ) + ).replace("", "") + + +def __parse_version_date(heading: str) -> tuple[str, str]: + heading = heading.strip("##").strip() + version_sub, date = heading.split(" - ") + + return version_sub.split("[")[1].split("]")[0].strip(), date.strip() + + +def __parse_release_xml(release: tuple[str, list[str]]) -> str: + version, date = __parse_version_date(release[0]) + + markup = __parse_markup(release[1]) + + urgency = "medium" if version.endswith(".0") else "low" + + return f""" + + {markup} + + https://github.com/lxgr-linux/pokete/releases/tag/{version} +""" + + +def __get_full_releases(releases: list[str]): + return f""" + {"\n".join(releases)} +""" + + +def check_versions(tag: str, raw_releases: RawReleases): + all_versions = [__parse_version_date(release[0])[0] + for release in raw_releases] + if tag.lstrip("v") not in all_versions: + print(f":: Warning: release tag `{tag}` has no changelog entry!") + + +def write_changelog(tag: str): + with open("Changelog.md", "r") as changelog_file: + changelog_content = changelog_file.read() + raw_releases = __get_raw_releases(changelog_content) + check_versions(tag, raw_releases) + releases = [__parse_release_xml(r) for r in raw_releases] + full_releases = __get_full_releases(releases) + with open("assets/pokete.metainfo.xml", "r") as metainfo_file: + content = metainfo_file.read() + new_content = re.sub(r'.*?', full_releases, + content, flags=re.DOTALL) + with open("assets/pokete.metainfo.xml", "w") as metainfo_file: + metainfo_file.write( + "\n".join( + line for line in xml.dom.minidom.parseString( + new_content.replace("\n", "") + ) + .toprettyxml(encoding="UTF-8") + .decode("UTF-8") + .split("\n") + if line.strip() + ) + ) diff --git a/util/release/release_py.py b/util/release/release_py.py new file mode 100644 index 00000000..03967d07 --- /dev/null +++ b/util/release/release_py.py @@ -0,0 +1,11 @@ +def write_release_py(tag: str): + with open("release.py", "r") as f: + content = f.readlines() + + for idx, line in enumerate(content): + if line.startswith('VERSION = "'): + content[idx] = f'VERSION = "{tag.lstrip("v")}"\n' + break + + with open("release.py", "w") as f: + f.writelines(content) diff --git a/util/versions.py b/util/versions.py new file mode 100644 index 00000000..9fa7f6bc --- /dev/null +++ b/util/versions.py @@ -0,0 +1,8 @@ +def sort_vers(vers): + """Sorts versions + ARGS: + vers: List of versions + RETURNS: + Sorted list""" + return [k[-1] for k in + sorted([([int(j) for j in i.split(".")], i) for i in vers])] diff --git a/gen_wiki.py b/util/wiki.py similarity index 93% rename from gen_wiki.py rename to util/wiki.py index 4a1e037f..5c867e2b 100755 --- a/gen_wiki.py +++ b/util/wiki.py @@ -7,6 +7,7 @@ import release from pokete_classes.effects import effects, effect_list from pokete_data import pokes, attacks, types, items, maps +from util.command import Flag SILENT = False QUIET = False @@ -28,9 +29,9 @@ def start() -> str: # Pokete Wiki This wiki/documentation is a compilation of all Poketes, attacks, and types present in the Pokete game. -The wiki can be generated using ```$ ./gen_wiki.py```. +The wiki can be generated using ```$ ./util.py wiki```. -Use ```$ ./gen_wiki.py help``` to get more information about different wikis. +Use ```$ ./util.py wiki --help``` to get more information about different wikis. You can find different versions of this wiki: @@ -591,51 +592,34 @@ def gen_pics(): file.write(md_str) -if __name__ == "__main__": - if len(sys.argv) == 1: +def gen(ex: str, options: list[str], + flags: dict[str, list[str]]): + global SILENT, QUIET, VERBOSE + if len(flags) == 0: SILENT, QUIET, VERBOSE = False, True, False Wiki.single() gen_pics() else: - for arg in sys.argv[1:]: - if arg.lower() in ["silent", "quite", "verbose"]: - SILENT, QUIET, VERBOSE = False, False, False - if arg.lower() == "silent": - SILENT = True - elif arg.lower() == "quite": - QUIET = True - else: - VERBOSE = True - elif arg.lower() == "single": + for flag in flags: + if silent_flag.is_flag(flag): + SILENT, QUIET, VERBOSE = True, False, False + elif quiet_flag.is_flag(flag): + SILENT, QUIET, VERBOSE = False, True, False + elif silent_flag.is_flag(flag): + SILENT, QUIET, VERBOSE = False, False, True + elif single_flag.is_flag(flag): Wiki.single() - elif arg.lower() == "multi": + elif multi_flag.is_flag(flag): Wiki.multi("wiki") - elif arg.lower() == "pics": + elif pics_flag.is_flag(flag): gen_pics() - else: - print(f"""gen_wiki.py: - -Usage: ------- -{sys.argv[0]} OPTION1 (OPTION2 OPTION3 ...) - -Options: --------- -silent:\t\tPrints no statements at all -quite:\t\tPrints only some minimal statements -verbose:\tPrints everything that it's doing -single:\t\tGenerated the `wiki.md` as a single file -multi:\t\tGenerates a folder `wiki` with the wiki files -\t\t(Warning: Links are for html pages, not markdown pages!) -pics:\t\tGenerates the `assets/pics.md` file with all sample pictures - -Examples: ---------- -- {sys.argv[0]} silent single verbose multi -\t`-> Creates wiki.md silently and the multi-wiki verbosely -- {sys.argv[0]} quite single multi pics -\t`-> Creates wiki.md, the multi-page wiki and pics.md quitely - -Copyright (c) lxgr-linux 2021""") - if arg.lower() not in ["-h", "--help", "help"]: - sys.exit(2) + + +silent_flag = Flag(["--silent"], "Prints no statements at all") +quiet_flag = Flag(["--quiet"], "Prints only some minimal statements") +verbose_flag = Flag(["--verbose"], "Prints everything it's doing") +single_flag = Flag(["--single"], "Generates the `wiki.md` as a single file") +multi_flag = Flag(["--multi"], + "Generates a folder `wiki` with the wiki files") +pics_flag = Flag(["--pics"], + "Generates the `assets/pics.md` file with all sample pictures") diff --git a/wiki.md b/wiki.md index a7abfead..78e4142b 100644 --- a/wiki.md +++ b/wiki.md @@ -2,9 +2,9 @@ v0.9.2 # Pokete Wiki This wiki/documentation is a compilation of all Poketes, attacks, and types present in the Pokete game. -The wiki can be generated using ```$ ./gen_wiki.py```. +The wiki can be generated using ```$ ./util.py wiki```. -Use ```$ ./gen_wiki.py help``` to get more information about different wikis. +Use ```$ ./util.py wiki --help``` to get more information about different wikis. You can find different versions of this wiki: