示例#1
0
 def redact(hashed_id):
     form = RedactForm()
     session = db_session.create_session()
     player = session.query(Player).filter(
         Player.hashed_id == hashed_id).first()
     if form.validate_on_submit():
         if not player.check_password(form.old_password.data):
             return render_template('redact.html',
                                    title='Редактировать информацию о себе',
                                    form=form,
                                    message='Некорректный старый пароль')
         if form.password.data != form.password_again.data:
             return render_template('redact.html',
                                    title='Редактировать информацию о себе',
                                    form=form,
                                    message="Пароли не совпадают")
         player = Player(name=form.name.data,
                         surname=form.surname.data,
                         nickname=form.nickname.data,
                         public=form.public.data)
         player.set_password(form.password.data)
         session.add(player)
         session.commit()
         return redirect('/login')
     return render_template('redact.html',
                            title='Редактировать информацию о себе',
                            form=form,
                            id=hashed_id)
示例#2
0
    def newProfile(self, name=""):
        """New profile interface."""

        run = True
        profiles = self.profilesManager.getProfiles()
        while name == "":
            name = safe_input("Enter profile name : ", str)
            if name in profiles.keys():
                print("The name has been used previosly."
                      "Please enter a new one.")
                name = ""
        player = Player(name, 1200)  
        # novice ELO
        print("Indicate your ELO score,"
              "or leave this part blank (hit ENTER)")
        while run:
            entry = input("Your ELO score (1200) : ")
            try:
                player.elo = int(entry)
            except:
                if(entry == ""):
                    run = False
                else:
                    print("Plaese enter an integer.")
            else:
                run = False
        self.profilesManager.saveProfile(player)
        return player
 def add_player(self, player_id, full_name, first_name, last_name,
                is_active):
     if player_id not in self.db_player:
         self.db_player[player_id] = Player(player_id, full_name,
                                            first_name, last_name,
                                            is_active)
     else:
         print(f"{player_id} is already in the database!")
示例#4
0
 def post(self):
     args = parser.parse_args()
     session = db_session.create_session()
     player = Player(surname=args['surname'],
                     name=args['name'],
                     nickname=args['nickname'],
                     player_id=args['player_id'],
                     email=args['email'],
                     public=args['public'])
     session.add(player)
     session.commit()
     return jsonify({'success': 'OK'})
示例#5
0
 def register():
     form = RegisterForm()
     if form.validate_on_submit():
         if form.password.data != form.password_again.data:
             return render_template('register.html',
                                    title='Регистрация',
                                    form=form,
                                    message="Пароли не совпадают")
         session = db_session.create_session()
         if session.query(Player).filter(
                 Player.email == form.email.data).first():
             return render_template('register.html',
                                    title='Регистрация',
                                    form=form,
                                    message="Такой пользователь уже есть")
         player = Player(name=form.name.data,
                         email=form.email.data,
                         surname=form.surname.data,
                         nickname=form.nickname.data,
                         public=form.public.data)
         player.set_password(form.password.data)
         player.set_hashed_id()
         session.add(player)
         session.commit()
         return redirect('/login')
     return render_template('register.html', title='Регистрация', form=form)
示例#6
0
    def __init__(self, params):
        players, bonuses, tick_num = params['players'], params[
            'bonuses'], params['tick_num']

        self.players = Player.de_json(players)
        self.bonuses = tuple(get_bonus(bonus) for bonus in bonuses)
        self.map = Map
        self.tick = tick_num
        self.debug = ''

        for player in self.players:
            if player.id == 'i':
                self.me = player
示例#7
0
def create_player() -> int:
    player_id = cookie_service.get_player_id_via_cookie(request)

    session = db_session.create_session()
    player = session.query(Player).filter(Player.id == player_id).first()

    if player_id and player:
        return player_id

    player = Player()

    session.add(player)
    session.commit()
    session.close()

    return player.id
示例#8
0
    import time
    from re import sub as regex_sub
    from colorama import init, Back
    from sys import exit
except Exception:
    print(
        "The game runs best with Python 3.x and the Colorama, re, Time, zLib, and Base64 Module."
    )  # You only need to install the Colorama module
    exit(0)

# --------------------------- MODULES ---------------------------

from data.player import Player
from data.map import Map

player = Player()
map = Map()

init(autoreset=True)  # Colorama


def c_format(color_string):  # Automatic color formatting by replacing words
    global player
    temp_string = color_string
    for word in player.all_commands:
        temp_string = regex_sub(word, Back.GREEN + word + Back.RESET,
                                temp_string)
    return temp_string


