コード例 #1
0
ファイル: ninja.py プロジェクト: klabacher/houdini-ServiceWin
class Card(db.Model):
    __tablename__ = 'card'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), nullable=False)
    set_id = db.Column(db.SmallInteger,
                       nullable=False,
                       server_default=db.text("1"))
    power_id = db.Column(db.SmallInteger,
                         nullable=False,
                         server_default=db.text("0"))
    element = db.Column(db.CHAR(1),
                        nullable=False,
                        server_default=db.text("'s'::bpchar"))
    color = db.Column(db.CHAR(1),
                      nullable=False,
                      server_default=db.text("'b'::bpchar"))
    value = db.Column(db.SmallInteger,
                      nullable=False,
                      server_default=db.text("2"))
    description = db.Column(db.String(255),
                            nullable=False,
                            server_default=db.text("''::character varying"))

    def get_string(self):
        return f'{self.id}|{self.element}|{self.value}|{self.color}|{self.power_id}'
コード例 #2
0
class Stamp(db.Model):
    __tablename__ = 'stamp'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), nullable=False)
    group_id = db.Column(db.ForeignKey('stamp_group.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
    member = db.Column(db.Boolean, nullable=False, server_default=db.text("false"))
    rank = db.Column(db.SmallInteger, nullable=False, server_default=db.text("1"))
    description = db.Column(db.String(255), nullable=False, server_default=db.text("''::character varying"))
コード例 #3
0
class RedemptionCode(db.Model):
    __tablename__ = 'redemption_code'

    id = db.Column(db.Integer,
                   primary_key=True,
                   server_default=db.text(
                       "nextval('\"redemption_code_id_seq\"'::regclass)"))
    code = db.Column(db.String(16), nullable=False, unique=True)
    type = db.Column(db.String(8),
                     nullable=False,
                     server_default=db.text("'BLANKET'::character varying"))
    coins = db.Column(db.Integer, nullable=False, server_default=db.text("0"))
    expires = db.Column(db.DateTime)
コード例 #4
0
class QuestTask(db.Model):
    __tablename__ = 'quest_task'

    id = db.Column(
        db.Integer,
        primary_key=True,
        server_default=db.text("nextval('\"quest_id_seq\"'::regclass)"))
    quest_id = db.Column(db.ForeignKey('quest.id',
                                       ondelete='CASCADE',
                                       onupdate='CASCADE'),
                         nullable=False)
    description = db.Column(db.String(50), nullable=False)
    room_id = db.Column(
        db.ForeignKey('room.id', ondelete='CASCADE', onupdate='CASCADE'))
    data = db.Column(db.String(50))
コード例 #5
0
class PenguinTrack(db.Model):
    __tablename__ = 'penguin_track'

    id = db.Column(db.Integer,
                   primary_key=True,
                   server_default=db.text(
                       "nextval('\"penguin_track_id_seq\"'::regclass)"))
    name = db.Column(db.String(12),
                     nullable=False,
                     server_default=db.text("''::character varying"))
    owner_id = db.Column(db.ForeignKey('penguin.id',
                                       ondelete='CASCADE',
                                       onupdate='CASCADE'),
                         nullable=False)
    sharing = db.Column(db.Boolean,
                        nullable=False,
                        server_default=db.text("false"))
    pattern = db.Column(db.Text, nullable=False)

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        self._likes = 0

    @property
    def likes(self):
        return self._likes

    @likes.setter
    def likes(self, like_count):
        self._likes = like_count
コード例 #6
0
class Character(db.Model):
    __tablename__ = 'character'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(30), nullable=False)
    gift_id = db.Column(db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    stamp_id = db.Column(db.ForeignKey('stamp.id', ondelete='CASCADE', onupdate='CASCADE'))
コード例 #7
0
ファイル: mail.py プロジェクト: klabacher/houdini-ServiceWin
class PenguinPostcard(db.Model):
    __tablename__ = 'penguin_postcard'

    id = db.Column(db.Integer,
                   primary_key=True,
                   server_default=db.text(
                       "nextval('\"penguin_postcard_id_seq\"'::regclass)"))
    penguin_id = db.Column(db.ForeignKey('penguin.id',
                                         ondelete='CASCADE',
                                         onupdate='CASCADE'),
                           nullable=False,
                           index=True)
    sender_id = db.Column(db.ForeignKey('penguin.id',
                                        ondelete='CASCADE',
                                        onupdate='CASCADE'),
                          index=True)
    postcard_id = db.Column(db.ForeignKey('postcard.id',
                                          ondelete='CASCADE',
                                          onupdate='CASCADE'),
                            nullable=False)
    send_date = db.Column(db.DateTime,
                          nullable=False,
                          server_default=db.text("now()"))
    details = db.Column(db.String(255),
                        nullable=False,
                        server_default=db.text("''::character varying"))
    has_read = db.Column(db.Boolean,
                         nullable=False,
                         server_default=db.text("false"))
コード例 #8
0
ファイル: pet.py プロジェクト: Josecholi/Houdini-asyncio
class Puffle(db.Model):
    __tablename__ = 'puffle'

    id = db.Column(db.Integer, primary_key=True)
    parent_id = db.Column(db.ForeignKey('puffle.id',
                                        ondelete='CASCADE',
                                        onupdate='CASCADE'),
                          nullable=False)
    name = db.Column(db.String(50),
                     nullable=False,
                     server_default=db.text("''::character varying"))
    member = db.Column(db.Boolean,
                       nullable=False,
                       server_default=db.text("false"))
    favourite_food = db.Column(db.ForeignKey('puffle_item.id',
                                             ondelete='CASCADE',
                                             onupdate='CASCADE'),
                               nullable=False)
    runaway_postcard = db.Column(
        db.ForeignKey('postcard.id', ondelete='CASCADE', onupdate='CASCADE'))
    max_food = db.Column(db.SmallInteger,
                         nullable=False,
                         server_default=db.text("100"))
    max_rest = db.Column(db.SmallInteger,
                         nullable=False,
                         server_default=db.text("100"))
    max_clean = db.Column(db.SmallInteger,
                          nullable=False,
                          server_default=db.text("100"))
コード例 #9
0
ファイル: igloo.py プロジェクト: Blueyzachary/houdini-asyncio
class Furniture(db.Model):
    __tablename__ = 'furniture'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), nullable=False)
    type = db.Column(db.SmallInteger,
                     nullable=False,
                     server_default=db.text("1"))
    sort = db.Column(db.SmallInteger,
                     nullable=False,
                     server_default=db.text("1"))
    cost = db.Column(db.Integer, nullable=False, server_default=db.text("0"))
    member = db.Column(db.Boolean,
                       nullable=False,
                       server_default=db.text("false"))
    patched = db.Column(db.Boolean,
                        nullable=False,
                        server_default=db.text("false"))
    legacy_inventory = db.Column(db.Boolean,
                                 nullable=False,
                                 server_default=db.text("false"))
    vanilla_inventory = db.Column(db.Boolean,
                                  nullable=False,
                                  server_default=db.text("false"))
    bait = db.Column(db.Boolean,
                     nullable=False,
                     server_default=db.text("false"))
    max_quantity = db.Column(db.SmallInteger,
                             nullable=False,
                             server_default=db.text("100"))
    innocent = db.Column(db.Boolean,
                         nullable=False,
                         server_default=db.text("false"))
