From a774ba0f9385334da240d91e5899d4a20e349166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B2=D0=B5=D1=82=D0=B0=20=D0=A4=D0=B0=D0=B4=D0=B5?= =?UTF-8?q?=D0=B5=D0=B2=D0=B0?= Date: Sat, 26 Nov 2022 18:02:43 +0300 Subject: [PATCH 1/7] code according to PEP8 --- .DS_Store | Bin 0 -> 6148 bytes first_venv/.DS_Store | Bin 0 -> 6148 bytes first_venv/bin/Activate.ps1 | 241 +++++++++++++++++++++++++++++++++++ first_venv/bin/activate | 66 ++++++++++ first_venv/bin/activate.csh | 25 ++++ first_venv/bin/activate.fish | 64 ++++++++++ first_venv/bin/flake8 | 8 ++ first_venv/bin/pip | 8 ++ first_venv/bin/pip3 | 8 ++ first_venv/bin/pip3.9 | 8 ++ first_venv/bin/py.test | 8 ++ first_venv/bin/pycodestyle | 8 ++ first_venv/bin/pyflakes | 8 ++ first_venv/bin/pytest | 8 ++ first_venv/bin/python | 1 + first_venv/bin/python3 | 1 + first_venv/bin/python3.9 | 1 + first_venv/pyvenv.cfg | 3 + 18 files changed, 466 insertions(+) create mode 100644 .DS_Store create mode 100644 first_venv/.DS_Store create mode 100644 first_venv/bin/Activate.ps1 create mode 100644 first_venv/bin/activate create mode 100644 first_venv/bin/activate.csh create mode 100644 first_venv/bin/activate.fish create mode 100755 first_venv/bin/flake8 create mode 100755 first_venv/bin/pip create mode 100755 first_venv/bin/pip3 create mode 100755 first_venv/bin/pip3.9 create mode 100755 first_venv/bin/py.test create mode 100755 first_venv/bin/pycodestyle create mode 100755 first_venv/bin/pyflakes create mode 100755 first_venv/bin/pytest create mode 120000 first_venv/bin/python create mode 120000 first_venv/bin/python3 create mode 120000 first_venv/bin/python3.9 create mode 100644 first_venv/pyvenv.cfg diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ee136c9359a7128c225a24cfd3986a83844ca5bf GIT binary patch literal 6148 zcmeHKL2uJA6n^dsO*?^l0BM&=k+@c++W;|f$-4G12{J0z}K=s%ckERi&Ka z$8hDB@LxE=_iPWfS$9K-AwTK)v;E!|+g}trCL+>u z6zUlh3h0ay%28Ug3RngHbp`m_ZP5oxX-owzeZNPUd>>^pLYy~;19yK|*Vh53=`@4()_lJEc)#QB?L1s`-1+`)uj4-0d$d?I zoxAt$KRFIgveR6CRw*<{NM}ul-8w0;~d7fj_MP?+-4V(KA?TR9goM zbp-&{(X9-1{#{^>YtS=TYD5GkG!>|+!dx+grla3Ad7i;iqo$KEmk(h^7UqT`)aZD= ztI|n$8f|G6unMdyu%Vl6KL3YT-~U%hwq+Ht3j9|Ji2A@E^syv!wq9BspS3Rh9h{Bx nN{xzw!W_q{!bkBITp406SAd?uQX_g`_D4X;U<<3jUsd22_H>^c literal 0 HcmV?d00001 diff --git a/first_venv/.DS_Store b/first_venv/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..78c05bc0d9508ce4f6563ba3c1476ae841379871 GIT binary patch literal 6148 zcmeHKO-~y!5FIChY>JR_pb{6Pm3ob6fPz3=wkbXI+O66{TZJsUg%!&>%BQL*(w^bR zaP2SQ@6b24sk)&(f&`k8#?KzljN|9X-XS8@8OK{hO(OE3jFkqOe+bXB-jj;6ECUti z&?ix*BaAqm$Wvf|&#p=lrIdfjO6T_$Gn=y3 z|4AdO4)5R!9k-iFILI@dpTff4b>@LiD5EjOlq@iE4UaM-8T_NNm)cnHdO>~qNfSzt zc|x1W{)0{zV)z&Rof$(BVL%uV1|EUw(?$p+;c$xdRLw78YTF$cKQTK^kG;Q5pCRqq2Bz literal 0 HcmV?d00001 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/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/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/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/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 From 38bf2df765787f31ce5777fc20a30232b9c152fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B2=D0=B5=D1=82=D0=B0=20=D0=A4=D0=B0=D0=B4=D0=B5?= =?UTF-8?q?=D0=B5=D0=B2=D0=B0?= Date: Fri, 2 Dec 2022 21:07:01 +0300 Subject: [PATCH 2/7] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=5F1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 5 ++- first_venv/bin/dmypy | 8 ++++ first_venv/bin/mypy | 8 ++++ first_venv/bin/mypyc | 8 ++++ first_venv/bin/stubgen | 8 ++++ first_venv/bin/stubtest | 8 ++++ graphic_arts/start_game_banner.py | 47 +++++++++++++++++++++ main.py | 68 ++++++++++++++++++++----------- temp.py | 10 +++++ 9 files changed, 145 insertions(+), 25 deletions(-) create mode 100755 first_venv/bin/dmypy create mode 100755 first_venv/bin/mypy create mode 100755 first_venv/bin/mypyc create mode 100755 first_venv/bin/stubgen create mode 100755 first_venv/bin/stubtest create mode 100644 graphic_arts/start_game_banner.py create mode 100644 temp.py 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/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/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/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/graphic_arts/start_game_banner.py b/graphic_arts/start_game_banner.py new file mode 100644 index 000000000..8ac681b31 --- /dev/null +++ b/graphic_arts/start_game_banner.py @@ -0,0 +1,47 @@ +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..14599d0a2 100644 --- a/main.py +++ b/main.py @@ -1,32 +1,41 @@ from random import randint -def attack(char_name, char_class): +def attack(char_name: str, char_class: str) -> str: if char_class == 'warrior': - return (f'{char_name} нанёс урон противнику равный {5 + randint(3, 5)}') + return (f'{char_name} нанёс урон противнику равный ' + f'{5 + randint(3, 5)}') if char_class == 'mage': - return (f'{char_name} нанёс урон противнику равный {5 + randint(5, 10)}') + return (f'{char_name} нанёс урон противнику равный ' + f'{5 + randint(5, 10)}') if char_class == 'healer': - return (f'{char_name} нанёс урон противнику равный {5 + randint(-3, -1)}') -def defence(char_name, char_class): + return (f'{char_name} нанёс урон противнику равный ' + f'{5 + randint(-3, -1)}') + return (f'{char_name} не применил специальное умение') + + +def defence(char_name: str, char_class: str) -> str: 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}»') + return (f'{char_name} не применил специальное умение') + + +def special(char_name: str, char_class: str) -> str: + if char_class == 'warrior': + return (f'{char_name} применил специальное умение «Выносливость ' + f'{80 + 25}»') if char_class == 'mage': return (f'{char_name} применил специальное умение «Атака {5 + 40}»') if char_class == 'healer': return (f'{char_name} применил специальное умение «Защита {10 + 30}»') + return (f'{char_name} не применил специальное умение') - - -def start_training(char_name, char_class): +def start_training(char_name: str, char_class: str) -> str: if char_class == 'warrior': print(f'{char_name}, ты Воитель — отличный боец ближнего боя.') if char_class == 'mage': @@ -34,9 +43,11 @@ def start_training(char_name, char_class): if char_class == 'healer': print(f'{char_name}, ты Лекарь — чародей, способный исцелять раны.') print('Потренируйся управлять своими навыками.') - print('Введи одну из команд: attack — чтобы атаковать противника, defence — чтобы блокировать атаку противника или special — чтобы использовать свою суперсилу.') + print('Введи одну из команд: attack — чтобы атаковать противника, ' + 'defence — чтобы блокировать атаку противника или special — ' + 'чтобы использовать свою суперсилу.') print('Если не хочешь тренироваться, введи команду skip.') - cmd = None + cmd: str = None while cmd != 'skip': cmd = input('Введи команду: ') if cmd == 'attack': @@ -47,31 +58,42 @@ def start_training(char_name, char_class): print(special(char_name, char_class)) return 'Тренировка окончена.' -def choice_char_class(): + +def choice_char_class() -> str: approve_choice = None char_class = None while approve_choice != 'y': - char_class = input('Введи название персонажа, за которого хочешь играть: Воитель — warrior, Маг — mage, Лекарь — healer: ') + char_class: str = input('Введи название персонажа, ' + 'за которого хочешь играть: ' + 'Воитель — warrior, Маг — mage, ' + 'Лекарь — healer: ') if char_class == 'warrior': - print('Воитель — дерзкий воин ближнего боя. Сильный, выносливый и отважный.') + print('Воитель — дерзкий воин ближнего боя. ' + 'Сильный, выносливый и отважный.') if char_class == 'mage': - print('Маг — находчивый воин дальнего боя. Обладает высоким интеллектом.') + print('Маг — находчивый воин дальнего боя. ' + 'Обладает высоким интеллектом.') if char_class == 'healer': - print('Лекарь — могущественный заклинатель. Черпает силы из природы, веры и духов.') - approve_choice = input('Нажми (Y), чтобы подтвердить выбор, или любую другую кнопку, чтобы выбрать другого персонажа ').lower() + print('Лекарь — могущественный заклинатель. ' + 'Черпает силы из природы, веры и духов.') + approve_choice: str = input('Нажми (Y), чтобы подтвердить выбор, ' + 'или любую другую кнопку, чтобы выбрать ' + 'другого персонажа ').lower() return char_class def main(): print('Приветствую тебя, искатель приключений!') print('Прежде чем начать игру...') - char_name = input('...назови себя: ') + char_name: str = input('...назови себя: ') print(f'Здравствуй, {char_name}! ' 'Сейчас твоя выносливость — 80, атака — 5 и защита — 10.') print('Ты можешь выбрать один из трёх путей силы:') print('Воитель, Маг, Лекарь') - char_class = choice_char_class() + char_class: str = choice_char_class() print(start_training(char_name, char_class)) - -main() \ No newline at end of file + +main() + + diff --git a/temp.py b/temp.py new file mode 100644 index 000000000..0f6760800 --- /dev/null +++ b/temp.py @@ -0,0 +1,10 @@ +def we_crash_all(name: str) -> str: + return 'Привет, ' + name + ', мы всё сломали!' + +print(we_crash_all(100)) + + + + + + From af79d9166bd2669669ea9cdff5f64aa4bb6e6f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9C=D0=A1=D0=B2=D0=B5=D1=82=D0=B0?= Date: Sat, 3 Dec 2022 13:59:20 +0300 Subject: [PATCH 3/7] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=B2=D1=81=D0=B5=20=D1=81=D0=BD=D0=B0=D1=87=D0=B0=D0=BB=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 6148 -> 6148 bytes graphic_arts/start_game_banner.py | 47 ------------------------------ 2 files changed, 47 deletions(-) delete mode 100644 graphic_arts/start_game_banner.py diff --git a/.DS_Store b/.DS_Store index ee136c9359a7128c225a24cfd3986a83844ca5bf..09ab5df58dec3671499568eafc8b18acf29b5979 100644 GIT binary patch delta 207 zcmZoMXfc@J&&abeU^g=(&twM{iODJ~TiMMFbQFwDOeQ~INe<*;NM|TwNMtBr$Y981 zNM?u!vWpl>7>Ye}@{^Nt@{<@C7zBXW5s2sg2Lm9BfdQw!$q_7#NH*9@;#O(GdQq7j eXjdvjF3^5GAg)BSbv?+|$-h|VZ)WHC%MSpO=`_Fq delta 51 zcmV-30L=e{FoZCWPXP$AP`d*G2$Mhr7?UIfwFfvkEFd#6HIv{3W0Qjh!jp3cl(B$r J0ka1P{STA~5S#!2 diff --git a/graphic_arts/start_game_banner.py b/graphic_arts/start_game_banner.py deleted file mode 100644 index 8ac681b31..000000000 --- a/graphic_arts/start_game_banner.py +++ /dev/null @@ -1,47 +0,0 @@ -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) - From 9a3134d6313438b2a5664755be4c44611b936bab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9C=D0=A1=D0=B2=D0=B5=D1=82=D0=B0?= Date: Sat, 3 Dec 2022 16:46:57 +0300 Subject: [PATCH 4/7] Start game --- graphic_arts/start_game_banner.py | 46 +++++++++++++++++++++++++++++++ main.py | 8 ++++-- temp.py | 10 ------- 3 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 graphic_arts/start_game_banner.py delete mode 100644 temp.py 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 14599d0a2..3a591dfd9 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,9 @@ from random import randint +from graphic_arts.start_game_banner import run_screensaver + + def attack(char_name: str, char_class: str) -> str: if char_class == 'warrior': return (f'{char_name} нанёс урон противнику равный ' @@ -82,7 +85,8 @@ def choice_char_class() -> str: return char_class -def main(): +if __name__ == '__main__': + run_screensaver() print('Приветствую тебя, искатель приключений!') print('Прежде чем начать игру...') char_name: str = input('...назови себя: ') @@ -93,7 +97,7 @@ def main(): char_class: str = choice_char_class() print(start_training(char_name, char_class)) - + main() diff --git a/temp.py b/temp.py deleted file mode 100644 index 0f6760800..000000000 --- a/temp.py +++ /dev/null @@ -1,10 +0,0 @@ -def we_crash_all(name: str) -> str: - return 'Привет, ' + name + ', мы всё сломали!' - -print(we_crash_all(100)) - - - - - - From 29092e8541a9805c446bf7782f4d48c121b510df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9C=D0=A1=D0=B2=D0=B5=D1=82=D0=B0?= Date: Sun, 4 Dec 2022 16:24:53 +0300 Subject: [PATCH 5/7] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=D0=B0=20=D0=B4=D0=BE=D0=BA=D1=81=D1=82=D1=80=D0=B8=D0=BD=D0=B3?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 6148 -> 6148 bytes main.py | 13 ++++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.DS_Store b/.DS_Store index 09ab5df58dec3671499568eafc8b18acf29b5979..15cfe2d2a2ed76c35ba973e131044ea18b8d1ddf 100644 GIT binary patch delta 35 rcmZoMXfc@J&&a(oU^g=(_hbhaiOni3ip-OX*{4iw(A&(;@s}R}y?Y9~ delta 68 zcmZoMXfc@J&&abeU^g=(&twM{iOni3ip6w$CoRpKF#K6EH U0L1Hoc-~|y_W7IHIsWnk07GRE$^ZZW diff --git a/main.py b/main.py index 3a591dfd9..93aabd051 100644 --- a/main.py +++ b/main.py @@ -5,6 +5,10 @@ def attack(char_name: str, char_class: str) -> str: + """Генерирует количество очков атаки. + В зависимости от выбранного типа персонажа. + И возвращает строковое сообщение о проведённой атаке. + """ if char_class == 'warrior': return (f'{char_name} нанёс урон противнику равный ' f'{5 + randint(3, 5)}') @@ -18,6 +22,7 @@ def attack(char_name: str, char_class: str) -> str: def defence(char_name: str, char_class: str) -> str: + """Генерирует количество очков защиты.""" if char_class == 'warrior': return (f'{char_name} блокировал {10 + randint(5, 10)} урона') if char_class == 'mage': @@ -28,6 +33,7 @@ def defence(char_name: str, char_class: str) -> str: def special(char_name: str, char_class: str) -> str: + """КВозвращает сообщение о применении специального умения.""" if char_class == 'warrior': return (f'{char_name} применил специальное умение «Выносливость ' f'{80 + 25}»') @@ -39,6 +45,7 @@ def special(char_name: str, char_class: str) -> str: def start_training(char_name: str, char_class: str) -> str: + """Запускает цикл тренировки навыков персонажа.""" if char_class == 'warrior': print(f'{char_name}, ты Воитель — отличный боец ближнего боя.') if char_class == 'mage': @@ -63,6 +70,8 @@ def start_training(char_name: str, char_class: str) -> str: def choice_char_class() -> str: + """Позволяет игроку выбрать тип игрового персонажа. + И возвращает выбранный вариант.""" approve_choice = None char_class = None while approve_choice != 'y': @@ -98,6 +107,4 @@ def choice_char_class() -> str: print(start_training(char_name, char_class)) -main() - - +main() \ No newline at end of file From 42e0df9325dc918efa8df1e99b1e2a64a7dcad1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9C=D0=A1=D0=B2=D0=B5=D1=82=D0=B0?= Date: Sun, 18 Dec 2022 13:24:03 +0300 Subject: [PATCH 6/7] add working version without classes --- first_venv/bin/futurize | 33 +++++++++++++++++++++++++++++++++ first_venv/bin/pasteurize | 33 +++++++++++++++++++++++++++++++++ first_venv/bin/pyfiglet | 8 ++++++++ 3 files changed, 74 insertions(+) create mode 100755 first_venv/bin/futurize create mode 100755 first_venv/bin/pasteurize create mode 100755 first_venv/bin/pyfiglet 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/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/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()) From 98922a2202f5f470636c1b2d5b42c3d4e05570e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9C=D0=A1=D0=B2=D0=B5=D1=82=D0=B0?= Date: Sun, 18 Dec 2022 18:12:33 +0300 Subject: [PATCH 7/7] add working version with classes --- main.py | 194 +++++++++++++++++++++++++++----------------------------- 1 file changed, 95 insertions(+), 99 deletions(-) diff --git a/main.py b/main.py index 93aabd051..cbe370a96 100644 --- a/main.py +++ b/main.py @@ -1,110 +1,106 @@ from random import randint -from graphic_arts.start_game_banner import run_screensaver +DEFAULT_ATTACK = 5 +DEFAULT_DEFENCE = 10 +DEFAULT_STAMINA = 80 -def attack(char_name: str, char_class: str) -> str: - """Генерирует количество очков атаки. - В зависимости от выбранного типа персонажа. - И возвращает строковое сообщение о проведённой атаке. +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: + """ + Возвращает строку с выбранным + классом персонажа. """ - if char_class == 'warrior': - return (f'{char_name} нанёс урон противнику равный ' - f'{5 + randint(3, 5)}') - if char_class == 'mage': - return (f'{char_name} нанёс урон противнику равный ' - f'{5 + randint(5, 10)}') - if char_class == 'healer': - return (f'{char_name} нанёс урон противнику равный ' - f'{5 + randint(-3, -1)}') - return (f'{char_name} не применил специальное умение') - - -def defence(char_name: str, char_class: str) -> str: - """Генерирует количество очков защиты.""" - 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)} урона') - return (f'{char_name} не применил специальное умение') - - -def special(char_name: str, char_class: str) -> str: - """КВозвращает сообщение о применении специального умения.""" - if char_class == 'warrior': - return (f'{char_name} применил специальное умение «Выносливость ' - f'{80 + 25}»') - if char_class == 'mage': - return (f'{char_name} применил специальное умение «Атака {5 + 40}»') - if char_class == 'healer': - return (f'{char_name} применил специальное умение «Защита {10 + 30}»') - return (f'{char_name} не применил специальное умение') - - -def start_training(char_name: str, char_class: str) -> str: - """Запускает цикл тренировки навыков персонажа.""" - if char_class == 'warrior': - print(f'{char_name}, ты Воитель — отличный боец ближнего боя.') - if char_class == 'mage': - print(f'{char_name}, ты Маг — превосходный укротитель стихий.') - if char_class == 'healer': - print(f'{char_name}, ты Лекарь — чародей, способный исцелять раны.') + + 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 — ' - 'чтобы использовать свою суперсилу.') + 'defence — чтобы блокировать атаку противника или ' + 'special — чтобы использовать свою суперсилу.') print('Если не хочешь тренироваться, введи команду skip.') - cmd: str = None + 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() -> str: - """Позволяет игроку выбрать тип игрового персонажа. - И возвращает выбранный вариант.""" - approve_choice = None - char_class = None - while approve_choice != 'y': - char_class: str = input('Введи название персонажа, ' - 'за которого хочешь играть: ' - 'Воитель — warrior, Маг — mage, ' - 'Лекарь — healer: ') - if char_class == 'warrior': - print('Воитель — дерзкий воин ближнего боя. ' - 'Сильный, выносливый и отважный.') - if char_class == 'mage': - print('Маг — находчивый воин дальнего боя. ' - 'Обладает высоким интеллектом.') - if char_class == 'healer': - print('Лекарь — могущественный заклинатель. ' - 'Черпает силы из природы, веры и духов.') - approve_choice: str = input('Нажми (Y), чтобы подтвердить выбор, ' - 'или любую другую кнопку, чтобы выбрать ' - 'другого персонажа ').lower() - return char_class - - -if __name__ == '__main__': - run_screensaver() - print('Приветствую тебя, искатель приключений!') - print('Прежде чем начать игру...') - char_name: str = input('...назови себя: ') - print(f'Здравствуй, {char_name}! ' - 'Сейчас твоя выносливость — 80, атака — 5 и защита — 10.') - print('Ты можешь выбрать один из трёх путей силы:') - print('Воитель, Маг, Лекарь') - char_class: str = 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