add suit class
This commit is contained in:
parent
a85d1e5f9a
commit
49792f530d
1 changed files with 38 additions and 5 deletions
43
variants.py
43
variants.py
|
@ -1,8 +1,4 @@
|
||||||
import json
|
import enum
|
||||||
import os
|
|
||||||
import networkx as nx
|
|
||||||
from collections import OrderedDict
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
|
|
||||||
from database import cur
|
from database import cur
|
||||||
|
|
||||||
|
@ -31,6 +27,43 @@ def num_suits(var_id):
|
||||||
return cur.fetchone()[0]
|
return cur.fetchone()[0]
|
||||||
|
|
||||||
|
|
||||||
|
class ClueBehaviour(enum.Enum):
|
||||||
|
none = 0
|
||||||
|
default = 1
|
||||||
|
all = 2
|
||||||
|
|
||||||
|
|
||||||
|
class Suit:
|
||||||
|
def __init__(self, name, display_name, abbreviation, rank_clues, color_clues, prism, dark, rev, colors):
|
||||||
|
self.name = name
|
||||||
|
self.display_name = display_name
|
||||||
|
self.abbreviation = abbreviation
|
||||||
|
self.rank_clues = ClueBehaviour(rank_clues)
|
||||||
|
self.color_clues = ClueBehaviour(color_clues)
|
||||||
|
self.prism = prism
|
||||||
|
self.dark = dark
|
||||||
|
self.reversed = rev
|
||||||
|
|
||||||
|
self.colors = colors
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def from_db(suit_id):
|
||||||
|
cur.execute(
|
||||||
|
"SELECT name, display_name, abbreviation, rank_clues, color_clues, prism, dark, reversed "
|
||||||
|
"FROM suits "
|
||||||
|
"WHERE id = %s",
|
||||||
|
(suit_id,)
|
||||||
|
)
|
||||||
|
suit_properties = cur.fetchone()
|
||||||
|
|
||||||
|
cur.execute(
|
||||||
|
"SELECT color_id FROM suit_colors WHERE suit_id = %s",
|
||||||
|
(suit_id,)
|
||||||
|
)
|
||||||
|
colors = list(map(lambda t: t[0], cur.fetchall()))
|
||||||
|
return Suit(*suit_properties, colors)
|
||||||
|
|
||||||
|
|
||||||
class Variant:
|
class Variant:
|
||||||
def __init__(
|
def __init__(
|
||||||
self, name, clue_starved, throw_it_in_a_hole, alternating_clues, synesthesia, chimneys, funnels,
|
self, name, clue_starved, throw_it_in_a_hole, alternating_clues, synesthesia, chimneys, funnels,
|
||||||
|
|
Loading…
Reference in a new issue