コード例 #10
0
class Permission(db.Model):
    __tablename__ = 'permission'

    name = db.Column(db.String(50), nullable=False, primary_key=True)
    enabled = db.Column(db.Boolean,
                        nullable=False,
                        server_default=db.text("true"))
コード例 #11
0
class StampGroup(db.Model):
    __tablename__ = 'stamp_group'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), nullable=False)
    parent_id = db.Column(
        db.ForeignKey('stamp_group.id', ondelete='CASCADE',
                      onupdate='CASCADE'))
コード例 #12
0
class DanceSong(db.Model):
    __tablename__ = 'dance_song'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(30), nullable=False)
    song_length_millis = db.Column(db.Integer, nullable=False)
    song_length = db.Column(db.Integer, nullable=False)
    millis_per_bar = db.Column(db.Integer, nullable=False)
コード例 #13
0
class RoomWaddle(db.Model):
    __tablename__ = 'room_waddle'

    id = db.Column(db.Integer, primary_key=True, nullable=False)
    room_id = db.Column(db.ForeignKey('room.id',
                                      ondelete='CASCADE',
                                      onupdate='CASCADE'),
                        primary_key=True,
                        nullable=False)
    seats = db.Column(db.SmallInteger,
                      nullable=False,
                      server_default=db.text("2"))
    game = db.Column(db.String(20), nullable=False)

    def __init__(self, *args, **kwargs):
        self.temporary = kwargs.pop('temporary', False)
        self.penguins = []
        self.logic = None
        self.room = None

        super().__init__(*args, **kwargs)

    async def add_penguin(self, p):
        seat_id = self.penguins.index(None)
        self.penguins[seat_id] = p
        await p.send_xt('jw', seat_id)
        await p.room.send_xt('uw', self.id, seat_id, p.safe_name)

        p.waddle = self

        if self.penguins.count(None) == 0:
            game_instance = self.logic(self)

            await game_instance.start()

            await self.reset()

            if self.temporary:
                del self.room.waddles[self.id]

    async def remove_penguin(self, p):
        seat_id = self.get_seat_id(p)
        self.penguins[seat_id] = None
        await p.room.send_xt('uw', self.id, seat_id)

        p.waddle = None

        if self.temporary and self.penguins.count(None) == self.seats:
            del self.room.waddles[self.id]

    async def reset(self):
        for seat_id, penguin in enumerate(self.penguins):
            if penguin:
                self.penguins[seat_id] = None
                await penguin.room.send_xt('uw', self.id, seat_id)

    def get_seat_id(self, p):
        return self.penguins.index(p)
コード例 #14
0
ファイル: mail.py プロジェクト: klabacher/houdini-ServiceWin
class Postcard(db.Model):
    __tablename__ = 'postcard'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), nullable=False)
    cost = db.Column(db.Integer, nullable=False, server_default=db.text("10"))
    enabled = db.Column(db.Boolean,
                        nullable=False,
                        server_default=db.text("false"))
コード例 #15
0
class Flooring(db.Model):
    __tablename__ = 'flooring'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50))
    cost = db.Column(db.Integer, nullable=False, server_default=db.text("0"))
    patched = db.Column(db.Boolean,
                        nullable=False,
                        server_default=db.text("false"))
