develop-entities #2

Open
elia wants to merge 7 commits from develop-entities into main
8 changed files with 535 additions and 6 deletions

1
.gitignore vendored
View file

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

View file

@ -1,4 +1,22 @@
CARDS = { from src.entities.constants import CARDS
"fibonacci": [0.5, 1, 2, 3, 5, 8, 13, 21, 34, 55, "?"],
"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

435
src/entities/constants.py Normal file
View file

@ -0,0 +1,435 @@
"""
File containing all constant entities
"""
CARDS = {
"fibonacci": [0.5, 1, 2, 3, 5, 8, 13, 21, 34, 55, "?"],
"tshirt": ["XS", "S", "M", "L", "XL", "XXL", "XXXL", "?"],
}
PERSON_NAMES = [
"Marsha Mellow",
"Chip Munk",
"Neil Down",
"Paige Turner",
"Anita Bath",
"Art Major",
"Story Teller",
"Al O'Vera",
"Cliff Hanger",
"Clair Annette",
"Kerry Oki",
"Ella Vator",
"Holly Daze",
"Noah Lott",
"Willie Makeit",
"Noah Dia",
"Barry Cade",
"Cam Payne",
"Cara Van",
"Candace Spencer",
"Duane Pipe",
"Justin Time",
"Sal Monella",
"Dill Eavery",
"Al Dente",
"Gene Pool",
"Frank Enstein",
"Jed Dye",
"Artie Choke",
"Ray D. Ater",
"Tim Burr",
"Tish Hughes",
"Walter Melon",
"Jack Inabocks",
"Emma Grate",
"Rosa Bush",
"Holden Aseck",
"Ivy League",
"Cy Nara",
"Ginny Tonic",
"Pearl Button",
"Colleen Cardd",
"Mae Day",
"Jack Pott",
"Ty Coon",
"Anna Graham",
"Izzy Gone",
"Joe King",
"Al Bino",
"Ali Gaither",
"Stanley Cupp",
"Sloane Steady",
"Crystal Clearwater",
"Douglas Furr",
"Tad Moore",
"Landon Pi",
"Justin Case",
"Ken Dahl",
"Walt R. Upto",
"Biff Wellington",
"Brighton Early",
"Major Payne",
"Earl E. Bird",
"Liv Long",
"Teddy Baer",
"Candy Barr",
"Annie Howe",
"Marty Graw",
"Mary Kristmas",
"Bea Havior",
"Chris Coe",
"Buck N. Ears",
"Olive Green",
"Phil Graves",
"Piece Heart",
"Mel O'Drama",
"Sue Flay",
"Joy Rider",
"Polly Ester",
"Chris P. Bacon",
"Ali Katt",
"Peg Legge",
"Robyn Banks",
"Otto Graf",
"Rhoda Carr",
"Jasmine Rice",
"Matt Tress",
"Rocky Rhodes",
"Sandy Banks",
"Russell Sprout",
"Manny Moore",
"Rose Bush",
"Sharon Lunch",
"June Bugg",
"Story Tyme",
"Blue Knight",
"Tommy Hawk",
"Rusty Bridges",
"Brock Lee",
"Sonny Day",
"Wanda Rinn",
"Willie Leeve",
"Harry Houze",
"Tom Morrow",
"Bill Board",
"Virginia Beach",
"Owen Cash",
"Guy Power",
"North West",
"Sweetie Pi",
"Herb Garden",
"Eaton Wright",
"Lisa Ford",
"Ben Dover",
"Sage Berger",
"Patty O'Furniture",
"Ophelia Payne",
"Kay Bull",
"Piper Down",
"Tiffany Box",
"Warren Peace",
"Lake Day",
"Candy Kane",
"Olive Yu",
"Richie Poore",
"Dan Saul Knight",
"Sandy Beach",
"Raven Claw",
"Dee Liver",
"Phillip Button",
"Ferris Wheeler",
"Mel Loewe",
"Miles A. Head",
"Ima Foxx",
"Kandi Queene",
"Apple Pi",
"Crystal Clear",
"Forrest Green",
"Cy Klone",
"Bea O'Problem",
"Carry Oakey",
"Rocky Stone",
"Bud Wiser",
"Ima Pigg",
"Will Power",
"Ann Teak",
"Kelly Green",
"Bonnie Ann Clyde",
"Cole Slaw",
"Foster Child",
"Joe Kerr",
"Penny Loafer",
"Dusty Carr",
"Ray Gunn",
"Buck Wild",
"Ocean Ball",
"Don Key",
"Art Seller",
"Annie May Shin",
"Anna May",
"Gus T. Wind",
"Guy Swett",
"Harry Baer",
"Tad Pohl",
"Charity Case",
"Summer Day",
"Stan Still",
"Reign Mann",
"Rusty Dorr",
"Lisa Mann",
"Anna Conda",
"Joy Ful",
"Roman Holiday",
"Daisy Gardener",
"Royal Payne",
"Holly Wood",
"Rowan Boatmann",
"Ella Funt",
"Rocky Hill",
"Lou Natic",
"Olive Barr",
"Myles Long",
"Manny Kin",
"Ginger Snap",
"Anita Resume",
"Marshall Law",
"Pat Myback",
"Dan Druff",
"Jack Hammer",
"Crystal Glass",
"Constance Noring",
"Polly Tics",
"Sunny Day",
"Shirley U. Jest",
"Lucy Fer",
"Walker Strait",
"Grace Kyes",
"Misty Meanor",
"Amanda Lynn",
"Johnny B. Good",
"Rick O'Shea",
"Barb Dwyer",
"Criss Chross",
"Saint O'ffender",
"Max Power",
]
ROOM_NAMES = [
"Åland - Mariehamn",
"Albania - Tirana",
"Andorra - Andorra la Vella",
"Austria - Vienna",
"Belarus - Minsk",
"Belgium - Brussels",
"Bosnia and Herzegovina - Sarajevo",
"Bulgaria - Sofia",
"Croatia - Zagreb",
"Czechia - Prague",
"Denmark - Copenhagen",
"Estonia - Tallinn",
"Faroe Islands - Tórshavn",
"Finland - Helsinki",
"France - Paris",
"Germany - Berlin",
"Gibraltar - Gibraltar",
"Greece - Athens",
"Guernsey - Saint Peter Port",
"Hungary - Budapest",
"Iceland - Reykjavík",
"Ireland - Dublin",
"Isle of Man - Douglas",
"Italy - Rome",
"Jersey - Saint Helier",
"Kosovo - Pristina",
"Latvia - Riga",
"Liechtenstein - Vaduz",
"Lithuania - Vilnius",
"Luxembourg - Luxembourg",
"Malta - Valletta",
"Moldova - Chisinau",
"Monaco - Monaco",
"Montenegro - Podgorica",
"Netherlands - Amsterdam",
"North Macedonia - Skopje",
"Norway - Oslo",
"Poland - Warsaw",
"Portugal - Lisbon",
"Romania - Bucharest",
"Russia - Moscow",
"San Marino - San Marino",
"Serbia - Belgrade",
"Slovakia - Bratislava",
"Slovenia - Ljubljana",
"Spain - Madrid",
"Svalbard - Longyearbyen",
"Sweden - Stockholm",
"Switzerland - Bern",
"Ukraine - Kyiv",
"United Kingdom - London",
"Vatican - Vatican City",
"Anguilla - The Valley",
"Antigua and Barbuda - Saint John's",
"Argentina - Buenos Aires",
"Aruba - Oranjestad",
"Bahamas - Nassau",
"Barbados - Bridgetown",
"Belize - Belmopan",
"Bermuda - Hamilton",
"Bolivia - Sucre",
"Brazil - Brasilia",
"British Virgin Islands - Road Town",
"Canada - Ottawa",
"Cayman Islands - George Town",
"Chile - Santiago",
"Colombia - Bogota",
"Costa Rica - San José",
"Cuba - Havana",
"Curacao - Willemstad",
"Dominica - Roseau",
"Dominican Republic - Santo Domingo",
"Ecuador - Quito",
"El Salvador - San Salvador",
"Falkland Islands - Stanley",
"French Guiana - Cayenne",
"Greenland - Nuuk",
"Grenada - Saint George's",
"Guadeloupe - Basse-Terre",
"Guatemala - Guatemala City",
"Guyana - Georgetown",
"Haiti - Port-au-Prince",
"Honduras - Tegucigalpa",
"Jamaica - Kingston",
"Martinique - Fort-de-France",
"Mexico - Mexico City",
"Montserrat - Brades",
"Nicaragua - Managua",
"Panama - Panama City",
"Paraguay - Asunción",
"Peru - Lima",
"Puerto Rico - San Juan",
"Saint Barthelemy - Gustavia",
"Saint Kitts and Nevis - Basseterre",
"Saint Lucia - Castries",
"Saint Pierre and Miquelon - Saint-Pierre",
"Saint Vincent and the Grenadines - Kingstown",
"Sint Maarten - Philipsburg",
"South Georgia - King Edward Point",
"St. Martin - Marigot",
"Suriname - Paramaribo",
"Trinidad and Tobago - Port-of-Spain",
"Turks and Caicos Islands - Cockburn Town",
"United States - Washington, D.C.",
"Uruguay - Montevideo",
"Venezuela - Caracas",
"Virgin Islands - Charlotte Amalie",
"Afghanistan - Kabul",
"Armenia - Yerevan",
"Azerbaijan - Baku",
"Bahrain - Manama",
"Bangladesh - Dhaka",
"Bhutan - Thimphu",
"Brunei - Bandar Seri Begawan",
"Cambodia - Phnom Penh",
"China - Beijing",
"Cyprus - Nicosia",
"East Timor - Dili",
"Georgia - Tbilisi",
"Hong Kong - Hong Kong",
"India - New Delhi",
"Indonesia - Jakarta",
"Iran - Tehran",
"Iraq - Baghdad",
"Japan - Tokyo",
"Jordan - Amman",
"Kazakhstan - Astana",
"Kuwait - Kuwait City",
"Kyrgyzstan - Bishkek",
"Laos - Vientiane",
"Lebanon - Beirut",
"Macao - Concelho de Macau",
"Malaysia - Kuala Lumpur",
"Maldives - Malé",
"Mongolia - Ulaanbaatar",
"Myanmar - Nay Pyi Taw",
"Nepal - Kathmandu",
"North Korea - Pyongyang",
"Oman - Muscat",
"Pakistan - Islamabad",
"Palestine - Jerusalem",
"Philippines - Manila",
"Qatar - Doha",
"Saudi Arabia - Riyadh",
"Singapore - Singapore",
"South Korea - Seoul",
"Sri Lanka - Colombo",
"Syria - Damascus",
"Taiwan - Taipei",
"Tajikistan - Dushanbe",
"Thailand - Bangkok",
"Turkey - Ankara",
"Turkmenistan - Ashgabat",
"United Arab Emirates - Abu Dhabi",
"Uzbekistan - Tashkent",
"Vietnam - Hanoi",
"Yemen - Sanaa",
"Algeria - Algiers",
"Angola - Luanda",
"Benin - Porto-Novo",
"Botswana - Gaborone",
"Burkina Faso - Ouagadougou",
"Burundi - Bujumbura",
"Cameroon - Yaounde",
"Cape Verde - Praia",
"Central Africa - Bangui",
"Chad - N'Djamena",
"Comoros - Moroni",
"Congo - Brazzaville",
"Congo (Dem. Republic) - Kinshasa",
"Djibouti - Djibouti City",
"Egypt - Cairo",
"Equatorial Guinea - Malabo",
"Eritrea - Asmara",
"Eswatini - Mbabane",
"Ethiopia - Addis Ababa",
"Gabon - Libreville",
"Gambia - Banjul",
"Ghana - Accra",
"Guinea - Conakry",
"Guinea-Bissau - Bissau",
"Ivory Coast - Yamoussoukro",
"Kenya - Nairobi",
"Lesotho - Maseru",
"Liberia - Monrovia",
"Libya - Tripoli",
"Madagascar - Antananarivo",
"Malawi - Lilongwe",
"Mali - Bamako",
"Mauritania - Nouakchott",
"Mauritius - Port Louis",
"Mayotte - Mamoudzou",
"Morocco - Rabat",
"Mozambique - Maputo",
"Namibia - Windhoek",
"Niger - Niamey",
"Nigeria - Abuja",
"Reunion - Saint-Denis",
"Rwanda - Kigali",
"Saint Helena - Jamestown",
"Sao Tome and Principe - São Tomé",
"Senegal - Dakar",
"Seychelles - Victoria",
"Sierra Leone - Freetown",
"Somalia - Mogadishu",
"South Africa - Pretoria",
"South Sudan - Juba",
"Sudan - Khartoum",
"Tanzania - Dodoma",
"Togo - Lomé",
"Tunisia - Tunis",
"Uganda - Kampala",
"Western Sahara - El Aaiún",
"Zambia - Lusaka",
"Zimbabwe - Harare",
]

View file

@ -1,3 +1,6 @@
import uuid
class Person: class Person:
""" """
Person entity Person entity
@ -8,3 +11,4 @@ class Person:
Person entity initializer Person entity initializer
""" """
self.name = name self.name = name
self.uuid = uuid.uuid1()

View file

@ -1,10 +1,45 @@
import uuid
from src.entities.cards import Cards
class Room: class Room:
""" """
Room entity Room entity
""" """
def __init__(self, name): def __init__(self, name: str, creator: uuid.UUID, card_type="fibonacci"):
""" """
Room entity initializer Room entity initializer
""" """
self.name = name self.name = name
self.creator = creator
self.uuid = uuid.uuid1()
self.attendant = []
self.card_type = card_type
self.cards = self.assign_cards(card_type)
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

17
src/flow/person.py Normal file
View file

@ -0,0 +1,17 @@
import random
from src.entities.constants import PERSON_NAMES
from src.entities.person import Person
def create_person(name: str = None):
"""
Method to create a person with a name.
If a name is not provided a random one will be chosen.
"""
if not name:
name = random.choice(PERSON_NAMES)
p = Person(name=name)
return p

18
src/flow/room.py Normal file
View file

@ -0,0 +1,18 @@
import random
import uuid
from src.entities.constants import ROOM_NAMES
from src.entities.room import Room
def create_room(person: uuid.UUID, name: str = None):
"""
Method to create a room
"""
if not name:
name = random.choice(ROOM_NAMES)
r = Room(name=name, creator=person)
r.add_person(person)
return r

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()