Ejemplo n.º 1
0
Archivo: guild.py Proyecto: diath/pyfsw
class GuildWar(db.Model):
    __tablename__ = 'guild_wars'

    # Constants
    Pending = 0
    Active = 1
    Rejected = 2
    Revoked = 3
    #PendingEnd = 4
    Ended = 4

    # Standard columns
    id = Column(Integer, primary_key=True, unique=True)
    guild1 = Column(Integer, ForeignKey('guilds.id'))
    guild2 = Column(Integer, ForeignKey('guilds.id'))
    name1 = Column(String(255))
    name2 = Column(String(255))
    status = Column(Integer)
    started = Column(Integer)
    ended = Column(Integer)
    frags = Column(Integer)

    # Relationships
    g1 = db.relationship('Guild', foreign_keys='GuildWar.guild1')
    g2 = db.relationship('Guild', foreign_keys='GuildWar.guild2')

    # Methods
    def __init__(self):
        pass

    def __repr__(self):
        return '<GuildWar.{}.{}.{}>'.format(self.id, self.guild1, self.guild2)
Ejemplo n.º 2
0
class Account(db.Model):
    __tablename__ = 'accounts'

    # Standard columns
    id = Column(Integer, primary_key=True, unique=True)
    name = Column(String(32))
    password = Column(String(40))
    type = Column(Integer, default=1)
    premdays = Column(Integer, default=0)
    lastday = Column(Integer, default=0)
    email = Column(String(255))
    creation = Column(Integer)
    lastpost = Column(Integer, default=0)

    # Custom columns
    key = Column(String(19))
    points = Column(Integer, default=0)
    web_access = Column(Integer, default=0)

    # Relationships
    players = db.relationship('Player', backref='accounts')

    # Methods
    def __init__(self):
        pass

    def __repr__(self):
        return '<Account.{}>'.format(self.id)
Ejemplo n.º 3
0
Archivo: guild.py Proyecto: diath/pyfsw
class GuildInvite(db.Model):
    __tablename__ = 'guild_invites'

    # Standard columns
    player_id = Column(Integer, ForeignKey('players.id'), primary_key=True)
    guild_id = Column(Integer, ForeignKey('guilds.id'))

    # Relationships
    player = db.relationship('Player', foreign_keys='GuildInvite.player_id')
    guild = db.relationship('Guild', foreign_keys='GuildInvite.guild_id')

    # Methods
    def __init__(self):
        pass

    def __repr__(self):
        return '<GuildInvite.{}.{}>'.format(self.guild_id, self.player_id)
Ejemplo n.º 4
0
Archivo: guild.py Proyecto: diath/pyfsw
class GuildWarKill(db.Model):
    __tablename__ = 'guildwar_kills'

    # Standard columns
    id = Column(Integer, primary_key=True, unique=True)
    killer = Column(Integer, ForeignKey('players.id'))
    target = Column(Integer, ForeignKey('players.id'))
    killerguild = Column(Integer, ForeignKey('guilds.id'))
    targetguild = Column(Integer, ForeignKey('guilds.id'))
    warid = Column(Integer, ForeignKey('guild_wars.id'))
    time = Column(Integer)

    # Relationships
    g1 = db.relationship('Guild', foreign_keys='GuildWarKill.killerguild')
    g2 = db.relationship('Guild', foreign_keys='GuildWarKill.targetguild')

    # Methods
    def __init__(self):
        pass

    def __repr__(self):
        return '<GuildWarKill.{}.{}>'.format(self.id, self.warid)
Ejemplo n.º 5
0
Archivo: guild.py Proyecto: diath/pyfsw
class GuildMembership(db.Model):
    __tablename__ = 'guild_membership'

    # Standard columns
    player_id = Column(Integer, ForeignKey('players.id'), primary_key=True)
    guild_id = Column(Integer, ForeignKey('guilds.id'))
    rank_id = Column(Integer, ForeignKey('guild_ranks.id'))
    nick = Column(String(15), default='')

    # Relationship
    player = db.relationship('Player',
                             foreign_keys='GuildMembership.player_id')
    guild = db.relationship('Guild', foreign_keys='GuildMembership.guild_id')
    rank = db.relationship('GuildRank', foreign_keys='GuildMembership.rank_id')

    # Methods
    def __init__(self):
        pass

    def __repr__(self):
        return '<GuildMembership.{}.{}.{}>'.format(self.guild_id,
                                                   self.player_id,
                                                   self.rank_id)
Ejemplo n.º 6
0
Archivo: shop.py Proyecto: diath/pyfsw
class ShopCategory(db.Model):
    __tablename__ = 'shop_category'

    # Standard columns
    id = Column(Integer, primary_key=True, unique=True)
    name = Column(String(32))
    enabled = Column(Integer, default=1)

    # Relationship
    items = db.relationship('ShopItem', backref='shop_category')

    # Methods
    def __init__(self):
        pass

    def __repr__(self):
        return '<ShopCategory.{}>'.format(self.id)
Ejemplo n.º 7
0
class ForumCategory(db.Model):
    __tablename__ = 'forum_categories'

    # Standard columns
    id = Column(Integer, unique=True, primary_key=True)
    name = Column(String(64))

    # Relationships
    boards = db.relationship('ForumBoard',
                             foreign_keys='ForumBoard.category_id')

    # Methods
    def __init__(self):
        pass

    def __repr__(self):
        return '<ForumCategory.{}>'.format(self.id)