コード例 #16
0
class Item(db.Model):
    __tablename__ = 'item'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50))
    type = db.Column(db.SmallInteger,
                     nullable=False,
                     server_default=db.text("1"))
    cost = db.Column(db.Integer, nullable=False, server_default=db.text("0"))
    member = db.Column(db.Boolean,
                       nullable=False,
                       server_default=db.text("false"))
    bait = db.Column(db.Boolean,
                     nullable=False,
                     server_default=db.text("false"))
    patched = db.Column(db.Boolean,
                        nullable=False,
                        server_default=db.text("false"))
    epf = db.Column(db.Boolean,
                    nullable=False,
                    server_default=db.text("false"))
    tour = db.Column(db.Boolean,
                     nullable=False,
                     server_default=db.text("false"))
    release_date = db.Column(db.Date,
                             nullable=False,
                             server_default=db.text("now()"))

    def is_color(self):
        return self.type == 1

    def is_head(self):
        return self.type == 2

    def is_face(self):
        return self.type == 3

    def is_neck(self):
        return self.type == 4

    def is_body(self):
        return self.type == 5

    def is_hand(self):
        return self.type == 6

    def is_feet(self):
        return self.type == 7

    def is_flag(self):
        return self.type == 8

    def is_photo(self):
        return self.type == 9

    def is_award(self):
        return self.type == 10
コード例 #17
0
class RedemptionBookWord(db.Model):
    __tablename__ = 'redemption_book_word'

    question_id = db.Column(db.Integer, primary_key=True, server_default=db.text("nextval('\"redemption_book_word_question_id_seq\"'::regclass)"))
    book_id = db.Column(db.ForeignKey('redemption_book.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,
                        nullable=False)
    page = db.Column(db.SmallInteger, primary_key=True, nullable=False, server_default=db.text("1"))
    line = db.Column(db.SmallInteger, primary_key=True, nullable=False, server_default=db.text("1"))
    word_number = db.Column(db.SmallInteger, primary_key=True, nullable=False, server_default=db.text("1"))
    answer = db.Column(db.String(20), nullable=False)
コード例 #18
0
class DanceSong(db.Model):
    __tablename__ = 'dance_song'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(30), nullable=False)
    song_length = db.Column(db.Integer,
                            nullable=False,
                            server_default=db.text("100000"))
    millis_per_bar = db.Column(db.Integer,
                               nullable=False,
                               server_default=db.text("2000"))
コード例 #19
0
class Permission(db.Model):
    __tablename__ = 'permission'

    id = db.Column(
        db.Integer,
        primary_key=True,
        server_default=db.text("nextval('\"permission_id_seq\"'::regclass)"))
    name = db.Column(db.String(50), nullable=False, unique=True)
    enabled = db.Column(db.Boolean,
                        nullable=False,
                        server_default=db.text("true"))
コード例 #20
0
class RoomWaddle(db.Model):
    __tablename__ = 'room_waddle'

    id = db.Column(db.Integer, primary_key=True, nullable=False)
    room_id = db.Column(db.ForeignKey('room.id',
                                      ondelete='CASCADE',
                                      onupdate='CASCADE'),
                        primary_key=True,
                        nullable=False)
    seats = db.Column(db.SmallInteger,
                      nullable=False,
                      server_default=db.text("2"))
    game = db.Column(db.String(20), nullable=False)

    GameClassMapping = {}

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.penguins = []

    async def add(self, p):
        if not self.penguins:
            self.penguins = [None] * self.Seats

        seat_id = self.penguins.index(None)
        self.penguins[seat_id] = p
        await p.send_xt("jw", seat_id)
        await p.room.send_xt("uw", self.id, seat_id, p.Nickname)

        p.waddle = self

        if self.penguins.count(None) == 0:
            await self.reset()

    async def remove(self, p):
        seat_id = self.get_seat_id(p)
        self.penguins[seat_id] = None
        await self.room.send_xt("uw", self.id, seat_id)

        p.waddle = None

    async def reset(self):
        for seat_id, penguin in enumerate(self.penguins):
            if penguin:
                self.penguins[seat_id] = None
                await penguin.room.send_xt("uw", self.id, seat_id)

    def get_seat_id(self, p):
        return self.penguins.index(p)
コード例 #21
0
class PuffleItem(db.Model):
    __tablename__ = 'puffle_item'

    id = db.Column(db.Integer, primary_key=True)
    parent_id = db.Column(db.ForeignKey('puffle_item.id',
                                        ondelete='CASCADE',
                                        onupdate='CASCADE'),
                          nullable=False)
    name = db.Column(db.String(50),
                     nullable=False,
                     server_default=db.text("''::character varying"))
    type = db.Column(db.String(10),
                     nullable=False,
                     server_default=db.text("'care'::character varying"))
    play_external = db.Column(
        db.String(10),
        nullable=False,
        server_default=db.text("'none'::character varying"))
    cost = db.Column(db.Integer, nullable=False, server_default=db.text("0"))
    quantity = db.Column(db.SmallInteger,
                         nullable=False,
                         server_default=db.text("1"))
    member = db.Column(db.Boolean,
                       nullable=False,
                       server_default=db.text("false"))
    food_effect = db.Column(db.SmallInteger,
                            nullable=False,
                            server_default=db.text("0"))
    rest_effect = db.Column(db.SmallInteger,
                            nullable=False,
                            server_default=db.text("0"))
    play_effect = db.Column(db.SmallInteger,
                            nullable=False,
                            server_default=db.text("0"))
    clean_effect = db.Column(db.SmallInteger,
                             nullable=False,
                             server_default=db.text("0"))