# --------------------------- BEGINNING ---------------------------
示例#9
0
def main():
    """Main program"""

    pygame.init()
    view = View()
    events = Events()
    player = Player()

    view.init_textures()
    view.update()
    player.retrieve_scores()

    main_loop = True
    active_game = False
    prev_state = None
    state = "MENU"

    # Main looop
    while main_loop:

        # Menu loop
        while main_loop and state == "MENU":

            if prev_state != state:
                view.draw_menu()
                view.update()
                active_game = False
                prev_state = state
            else:
                view.tick()

            actions = events.get()
            if "quit" in actions:
                main_loop = False
            if "enter" in actions:
                state = "GAME"

        # Game loop
        while main_loop and state == "GAME":
            if prev_state != "PAUSE":
                frames = 0

            if prev_state != state:
                if not active_game:
                    grid = Grid()
                    snake = Snake()
                    player.start_game()
                    snake.place_head(grid)
                    grid.generate()
                    direction = None
                    active_game = True
                prev_state = state

            view.draw_header(snake, player)

            while frames < c.NB_FRAMES:

                view.draw_field(grid, snake, frames)
                view.draw_game()
                view.update()
                view.tick()

                actions = events.get()
                if "quit" in actions:
                    main_loop = False
                if "pause" in actions:
                    state = "PAUSE"
                if not (main_loop and state == "GAME"):
                    break

                new_dir = events.calc_dir(snake.dir)
                if new_dir:
                    direction = new_dir
                frames += 1

            if snake.dead:
                state = "GAME OVER"
            if not (main_loop and state == "GAME"):
                break
            if not direction:
                continue

            snake.place_head(grid)
            snake.propagate(grid, direction, player.goal_reached)
            player.calc_score(snake.parts)
            snake.behind_trail(grid, player)
            snake.check_front(grid)

            snake.goal_reached(player)

            if player.goal_reached:
                player.new_goal()

        # Pause
        while main_loop and state == "PAUSE":

            if prev_state != state:
                view.draw_pause()
                view.update()
                prev_state = state
            else:
                view.tick()

            actions = events.get()
            if "quit" in actions:
                main_loop = False
            if "pause" in actions:
                state = "GAME"

        # Game over
        while main_loop and state == "GAME OVER":

            if prev_state != state:
                player.calc_score(snake.parts)
                player.compare_scores()
                view.draw_game_over(player)
                view.update()
                player.save_scores()
                prev_state = state
            else:
                view.tick()

            actions = events.get()
            if "quit" in actions:
                main_loop = False
            if "escape" in actions:
                state = "MENU"
            if "enter" in actions:
                state = "MENU"

    pygame.quit()
示例#10
0
def intro(en1):
    winsound.PlaySound("music\\story_intro.wav",
                       winsound.SND_ASYNC + winsound.SND_LOOP)
    os.system("cls")
    print(cut_scene_art.sleeping)
    typewriter(
        "It's 3am, the night is young, you're up late again playing your favourite RPG game - Skyrim.\n"
        "You drift off to sleep in front of your computer, dreaming of what it would be like to live in\n"
        "a world just like that, where you can fight Mudcrabs and shout at Dragons.\n"
    )
    input(">...")
    os.system("cls")
    print(cut_scene_art.bedroom)
    typewriter(
        "The next morning you wake from your chair but nothing in your room is the same, your computer is gone,\n"
        "along with all of your other possessions.\n")
    input(">...")
    os.system("cls")
    print(cut_scene_art.bedroom)
    typewriter("Suddenly you hear a voice coming from behind you.\n")
    input(">...")
    os.system("cls")
    print(cut_scene_art.bedroom)
    typewriter('''“Hey, you. You're finally awake.”\n''')
    input(">...")
    os.system("cls")
    print(cut_scene_art.bedroom)
    typewriter(
        "You quickly spin around, but there's nobody there. It must have just been your imagination.\n"
    )
    input(">...")
    os.system("cls")
    print(cut_scene_art.village)
    typewriter(
        "You walk over to your window to check what's outside, and you see this beautiful village,\n"
        "just like the one you dreamed of.\n")
    input(">...")
    os.system("cls")
    print(cut_scene_art.village)
    typewriter(
        "Then it hits you, suddenly you realise you are in the village you dreamed of, whether it's still a dream\n"
        "or not you are unsure of, but one thing is for certain, you have decided that you are going to be the hero\n"
        "that this village may, or may not need!\n")
    input(">...")
    os.system("cls")
    print(cut_scene_art.village)
    typewriter(
        "Though you think to yourself, if you're going to be a hero, you will need a name worthy to be one that\n"
        "people can write stories about and sing songs in your name.\n")
    input(">...\n")
    player_name = input("Enter Name: ")
    typewriter("\nGood! " + player_name + " is a great name.\n")
    input(">...\n")
    typewriter(
        "So, " + player_name +
        ", it's now time to venture outside and conquer whatever challenges you\n"
        "may face in your adventures.\n")
    # hp 250, atk 15, defence, name, atk_l, atk_h, b_atk_p, m_atk_p, bleed_dot_count, bleed_dot_dmg, burn_dot_count, burn_dot_dmg, gold, level, xp1, xp2, str
    character = Player(250, 15, 0, player_name, -5, +5, 0, 100, 0, 0, 0, 0, 0,
                       Attributes.char["xp"], Attributes.char["level_up"],
                       Attributes.char["level"], Attributes.stats["str"])
    input(">...")
    game_menu(character, en1)