Compare commits

..

4 commits

Author SHA1 Message Date
c2e51a9f71 chore(): Assigns cards to a room 2024-11-23 19:03:38 +01:00
43f444d48f fix(): isort import fix 2024-11-23 18:37:32 +01:00
307c3ff414 chore(): Expands the definitions of the entities
- Adds create methods to the room, person and cards
- Adds methods to add and remove person from room
2024-11-23 18:37:16 +01:00
7955c6cd46 chore(): ignore intellij configuration specific directories from being committed to git 2024-11-23 18:31:05 +01:00
5 changed files with 82 additions and 2 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
__pycache__/ __pycache__/
.idea/

View file

@ -2,3 +2,24 @@ CARDS = {
"fibonacci": [0.5, 1, 2, 3, 5, 8, 13, 21, 34, 55, "?"], "fibonacci": [0.5, 1, 2, 3, 5, 8, 13, 21, 34, 55, "?"],
"tshirt": ["XS", "S", "M", "L", "XL", "XXL", "XXXL", "?"], "tshirt": ["XS", "S", "M", "L", "XL", "XXL", "XXXL", "?"],
} }
class Cards:
"""
Cards class object
"""
def __init__(self, card_type="fibonacci"):
self.card_type = card_type
self.cards = []
self.create()
def create(self):
"""
Method to create a deck of cards
"""
if self.card_type in CARDS.keys():
self.cards = CARDS[self.card_type]
return self
return None

View file

@ -1,3 +1,6 @@
import uuid
class Person: class Person:
""" """
Person entity Person entity
@ -8,3 +11,11 @@ class Person:
Person entity initializer Person entity initializer
""" """
self.name = name self.name = name
self.uuid = None
self.create()
def create(self):
if not self.uuid:
self.uuid = uuid.uuid1()
return self

View file

@ -1,10 +1,56 @@
import uuid
from src.entities.cards import Cards
class Room: class Room:
""" """
Room entity Room entity
""" """
def __init__(self, name): def __init__(self, name, card_type="fibonacci"):
""" """
Room entity initializer Room entity initializer
""" """
self.name = name self.name = name
self.uuid = None
self.attendant = []
self.card_type = card_type
self.cards = None
self.create()
def create(self):
"""
Method to create a new room object
"""
if not self.uuid:
self.uuid = uuid.uuid1()
self.assign_cards()
return self
def add_person(self, person: uuid.UUID):
"""
Method to add a person to a room
"""
if person not in self.attendant:
self.attendant.append(person)
def remove_person(self, person: uuid.UUID):
"""
Method to remove a person from a room
"""
if person in self.attendant:
self.attendant.remove(person)
def assign_cards(self, card_type=None):
"""
Method to assign cards to a room
"""
if card_type:
self.cards = Cards(card_type)
else:
self.cards = Cards()
return self.cards

View file

@ -1,6 +1,7 @@
from fastapi import FastAPI, HTTPException
from typing import Annotated from typing import Annotated
from fastapi import FastAPI, HTTPException
import src.routers.cards as cards import src.routers.cards as cards
app = FastAPI() app = FastAPI()