コード例 #22
0
ファイル: igloo.py プロジェクト: Blueyzachary/houdini-asyncio
class Location(db.Model):
    __tablename__ = 'location'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), nullable=False)
    cost = db.Column(db.Integer, nullable=False, server_default=db.text("0"))
    patched = db.Column(db.Boolean,
                        nullable=False,
                        server_default=db.text("false"))
    legacy_inventory = db.Column(db.Boolean,
                                 nullable=False,
                                 server_default=db.text("false"))
    vanilla_inventory = db.Column(db.Boolean,
                                  nullable=False,
                                  server_default=db.text("false"))
コード例 #23
0
class Room(db.Model, RoomMixin):
    __tablename__ = 'room'

    id = db.Column(db.Integer, primary_key=True)
    internal_id = db.Column(
        db.Integer,
        nullable=False,
        unique=True,
        server_default=db.text(
            "nextval('\"room_internal_id_seq\"'::regclass)"))
    name = db.Column(db.String(50), nullable=False)
    member = db.Column(db.Boolean,
                       nullable=False,
                       server_default=db.text("false"))
    max_users = db.Column(db.SmallInteger,
                          nullable=False,
                          server_default=db.text("80"))
    required_item = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    game = db.Column(db.Boolean,
                     nullable=False,
                     server_default=db.text("false"))
    blackhole = db.Column(db.Boolean,
                          nullable=False,
                          server_default=db.text("false"))
    spawn = db.Column(db.Boolean,
                      nullable=False,
                      server_default=db.text("false"))
    stamp_group = db.Column(
        db.ForeignKey('stamp_group.id', ondelete='CASCADE',
                      onupdate='CASCADE'))

    def __init__(self, *args, **kwargs):
        RoomMixin.__init__(self, *args, **kwargs)
        super().__init__(*args, **kwargs)

    async def add_penguin(self, p):
        await RoomMixin.add_penguin(self, p)

        if self.game:
            await p.send_xt('jg', self.id)
        elif p.is_vanilla_client and p.data.stealth_moderator:
            await p.send_xt('jr', self.id, await
                            self.get_string(is_stealth=True))
        else:
            await p.send_xt('jr', self.id, await self.get_string())
            await self.send_xt('ap', await p.string)
コード例 #24
0
ファイル: pet.py プロジェクト: Josecholi/Houdini-asyncio
class PenguinPuffle(db.Model):
    __tablename__ = 'penguin_puffle'

    id = db.Column(db.Integer,
                   primary_key=True,
                   server_default=db.text(
                       "nextval('\"penguin_puffle_id_seq\"'::regclass)"))
    penguin_id = db.Column(db.ForeignKey('penguin.id',
                                         ondelete='CASCADE',
                                         onupdate='CASCADE'),
                           nullable=False)
    puffle_id = db.Column(db.ForeignKey('puffle.id',
                                        ondelete='CASCADE',
                                        onupdate='CASCADE'),
                          nullable=False)
    name = db.Column(db.String(16), nullable=False)
    adoption_date = db.Column(db.DateTime,
                              nullable=False,
                              server_default=db.text("now()"))
    food = db.Column(db.SmallInteger,
                     nullable=False,
                     server_default=db.text("100"))
    play = db.Column(db.SmallInteger,
                     nullable=False,
                     server_default=db.text("100"))
    rest = db.Column(db.SmallInteger,
                     nullable=False,
                     server_default=db.text("100"))
    clean = db.Column(db.SmallInteger,
                      nullable=False,
                      server_default=db.text("100"))
    walking = db.Column(db.Boolean, server_default=db.text("false"))
    hat = db.Column(
        db.ForeignKey('puffle_item.id', ondelete='CASCADE',
                      onupdate='CASCADE'))
    backyard = db.Column(db.Boolean, server_default=db.text("false"))
    has_dug = db.Column(db.Boolean, server_default=db.text("false"))
