Пример #1
0
class GameClass(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    spec = db.relationship('GameSpec', backref = 'g_class', lazy='dynamic') #dynamic

    name_ru = db.Column(db.String(128), index = True, unique = False)
    name_en = db.Column(db.String(128), index = True, unique = False)
    name_de = db.Column(db.String(128), index = True, unique = False)
    name_fr = db.Column(db.String(128), index = True, unique = False)
    name_es = db.Column(db.String(128), index = True, unique = False)

    power_type = db.Column(db.String(128), index = True, unique = False)
    icon = db.Column(db.String(64), index = False, unique = False)


    def __init__(self,
                 name_ru,
                 name_en,
                 name_de,
                 name_fr,
                 name_es,
                 power_type,
                 icon):
        self.name_ru = name_ru
        self.name_en = name_en
        self.name_de = name_de
        self.name_fr = name_fr
        self.name_es = name_es

        self.power_type = power_type
        self.icon = icon

    def __repr__(self):

        return 'Name: {}; Id: {}'.format(self.name_ru, self.id)
Пример #2
0
class Items(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    gameId = db.Column(db.Integer, index = True)

    description_ru = db.Column(db.String(512), index = True, unique = False)
    description_en = db.Column(db.String(512), index = False, unique = False)
    description_de = db.Column(db.String(512), index = False, unique = False)
    description_fr = db.Column(db.String(512), index = False, unique = False)

    name_ru = db.Column(db.String(128), index = True, unique = False)
    name_en = db.Column(db.String(128), index = True, unique = False)
    name_de = db.Column(db.String(128), index = True, unique = False)
    name_fr = db.Column(db.String(128), index = True, unique = False)

    icon = db.Column(db.String(128), index = True, unique = False)
    buyPrice = db.Column(db.Integer, index = True)
    itemClass = db.Column(db.Integer, index = True)
    itemSubClass = db.Column(db.Integer, index = True)
    inventoryType = db.Column(db.Integer, index = True)
    equippable = db.Column(db.Boolean, index = True)
    itemLevel = db.Column(db.Integer, index = True)
    sellPrice = db.Column(db.Integer, index = True)
    isAuctionable = db.Column(db.Boolean, index = True)
    sourceId = db.Column(db.String(64), index = True, unique = False)
    sourceType = db.Column(db.String(64), index = True, unique = False)
    nameDescription = db.Column(db.String(128), index = False, unique = False)

    aucs = db.relationship('Auctions', backref = 'item', lazy='dynamic')




    def __init__(self,gameId,description_ru,description_en,description_de,description_fr,name_ru,name_en, name_de, name_fr,icon,buyPrice,itemClass,itemSubClass,inventoryType,equippable,itemLevel,sellPrice,isAuctionable,sourceId,sourceType,nameDescription):
        self.gameId = int(gameId)

        self.description_ru = description_ru
        self.description_en = description_en
        self.description_de =description_de
        self.description_fr = description_fr

        self.name_ru = name_ru
        self.name_en = name_en
        self.name_de = name_de
        self.name_fr = name_fr

        self.icon = icon
        self.buyPrice = int(buyPrice)
        self.itemClass = int(itemClass)
        self.itemSubClass = int(itemSubClass)
        self.inventoryType = int(inventoryType)
        self.equippable = bool(equippable)
        self.itemLevel = int(itemLevel)
        self.sellPrice = int(sellPrice)
        self.isAuctionable = bool(isAuctionable)
        self.sourceId = sourceId
        self.sourceType=sourceType
        self.nameDescription = nameDescription

    def __repr__(self):
        return "Name: {}; Description: {}; Source: {};".format(self.name_ru, self.description_ru, self.sourceType)
Пример #3
0
class GameSpec(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    class_id = db.Column(db.Integer, db.ForeignKey('game_class.id'), nullable = False)
    spec = db.relationship('Talants', backref = 'g_spec', lazy='dynamic') #Поле нужно переименновать в talant


    name_ru = db.Column(db.String(128), index=True, unique=False)
    name_en = db.Column(db.String(128), index=True, unique=False)
    name_de = db.Column(db.String(128), index=True, unique=False)
    name_fr = db.Column(db.String(128), index=True, unique=False)
    name_es = db.Column(db.String(128), index=True, unique=False)

    description_ru = db.Column(db.String(550), index=True, unique=False)
    description_en = db.Column(db.String(550), index=True, unique=False)
    description_de = db.Column(db.String(550), index=True, unique=False)
    description_fr = db.Column(db.String(550), index=True, unique=False)
    description_es = db.Column(db.String(550), index=True, unique=False)

    role = db.Column(db.String(64), index=True, unique=False)
    icon = db.Column(db.String(64), index=True, unique=False)
    backgroundImage = db.Column(db.String(64), index=True, unique=False)
    order = db.Column(db.Integer, index=True)

    def __init__(self,
                 g_class,
                 name_ru,
                 name_en,
                 name_de,
                 name_fr,
                 name_es,

                 description_ru,
                 description_en,
                 description_de,
                 description_fr,
                 description_es,
                 role,
                 icon,
                 backgroundImage,
                 order
                 ):

        self.g_class = g_class

        self.name_ru = name_ru
        self.name_en = name_en
        self.name_de = name_de
        self.name_fr = name_fr
        self.name_es = name_es

        self.description_ru = description_ru
        self.description_en = description_en
        self.description_de = description_de
        self.description_fr = description_fr
        self.description_es = description_es

        self.role = role
        self.icon = icon
        self.backgroundImage = backgroundImage
        self.order = int(order)

    def __repr__(self):
        return "Spec: {}; Class: {}".format(self.name_ru, self.g_class.name_ru) #Протестить
Пример #4
0
class Pets(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    canBattle = db.Column(db.Boolean, index = True)
    creatureId = db.Column(db.Integer, index = True)

    name_ru = db.Column(db.String(128), index = True, unique = False)
    name_en = db.Column(db.String(128), index = True, unique = False)
    name_de = db.Column(db.String(128), index = True, unique = False)
    name_fr = db.Column(db.String(128), index = True, unique = False)
    name_es = db.Column(db.String(128), index = True, unique = False)

    description_ru = db.Column(db.String(1200), index = True, unique = False)
    description_en = db.Column(db.String(1200), index = True, unique = False)
    description_de = db.Column(db.String(1200), index = True, unique = False)
    description_fr = db.Column(db.String(1200), index = True, unique = False)
    description_es = db.Column(db.String(1200), index = True, unique = False)

    source_ru = db.Column(db.String(1200), index = True, unique = False)
    source_en = db.Column(db.String(1200), index = True, unique = False)
    source_de = db.Column(db.String(1200), index = True, unique = False)
    source_fr = db.Column(db.String(1200), index = True, unique = False)
    source_es = db.Column(db.String(1200), index = True, unique = False)

    abilities = db.Column(JSON)
    family = db.Column(db.String(64), index = True, unique = False)
    icon = db.Column(db.String(64), index = True, unique = False)
    speciesId = db.Column(db.Integer, index = True)
    qualityId = db.Column(db.Integer, index = True)

    breedId = db.Column(db.Integer, index = True)
    petQualityId = db.Column(db.Integer, index = True)
    level = db.Column(db.Integer, index = True)
    health = db.Column(db.Integer, index = True)
    power = db.Column(db.Integer, index = True)
    speed = db.Column(db.Integer, index = True)

    strongAgainst = db.Column(db.String(64), index = True, unique = False)
    weakAgainst = db.Column(db.String(64), index = True, unique = False)
    typeId = db.Column(db.Integer, index = True)

    aucs = db.relationship('Auctions', backref = 'pet', lazy='dynamic')

    def __init__(self,
                 canBattle,
                 creatureId,

                 name_ru,
                 name_en,
                 name_de,
                 name_fr,
                 name_es,

                 description_ru,
                 description_en,
                 description_de,
                 description_fr,
                 description_es,

                 source_ru,
                 source_en,
                 source_de,
                 source_fr,
                 source_es,

                 abilities,
                 family,
                 icon,
                 speciesId,
                 qualityId,

                 breedId,
                 petQualityId,
                 level,
                 health,
                 power,
                 speed,

                 strongAgainst,
                 weakAgainst,
                 typeId):

        self.canBattle = bool(canBattle)
        self.creatureId = int(creatureId)

        self.name_ru = name_ru
        self.name_en = name_en
        self.name_de = name_de
        self.name_fr = name_fr
        self.name_es = name_es

        self.description_ru = description_ru
        self.description_en = description_en
        self.description_de = description_de
        self.description_fr = description_fr
        self.description_es = description_es

        self.source_ru = source_ru
        self.source_en = source_en
        self.source_de = source_de
        self.source_fr = source_fr
        self.source_es = source_es

        self.abilities = abilities
        self.family = family
        self.icon = icon
        self.speciesId = int(speciesId)
        self.qualityId = int(qualityId)

        self.breedId = int(breedId)
        self.petQualityId = int(petQualityId)
        self.level = int(level)
        self.health = int(health)
        self.power = int(power)
        self.speed = int(speed)

        self.strongAgainst = strongAgainst
        self.weakAgainst = weakAgainst
        self.typeId = int(typeId)

    def __repr__(self):
        return "Name: {}; Desc: {} ".format(self.name_ru, self.description_ru)
Пример #5
0
class Auctions(db.Model, SavePetAndItem):
    id = db.Column(db.Integer, primary_key = True)
    auc = db.Column(db.Integer)

    item_id = db.Column(db.Integer, db.ForeignKey('items.id'), nullable = True)
    pet_id = db.Column(db.Integer, db.ForeignKey('pets.id'), nullable = True)
    servers = db.relationship('Servers', secondary = servers_auctions, backref = 'aucs')

    timestamp = db.Column(db.DateTime,index = True)
    owner = db.Column(db.String(64), index = True, unique = False)
    ownerRealm = db.Column(db.String(64), index = True, unique = False)
    bid = db.Column(BIGINT, index = True)
    buyout = db.Column(BIGINT, index = True)
    quantity = db.Column(db.Integer, index = True)
    timeLeft = db.Column(db.String(64), index = True, unique = False)
    rand = db.Column(db.String(128), unique = False)
    seed = db.Column(db.String(128), unique = False)
    context = db.Column(db.Integer, index = True)
    bonusLists = db.Column(JSON,nullable = True)
    modifiers = db.Column(JSON,nullable = True)
    petBreedId = db.Column(db.Integer, index = True,nullable = True)
    petLevel = db.Column(db.Integer, index = True,nullable = True)
    petQualityId = db.Column(db.Integer, index = True,nullable = True)

    def __init__(self, auc, itemId,servers, timestamp,owner,ownerRealm,bid,
                 buyout,quantity,timeLeft,rand,seed,context, token,
                 bonusLists = None,modifiers = None,petBreedId = None,petLevel = None,  speciesId = None, is_must_add_new = True):
        self.auc = int(auc)
        self.timestamp = timestamp
        self.owner = owner
        self.ownerRealm = ownerRealm
        self.bid = int(bid)
        self.buyout = int(buyout)
        self.quantity = int(quantity)
        self.timeLeft = timeLeft
        self.rand = rand
        self.seed = seed
        self.context = int(context)
        self.bonusLists = bonusLists
        self.modifiers = modifiers

        if petBreedId is None:
            self.petBreedId = petBreedId
        else:
            self.petBreedId = int(petBreedId)
        if petLevel is None:
            self.petLevel = petLevel
        else:
            self.petLevel = int(petLevel)



        self.pet = self.savePet(speciesId=speciesId, is_must_add_new=is_must_add_new, token=token)
        self.item = self.saveItem(id=itemId, token=token, is_must_add_new=is_must_add_new, is_run_in_model=True)
        self.addServers(servers)

        self.serv_for_repr = servers

    def __repr__(self):
        return "Auc: {}; Servers: {}".format(self.auc, list([s.name_ru for s in self.serv_for_repr]))



    def savePet(self,speciesId, token, is_must_add_new=True):
        apiMasterList = "https://us.api.blizzard.com/wow/pet/?locale=en_US&access_token={}".format(token)
        if speciesId is not None:
            pet_from_db = Pets.query.filter(Pets.speciesId == str(speciesId)).first()  # type: Pets
            if pet_from_db is not None:
                return  pet_from_db
            else: #хоть написаный выше код и повторяется в savePet, но зато нам не надо ради каждого пета обращаться по сети..
                pets = getJSON(apiMasterList)["pets"]
                pet = None
                for pet in pets: #Ищем нужного пета в списке
                    if pet["stats"]["speciesId"] == speciesId:
                        break
                SavePetAndItem.savePet(self, pet= pet, token = token,is_must_add_new=is_must_add_new, is_run_in_model=True)
        else:
            return None

    def addServers(self, servers):
        for server in servers:
            self.servers.append(server)