Пример #1
0
def _register_evos(cards):
    """Register `mon.evos`.
    """
    buckets = bucketize(values(cards), aget('preevo'), ignores={0})
    for mon_id, evos in items(buckets):
        mon = cards[mon_id]
        mon.evos = evos
Пример #2
0
def _register_families(cards):
    """Register `mon.family`.
    """
    buckets = bucketize(values(cards), aget('base'))
    for base_id, members in items(buckets):
        # fam = CardFamily(base_id, members)
        # for member in fam:
        # member.family = fam
        for member in members:
            member.family = members
Пример #3
0
def loadjson(j, limit=INSANE_CARD_LIMIT):
    """Load from JSON dict.
    """
    raws = j['card']
    v = j['v']
    #^ We can use version to determine what the fields are.
    if v < 810:
        raise NotImplementedError(v)
    raws = [card[:] for card in raws]
    if v < 900:  # Collab and inherits.
        for card in raws:
            card.extend((0, 0))
    if v < 920:  # Index.
        for i, card in items(raws):
            card.insert(0, i)
    if v < 1220:  # Weird furigana thing.
        for card in raws:
            card.append('')
    if v < 1230:  # Limit break.
        for card in raws:
            card.append(0)
    if v < 1240:  # Super awakening (prep).
        for card in raws:
            card.insert(-9, '')
    if v < 1520:  # Voice.
        for card in raws:
            card.append(0)
    if v < 1600:  # Orbskin.
        for card in raws:
            card.append(0)
    # 1800: HT 2019-10-11
    # 1800: NA 2019-10-~20
    if v < 1800:  # Only used so far for Fagan Rai?
        for card in raws:
            card.append('')
    if v > 1800:
        # Should raise a warning here.
        warnings.warn("Unknown card_data version: %s" % v)
    # else:
    # raise ValueError("%r has unknown card version %s." % (fpath, v))
    cards = Index((raw[0], BookCard(raw)) for raw in values(raws)
                  if not limit or raw[0] < limit)

    _register_evos(cards)
    _register_families(cards)

    return cards
Пример #4
0
def loadjson(j, limit=INSANE_CARD_LIMIT):
    """Load from JSON dict.
    """
    raws = j['card']
    v = j['v']
    #^ We can use version to determine what the fields are.
    if v == 810:
        raise NotImplementedError('BookCard810')
    elif v == 900:
        cards = [BookCard900(i, raw) for i, raw in items(raws)]
        # cards = util.Bag(cards)
    elif v == 920:
        cards = Index((raw[0], BookCard920(raw)) for raw in values(raws)
                      if not limit or raw[0] < limit)
    else:
        fpath = "FORGOT TO ADD FPATH"
        raise ValueError("%r has unknown card version %s." % (fpath, v))

    _register_evos(cards)
    _register_families(cards)

    return cards
Пример #5
0
def loadjson(j):
    """Load from JSON dict.
    """
    raws = j['card']
    v = j['v']
    #^ We can use version to determine what the fields are.
    if v < 810:
        raise NotImplementedError(v)
    raws = [card[:] for card in raws]
    if v < 900:  # Collab and inherits.
        for card in raws:
            card.extend((0, 0))
    if v < 920:  # Index.
        for i, card in items(raws):
            card.insert(0, i)
    if v < 1220:  # Weird furigana thing.
        for card in raws:
            card.append('')
    if v < 1230:  # Limit break.
        for card in raws:
            card.append(0)
    if v < 1240:  # Super awakening (prep).
        for card in raws:
            card.insert(-9, '')
    if v > 1250:
        # Should raise a warning here.
        warnings.warn("Unknown card_data version: %s" % v)
    # else:
    # raise ValueError("%r has unknown card version %s." % (fpath, v))
    cards = OrderedDict((raw[0], BookCard(raw)) for raw in values(raws)
                        if raw[0] < INSANE_CARD_LIMIT)

    _register_evos(cards)
    _register_families(cards)

    return cards
Пример #6
0
 def values(self):
     return values(self.db)