コード例 #25
0
ファイル: penguin.py プロジェクト: JointKush/houdini-1
class Penguin(db.Model):
    __tablename__ = 'penguin'

    id = db.Column(
        db.Integer,
        primary_key=True,
        server_default=db.text("nextval('\"penguin_id_seq\"'::regclass)"))
    username = db.Column(db.String(12), nullable=False, unique=True)
    nickname = db.Column(db.String(30), nullable=False)
    password = db.Column(db.CHAR(60), nullable=False)
    email = db.Column(db.String(255), nullable=False, index=True)
    registration_date = db.Column(db.DateTime,
                                  nullable=False,
                                  server_default=db.text("now()"))
    active = db.Column(db.Boolean,
                       nullable=False,
                       server_default=db.text("false"))
    safe_chat = db.Column(db.Boolean,
                          nullable=False,
                          server_default=db.text("false"))
    last_paycheck = db.Column(db.DateTime,
                              nullable=False,
                              server_default=db.text("now()"))
    minutes_played = db.Column(db.Integer,
                               nullable=False,
                               server_default=db.text("0"))
    moderator = db.Column(db.Boolean,
                          nullable=False,
                          server_default=db.text("false"))
    stealth_moderator = db.Column(db.Boolean,
                                  nullable=False,
                                  server_default=db.text("false"))
    character = db.Column(
        db.ForeignKey('character.id', ondelete='CASCADE', onupdate='CASCADE'))
    igloo = db.Column(
        db.ForeignKey('penguin_igloo_room.id',
                      ondelete='CASCADE',
                      onupdate='CASCADE'))
    coins = db.Column(db.Integer,
                      nullable=False,
                      server_default=db.text("500"))
    color = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    head = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    face = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    neck = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    body = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    hand = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    feet = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    photo = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    flag = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    permaban = db.Column(db.Boolean,
                         nullable=False,
                         server_default=db.text("false"))
    book_modified = db.Column(db.SmallInteger,
                              nullable=False,
                              server_default=db.text("0"))
    book_color = db.Column(db.SmallInteger,
                           nullable=False,
                           server_default=db.text("1"))
    book_highlight = db.Column(db.SmallInteger,
                               nullable=False,
                               server_default=db.text("1"))
    book_pattern = db.Column(db.SmallInteger,
                             nullable=False,
                             server_default=db.text("0"))
    book_icon = db.Column(db.SmallInteger,
                          nullable=False,
                          server_default=db.text("1"))
    agent_status = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))
    field_op_status = db.Column(db.SmallInteger,
                                nullable=False,
                                server_default=db.text("0"))
    career_medals = db.Column(db.Integer,
                              nullable=False,
                              server_default=db.text("0"))
    agent_medals = db.Column(db.Integer,
                             nullable=False,
                             server_default=db.text("0"))
    last_field_op = db.Column(db.DateTime,
                              nullable=False,
                              server_default=db.text("now()"))
    com_message_read_date = db.Column(db.DateTime,
                                      nullable=False,
                                      server_default=db.text("now()"))
    ninja_rank = db.Column(db.SmallInteger,
                           nullable=False,
                           server_default=db.text("0"))
    ninja_progress = db.Column(db.SmallInteger,
                               nullable=False,
                               server_default=db.text("0"))
    fire_ninja_rank = db.Column(db.SmallInteger,
                                nullable=False,
                                server_default=db.text("0"))
    fire_ninja_progress = db.Column(db.SmallInteger,
                                    nullable=False,
                                    server_default=db.text("0"))
    water_ninja_rank = db.Column(db.SmallInteger,
                                 nullable=False,
                                 server_default=db.text("0"))
    water_ninja_progress = db.Column(db.SmallInteger,
                                     nullable=False,
                                     server_default=db.text("0"))
    ninja_matches_won = db.Column(db.Integer,
                                  nullable=False,
                                  server_default=db.text("0"))
    fire_matches_won = db.Column(db.Integer,
                                 nullable=False,
                                 server_default=db.text("0"))
    water_matches_won = db.Column(db.Integer,
                                  nullable=False,
                                  server_default=db.text("0"))
    rainbow_adoptability = db.Column(db.Boolean,
                                     nullable=False,
                                     server_default=db.text("false"))
    has_dug = db.Column(db.Boolean,
                        nullable=False,
                        server_default=db.text("false"))
    puffle_handler = db.Column(db.Boolean,
                               nullable=False,
                               server_default=db.text("false"))
    nuggets = db.Column(db.SmallInteger,
                        nullable=False,
                        server_default=db.text("0"))
    walking = db.Column(
        db.ForeignKey('penguin_puffle.id',
                      ondelete='CASCADE',
                      onupdate='CASCADE'))
    opened_playercard = db.Column(db.Boolean,
                                  nullable=False,
                                  server_default=db.text("false"))
    special_wave = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))
    special_dance = db.Column(db.Boolean,
                              nullable=False,
                              server_default=db.text("false"))
    special_snowball = db.Column(db.Boolean,
                                 nullable=False,
                                 server_default=db.text("false"))
    map_category = db.Column(db.SmallInteger,
                             nullable=False,
                             server_default=db.text("0"))
    status_field = db.Column(db.Integer,
                             nullable=False,
                             server_default=db.text("0"))
    timer_active = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))
    timer_start = db.Column(
        db.Time,
        nullable=False,
        server_default=db.text("'00:00:00'::time without time zone"))
    timer_end = db.Column(
        db.Time,
        nullable=False,
        server_default=db.text("'23:59:59'::time without time zone"))
    timer_total = db.Column(db.Interval,
                            nullable=False,
                            server_default=db.text("'01:00:00'::interval"))
    grounded = db.Column(db.Boolean,
                         nullable=False,
                         server_default=db.text("false"))
    approval_en = db.Column(db.Boolean,
                            nullable=False,
                            server_default=db.text("false"))
    approval_pt = db.Column(db.Boolean,
                            nullable=False,
                            server_default=db.text("false"))
    approval_fr = db.Column(db.Boolean,
                            nullable=False,
                            server_default=db.text("false"))
    approval_es = db.Column(db.Boolean,
                            nullable=False,
                            server_default=db.text("false"))
    approval_de = db.Column(db.Boolean,
                            nullable=False,
                            server_default=db.text("false"))
    approval_ru = db.Column(db.Boolean,
                            nullable=False,
                            server_default=db.text("false"))
    rejection_en = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))
    rejection_pt = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))
    rejection_fr = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))
    rejection_es = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))
    rejection_de = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))
    rejection_ru = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))

    def __init__(self, *args, **kwargs):
        self.inventory = None
        self.permissions = None
        self.attributes = None
        self.igloos = None
        self.igloo_rooms = None
        self.furniture = None
        self.flooring = None
        self.locations = None
        self.stamps = None
        self.cards = None
        self.puffles = None
        self.puffle_items = None
        self.buddies = None
        self.buddy_requests = None
        self.character_buddies = None
        self.ignore = None

        super().__init__(*args, **kwargs)

    @lru_cache()
    def safe_nickname(self, language_bitmask):
        return self.nickname if self.approval & language_bitmask else "P" + str(
            self.id)

    async def status_field_set(self, field_bitmask):
        if (self.status_field & field_bitmask) == 0:
            await self.update(status_field=self.status_field ^ field_bitmask
                              ).apply()

    def status_field_get(self, field_bitmask):
        return (self.status_field & field_bitmask) != 0

    @property
    @lru_cache()
    def age(self):
        return (datetime.now() - self.registration_date).days

    @property
    @lru_cache()
    def approval(self):
        return int(
            f'{self.approval_ru * 1}{self.approval_de * 1}0{self.approval_es * 1}'
            f'{self.approval_fr * 1}{self.approval_pt * 1}{self.approval_en * 1}',
            2)

    @property
    @lru_cache()
    def rejection(self):
        return int(
            f'{self.rejection_ru * 1}{self.rejection_de * 1}0{self.rejection_es * 1}'
            f'{self.rejection_fr * 1}{self.rejection_pt * 1}{self.rejection_en * 1}',
            2)
