Esempio n. 1
0
    def create_new_game(self, message):
        user = message.user
        game = Game()
        game.users.append(user)
        game.state = game_state.awaiting_characters()
        game.story = db.find(Story, name='Test Story')
        db.insert(game)
        self.game_master.game = game
        self.game = game

        response = '[+] Created new game\n{}\n'.format(game)
        response += '\n- Who else wants to join the game?\n'
        response += '(tag user / nobody)'
        return response
Esempio n. 2
0
def create_user(username):
    user = User(username)
    db.insert(user)
    return db.find(User, username=username)
Esempio n. 3
0
def get_user_or_create_if_new(username):
    user = db.find(User, username=username)
    if user is None:
        user = create_user(username)
        print('\n[+] Created new user:\n{}\n'.format(user))
    return user
Esempio n. 4
0
 def get_character_class(self, parameters):
     character_class_name = parameters['character-class']
     character_class = db.find(CharacterClass, name=character_class_name)
     return character_class
Esempio n. 5
0
 def get_race(self, parameters):
     race_name = parameters['race']
     race = db.find(Race, name=race_name)
     return race
Esempio n. 6
0
def populate_races():
    races = []

    dragonborn = Race('dragonborn', 30)
    dragonborn.languages.append(db.find(Language, name='common'))
    dragonborn.languages.append(db.find(Language, name='draconic'))
    races.append(dragonborn)

    dwarf = Race('dwarf', 25)
    dwarf.languages.append(db.find(Language, name='common'))
    dwarf.languages.append(db.find(Language, name='dwarvish'))
    races.append(dwarf)

    elf = Race('elf', 30)
    elf.languages.append(db.find(Language, name='common'))
    elf.languages.append(db.find(Language, name='elvish'))
    races.append(elf)

    gnome = Race('gnome', 25)
    gnome.languages.append(db.find(Language, name='common'))
    gnome.languages.append(db.find(Language, name='gnomish'))
    races.append(gnome)

    half_elf = Race('half-elf', 30)
    half_elf.languages.append(db.find(Language, name='common'))
    half_elf.languages.append(db.find(Language, name='elvish'))
    races.append(half_elf)

    half_orc = Race('half-orc', 30)
    half_orc.languages.append(db.find(Language, name='common'))
    half_orc.languages.append(db.find(Language, name='orc'))
    races.append(half_orc)

    hafling = Race('hafling', 30)
    hafling.languages.append(db.find(Language, name='common'))
    hafling.languages.append(db.find(Language, name='hafling'))
    races.append(hafling)

    human = Race('human', 30)
    human.languages.append(db.find(Language, name='common'))
    races.append(human)

    tiefling = Race('tiefling', 30)
    tiefling.languages.append(db.find(Language, name='common'))
    tiefling.languages.append(db.find(Language, name='infernal'))
    races.append(tiefling)

    for race in races:
        db.session.add(race)
    db.session.commit()
    print('[+] All races added to the database.')
Esempio n. 7
0
def started():
    return db.find(GameState, name=STARTED)
Esempio n. 8
0
def awaiting_start_confirmation():
    return db.find(GameState, name=AWAITING_START_CONFIRMATION)
Esempio n. 9
0
def awaiting_characters():
    return db.find(GameState, name=AWAITING_CHARACTERS)