def __init__(self): Struct.__init__( self, # line[0] version=1, ext=".gif", type=CSI.TYPE_FRENCH, ncards=-1, styles=[], year=0, # line[1] ident="", name="", # line[2] CARDW=0, CARDH=0, CARDD=0, # line[3] CARD_XOFFSET=0, CARD_YOFFSET=0, SHADOW_XOFFSET=0, SHADOW_YOFFSET=0, # line[4] backindex=0, # line[5] backnames=(), # other CARD_DX=0, # relative pos of real card image within Card CARD_DY=0, )
def __init__(self, **kw): kw = KwStruct(kw, name = "", filename = "", basename = "", # basename of filename absname = "", # absolute filename # implicit index = -1, error = 0, # error while loading this resource ) Struct.__init__(self, **kw.getKw())
def __init__(self, **kw): kw = KwStruct( kw, name="", filename="", basename="", # basename of filename absname="", # absolute filename # implicit index=-1, error=0, # error while loading this resource ) Struct.__init__(self, **kw.getKw())
def __init__( self, id, gameclass, name, game_type, decks, redeals, skill_level=None, # keyword arguments: si={}, category=0, short_name=None, altnames=(), suits=list(range(4)), ranks=list(range(13)), trumps=(), rules_filename=None, ): # def to_unicode(s): if isinstance(s, six.text_type): return s try: s = six.text_type(s, 'utf-8') except UnicodeDecodeError as err: print_err(err) s = six.text_type(s, 'utf-8', 'ignore') return s ncards = decks * (len(suits) * len(ranks) + len(trumps)) game_flags = game_type & ~1023 game_type = game_type & 1023 name = to_unicode(name) en_name = name # for app.getGameRulesFilename if pysollib.settings.TRANSLATE_GAME_NAMES: name = _(name) if not short_name: short_name = name else: short_name = to_unicode(short_name) if pysollib.settings.TRANSLATE_GAME_NAMES: short_name = _(short_name) if isinstance(altnames, six.string_types): altnames = (altnames, ) altnames = [to_unicode(n) for n in altnames] if pysollib.settings.TRANSLATE_GAME_NAMES: altnames = [_(n) for n in altnames] # if not (1 <= category <= 9): if game_type == GI.GT_HANAFUDA: category = GI.GC_HANAFUDA elif game_type == GI.GT_TAROCK: category = GI.GC_TAROCK elif game_type == GI.GT_MAHJONGG: category = GI.GC_MAHJONGG elif game_type == GI.GT_HEXADECK: category = GI.GC_HEXADECK elif game_type == GI.GT_MUGHAL_GANJIFA: category = GI.GC_MUGHAL_GANJIFA elif game_type == GI.GT_NAVAGRAHA_GANJIFA: category = GI.GC_NAVAGRAHA_GANJIFA elif game_type == GI.GT_DASHAVATARA_GANJIFA: category = GI.GC_DASHAVATARA_GANJIFA else: category = GI.GC_FRENCH # if not (1 <= id <= 999999): raise GameInfoException(name + ": invalid game ID " + str(id)) if category == GI.GC_MAHJONGG: if decks % 4: raise GameInfoException(name + ": invalid number of decks " + str(id)) else: if not (1 <= decks <= 4): raise GameInfoException(name + ": invalid number of decks " + str(id)) if not name: raise GameInfoException(name + ": invalid game name") if GI.PROTECTED_GAMES.get(id): raise GameInfoException(name + ": protected game ID " + str(id)) # for f, l in ((GI.GT_CHILDREN, GI._CHILDREN_GAMES), (GI.GT_OPEN, GI._OPEN_GAMES), (GI.GT_POPULAR, GI._POPULAR_GAMES)): if (game_flags & f) and (id not in l): l.append(id) elif not (game_flags & f) and (id in l): game_flags = game_flags | f # si is the SelectionInfo struct that will be queried by # the "select game" dialogs. It can be freely modified. gi_si = Struct(game_type=game_type, game_flags=game_flags, decks=decks, redeals=redeals, ncards=ncards) gi_si.update(si) # Struct.__init__(self, id=id, gameclass=gameclass, name=name, short_name=short_name, altnames=tuple(altnames), en_name=en_name, decks=decks, redeals=redeals, ncards=ncards, category=category, skill_level=skill_level, suits=tuple(suits), ranks=tuple(ranks), trumps=tuple(trumps), si=gi_si, rules_filename=rules_filename)