コード例 #26
0
ファイル: penguin.py プロジェクト: Josecholi/Houdini-asyncio
class Penguin(db.Model):
    __tablename__ = 'penguin'

    id = db.Column(
        db.Integer,
        primary_key=True,
        server_default=db.text("nextval('\"penguin_id_seq\"'::regclass)"))
    username = db.Column(db.String(12), nullable=False, unique=True)
    nickname = db.Column(db.String(30), nullable=False)
    password = db.Column(db.CHAR(60), nullable=False)
    email = db.Column(db.String(255), nullable=False, index=True)
    registration_date = db.Column(db.DateTime,
                                  nullable=False,
                                  server_default=db.text("now()"))
    active = db.Column(db.Boolean,
                       nullable=False,
                       server_default=db.text("false"))
    safe_chat = db.Column(db.Boolean,
                          nullable=False,
                          server_default=db.text("false"))
    last_paycheck = db.Column(db.DateTime,
                              nullable=False,
                              server_default=db.text("now()"))
    minutes_played = db.Column(db.Integer,
                               nullable=False,
                               server_default=db.text("0"))
    moderator = db.Column(db.Boolean,
                          nullable=False,
                          server_default=db.text("false"))
    stealth_moderator = db.Column(db.Boolean,
                                  nullable=False,
                                  server_default=db.text("false"))
    character = db.Column(
        db.ForeignKey('character.id', ondelete='CASCADE', onupdate='CASCADE'))
    igloo = db.Column(
        db.ForeignKey('penguin_igloo_room.id',
                      ondelete='CASCADE',
                      onupdate='CASCADE'))
    coins = db.Column(db.Integer,
                      nullable=False,
                      server_default=db.text("500"))
    color = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    head = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    face = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    neck = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    body = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    hand = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    feet = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    photo = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    flag = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    permaban = db.Column(db.Boolean,
                         nullable=False,
                         server_default=db.text("false"))
    book_modified = db.Column(db.SmallInteger,
                              nullable=False,
                              server_default=db.text("0"))
    book_color = db.Column(db.SmallInteger,
                           nullable=False,
                           server_default=db.text("1"))
    book_highlight = db.Column(db.SmallInteger,
                               nullable=False,
                               server_default=db.text("1"))
    book_pattern = db.Column(db.SmallInteger,
                             nullable=False,
                             server_default=db.text("0"))
    book_icon = db.Column(db.SmallInteger,
                          nullable=False,
                          server_default=db.text("1"))
    agent_status = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))
    field_op_status = db.Column(db.SmallInteger,
                                nullable=False,
                                server_default=db.text("0"))
    career_medals = db.Column(db.Integer,
                              nullable=False,
                              server_default=db.text("0"))
    agent_medals = db.Column(db.Integer,
                             nullable=False,
                             server_default=db.text("0"))
    last_field_op = db.Column(db.DateTime,
                              nullable=False,
                              server_default=db.text("now()"))
    ninja_rank = db.Column(db.SmallInteger,
                           nullable=False,
                           server_default=db.text("0"))
    ninja_progress = db.Column(db.SmallInteger,
                               nullable=False,
                               server_default=db.text("0"))
    fire_ninja_rank = db.Column(db.SmallInteger,
                                nullable=False,
                                server_default=db.text("0"))
    fire_ninja_progress = db.Column(db.SmallInteger,
                                    nullable=False,
                                    server_default=db.text("0"))
    water_ninja_rank = db.Column(db.SmallInteger,
                                 nullable=False,
                                 server_default=db.text("0"))
    water_ninja_progress = db.Column(db.SmallInteger,
                                     nullable=False,
                                     server_default=db.text("0"))
    ninja_matches_won = db.Column(db.Integer,
                                  nullable=False,
                                  server_default=db.text("0"))
    fire_matches_won = db.Column(db.Integer,
                                 nullable=False,
                                 server_default=db.text("0"))
    water_matches_won = db.Column(db.Integer,
                                  nullable=False,
                                  server_default=db.text("0"))
    rainbow_adoptability = db.Column(db.SmallInteger,
                                     nullable=False,
                                     server_default=db.text("0"))
    has_dug = db.Column(db.Boolean,
                        nullable=False,
                        server_default=db.text("false"))
    nuggets = db.Column(db.SmallInteger,
                        nullable=False,
                        server_default=db.text("0"))
    opened_playercard = db.Column(db.Boolean,
                                  nullable=False,
                                  server_default=db.text("false"))
    special_wave = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))
    special_dance = db.Column(db.Boolean,
                              nullable=False,
                              server_default=db.text("false"))
    special_snowball = db.Column(db.Boolean,
                                 nullable=False,
                                 server_default=db.text("false"))
    map_category = db.Column(db.SmallInteger,
                             nullable=False,
                             server_default=db.text("0"))
    status_field = db.Column(db.Integer,
                             nullable=False,
                             server_default=db.text("0"))
    timer_active = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))
    timer_start = db.Column(
        db.Time,
        nullable=False,
        server_default=db.text("'00:00:00'::time without time zone"))
    timer_end = db.Column(
        db.Time,
        nullable=False,
        server_default=db.text("'23:59:59'::time without time zone"))
    timer_total = db.Column(db.Interval,
                            nullable=False,
                            server_default=db.text("'01:00:00'::interval"))
    grounded = db.Column(db.Boolean,
                         nullable=False,
                         server_default=db.text("false"))
    approval_en = db.Column(db.Boolean,
                            nullable=False,
                            server_default=db.text("false"))
    approval_pt = db.Column(db.Boolean,
                            nullable=False,
                            server_default=db.text("false"))
    approval_fr = db.Column(db.Boolean,
                            nullable=False,
                            server_default=db.text("false"))
    approval_es = db.Column(db.Boolean,
                            nullable=False,
                            server_default=db.text("false"))
    approval_de = db.Column(db.Boolean,
                            nullable=False,
                            server_default=db.text("false"))
    approval_ru = db.Column(db.Boolean,
                            nullable=False,
                            server_default=db.text("false"))
    rejection_en = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))
    rejection_pt = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))
    rejection_fr = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))
    rejection_es = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))
    rejection_de = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))
    rejection_ru = db.Column(db.Boolean,
                             nullable=False,
                             server_default=db.text("false"))

    def __init__(self, *args, **kwargs):
        self.inventory = None
        self.permissions = None
        self.igloos = None
        self.furniture = None
        self.flooring = None
        self.locations = None
        self.stamps = None
        self.cards = None
        self.puffles = None
        self.puffle_items = None
        self.buddies = None
        self.buddy_requests = None
        self.character_buddies = None
        self.ignore = None

        super().__init__(*args, **kwargs)

    async def load_inventories(self):
        self.inventory = await ItemCrumbsCollection.get_collection(self.id)
        self.permissions = await PermissionCrumbsCollection.get_collection(
            self.id)
        self.igloos = await IglooCrumbsCollection.get_collection(self.id)
        self.furniture = await FurnitureCrumbsCollection.get_collection(self.id
                                                                        )
        self.flooring = await FlooringCrumbsCollection.get_collection(self.id)
        self.locations = await LocationCrumbsCollection.get_collection(self.id)
        self.stamps = await StampCrumbsCollection.get_collection(self.id)
        self.cards = await CardCrumbsCollection.get_collection(self.id)
        self.puffles = await PuffleCrumbsCollection.get_collection(self.id)
        self.puffle_items = await PuffleItemCrumbsCollection.get_collection(
            self.id)
        self.buddies = await BuddyListCollection.get_collection(self.id)
        self.buddy_requests = await BuddyRequestCollection.get_collection(
            self.id)
        self.character_buddies = await CharacterBuddyCollection.get_collection(
            self.id)
        self.ignore = await IgnoreListCollection.get_collection(self.id)

    def safe_nickname(self, language_bitmask):
        return self.nickname if self.approval & language_bitmask else "P" + str(
            self.id)

    @property
    def minutes_played_today(self):
        async def get_minutes():
            yesterday = datetime.combine(date.today(), datetime.min.time())
            minutes_played_today = await db.select([db.func.sum(Login.minutes_played)]) \
                .where((Login.penguin_id == self.id) & (Login.date > yesterday)).gino.scalar()
            return minutes_played_today or 0

        return get_minutes()

    @property
    def age(self):
        return (datetime.now() - self.registration_date).days

    @property
    def approval(self):
        return int(
            '{}{}0{}{}{}{}'.format(self.approval_ru * 1, self.approval_de * 1,
                                   self.approval_es * 1, self.approval_fr * 1,
                                   self.approval_pt * 1, self.approval_en * 1),
            2)

    @property
    def rejection(self):
        return int(
            '{}{}0{}{}{}{}'.format(self.rejection_ru * 1,
                                   self.rejection_de * 1,
                                   self.rejection_es * 1,
                                   self.rejection_fr * 1,
                                   self.rejection_pt * 1,
                                   self.rejection_en * 1), 2)
