initial work

This commit is contained in:
Alberto Xamin 2020-11-15 17:23:09 +01:00
parent 8362aa8081
commit f358ab0c23
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
5 changed files with 267 additions and 0 deletions

138
.gitignore vendored Normal file
View File

@ -0,0 +1,138 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
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.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
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
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.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/

12
cards.py Normal file
View File

@ -0,0 +1,12 @@
from abc import ABC, abstractmethod
from enum import Enum
class Suit(Enum):
DIAMONDS = 1 # ♦
CLUBS = 2 # ♣
HEARTS = 3 # ♥
SPADES = 4 # ♠
class Card(ABC):
def __init__(self):
super().__init__()

36
characters.py Normal file
View File

@ -0,0 +1,36 @@
from abc import ABC, abstractmethod
class Character(ABC):
def __init__(self, name: str, max_lives: int, sight_mod: int = 0, visibility_mod: int = 0):
super().__init__()
self.name = name
self.max_lives = max_lives
self.sight_mod = 0
self.visibility_mod = 0
@abstractmethod
def on_hurt(self, dmg: int):
pass
@abstractmethod
def on_pick(self, card): # tipo dinamite e prigione
pass
@abstractmethod
def on_empty_hand(self):
pass
@abstractmethod
def on_empty_hand(self):
pass
class BartCassidy(Character):
def __init__(self):
super().__init__("Bart Cassidy", max_lives=4)
def on_hurt(self, dmg):
pass
class BlackJack(Character):
def __init__(self):
super().__init__("Black Jack", max_lives=4)

24
players.py Normal file
View File

@ -0,0 +1,24 @@
import roles
import characters
class Player:
def __init__(self, id):
super().__init__()
self.id = id
self.hand = []
self.role: roles.Role = None
self.character: characters.Character = None
self.lives = 0
self.max_lives = 0
def set_role(self, role: roles.Role):
self.role = role
def set_character(self, character: characters.Character):
self.character = character
def prepare(self):
self.max_lives = self.character.max_lives + self.role.health_mod
self.lives = self.max_lives

57
roles.py Normal file
View File

@ -0,0 +1,57 @@
from abc import ABC, abstractmethod
class Role(ABC):
def __init__(self, name: str, goal: str, health_mod: int = 0):
super().__init__()
self.name = name
self.goal = goal
self.health_mod = health_mod
@abstractmethod
def on_player_death(self, alive_players: list):
pass
class Sheriff(Role):
def __init__(self, name):
super().__init__(name, +1)
self.goal = "Elimina tutti i Fuorilegge e il Rinnegato!"
self.max_players = 1
def on_player_death(self, alive_players: list):
if not any([type(p.role) == Outlaw or type(p.role) == Renegade for p in alive_players]):
print("The Sheriff won!")
pass
class Vice(Role):
def __init__(self, name):
super().__init__(name)
self.goal = "Proteggi lo Sceriffo! Elimina tutti i Fuorilegge e il Rinnegato!"
self.max_players = 1
def on_player_death(self, alive_players: list):
if not any([type(p.role) == Outlaw or type(p.role) == Renegade for p in alive_players]):
print("The Vice won!")
pass
class Outlaw(Role):
def __init__(self, name):
super().__init__(name)
self.goal = "Elimina lo Sceriffo!"
self.max_players = 3
def on_player_death(self, alive_players: list):
if not any([type(p.role) == Sheriff for p in alive_players]):
print("The Outlaw won!")
pass
class Renegade(Role):
def __init__(self, name):
super().__init__(name)
self.goal = "Rimani l'ultimo personaggio in gioco!"
self.max_players = 1
def on_player_death(self, alive_players: list):
if len(alive_players) == 1 and type(alive_players[0]) == Renegade:
print("The Renegade won!")
pass