def __init__(self, card: Card, n_gold_gems_to_use: int=0, use_gold_as: GemsCollection = GemsCollection()): """Parameters: _ _ _ _ _ _ _ _ card: Card to buy. gold_gems_to_use: Integer determining how many golden gems will be used to pay for the card. use_gold_as: Gems collection that reduces the price (its sum must equal n_gold_gems_to_use).""" self.card = card assert n_gold_gems_to_use == use_gold_as.sum(), 'n_gold_gems_to_use must be equal the sum of gems in use_gold_as' self.n_gold_gems_to_use = n_gold_gems_to_use self.use_gold_as = use_gold_as
def draw_gems(self, gems_collection: GemsCollection, x_coord: int, y_coord: int) -> None: self.main_canvas.create_text(x_coord + GEMS_SUMMARY_X, y_coord + GEMS_SUMMARY_Y, text=GEMS_SUMMARY_TITLE + str(gems_collection.sum()), font=GEMS_SUMMARY_FONT) for gem_color in GemColor: self.main_canvas.create_oval( x_coord + GEMS_BOARD_SHIFT * gem_color.value, y_coord, x_coord + GEMS_BOARD_SHIFT * gem_color.value + GEM_BOARD_OVAL_SIZE, y_coord + GEM_BOARD_OVAL_SIZE, fill=color_dict_tkiter[gem_color]) self.main_canvas.create_text( x_coord + GEMS_BOARD_SHIFT * gem_color.value + GEMS_BOARD_VALUE_SHIFT, y_coord + GEMS_BOARD_VALUE_VERTICAL_SHIFT, text=str(gems_collection.value(gem_color)), font=GEMS_BOARD_FONT)