Ejemplo n.º 1
0
def load_treasures(relpath=None):
    file = "treasures.csv"
    if relpath is None:
        treasure_values.clear()
    else:
        file = os.path.join("guilds", relpath, file)
        if not os.path.isfile(file):
            return
    with _open(file) as treasure_file:
        content = csv.reader(treasure_file, dialect="excel")
        for name, ttype, code, effect, flavour, box, deck, number in content:
            if not name or name.startswith("#"):
                continue
            treasure_values[casefold(name)].append({
                "name": name, "type": ttype, "code": parse(code, "T"), "effect": expand(effect),
                "flavour": expand(flavour), "box": box, "deck": deck, "number": int(number),
                "guild": int(relpath) if relpath else 0
            })
            wave = waves[box][0]
            pvalue = "T"
            if ttype == "O":
                pvalue = "O"
            if not deck:
                deck = None
            if deck not in cards_num[wave]:
                cards_num[wave][deck] = {}
            cards_num[wave][deck][int(number)] = (pvalue, name)

    log("Treasures loaded", level="local")
Ejemplo n.º 2
0
def load_pcards(relpath=None):
    file = "player_cards.csv"
    if relpath is None:
        player_cards.clear()
    else:
        file = os.path.join("guilds", relpath, file)
        if not os.path.isfile(file):
            return
    with _open(file) as player_file:
        content = csv.reader(player_file, dialect="excel")
        for name, ctype, cost, code, special, text, flavour, starter, box, deck, start, end in content:
            if not name or name.startswith("#"):
                continue
            start = int(start)
            end = int(end)
            player_cards[casefold(name)].append({
                "name": name, "type": ctype, "cost": int(cost), "code": parse(code, "P"),
                "special": expand(special, prefix=True), "text": expand(text),
                "flavour": expand(flavour), "starter": starter, "box": box,
                "deck": deck, "start": start, "end": end, "guild": int(relpath) if relpath else 0
            })
            nums = [start]
            if end and not starter:
                nums = range(start, end+1)
            elif end and starter:
                nums = [start, end]
            wave = waves[box][0]
            if not deck:
                deck = None
            if deck not in cards_num[wave]:
                cards_num[wave][deck] = {}
            for num in nums:
                cards_num[wave][deck][num] = ("P", name)

    log("Player cards loaded", level="local")
Ejemplo n.º 3
0
def load_nmats(relpath=None):
    file = "nemesis_mats.csv"
    if relpath is None:
        nemesis_mats.clear()
    else:
        file = os.path.join("guilds", relpath, file)
        if not os.path.isfile(file):
            return
    with _open(file) as nmats_file:
        content = csv.reader(nmats_file, dialect="excel")
        for name, hp, diff, battle, code, extra, unleash, setup, id_s, id_u, id_r, add_r, flavour, side, box, cards in content:
            if not name or name.startswith("#"):
                continue
            nemesis_mats[casefold(name)].append({
                "name": name, "hp": int(hp), "difficulty": int(diff), "unleash": expand(unleash),
                "setup": expand(setup), "additional_rules": expand(add_r), "flavour": expand(flavour),
                "code": parse(code, "M"), "extra": expand(extra), "id_setup": id_s, "id_unleash": id_u,
                "id_rules": id_r, "side": expand(side), "box": box, "battle": int(battle),
                "cards": cards.split(","), "guild": int(relpath) if relpath else 0
            })

    log("Nemesis mats loaded", level="local")
Ejemplo n.º 4
0
def load_ncards(relpath=None):
    file = "nemesis_cards.csv"
    if relpath is None:
        nemesis_cards.clear()
    else:
        file = os.path.join("guilds", relpath, file)
        if not os.path.isfile(file):
            return
    with _open(file) as nemesis_file:
        content = csv.reader(nemesis_file, dialect="excel")
        for name, ctype, tokens_hp, shield, tier, cat, code, special, discard, immediate, effect, flavour, box, deck, start, end in content:
            if not name or name.startswith("#"):
                continue
            start = int(start)
            if end:
                end = int(end)
            else:
                end = 0
            nemesis_cards[casefold(name)].append({
                "name": name, "type": ctype, "tokens_hp": (int(tokens_hp) if tokens_hp else 0),
                "shield": (int(shield) if shield else 0), "tier": int(tier), "category": cat,
                "code": parse(code, "N"), "special": expand(special, prefix=True), "discard": expand(discard),
                "immediate": expand(immediate), "effect": expand(effect), "flavour": expand(flavour),
                "box": box, "deck": deck, "start": start, "end": end, "guild": int(relpath) if relpath else 0
            })
            nums = [start]
            if end:
                nums = range(start, end+1)
            wave = waves[box][0]
            if not deck:
                deck = None
            if deck not in cards_num[wave]:
                cards_num[wave][deck] = {}
            for num in nums:
                cards_num[wave][deck][num] = ("N", name)

    log("Nemesis cards loaded", level="local")
Ejemplo n.º 5
0
def load_pmats(relpath=None):
    file = "player_mats.csv"
    if relpath is None:
        player_mats.clear()
    else:
        file = os.path.join("guilds", relpath, file)
        if not os.path.isfile(file):
            return
    with _open(file) as pmats_file:
        content = csv.reader(pmats_file, dialect="excel")
        for name, title, rating, aname, charges, atype, code, ability, special, breaches, hand, deck, b1, b2, b3, b4, flavour, box in content:
            if not name or name.startswith("#"):
                continue
            if not charges:
                charges = 0
            if not rating:
                rating = 0
            adict = {"name": aname, "charges": int(charges), "type": atype, "effect": expand(ability), "code": parse(code, "A")}
            blist = []
            for pos, breach in zip(breaches.split(","), (b1, b2, b3, b4)):
                pos = int(pos) if pos else 0
                if not breach: # just a regular breach
                    breach = None
                blist.append((pos, breach))
            player_mats[casefold(name)].append({
                "name": name, "title": title, "rating": int(rating), "ability": adict, "breaches": blist,
                "hand": hand.split(","), "deck": deck.split(","), "flavour": expand(flavour),
                "special": expand(special, prefix=True), "box": box, "guild": int(relpath) if relpath else 0
            })

    log("Player mats loaded", level="local")