commit f3e79af444f0d5e24ab0d45f77b38d4c61848983 Author: Waylon S. Walker Date: Mon May 15 11:37:32 2023 -0500 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..19e0f43 --- /dev/null +++ b/.gitignore @@ -0,0 +1,961 @@ +# Created by https://www.toptal.com/developers/gitignore/api/vim,node,data,emacs,python,pycharm,executable,sublimetext,visualstudio,visualstudiocode +# Edit at https://www.toptal.com/developers/gitignore?templates=vim,node,data,emacs,python,pycharm,executable,sublimetext,visualstudio,visualstudiocode + +### Data ### +*.csv +*.dat +*.efx +*.gbr +*.key +*.pps +*.ppt +*.pptx +*.sdf +*.tax2010 +*.vcf +*.xml + +### Emacs ### +# -*- mode: gitignore; -*- +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +*.elc +auto-save-list +tramp +.\#* + +# Org-mode +.org-id-locations +*_archive + +# flymake-mode +*_flymake.* + +# eshell files +/eshell/history +/eshell/lastdir + +# elpa packages +/elpa/ + +# reftex files +*.rel + +# AUCTeX auto folder +/auto/ + +# cask packages +.cask/ +dist/ + +# Flycheck +flycheck_*.el + +# server auth directory +/server/ + +# projectiles files +.projectile + +# directory configuration +.dir-locals.el + +# network security +/network-security.data + + +### Executable ### +*.app +*.bat +*.cgi +*.com +*.exe +*.gadget +*.jar +*.pif +*.vb +*.wsf + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +### Node Patch ### +# Serverless Webpack directories +.webpack/ + +# Optional stylelint cache + +# SvelteKit build / generate output +.svelte-kit + +### PyCharm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### PyCharm Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij +.idea/**/azureSettings.xml + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +### Python Patch ### +# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration +poetry.toml + +# ruff +.ruff_cache/ + +### SublimeText ### +# Cache files for Sublime Text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# Workspace files are user-specific +*.sublime-workspace + +# Project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using Sublime Text +# *.sublime-project + +# SFTP configuration file +sftp-config.json +sftp-config-alt*.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +### VisualStudio ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +*.code-workspace + +# Local History for Visual Studio Code + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml + +### VisualStudio Patch ### +# Additional files built by Visual Studio + +# End of https://www.toptal.com/developers/gitignore/api/vim,node,data,emacs,python,pycharm,executable,sublimetext,visualstudio,visualstudiocode diff --git a/.marvin-sw-text-adventure-copier-answers.yml b/.marvin-sw-text-adventure-copier-answers.yml new file mode 100644 index 0000000..91bf14b --- /dev/null +++ b/.marvin-sw-text-adventure-copier-answers.yml @@ -0,0 +1,11 @@ +# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY +_commit: 992464f +_src_path: /home/waylon/git/pytool-template +author_github: waylonwalker +author_name: Waylon Walker +description: A text adventure game using @askmarvinai +package_name: marvin-sw-text-adventure +package_title: Marvin Star Wars Text Adventure +package_title_input: Marvin Star Wars Text Adventure +python_package: marvin_sw_text_adventure + diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..eb014a6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.0 + +init diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..9cde24d --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2023-present Waylon S. Walker + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2e7ad39 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# Marvin Star Wars Text Adventure + +A text adventure game using @askmarvinai + +## Installation + +```console +pip install git+https://github.com/waylonwalker/marvin-sw-text-adventure.git +# or +pipx install git+https://github.com/waylonwalker/marvin-sw-text-adventure.git +``` + +## Run + +run the game + +```console +sw-adventure game run +``` + +## License + +`marvin-sw-text-adventure` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license. diff --git a/marvin_sw_text_adventure/__about__.py b/marvin_sw_text_adventure/__about__.py new file mode 100644 index 0000000..90da1db --- /dev/null +++ b/marvin_sw_text_adventure/__about__.py @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2023-present Waylon S. Walker +# +# SPDX-License-Identifier: MIT +__version__ = "0.0.0.dev1" diff --git a/marvin_sw_text_adventure/__init__.py b/marvin_sw_text_adventure/__init__.py new file mode 100644 index 0000000..2a9f0e4 --- /dev/null +++ b/marvin_sw_text_adventure/__init__.py @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: 2023-present Waylon S. Walker +# +# SPDX-License-Identifier: MIT diff --git a/marvin_sw_text_adventure/__main__.py b/marvin_sw_text_adventure/__main__.py new file mode 100644 index 0000000..3a253e6 --- /dev/null +++ b/marvin_sw_text_adventure/__main__.py @@ -0,0 +1,9 @@ +# SPDX-FileCopyrightText: 2023-present Waylon S. Walker +# +# SPDX-License-Identifier: MIT +import sys + +if __name__ == '__main__': + from .cli import marvin_sw_text_adventure.game import game + + sys.exit(game()) diff --git a/marvin_sw_text_adventure/cli/__init__.py b/marvin_sw_text_adventure/cli/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/marvin_sw_text_adventure/cli/app.py b/marvin_sw_text_adventure/cli/app.py new file mode 100644 index 0000000..4ad14d6 --- /dev/null +++ b/marvin_sw_text_adventure/cli/app.py @@ -0,0 +1,55 @@ +import typer + +from marvin_sw_text_adventure.cli.common import verbose_callback +from marvin_sw_text_adventure.console import console +from marvin_sw_text_adventure.cli.game import game_app +# from marvin_sw_text_adventure.cli.config import config_app +# from marvin_sw_text_adventure.cli.tui import tui_app + +app = typer.Typer( + name="marvin_sw_text_adventure", + help="a text adventure game leveraging @askmarvinai", +) +app.add_typer(game_app) +# app.add_typer(config_app) +# app.add_typer(tui_app) + + +def version_callback(value: bool) -> None: + """Callback function to print the version of the marvin-sw-text-adventure package. + + Args: + value (bool): Boolean value to determine if the version should be printed. + + Raises: + typer.Exit: If the value is True, the version will be printed and the program will exit. + + Example: + version_callback(True) + """ + if value: + from marvin_sw_text_adventure.__about__ import __version__ + + typer.echo(f"{__version__}") + raise typer.Exit() + + +@app.callback() +def main( + version: bool = typer.Option( + None, + "--version", + callback=version_callback, + is_eager=True, + ), + verbose: bool = typer.Option( + False, + callback=verbose_callback, + help="show the log messages", + ), +) -> None: + return + + +if __name__ == "__main__": + typer.run(main) diff --git a/marvin_sw_text_adventure/cli/common.py b/marvin_sw_text_adventure/cli/common.py new file mode 100644 index 0000000..984d336 --- /dev/null +++ b/marvin_sw_text_adventure/cli/common.py @@ -0,0 +1,6 @@ +from marvin_sw_text_adventure.console import console + + +def verbose_callback(value: bool) -> None: + if value: + console.quiet = False diff --git a/marvin_sw_text_adventure/cli/config.py b/marvin_sw_text_adventure/cli/config.py new file mode 100644 index 0000000..9da413d --- /dev/null +++ b/marvin_sw_text_adventure/cli/config.py @@ -0,0 +1,29 @@ +from rich.console import Console +import typer + +from marvin_sw_text_adventure.cli.common import verbose_callback +from marvin_sw_text_adventure.config import config as configuration + +config_app = typer.Typer() + + +@config_app.callback() +def config( + verbose: bool = typer.Option( + False, + callback=verbose_callback, + help="show the log messages", + ), +): + "configuration cli" + + +@config_app.command() +def show( + verbose: bool = typer.Option( + False, + callback=verbose_callback, + help="show the log messages", + ), +): + Console().print(configuration) diff --git a/marvin_sw_text_adventure/cli/game.py b/marvin_sw_text_adventure/cli/game.py new file mode 100644 index 0000000..3c82ec9 --- /dev/null +++ b/marvin_sw_text_adventure/cli/game.py @@ -0,0 +1,31 @@ +from rich.console import Console +import typer + +from marvin_sw_text_adventure.cli.common import verbose_callback +from marvin_sw_text_adventure.game import game as game_run + +game_app = typer.Typer() + + +@game_app.callback() +def game( + verbose: bool = typer.Option( + False, + callback=verbose_callback, + help="show the log messages", + ), +): + "game cli" + + +@game_app.command() +def run( + verbose: bool = typer.Option( + False, + callback=verbose_callback, + help="show the log messages", + ), +): + from marvin_sw_text_adventure.console import console + console.log("Starting game") + game_run() diff --git a/marvin_sw_text_adventure/cli/tui.py b/marvin_sw_text_adventure/cli/tui.py new file mode 100644 index 0000000..e78c643 --- /dev/null +++ b/marvin_sw_text_adventure/cli/tui.py @@ -0,0 +1,18 @@ +import typer + +from marvin_sw_text_adventure.cli.common import verbose_callback +from marvin_sw_text_adventure.tui.app import run_app + +tui_app = typer.Typer() + + +@tui_app.callback(invoke_without_command=True) +def i( + verbose: bool = typer.Option( + False, + callback=verbose_callback, + help="show the log messages", + ), +): + "interactive tui" + run_app() diff --git a/marvin_sw_text_adventure/config.py b/marvin_sw_text_adventure/config.py new file mode 100644 index 0000000..07a49c3 --- /dev/null +++ b/marvin_sw_text_adventure/config.py @@ -0,0 +1,3 @@ +from marvin_sw_text_adventure.standard_config import load + +config = load("marvin_sw_text_adventure") diff --git a/marvin_sw_text_adventure/console.py b/marvin_sw_text_adventure/console.py new file mode 100644 index 0000000..a9463af --- /dev/null +++ b/marvin_sw_text_adventure/console.py @@ -0,0 +1,3 @@ +from rich.console import Console + +console = Console() diff --git a/marvin_sw_text_adventure/game.py b/marvin_sw_text_adventure/game.py new file mode 100644 index 0000000..faf292c --- /dev/null +++ b/marvin_sw_text_adventure/game.py @@ -0,0 +1,147 @@ +from marvin import ai_fn + +import pydantic +from pydantic import Field +from typing import List, Tuple +from rich.prompt import Prompt + +from marvin_sw_text_adventure.console import console + + +@ai_fn +def get_star_wars_character() -> str: + "return a brand new never before heard of star wars character" + + +@ai_fn +def create_backstory(name: str) -> str: + "create a backstory for a character" + + +class Mission(pydantic.BaseModel): + name: str = Field(..., description='The name of a brand new never before heard of star wars mission') + place: str = Field(..., description='The place of the mission') + leader: str = Field(..., description='The name of the leader of the mission') + year: int = Field(..., description='The year of the mission') + description: str = Field( + ..., description='The description of the brand new never before heard of star wars mission') + risk: int = Field(..., + description='The risk of the mission in health the character will loose') + reward: int = Field(..., + description='The reward of the mission in imperial credits') + image_prompt: str = Field(..., + description='An ai image generator prompt of the mission') + + +class MissionResult(pydantic.BaseModel): + success: bool = Field(..., description='The success of the mission') + imperial_credits_spent: int = Field(..., + description='The imperial credits spent on the mission') + imperial_credits_earned: int = Field(..., + description='The imperial credits earned on the mission') + health_lost: int = Field(..., description='The health lost on the mission') + health_gained: int = Field(..., description='The health gained on the mission') + story: str = Field(..., description='The story of the mission') + image_prompt: str = Field(..., + description='An ai image generator prompt of the mission') + fuel_used: int = Field(..., description='The fuel used on the mission') + + +class Ship(pydantic.BaseModel): + name: str = Field(..., description='The name of the ship') + ship_type: str = Field(..., description='The type of the ship') + year_built: int = Field(..., description='The year built of the ship') + capacity: int = Field(..., description='The capacity of the ship') + fuel_type: str = Field(..., description='The fuel type of the ship') + fuel_level: int = Field(..., description='The fuel level of the ship') + image_prompt: str = Field(..., + description='An ai image generator prompt of the mission') + + +class StarWarsCharacter(pydantic.BaseModel): + name: str = Field(..., + description='The name of a brand new never before heard of star wars character') + imperial_credits: int = Field(..., + description='The imperial credits of the character') + health: int = Field(..., description='The health of the character') + home_planet: str = Field(..., + description='The name of the planet where the character was born') + age: int = Field(..., description='The age of the character') + birth_year_bby: int = Field(..., description='The birth year of the character') + backstory: str = Field(..., description='The backstory of the character') + ship: Ship = Field(..., + description='The name of the ship where the character operates') + side: str = Field(..., description='The side of the character') + city: str = Field(..., description='The name of the city where the character lives') + friends: List[str] = Field(..., + description='The names of the friends of the character') + team: str = Field(..., + description='The name of the team that the character belongs to') + enemies: List[str] = Field(..., + description='The names of the enemies of the character') + mission: Mission = Field(..., description='The current mission of the character') + role: str = Field(..., description='The role of the character') + image_prompt: str = Field(..., + description='An ai image generator prompt of the mission') + previous_missions: List[Tuple[Mission, MissionResult]] = Field( + [], description='The previous missions of the character') + + +@ai_fn +def did_complete_mission(character: StarWarsCharacter, action: str) -> MissionResult: + "check if a character completed the mission or if they failed" + + +@ai_fn +def get_next_mission(character: StarWarsCharacter, action: str, last_mission_success: bool) -> Mission: + """given a character, their action and the last mission success, return the next mission""" + + +@ai_fn +def create_character() -> StarWarsCharacter: + "create a new character" + + +def game(): + console.print('generating your character') + + prompt = Prompt() + + character = create_character() + console.print(character) + + while character.health > 0 and character.imperial_credits > 0 and character.ship.fuel_level > 0: + console.print('Your character status is'.center(50, '-')) + console.print(f'health: {character.health}') + console.print(f'imperial credits: {character.imperial_credits}') + console.print(f'fuel level: {character.ship.fuel_level}') + console.print() + console.print('Your current mission is'.center(50, '-')) + console.print(character.mission) + action = prompt.ask('What would you like to do? ') + result = did_complete_mission(character, action) + character.previous_missions.append((character.mission, result)) + character.imperial_credits -= result.imperial_credits_spent + character.imperial_credits += result.imperial_credits_earned + character.health -= result.health_lost + character.health += result.health_gained + character.ship.fuel_level -= result.fuel_used + console.print() + console.print('Your mission has been completed') + console.print(result.story) + console.print(f'You earned {result.imperial_credits_earned} imperial credits') + console.print(f'You spent {result.imperial_credits_spent} imperial credits') + console.print(f'You gained {result.health_gained} health') + console.print(f'You lost {result.health_lost} health') + character.mission = get_next_mission(character, action, result.success) + + if character.health <= 0: + console.print('You are dead') + if character.imperial_credits <= 0: + console.print('You lost all your imperial credits') + if character.ship.fuel_level <= 0: + console.print('You lost all your fuel') + + +if __name__ == '__main__': + game() diff --git a/marvin_sw_text_adventure/standard_config.py b/marvin_sw_text_adventure/standard_config.py new file mode 100644 index 0000000..0f99499 --- /dev/null +++ b/marvin_sw_text_adventure/standard_config.py @@ -0,0 +1,239 @@ +"""Standard Config. +A module to load tooling config from a users project space. + +Inspired from frustrations that some tools have a tool.ini, .tool.ini, +setup.cfg, or pyproject.toml. Some allow for global configs, some don't. Some +properly follow the users home directory, others end up in a weird temp +directory. Windows home directory is only more confusing. Some will even +respect the users `$XDG_HOME` directory. + + +This file is for any project that can be configured in plain text such as `ini` +or `toml` and not requiring a .py file. Just name your tool and let users put +config where it makes sense to them, no need to figure out resolution order. + +## Usage: + +``` python +from standard_config import load + +# Retrieve any overrides from the user +overrides = {'setting': True} +config = load('my_tool', overrides) +``` + +## Resolution Order + +* First global file with a tool key +* First local file with a tool key +* Environment variables prefixed with `TOOL` +* Overrides + +### Tool Specific Ini files + +Ini file formats must include a `` key. + +``` ini +[my_tool] +setting = True +``` + +### pyproject.toml + +Toml files must include a `tool.` key + +``` toml +[tool.my_tool] +setting = True +``` + +### setup.cfg + +setup.cfg files must include a `tool:` key + +``` ini +[tool:my_tool] +setting = True +``` + + +### global files to consider + +* /tool.ini +* /.tool +* /.tool.ini +* /.config/tool.ini +* /.config/.tool +* /.config/.tool.ini + +### local files to consider + +* /tool.ini +* /.tool +* /.tool.ini +* /pyproject.toml +* /setup.cfg + +""" + +import os +from pathlib import Path +from typing import Dict, List, Union + +import anyconfig + +# path_spec_type = List[Dict[str, Union[Path, str, List[str\}\}\}\} +path_spec_type = List + + +def _get_global_path_specs(tool: str) -> path_spec_type: + """ + Generate a list of standard pathspecs for global config files. + + Args: + tool (str): name of the tool to configure + """ + try: + home = Path(os.environ["XDG_HOME"]) + except KeyError: + home = Path.home() + + return [ + {"path_specs": home / f"{tool}.ini", "ac_parser": "ini", "keys": [tool]}, + {"path_specs": home / f".{tool}", "ac_parser": "ini", "keys": [tool]}, + {"path_specs": home / f".{tool}.ini", "ac_parser": "ini", "keys": [tool]}, + { + "path_specs": home / ".config" / f"{tool}.ini", + "ac_parser": "ini", + "keys": [tool], + }, + { + "path_specs": home / ".config" / f".{tool}", + "ac_parser": "ini", + "keys": [tool], + }, + { + "path_specs": home / ".config" / f".{tool}.ini", + "ac_parser": "ini", + "keys": [tool], + }, + ] + + +def _get_local_path_specs(tool: str, project_home: Union[str, Path]) -> path_spec_type: + """ + Generate a list of standard pathspecs for local, project directory config files. + + Args: + tool (str): name of the tool to configure + """ + return [ + { + "path_specs": Path(project_home) / f"{tool}.ini", + "ac_parser": "ini", + "keys": [tool], + }, + { + "path_specs": Path(project_home) / f".{tool}", + "ac_parser": "ini", + "keys": [tool], + }, + { + "path_specs": Path(project_home) / f".{tool}.ini", + "ac_parser": "ini", + "keys": [tool], + }, + { + "path_specs": Path(project_home) / f"{tool}.yml", + "ac_parser": "yaml", + "keys": [tool], + }, + { + "path_specs": Path(project_home) / f".{tool}.yml", + "ac_parser": "yaml", + "keys": [tool], + }, + { + "path_specs": Path(project_home) / f"{tool}.toml", + "ac_parser": "toml", + "keys": [tool], + }, + { + "path_specs": Path(project_home) / f".{tool}.toml", + "ac_parser": "toml", + "keys": [tool], + }, + { + "path_specs": Path(project_home) / "pyproject.toml", + "ac_parser": "toml", + "keys": ["tool", tool], + }, + { + "path_specs": Path(project_home) / "setup.cfg", + "ac_parser": "ini", + "keys": [f"tool.{tool}"], + }, + ] + + +def _get_attrs(attrs: list, config: Dict) -> Dict: + """Get nested config data from a list of keys. + + specifically written for pyproject.toml which needs to get `tool` then `` + """ + for attr in attrs: + config = config[attr] + return config + + +def _load_files(config_path_specs: path_spec_type) -> Dict: + """Use anyconfig to load config files stopping at the first one that exists. + + config_path_specs (list): a list of pathspecs and keys to load + """ + for file in config_path_specs: + if file["path_specs"].exists(): + config = anyconfig.load(**file) + else: + # ignore missing files + continue + + try: + return _get_attrs(file["keys"], config) + except KeyError: + # ignore incorrect keys + continue + + return {} + + +def _load_env(tool: str) -> Dict: + """Load config from environment variables. + + Args: + tool (str): name of the tool to configure + """ + vars = [var for var in os.environ.keys() if var.startswith(tool.upper())] + return { + var.lower().strip(tool.lower()).strip("_").strip("-"): os.environ[var] + for var in vars + } + + +def load(tool: str, project_home: Union[Path, str] = ".", overrides: Dict = {}) -> Dict: + """Load tool config from standard config files. + + Resolution Order + + * First global file with a tool key + * First local file with a tool key + * Environment variables prefixed with `TOOL` + * Overrides + + Args: + tool (str): name of the tool to configure + """ + global_config = _load_files(_get_global_path_specs(tool)) + local_config = _load_files(_get_local_path_specs(tool, project_home)) + env_config = _load_env(tool) + return {**global_config, **local_config, **env_config, **overrides} diff --git a/marvin_sw_text_adventure/tui/app.css b/marvin_sw_text_adventure/tui/app.css new file mode 100644 index 0000000..7ed9fce --- /dev/null +++ b/marvin_sw_text_adventure/tui/app.css @@ -0,0 +1,18 @@ +Screen { + align: center middle; + layers: main footer; +} + +Sidebar { + height: 100vh; + width: auto; + min-width: 20; + background: $secondary-background-darken-2; + dock: left; + margin-right: 1; + layer: main; +} + +Footer { + layer: footer; +} diff --git a/marvin_sw_text_adventure/tui/app.py b/marvin_sw_text_adventure/tui/app.py new file mode 100644 index 0000000..adb54af --- /dev/null +++ b/marvin_sw_text_adventure/tui/app.py @@ -0,0 +1,62 @@ +from pathlib import Path + +from textual.app import App, ComposeResult +from textual.containers import Container +from textual.css.query import NoMatches +from textual.widgets import Footer, Static + +from marvin_sw_text_adventure.config import config + +config["tui"] = {} +config["tui"]["bindings"] = {} + + +class Sidebar(Static): + def compose(self) -> ComposeResult: + yield Container( + Static("sidebar"), + id="sidebar", + ) + + +class Tui(App): + """A Textual app to manage requests.""" + + CSS_PATH = Path("__file__").parent / "app.css" + BINDINGS = [tuple(b.values()) for b in config["tui"]["bindings"]] + + def compose(self) -> ComposeResult: + """Create child widgets for the app.""" + yield Container(Static("hello world")) + yield Footer() + + def action_toggle_dark(self) -> None: + """An action to toggle dark mode.""" + self.dark = not self.dark + + def action_toggle_sidebar(self): + try: + self.query_one("PromptSidebar").remove() + except NoMatches: + self.mount(Sidebar()) + + +def run_app(): + import os + import sys + + from textual.features import parse_features + + dev = "--dev" in sys.argv + features = set(parse_features(os.environ.get("TEXTUAL", ""))) + if dev: + features.add("debug") + features.add("devtools") + + os.environ["TEXTUAL"] = ",".join(sorted(features)) + app = Tui() + app.run() + + +if __name__ == "__main__": + run_app() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3201e89 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,161 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "marvin-sw-text-adventure" +description = 'A text adventure game using @askmarvinai' +readme = "README.md" +requires-python = ">=3.7" +license = "MIT" +keywords = [] +authors = [ + { name = "Waylon S. Walker", email = "waylon@waylonwalker.com" }, +] +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", +] +dependencies = [ + "rich", + "textual", + "typer", + "anyconfig", + "marvin", +] +dynamic = ["version"] + +[project.urls] +Documentation = "https://github.com/waylonwalker/marvin-sw-text-adventure#readme" +Issues = "https://github.com/waylonwalker/marvin-sw-text-adventure/issues" +Source = "https://github.com/waylonwalker/marvin-sw-text-adventure" +Changelog = "https://github.com/waylonwalker/marvin-sw-text-adventure" + +[project.scripts] +marvin-sw-text-adventure = "marvin_sw_text_adventure.cli.app:app" +sw-adventure = "marvin_sw_text_adventure.cli.app:app" + +[tool.hatch.version] +path = "marvin_sw_text_adventure/__about__.py" + +[tool.hatch.envs.default] +dependencies = [ + "ipython", + "mypy", + "pyflyby", + "pytest", + "pytest-cov", + "pytest-mock", + "pytest-rich", + "ruff", + "black", +] +[tool.hatch.envs.default.scripts] +test = "coverage run -m pytest" +cov = "coverage-rich" +lint = "ruff marvin_sw_text_adventure" +format = "black marvin_sw_text_adventure" +format-check = "black --check marvin_sw_text_adventure" +build-docs = "markata build" +lint-test = [ + "lint", + "format-check", + "test", + "cov", +] +test-lint = "lint-test" + +[[tool.hatch.envs.test.matrix]] +python = ["37", "38", "39", "310", "311"] + +[tool.coverage.run] +branch = true +parallel = true +omit = [ + "marvin_sw_text_adventure/__about__.py", +] + +[tool.coverage.report] +exclude_lines = [ + "no cov", + "if __name__ == .__main__.:", + "if TYPE_CHECKING:", +] + +[tool.pytest.ini_options] +addopts = "-ra -q --rich" +asyncio_mode = "auto" +testpaths = ["tests"] + +[tool.coverage_rich] +fail-under=80 + +[tool.ruff] + +ignore = ["E501"] +target-version = "py37" + +[tool.ruff.per-file-ignores] +'tests/**/*.py' = ['S101'] + + +select = [ +"F", # Pyflakes +"E", # Error +"W", # Warning +"C90", # mccabe +"I", # isort +"N", # pep8-naming +# "D", # pydocstyle +"UP", # pyupgrade +"YTT", # flake8-2020 +"ANN", # flake8-annotations +"S", # flake8-bandit +"BLE", # flake8-blind-except +"FBT", # flake8-boolean-trap +"B", # flake8-bugbear +"A", # flake8-builtins +"COM", # flake8-commas +"C4", # flake8-comprehensions +"DTZ", # flake8-datetimez +"T10", # flake8-debugger +"DJ", # flake8-django +"EM", # flake8-errmsg +"EXE", # flake8-executable +"ISC", # flake8-implicit-str-concat +"ICN", # flake8-import-conventions +"G", # flake8-logging-format +"INP", # flake8-no-pep420 +"PIE", # flake8-pie +"T20", # flake8-print +"PYI", # flake8-pyi +"PT", # flake8-pytest-style +"Q", # flake8-quotes +"RSE", # flake8-raise +"RET", # flake8-return +"SLF", # flake8-self +"SIM", # flake8-simplify +"TID", # flake8-tidy-imports +"TCH", # flake8-type-checking +# "INT", # flake8-gettext +"ARG", # flake8-unused-arguments +"PTH", # flake8-use-pathlib +"ERA", # eradicate +"PD", # pandas-vet +"PGH", # pygrep-hooks +"PL", # Pylint +"PLC", # Convention +"PLE", # Error +"PLR", # Refactor +"PLW", # Warning +"TRY", # tryceratops +"NPY", # NumPy-specific rules +"RUF", # Ruff-specific rules +] diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..2a9f0e4 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: 2023-present Waylon S. Walker +# +# SPDX-License-Identifier: MIT