diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..15cfe2d2a Binary files /dev/null and b/.DS_Store differ diff --git a/.vscode/settings.json b/.vscode/settings.json index 33fe63f7c..b40952230 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,5 @@ { - "python.linting.flake8Enabled": true, - "python.linting.enabled": true + "python.linting.flake8Enabled": false, + "python.linting.enabled": true, + "python.linting.mypyEnabled": true } \ No newline at end of file diff --git a/first_venv/.DS_Store b/first_venv/.DS_Store new file mode 100644 index 000000000..78c05bc0d Binary files /dev/null and b/first_venv/.DS_Store differ diff --git a/first_venv/bin/Activate.ps1 b/first_venv/bin/Activate.ps1 new file mode 100644 index 000000000..2fb3852c3 --- /dev/null +++ b/first_venv/bin/Activate.ps1 @@ -0,0 +1,241 @@ +<# +.Synopsis +Activate a Python virtual environment for the current PowerShell session. + +.Description +Pushes the python executable for a virtual environment to the front of the +$Env:PATH environment variable and sets the prompt to signify that you are +in a Python virtual environment. Makes use of the command line switches as +well as the `pyvenv.cfg` file values present in the virtual environment. + +.Parameter VenvDir +Path to the directory that contains the virtual environment to activate. The +default value for this is the parent of the directory that the Activate.ps1 +script is located within. + +.Parameter Prompt +The prompt prefix to display when this virtual environment is activated. By +default, this prompt is the name of the virtual environment folder (VenvDir) +surrounded by parentheses and followed by a single space (ie. '(.venv) '). + +.Example +Activate.ps1 +Activates the Python virtual environment that contains the Activate.ps1 script. + +.Example +Activate.ps1 -Verbose +Activates the Python virtual environment that contains the Activate.ps1 script, +and shows extra information about the activation as it executes. + +.Example +Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv +Activates the Python virtual environment located in the specified location. + +.Example +Activate.ps1 -Prompt "MyPython" +Activates the Python virtual environment that contains the Activate.ps1 script, +and prefixes the current prompt with the specified string (surrounded in +parentheses) while the virtual environment is active. + +.Notes +On Windows, it may be required to enable this Activate.ps1 script by setting the +execution policy for the user. You can do this by issuing the following PowerShell +command: + +PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser + +For more information on Execution Policies: +https://go.microsoft.com/fwlink/?LinkID=135170 + +#> +Param( + [Parameter(Mandatory = $false)] + [String] + $VenvDir, + [Parameter(Mandatory = $false)] + [String] + $Prompt +) + +<# Function declarations --------------------------------------------------- #> + +<# +.Synopsis +Remove all shell session elements added by the Activate script, including the +addition of the virtual environment's Python executable from the beginning of +the PATH variable. + +.Parameter NonDestructive +If present, do not remove this function from the global namespace for the +session. + +#> +function global:deactivate ([switch]$NonDestructive) { + # Revert to original values + + # The prior prompt: + if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) { + Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt + Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT + } + + # The prior PYTHONHOME: + if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) { + Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME + Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME + } + + # The prior PATH: + if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) { + Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH + Remove-Item -Path Env:_OLD_VIRTUAL_PATH + } + + # Just remove the VIRTUAL_ENV altogether: + if (Test-Path -Path Env:VIRTUAL_ENV) { + Remove-Item -Path env:VIRTUAL_ENV + } + + # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether: + if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) { + Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force + } + + # Leave deactivate function in the global namespace if requested: + if (-not $NonDestructive) { + Remove-Item -Path function:deactivate + } +} + +<# +.Description +Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the +given folder, and returns them in a map. + +For each line in the pyvenv.cfg file, if that line can be parsed into exactly +two strings separated by `=` (with any amount of whitespace surrounding the =) +then it is considered a `key = value` line. The left hand string is the key, +the right hand is the value. + +If the value starts with a `'` or a `"` then the first and last character is +stripped from the value before being captured. + +.Parameter ConfigDir +Path to the directory that contains the `pyvenv.cfg` file. +#> +function Get-PyVenvConfig( + [String] + $ConfigDir +) { + Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg" + + # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue). + $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue + + # An empty map will be returned if no config file is found. + $pyvenvConfig = @{ } + + if ($pyvenvConfigPath) { + + Write-Verbose "File exists, parse `key = value` lines" + $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath + + $pyvenvConfigContent | ForEach-Object { + $keyval = $PSItem -split "\s*=\s*", 2 + if ($keyval[0] -and $keyval[1]) { + $val = $keyval[1] + + # Remove extraneous quotations around a string value. + if ("'""".Contains($val.Substring(0, 1))) { + $val = $val.Substring(1, $val.Length - 2) + } + + $pyvenvConfig[$keyval[0]] = $val + Write-Verbose "Adding Key: '$($keyval[0])'='$val'" + } + } + } + return $pyvenvConfig +} + + +<# Begin Activate script --------------------------------------------------- #> + +# Determine the containing directory of this script +$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition +$VenvExecDir = Get-Item -Path $VenvExecPath + +Write-Verbose "Activation script is located in path: '$VenvExecPath'" +Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)" +Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)" + +# Set values required in priority: CmdLine, ConfigFile, Default +# First, get the location of the virtual environment, it might not be +# VenvExecDir if specified on the command line. +if ($VenvDir) { + Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values" +} +else { + Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir." + $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/") + Write-Verbose "VenvDir=$VenvDir" +} + +# Next, read the `pyvenv.cfg` file to determine any required value such +# as `prompt`. +$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir + +# Next, set the prompt from the command line, or the config file, or +# just use the name of the virtual environment folder. +if ($Prompt) { + Write-Verbose "Prompt specified as argument, using '$Prompt'" +} +else { + Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value" + if ($pyvenvCfg -and $pyvenvCfg['prompt']) { + Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'" + $Prompt = $pyvenvCfg['prompt']; + } + else { + Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virutal environment)" + Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'" + $Prompt = Split-Path -Path $venvDir -Leaf + } +} + +Write-Verbose "Prompt = '$Prompt'" +Write-Verbose "VenvDir='$VenvDir'" + +# Deactivate any currently active virtual environment, but leave the +# deactivate function in place. +deactivate -nondestructive + +# Now set the environment variable VIRTUAL_ENV, used by many tools to determine +# that there is an activated venv. +$env:VIRTUAL_ENV = $VenvDir + +if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) { + + Write-Verbose "Setting prompt to '$Prompt'" + + # Set the prompt to include the env name + # Make sure _OLD_VIRTUAL_PROMPT is global + function global:_OLD_VIRTUAL_PROMPT { "" } + Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT + New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt + + function global:prompt { + Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) " + _OLD_VIRTUAL_PROMPT + } +} + +# Clear PYTHONHOME +if (Test-Path -Path Env:PYTHONHOME) { + Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME + Remove-Item -Path Env:PYTHONHOME +} + +# Add the venv to the PATH +Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH +$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH" diff --git a/first_venv/bin/activate b/first_venv/bin/activate new file mode 100644 index 000000000..af59b6d25 --- /dev/null +++ b/first_venv/bin/activate @@ -0,0 +1,66 @@ +# This file must be used with "source bin/activate" *from bash* +# you cannot run it directly + +deactivate () { + # reset old environment variables + if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then + PATH="${_OLD_VIRTUAL_PATH:-}" + export PATH + unset _OLD_VIRTUAL_PATH + fi + if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then + PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}" + export PYTHONHOME + unset _OLD_VIRTUAL_PYTHONHOME + fi + + # This should detect bash and zsh, which have a hash command that must + # be called to get it to forget past commands. Without forgetting + # past commands the $PATH changes we made may not be respected + if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then + hash -r 2> /dev/null + fi + + if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then + PS1="${_OLD_VIRTUAL_PS1:-}" + export PS1 + unset _OLD_VIRTUAL_PS1 + fi + + unset VIRTUAL_ENV + if [ ! "${1:-}" = "nondestructive" ] ; then + # Self destruct! + unset -f deactivate + fi +} + +# unset irrelevant variables +deactivate nondestructive + +VIRTUAL_ENV="/Users/svetlanafadeeva/Dev/character_creation_module/first_venv" +export VIRTUAL_ENV + +_OLD_VIRTUAL_PATH="$PATH" +PATH="$VIRTUAL_ENV/bin:$PATH" +export PATH + +# unset PYTHONHOME if set +# this will fail if PYTHONHOME is set to the empty string (which is bad anyway) +# could use `if (set -u; : $PYTHONHOME) ;` in bash +if [ -n "${PYTHONHOME:-}" ] ; then + _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}" + unset PYTHONHOME +fi + +if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then + _OLD_VIRTUAL_PS1="${PS1:-}" + PS1="(first_venv) ${PS1:-}" + export PS1 +fi + +# This should detect bash and zsh, which have a hash command that must +# be called to get it to forget past commands. Without forgetting +# past commands the $PATH changes we made may not be respected +if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then + hash -r 2> /dev/null +fi diff --git a/first_venv/bin/activate.csh b/first_venv/bin/activate.csh new file mode 100644 index 000000000..926568b1d --- /dev/null +++ b/first_venv/bin/activate.csh @@ -0,0 +1,25 @@ +# This file must be used with "source bin/activate.csh" *from csh*. +# You cannot run it directly. +# Created by Davide Di Blasi . +# Ported to Python 3.3 venv by Andrew Svetlov + +alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate' + +# Unset irrelevant variables. +deactivate nondestructive + +setenv VIRTUAL_ENV "/Users/svetlanafadeeva/Dev/character_creation_module/first_venv" + +set _OLD_VIRTUAL_PATH="$PATH" +setenv PATH "$VIRTUAL_ENV/bin:$PATH" + + +set _OLD_VIRTUAL_PROMPT="$prompt" + +if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then + set prompt = "(first_venv) $prompt" +endif + +alias pydoc python -m pydoc + +rehash diff --git a/first_venv/bin/activate.fish b/first_venv/bin/activate.fish new file mode 100644 index 000000000..ab9c4e6a8 --- /dev/null +++ b/first_venv/bin/activate.fish @@ -0,0 +1,64 @@ +# This file must be used with "source /bin/activate.fish" *from fish* +# (https://fishshell.com/); you cannot run it directly. + +function deactivate -d "Exit virtual environment and return to normal shell environment" + # reset old environment variables + if test -n "$_OLD_VIRTUAL_PATH" + set -gx PATH $_OLD_VIRTUAL_PATH + set -e _OLD_VIRTUAL_PATH + end + if test -n "$_OLD_VIRTUAL_PYTHONHOME" + set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME + set -e _OLD_VIRTUAL_PYTHONHOME + end + + if test -n "$_OLD_FISH_PROMPT_OVERRIDE" + functions -e fish_prompt + set -e _OLD_FISH_PROMPT_OVERRIDE + functions -c _old_fish_prompt fish_prompt + functions -e _old_fish_prompt + end + + set -e VIRTUAL_ENV + if test "$argv[1]" != "nondestructive" + # Self-destruct! + functions -e deactivate + end +end + +# Unset irrelevant variables. +deactivate nondestructive + +set -gx VIRTUAL_ENV "/Users/svetlanafadeeva/Dev/character_creation_module/first_venv" + +set -gx _OLD_VIRTUAL_PATH $PATH +set -gx PATH "$VIRTUAL_ENV/bin" $PATH + +# Unset PYTHONHOME if set. +if set -q PYTHONHOME + set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME + set -e PYTHONHOME +end + +if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" + # fish uses a function instead of an env var to generate the prompt. + + # Save the current fish_prompt function as the function _old_fish_prompt. + functions -c fish_prompt _old_fish_prompt + + # With the original prompt function renamed, we can override with our own. + function fish_prompt + # Save the return status of the last command. + set -l old_status $status + + # Output the venv prompt; color taken from the blue of the Python logo. + printf "%s%s%s" (set_color 4B8BBE) "(first_venv) " (set_color normal) + + # Restore the return status of the previous command. + echo "exit $old_status" | . + # Output the original/"old" prompt. + _old_fish_prompt + end + + set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV" +end diff --git a/first_venv/bin/dmypy b/first_venv/bin/dmypy new file mode 100755 index 000000000..c2dc4b67d --- /dev/null +++ b/first_venv/bin/dmypy @@ -0,0 +1,8 @@ +#!/Users/svetlanafadeeva/Dev/character_creation_module/first_venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from mypy.dmypy.client import console_entry +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(console_entry()) diff --git a/first_venv/bin/flake8 b/first_venv/bin/flake8 new file mode 100755 index 000000000..4d2d49145 --- /dev/null +++ b/first_venv/bin/flake8 @@ -0,0 +1,8 @@ +#!/Users/svetlanafadeeva/Dev/character_creation_module/first_venv/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from flake8.main.cli import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/first_venv/bin/futurize b/first_venv/bin/futurize new file mode 100755 index 000000000..6e9e8d10f --- /dev/null +++ b/first_venv/bin/futurize @@ -0,0 +1,33 @@ +#!/Users/svetlanafadeeva/Dev/character_creation_module/first_venv/bin/python3 +# EASY-INSTALL-ENTRY-SCRIPT: 'future==0.18.2','console_scripts','futurize' +import re +import sys + +# for compatibility with easy_install; see #2198 +__requires__ = 'future==0.18.2' + +try: + from importlib.metadata import distribution +except ImportError: + try: + from importlib_metadata import distribution + except ImportError: + from pkg_resources import load_entry_point + + +def importlib_load_entry_point(spec, group, name): + dist_name, _, _ = spec.partition('==') + matches = ( + entry_point + for entry_point in distribution(dist_name).entry_points + if entry_point.group == group and entry_point.name == name + ) + return next(matches).load() + + +globals().setdefault('load_entry_point', importlib_load_entry_point) + + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) + sys.exit(load_entry_point('future==0.18.2', 'console_scripts', 'futurize')()) diff --git a/first_venv/bin/mypy b/first_venv/bin/mypy new file mode 100755 index 000000000..c4e1e4636 --- /dev/null +++ b/first_venv/bin/mypy @@ -0,0 +1,8 @@ +#!/Users/svetlanafadeeva/Dev/character_creation_module/first_venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from mypy.__main__ import console_entry +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(console_entry()) diff --git a/first_venv/bin/mypyc b/first_venv/bin/mypyc new file mode 100755 index 000000000..7f46dcac5 --- /dev/null +++ b/first_venv/bin/mypyc @@ -0,0 +1,8 @@ +#!/Users/svetlanafadeeva/Dev/character_creation_module/first_venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from mypyc.__main__ import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/first_venv/bin/pasteurize b/first_venv/bin/pasteurize new file mode 100755 index 000000000..22c0831ee --- /dev/null +++ b/first_venv/bin/pasteurize @@ -0,0 +1,33 @@ +#!/Users/svetlanafadeeva/Dev/character_creation_module/first_venv/bin/python3 +# EASY-INSTALL-ENTRY-SCRIPT: 'future==0.18.2','console_scripts','pasteurize' +import re +import sys + +# for compatibility with easy_install; see #2198 +__requires__ = 'future==0.18.2' + +try: + from importlib.metadata import distribution +except ImportError: + try: + from importlib_metadata import distribution + except ImportError: + from pkg_resources import load_entry_point + + +def importlib_load_entry_point(spec, group, name): + dist_name, _, _ = spec.partition('==') + matches = ( + entry_point + for entry_point in distribution(dist_name).entry_points + if entry_point.group == group and entry_point.name == name + ) + return next(matches).load() + + +globals().setdefault('load_entry_point', importlib_load_entry_point) + + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) + sys.exit(load_entry_point('future==0.18.2', 'console_scripts', 'pasteurize')()) diff --git a/first_venv/bin/pip b/first_venv/bin/pip new file mode 100755 index 000000000..254a87656 --- /dev/null +++ b/first_venv/bin/pip @@ -0,0 +1,8 @@ +#!/Users/svetlanafadeeva/Dev/character_creation_module/first_venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from pip._internal.cli.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/first_venv/bin/pip3 b/first_venv/bin/pip3 new file mode 100755 index 000000000..254a87656 --- /dev/null +++ b/first_venv/bin/pip3 @@ -0,0 +1,8 @@ +#!/Users/svetlanafadeeva/Dev/character_creation_module/first_venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from pip._internal.cli.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/first_venv/bin/pip3.9 b/first_venv/bin/pip3.9 new file mode 100755 index 000000000..254a87656 --- /dev/null +++ b/first_venv/bin/pip3.9 @@ -0,0 +1,8 @@ +#!/Users/svetlanafadeeva/Dev/character_creation_module/first_venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from pip._internal.cli.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/first_venv/bin/py.test b/first_venv/bin/py.test new file mode 100755 index 000000000..7ecbd4f28 --- /dev/null +++ b/first_venv/bin/py.test @@ -0,0 +1,8 @@ +#!/Users/svetlanafadeeva/Dev/character_creation_module/first_venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from pytest import console_main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(console_main()) diff --git a/first_venv/bin/pycodestyle b/first_venv/bin/pycodestyle new file mode 100755 index 000000000..538124a60 --- /dev/null +++ b/first_venv/bin/pycodestyle @@ -0,0 +1,8 @@ +#!/Users/svetlanafadeeva/Dev/character_creation_module/first_venv/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from pycodestyle import _main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(_main()) diff --git a/first_venv/bin/pyfiglet b/first_venv/bin/pyfiglet new file mode 100755 index 000000000..cce7a29cf --- /dev/null +++ b/first_venv/bin/pyfiglet @@ -0,0 +1,8 @@ +#!/Users/svetlanafadeeva/Dev/character_creation_module/first_venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from pyfiglet import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/first_venv/bin/pyflakes b/first_venv/bin/pyflakes new file mode 100755 index 000000000..7ffb264e8 --- /dev/null +++ b/first_venv/bin/pyflakes @@ -0,0 +1,8 @@ +#!/Users/svetlanafadeeva/Dev/character_creation_module/first_venv/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from pyflakes.api import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/first_venv/bin/pytest b/first_venv/bin/pytest new file mode 100755 index 000000000..7ecbd4f28 --- /dev/null +++ b/first_venv/bin/pytest @@ -0,0 +1,8 @@ +#!/Users/svetlanafadeeva/Dev/character_creation_module/first_venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from pytest import console_main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(console_main()) diff --git a/first_venv/bin/python b/first_venv/bin/python new file mode 120000 index 000000000..b8a0adbbb --- /dev/null +++ b/first_venv/bin/python @@ -0,0 +1 @@ +python3 \ No newline at end of file diff --git a/first_venv/bin/python3 b/first_venv/bin/python3 new file mode 120000 index 000000000..f25545fee --- /dev/null +++ b/first_venv/bin/python3 @@ -0,0 +1 @@ +/Library/Developer/CommandLineTools/usr/bin/python3 \ No newline at end of file diff --git a/first_venv/bin/python3.9 b/first_venv/bin/python3.9 new file mode 120000 index 000000000..b8a0adbbb --- /dev/null +++ b/first_venv/bin/python3.9 @@ -0,0 +1 @@ +python3 \ No newline at end of file diff --git a/first_venv/bin/stubgen b/first_venv/bin/stubgen new file mode 100755 index 000000000..8b03918e1 --- /dev/null +++ b/first_venv/bin/stubgen @@ -0,0 +1,8 @@ +#!/Users/svetlanafadeeva/Dev/character_creation_module/first_venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from mypy.stubgen import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/first_venv/bin/stubtest b/first_venv/bin/stubtest new file mode 100755 index 000000000..6deb96005 --- /dev/null +++ b/first_venv/bin/stubtest @@ -0,0 +1,8 @@ +#!/Users/svetlanafadeeva/Dev/character_creation_module/first_venv/bin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from mypy.stubtest import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/first_venv/pyvenv.cfg b/first_venv/pyvenv.cfg new file mode 100644 index 000000000..4760c1ffc --- /dev/null +++ b/first_venv/pyvenv.cfg @@ -0,0 +1,3 @@ +home = /Library/Developer/CommandLineTools/usr/bin +include-system-site-packages = false +version = 3.9.6 diff --git a/graphic_arts/start_game_banner.py b/graphic_arts/start_game_banner.py new file mode 100644 index 000000000..3cbdef0fd --- /dev/null +++ b/graphic_arts/start_game_banner.py @@ -0,0 +1,46 @@ +from asciimatics.renderers import FigletText, Fire +from asciimatics.renderers import SpeechBubble +from asciimatics.scene import Scene +from asciimatics.screen import Screen +from asciimatics.effects import Print +from asciimatics.exceptions import ResizeScreenError +from pyfiglet import Figlet +import sys + + +def animation(screen): + scenes = [] + + text = Figlet(font="banner", width=200).renderText("START GAME") + print(text) + effects = [ + Print(screen, + Fire(screen.height, 80, text, 0.4, 40, screen.colours), + 0, + speed=1, + transparent=False, + ), + Print(screen, + FigletText("Real Practic Game", "banner"), + screen.height - 15, + colour=Screen.COLOUR_WHITE, + bg=Screen.COLOUR_WHITE, + speed=1), + Print(screen, + SpeechBubble("Please press X - start game"), + screen.height-5, + speed=1, transparent=False) + + ] + scenes.append(Scene(effects, -1)) + + screen.play(scenes, stop_on_resize=True) + + +def run_screensaver(): + Screen.wrapper(animation) + + +if __name__ == "__main__": + run_screensaver() + sys.exit(0) diff --git a/main.py b/main.py index 1f468d66e..cbe370a96 100644 --- a/main.py +++ b/main.py @@ -1,77 +1,106 @@ from random import randint -def attack(char_name, char_class): - if char_class == 'warrior': - return (f'{char_name} нанёс урон противнику равный {5 + randint(3, 5)}') - if char_class == 'mage': - return (f'{char_name} нанёс урон противнику равный {5 + randint(5, 10)}') - if char_class == 'healer': - return (f'{char_name} нанёс урон противнику равный {5 + randint(-3, -1)}') -def defence(char_name, char_class): - if char_class == 'warrior': - return (f'{char_name} блокировал {10 + randint(5, 10)} урона') - if char_class == 'mage': - return (f'{char_name} блокировал {10 + randint(-2, 2)} урона') - if char_class == 'healer': - return (f'{char_name} блокировал {10 + randint(2, 5)} урона') -def special(char_name, char_class): - if char_class == 'warrior': - return (f'{char_name} применил специальное умение «Выносливость {80 + 25}»') - if char_class == 'mage': - return (f'{char_name} применил специальное умение «Атака {5 + 40}»') - if char_class == 'healer': - return (f'{char_name} применил специальное умение «Защита {10 + 30}»') - - - - -def start_training(char_name, char_class): - if char_class == 'warrior': - print(f'{char_name}, ты Воитель — отличный боец ближнего боя.') - if char_class == 'mage': - print(f'{char_name}, ты Маг — превосходный укротитель стихий.') - if char_class == 'healer': - print(f'{char_name}, ты Лекарь — чародей, способный исцелять раны.') +DEFAULT_ATTACK = 5 +DEFAULT_DEFENCE = 10 +DEFAULT_STAMINA = 80 + + +class Character: + BRIEF_DESC_CHAR_CLASS = 'отважный любитель приключений' + RANGE_VALUE_ATTACK = (1, 3) + RANGE_VALUE_DEFENCE = (1, 5) + SPECIAL_BUFF = 15 + SPECIAL_SKILL = 'Удача' + + + def __init__(self, name): + self.name = name + + def attack(self): + value_attack = DEFAULT_ATTACK + randint(*self.RANGE_VALUE_ATTACK) + return (f'{self.name} нанёс противнику урон, равный {value_attack}') + + def defence(self): + value_defence = DEFAULT_DEFENCE + randint(*self.RANGE_VALUE_DEFENCE) + return (f'{self.name} блокировал {value_defence} ед. урона.') + + def special(self): + return (f'{self.name} применил специальное умение ' + f'"{self.SPECIAL_SKILL} {self.SPECIAL_BUFF}".') + + def __str__(self): + return f'{self.__class__.__name__} - {self.BRIEF_DESC_CHAR_CLASS}.' + + +class Warrior(Character): + BRIEF_DESC_CHAR_CLASS = (' дерзкий воин ближнего боя. ' + 'Сильный, выносливый и отважный') + RANGE_VALUE_ATTACK = (3, 5) + RANGE_VALUE_DEFENCE = (5, 10) + SPECIAL_BUFF = DEFAULT_STAMINA + 25 + SPECIAL_SKILL = 'Выносливость' + +class Mage(Character): + BRIEF_DESC_CHAR_CLASS = (' находчивый воин дальнего боя. ' + 'Обладает высоким интеллектом') + RANGE_VALUE_ATTACK = (5, 10) + RANGE_VALUE_DEFENCE = (-2, 2) + SPECIAL_BUFF = DEFAULT_ATTACK + 40 + SPECIAL_SKILL = 'Атака' + +class Healer(Character): + BRIEF_DESC_CHAR_CLASS = (' могущественный заклинатель. ' + 'Черпает силы из природы, веры и духов') + RANGE_VALUE_ATTACK = (-3, -1) + RANGE_VALUE_DEFENCE = (2, 5) + SPECIAL_BUFF = DEFAULT_DEFENCE + 30 + SPECIAL_SKILL = 'Защита' + + +warrior = Warrior('Кодослав') +print(warrior) +print(warrior.attack()) + + +def choice_char_class(char_name: str) -> Character: + """ + Возвращает строку с выбранным + классом персонажа. + """ + + game_classes = {'warrior': Warrior, 'mage': Mage, 'healer': Healer} + + approve_choice: str = None + + while approve_choice != 'y': + selected_class = input('Введи название персонажа, ' + 'за которого хочешь играть: Воитель — warrior, ' + 'Маг — mage, Лекарь — healer: ') + char_class: Character = game_classes[selected_class](char_name) + + print(char_class) + approve_choice = input('Нажми (Y), чтобы подтвердить выбор, ' + 'или любую другую кнопку, ' + 'чтобы выбрать другого персонажа ').lower() + return char_class + +def start_training(character): + """ + Принимает на вход имя и класс персонажа. + Возвращает сообщения о результатах цикла тренировки персонажа. + """ + command_classes = {'attack': Character.attack, 'defence': Character.defence, + 'special': Character.special} + print('Потренируйся управлять своими навыками.') - print('Введи одну из команд: attack — чтобы атаковать противника, defence — чтобы блокировать атаку противника или special — чтобы использовать свою суперсилу.') + print('Введи одну из команд: attack — чтобы атаковать противника, ' + 'defence — чтобы блокировать атаку противника или ' + 'special — чтобы использовать свою суперсилу.') print('Если не хочешь тренироваться, введи команду skip.') cmd = None while cmd != 'skip': cmd = input('Введи команду: ') - if cmd == 'attack': - print(attack(char_name, char_class)) - if cmd == 'defence': - print(defence(char_name, char_class)) - if cmd == 'special': - print(special(char_name, char_class)) - return 'Тренировка окончена.' - -def choice_char_class(): - approve_choice = None - char_class = None - while approve_choice != 'y': - char_class = input('Введи название персонажа, за которого хочешь играть: Воитель — warrior, Маг — mage, Лекарь — healer: ') - if char_class == 'warrior': - print('Воитель — дерзкий воин ближнего боя. Сильный, выносливый и отважный.') - if char_class == 'mage': - print('Маг — находчивый воин дальнего боя. Обладает высоким интеллектом.') - if char_class == 'healer': - print('Лекарь — могущественный заклинатель. Черпает силы из природы, веры и духов.') - approve_choice = input('Нажми (Y), чтобы подтвердить выбор, или любую другую кнопку, чтобы выбрать другого персонажа ').lower() - return char_class - - -def main(): - print('Приветствую тебя, искатель приключений!') - print('Прежде чем начать игру...') - char_name = input('...назови себя: ') - print(f'Здравствуй, {char_name}! ' - 'Сейчас твоя выносливость — 80, атака — 5 и защита — 10.') - print('Ты можешь выбрать один из трёх путей силы:') - print('Воитель, Маг, Лекарь') - char_class = choice_char_class() - print(start_training(char_name, char_class)) - - -main() \ No newline at end of file + if cmd in command_classes: + print (command_classes[cmd]()) + return 'Тренировка окончена.' \ No newline at end of file