From 7955c6cd46bae3408ba3a912d4489cbe62e4732a Mon Sep 17 00:00:00 2001 From: Elia el Lazkani Date: Sat, 23 Nov 2024 18:31:05 +0100 Subject: [PATCH 1/7] chore(): ignore intellij configuration specific directories from being committed to git --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c18dd8d..8ae8ce5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ __pycache__/ +.idea/ -- 2.45.2 From 307c3ff41433701c19e03136a4916b5b87e40c10 Mon Sep 17 00:00:00 2001 From: Elia el Lazkani Date: Sat, 23 Nov 2024 18:31:53 +0100 Subject: [PATCH 2/7] 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 --- src/entities/cards.py | 21 +++++++++++++++++++++ src/entities/person.py | 11 +++++++++++ src/entities/room.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/src/entities/cards.py b/src/entities/cards.py index abf164a..7e95e39 100644 --- a/src/entities/cards.py +++ b/src/entities/cards.py @@ -2,3 +2,24 @@ 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 diff --git a/src/entities/person.py b/src/entities/person.py index bbd4e20..5a5ebd3 100644 --- a/src/entities/person.py +++ b/src/entities/person.py @@ -1,3 +1,6 @@ +import uuid + + class Person: """ Person entity @@ -8,3 +11,11 @@ class Person: Person entity initializer """ self.name = name + self.uuid = None + self.create() + + def create(self): + if not self.uuid: + self.uuid = uuid.uuid1() + + return self diff --git a/src/entities/room.py b/src/entities/room.py index e694bbc..e24edb2 100644 --- a/src/entities/room.py +++ b/src/entities/room.py @@ -1,3 +1,6 @@ +import uuid + + class Room: """ Room entity @@ -8,3 +11,29 @@ class Room: Room entity initializer """ self.name = name + self.uuid = None + self.attendant = [] + self.create() + + def create(self): + """ + Method to create a new room object + """ + if not self.uuid: + self.uuid = uuid.uuid1() + + 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) -- 2.45.2 From 43f444d48fab130bb75e395ac0437c51ea5c2105 Mon Sep 17 00:00:00 2001 From: Elia el Lazkani Date: Sat, 23 Nov 2024 18:37:32 +0100 Subject: [PATCH 3/7] fix(): isort import fix --- src/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index d23880d..114bb27 100644 --- a/src/main.py +++ b/src/main.py @@ -1,6 +1,7 @@ -from fastapi import FastAPI, HTTPException from typing import Annotated +from fastapi import FastAPI, HTTPException + import src.routers.cards as cards app = FastAPI() -- 2.45.2 From c2e51a9f7130dd2669396fdc46fa0c473d040a35 Mon Sep 17 00:00:00 2001 From: Elia el Lazkani Date: Sat, 23 Nov 2024 19:03:05 +0100 Subject: [PATCH 4/7] chore(): Assigns cards to a room --- src/entities/room.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/entities/room.py b/src/entities/room.py index e24edb2..279804e 100644 --- a/src/entities/room.py +++ b/src/entities/room.py @@ -1,18 +1,22 @@ import uuid +from src.entities.cards import Cards + class Room: """ Room entity """ - def __init__(self, name): + def __init__(self, name, card_type="fibonacci"): """ Room entity initializer """ self.name = name self.uuid = None self.attendant = [] + self.card_type = card_type + self.cards = None self.create() def create(self): @@ -22,6 +26,8 @@ class Room: if not self.uuid: self.uuid = uuid.uuid1() + self.assign_cards() + return self def add_person(self, person: uuid.UUID): @@ -37,3 +43,14 @@ class 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 -- 2.45.2 From 5d5cb2fdaba1a67d1a2d2a866b1968fb109edcf4 Mon Sep 17 00:00:00 2001 From: Elia el Lazkani Date: Sun, 24 Nov 2024 21:27:35 +0100 Subject: [PATCH 5/7] chore(): Moves the constants to their own entitiy file --- src/entities/cards.py | 5 +---- src/entities/constants.py | 8 ++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 src/entities/constants.py diff --git a/src/entities/cards.py b/src/entities/cards.py index 7e95e39..61b3647 100644 --- a/src/entities/cards.py +++ b/src/entities/cards.py @@ -1,7 +1,4 @@ -CARDS = { - "fibonacci": [0.5, 1, 2, 3, 5, 8, 13, 21, 34, 55, "?"], - "tshirt": ["XS", "S", "M", "L", "XL", "XXL", "XXXL", "?"], -} +from src.entities.constants import CARDS class Cards: diff --git a/src/entities/constants.py b/src/entities/constants.py new file mode 100644 index 0000000..67abbca --- /dev/null +++ b/src/entities/constants.py @@ -0,0 +1,8 @@ +""" +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", "?"], +} -- 2.45.2 From 9a1f1c8b67f71b65978e9296c1c55a885bbc66dd Mon Sep 17 00:00:00 2001 From: Elia el Lazkani Date: Sun, 24 Nov 2024 21:28:13 +0100 Subject: [PATCH 6/7] chore(): Creates the flow process. - Method to create a person - Method to create a room and assign a person to it --- src/entities/constants.py | 427 ++++++++++++++++++++++++++++++++++++++ src/flow/person.py | 17 ++ src/flow/room.py | 16 ++ 3 files changed, 460 insertions(+) create mode 100644 src/flow/person.py create mode 100644 src/flow/room.py diff --git a/src/entities/constants.py b/src/entities/constants.py index 67abbca..eafa0c0 100644 --- a/src/entities/constants.py +++ b/src/entities/constants.py @@ -6,3 +6,430 @@ 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", +] diff --git a/src/flow/person.py b/src/flow/person.py new file mode 100644 index 0000000..fcfd906 --- /dev/null +++ b/src/flow/person.py @@ -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 diff --git a/src/flow/room.py b/src/flow/room.py new file mode 100644 index 0000000..17b2247 --- /dev/null +++ b/src/flow/room.py @@ -0,0 +1,16 @@ +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) + r.add_person(person) + return r -- 2.45.2 From d3a4401d14d3db6c91fc3c4ec9071d379ca45e9c Mon Sep 17 00:00:00 2001 From: Elia el Lazkani Date: Sun, 24 Nov 2024 21:35:45 +0100 Subject: [PATCH 7/7] chore(): Cleaning up a bit of unneeded code --- src/entities/person.py | 9 +-------- src/entities/room.py | 19 ++++--------------- src/flow/room.py | 4 +++- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/entities/person.py b/src/entities/person.py index 5a5ebd3..ee0b4e6 100644 --- a/src/entities/person.py +++ b/src/entities/person.py @@ -11,11 +11,4 @@ class Person: Person entity initializer """ self.name = name - self.uuid = None - self.create() - - def create(self): - if not self.uuid: - self.uuid = uuid.uuid1() - - return self + self.uuid = uuid.uuid1() diff --git a/src/entities/room.py b/src/entities/room.py index 279804e..8222c3e 100644 --- a/src/entities/room.py +++ b/src/entities/room.py @@ -8,27 +8,16 @@ class Room: Room entity """ - def __init__(self, name, card_type="fibonacci"): + def __init__(self, name: str, creator: uuid.UUID, card_type="fibonacci"): """ Room entity initializer """ self.name = name - self.uuid = None + self.creator = creator + self.uuid = uuid.uuid1() 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 + self.cards = self.assign_cards(card_type) def add_person(self, person: uuid.UUID): """ diff --git a/src/flow/room.py b/src/flow/room.py index 17b2247..9e5f1ff 100644 --- a/src/flow/room.py +++ b/src/flow/room.py @@ -11,6 +11,8 @@ def create_room(person: uuid.UUID, name: str = None): """ if not name: name = random.choice(ROOM_NAMES) - r = Room(name) + + r = Room(name=name, creator=person) r.add_person(person) + return r -- 2.45.2