コード例 #27
0
class RedemptionBook(db.Model):
    __tablename__ = 'redemption_book'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255), nullable=False)
コード例 #28
0
class RedemptionCode(db.Model):
    __tablename__ = 'redemption_code'

    id = db.Column(db.Integer, primary_key=True,
                   server_default=db.text("nextval('\"redemption_code_id_seq\"'::regclass)"))
    code = db.Column(db.String(16), nullable=False, unique=True)
    type = db.Column(db.String(8), nullable=False, server_default=db.text("'BLANKET'::character varying"))
    coins = db.Column(db.Integer, nullable=False, server_default=db.text("0"))
    expires = db.Column(db.DateTime)
    uses = db.Column(db.Integer)

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self._cards = set()
        self._flooring = set()
        self._furniture = set()
        self._igloos = set()
        self._items = set()
        self._locations = set()
        self._puffles = set()
        self._puffle_items = set()

    @property
    def cards(self):
        return self._cards

    @cards.setter
    def cards(self, child):
        if isinstance(child, RedemptionAwardCard):
            self._cards.add(child)

    @property
    def flooring(self):
        return self._flooring

    @flooring.setter
    def flooring(self, child):
        if isinstance(child, RedemptionAwardFlooring):
            self._flooring.add(child)

    @property
    def furniture(self):
        return self._furniture

    @furniture.setter
    def furniture(self, child):
        if isinstance(child, RedemptionAwardFurniture):
            self._furniture.add(child)

    @property
    def igloos(self):
        return self._igloos

    @igloos.setter
    def igloos(self, child):
        if isinstance(child, RedemptionAwardIgloo):
            self._igloos.add(child)

    @property
    def items(self):
        return self._items

    @items.setter
    def items(self, child):
        if isinstance(child, RedemptionAwardItem):
            self._items.add(child)

    @property
    def locations(self):
        return self._locations

    @locations.setter
    def locations(self, child):
        if isinstance(child, RedemptionAwardLocation):
            self._locations.add(child)

    @property
    def puffles(self):
        return self._puffles

    @puffles.setter
    def puffles(self, child):
        if isinstance(child, RedemptionAwardPuffle):
            self._puffles.add(child)

    @property
    def puffle_items(self):
        return self._puffle_items

    @puffle_items.setter
    def puffle_items(self, child):
        if isinstance(child, RedemptionAwardPuffleItem):
            self._puffle_items.add(child)