Ejemplo n.º 8
0
Archivo: guild.py Proyecto: diath/pyfsw
class GuildRank(db.Model):
    __tablename__ = 'guild_ranks'

    # Standard columns
    id = Column(Integer, primary_key=True, unique=True)
    guild_id = Column(Integer, ForeignKey('guilds.id'))
    name = Column(String(255))
    level = Column(Integer)

    # Relationship
    guild = db.relationship('Guild', foreign_keys='GuildRank.guild_id')

    # Methods
    def __init__(self):
        pass

    def __repr__(self):
        return '<GuildRank.{}.{}.{}>'.format(self.guild_id, self.name,
                                             self.level)
Ejemplo n.º 9
0
Archivo: guild.py Proyecto: diath/pyfsw
class Guild(db.Model):
    __tablename__ = 'guilds'

    # Standard columns
    id = Column(Integer, primary_key=True, unique=True)
    name = Column(String(255))
    ownerid = Column(Integer, ForeignKey('players.id'))
    creationdata = Column(Integer)
    motd = Column(String(255))

    # Relationships
    owner = db.relationship('Player', foreign_keys='Guild.ownerid')

    # Methods
    def __init__(self):
        pass

    def __repr__(self):
        return '<Guild.{}>'.format(self.id)

    def memberCount(self):
        return db.session().query(GuildMembership.player_id).filter(
            GuildMembership.guild_id == self.id).count()
Ejemplo n.º 10
0
class Player(db.Model):
    __tablename__ = 'players'

    # Standard columns
    id = Column(Integer, primary_key=True, unique=True)
    name = Column(String(255), unique=True)
    group_id = Column(Integer, default=1)
    account_id = Column(Integer, ForeignKey('accounts.id'))
    level = Column(Integer, default=8)
    vocation = Column(Integer, default=0)
    health = Column(Integer, default=185)
    healthmax = Column(Integer, default=185)
    experience = Column(BigInteger, default=4200)
    lookbody = Column(Integer, default=0)
    lookfeet = Column(Integer, default=0)
    lookhead = Column(Integer, default=0)
    looklegs = Column(Integer, default=0)
    looktype = Column(Integer, default=136)
    lookaddons = Column(Integer, default=0)
    maglevel = Column(Integer, default=0)
    mana = Column(Integer, default=35)
    manamax = Column(Integer, default=35)
    manaspent = Column(Integer, default=0)
    soul = Column(Integer, default=100)
    town_id = Column(Integer, default=1)
    posx = Column(Integer, default=0)
    posy = Column(Integer, default=0)
    posz = Column(Integer, default=0)
    conditions = Column(Binary, default='')
    cap = Column(Integer, default=500)
    sex = Column(Integer, default=0)
    lastlogin = Column(BigInteger, default=0)
    lastip = Column(Integer, default=0)
    save = Column(Integer, default=1)
    skull = Column(Integer, default=0)
    skulltime = Column(Integer, default=0)
    lastlogout = Column(BigInteger, default=0)
    blessings = Column(Integer, default=0)
    onlinetime = Column(Integer, default=0)
    deletion = Column(BigInteger, default=0)
    balance = Column(BigInteger, default=0)
    offlinetraining_time = Column(Integer, default=43200)
    offlinetraining_skill = Column(Integer, default=-1)
    stamina = Column(Integer, default=2520)
    skill_fist = Column(Integer, default=10)
    skill_fist_tries = Column(Integer, default=0)
    skill_club = Column(Integer, default=10)
    skill_club_tries = Column(Integer, default=0)
    skill_sword = Column(Integer, default=10)
    skill_sword_tries = Column(Integer, default=0)
    skill_axe = Column(Integer, default=10)
    skill_axe_tries = Column(Integer, default=0)
    skill_dist = Column(Integer, default=10)
    skill_dist_tries = Column(Integer, default=0)
    skill_shielding = Column(Integer, default=10)
    skill_shielding_tries = Column(Integer, default=0)
    skill_fishing = Column(Integer, default=10)
    skill_fishing_tries = Column(Integer, default=10)

    # Custom columns
    comment = Column(String(255), default='')
    hidden = Column(Integer, default=0)
    postcount = Column(Integer, default=0)
    signature = Column(String(255), default='')

    # Relationships
    storages = db.relationship(
        'PlayerStorage',
        primaryjoin='Player.id == PlayerStorage.player_id',
        backref='players',
        passive_deletes=True)

    # Misc
    guild = None

    # Methods
    def __init__(self):
        pass

    def __repr__(self):
        return '<Player.{}>'.format(self.id)

    def getStorageValue(self, key):
        for storage in self.storages:
            if storage.key == key:
                return storage.value

        return -1

    def getGuild(self):
        if self.guild:
            return self.guild

        membership = db.session().query(GuildMembership.guild_id).filter(
            GuildMembership.player_id == self.id).first()
        if not membership:
            return None

        guild = Guild.query.filter(Guild.id == membership.guild_id).first()
        if not guild:
            return None

        self.guild = guild
        self.membership = membership

        return self.guild