Skip to content

Commit

Permalink
Create class Districs (#12)
Browse files Browse the repository at this point in the history
## What added:
- Rename district and rewrite function take_the_card

## This pull request close Issue #10 

Co-authored-by: Arrgentum <[email protected]>
  • Loading branch information
Arrgentum and Arrgentum authored Sep 18, 2022
1 parent 9044bfa commit d06134b
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions server/Districs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import random
from enum import Enum


class DistrictTypeList(Enum):
Bonus = 0
Military = 1
Religious = 2
Noble = 3
Trade = 4


class District(object):
"""Is a Basic character class"""

def __init__(self, name, type_of_district, price, quantity):
"""Constructor"""
self.name = name
self.type_of_district = type_of_district
self.price = price
self.quantity = quantity


class DistrictsList(Enum):
Watchtower = District("watchtower", DistrictTypeList.Military, 1, 3)
Prison = District("prison", DistrictTypeList.Military, 2, 3)
The_Field_of_Mars = District("the Field of Mars", DistrictTypeList.Military, 3, 3)
Fortress = District("fortress", DistrictTypeList.Military, 5, 2)

Temple = District("temple", DistrictTypeList.Religious, 1, 3)
Church = District("church", DistrictTypeList.Religious, 2, 3)
Monastery = District("monastery", DistrictTypeList.Religious, 3, 3)
Cathedral = District("cathedral", DistrictTypeList.Religious, 5, 2)

Estate = District("estate", DistrictTypeList.Noble, 3, 5)
Castle = District("castle", DistrictTypeList.Noble, 4, 4)
Palazzo = District("castle", DistrictTypeList.Noble, 5, 3)

Tavern = District("tavern", DistrictTypeList.Trade, 1, 5)
Market = District("market", DistrictTypeList.Trade, 2, 4)
Shop = District("shop", DistrictTypeList.Trade, 2, 3)
Port = District("port", DistrictTypeList.Trade, 3, 3)
Harbor = District("harbor", DistrictTypeList.Trade, 4, 3)
Guildhall = District("guildhall", DistrictTypeList.Trade, 5, 2)

@staticmethod
def take_the_cards(number=1, type_of_district=None):
return random.choices([i for i in DistrictsList for j in range(i.value.quantity) if (type_of_district is None or i.value.type_of_district == type_of_district)], k=number)

0 comments on commit d06134b

Please sign in to comment.