コード例 #29
0
class Room(db.Model, RoomMixin):
    __tablename__ = 'room'

    id = db.Column(db.Integer, primary_key=True)
    internal_id = db.Column(
        db.Integer,
        nullable=False,
        unique=True,
        server_default=db.text(
            "nextval('\"room_internal_id_seq\"'::regclass)"))
    name = db.Column(db.String(50), nullable=False)
    member = db.Column(db.Boolean,
                       nullable=False,
                       server_default=db.text("false"))
    max_users = db.Column(db.SmallInteger,
                          nullable=False,
                          server_default=db.text("80"))
    required_item = db.Column(
        db.ForeignKey('item.id', ondelete='CASCADE', onupdate='CASCADE'))
    game = db.Column(db.Boolean,
                     nullable=False,
                     server_default=db.text("false"))
    blackhole = db.Column(db.Boolean,
                          nullable=False,
                          server_default=db.text("false"))
    spawn = db.Column(db.Boolean,
                      nullable=False,
                      server_default=db.text("false"))
    stamp_group = db.Column(
        db.ForeignKey('stamp_group.id', ondelete='CASCADE',
                      onupdate='CASCADE'))

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        RoomMixin.__init__(self, *args, **kwargs)

        self.blackhole_penguins = {}

    async def add_penguin(self, p):
        if len(self.penguins_by_id) >= self.max_users and not p.moderator:
            return await p.send_error(210)

        if self.blackhole and p.is_vanilla_client:
            self.blackhole_penguins[p.id] = p.room
            p.room = self
            return await p.send_xt('jnbhg', self.id)

        await RoomMixin.add_penguin(self, p)

        if self.game:
            await p.send_xt('jg', self.id)
        else:
            await p.send_xt('jr', self.id, await
                            self.get_string(f=stealth_mod_filter(p.id)))
            if not p.stealth_moderator:
                await self.send_xt('ap', await p.string)

    async def remove_penguin(self, p):
        await RoomMixin.remove_penguin(self, p)

    async def leave_blackhole(self, p):
        if p.id in self.blackhole_penguins and p.is_vanilla_client:
            p.room = self.blackhole_penguins.pop(p.id)
コード例 #30
0
class RoomTable(db.Model):
    __tablename__ = 'room_table'

    id = db.Column(db.Integer, primary_key=True, nullable=False)
    room_id = db.Column(db.ForeignKey('room.id',
                                      ondelete='CASCADE',
                                      onupdate='CASCADE'),
                        primary_key=True,
                        nullable=False)
    game = db.Column(db.String(20), nullable=False)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.penguins = []
        self.room = None
        self.logic = None

    async def add_penguin(self, p):
        self.penguins.append(p)

        seat_id = len(self.penguins) - 1

        await p.send_xt('jt', self.id, seat_id + 1)
        await p.room.send_xt('ut', self.id, len(self.penguins))
        p.table = self

        return seat_id

    async def remove_penguin(self, p):
        seat_id = self.get_seat_id(p)
        is_player = seat_id < 2
        game_ready = len(self.penguins) > 1
        if is_player and game_ready:
            await self.send_xt('cz', p.safe_name)
            await self.reset()
        else:
            self.penguins.remove(p)

            await p.send_xt('lt')
            await self.room.send_xt('ut', self.id, len(self.penguins))
            p.table = None

    async def reset(self):
        for penguin in self.penguins:
            penguin.table = None

        self.logic = type(self.logic)()
        self.penguins = []
        await self.room.send_xt('ut', self.id, 0)

    def get_seat_id(self, p):
        return self.penguins.index(p)

    def get_string(self):
        if len(self.penguins) == 0:
            return str()
        elif len(self.penguins) == 1:
            player_one, = self.penguins
            return '%'.join(
                [player_one.safe_name,
                 str(), self.logic.get_string()])
        player_one, player_two = self.penguins[:2]
        if len(self.penguins) == 2:
            return '%'.join([
                player_one.safe_name, player_two.safe_name,
                self.logic.get_string()
            ])
        return '%'.join([
            player_one.safe_name, player_two.safe_name,
            self.logic.get_string(), '1'
        ])

    async def send_xt(self, *data):
        for penguin in self.penguins:
            await penguin.send_xt(*data)