예제 #1
0
def deploy(remote='origin'):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    if app_config.DEPLOY_TO_SERVERS:
        require('branch', provided_by=[stable, master, branch])

        if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'):
            utils.confirm(
                colored("You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch, "red")
            )

        servers.checkout_latest(remote)

        servers.fabcast('text.update')
        servers.fabcast('assets.sync')
        servers.fabcast('data.update')

        if app_config.DEPLOY_CRONTAB:
            servers.install_crontab()

        if app_config.DEPLOY_SERVICES:
            servers.deploy_confs()

    update()
    render.render_all()
    _gzip('www', '.gzip')
    _deploy_to_s3()
예제 #2
0
def target_tile(max_range=None):
    # TODO: replace this completely with the target_tile function below
    message("Use the mouse or the keyboard to select a tile...", tcod.blue)
    # return the position of a tile left-clicked in player's FOV (optionally
    # in a range), or (None,None) if right-clicked.
    while True:
        # render the screen. this erases the inventory and shows the names of
        # objects under the mouse.
        render.render_all()
        tcod.console_flush()

        tcod.sys_check_for_event(tcod.EVENT_MOUSE | tcod.EVENT_KEY_PRESS, key, mouse)
        (x, y) = (mouse.cx, mouse.cy)
        x += render.camera_width
        y += render.camera_height

        # accept the target if the player clicked in FOV, and in case a range
        # is specified, if it's in that range
        if (
            mouse.lbutton_pressed
            and tcod.map_is_in_fov(terain.map.fov_map, x, y)
            and (max_range is None or player.distance(x, y) <= max_range)
        ):
            return (x, y)
        elif mouse.rbutton_pressed or key.vk == tcod.KEY_ESCAPE:
            message("Targetting cancelled")
            return (None, None)  # cancel if the player right-clicked or pressed Escape
예제 #3
0
def deploy(remote='origin'):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    if app_config.DEPLOY_TO_SERVERS:
        require('branch', provided_by=[stable, master, branch])

        if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'):
            utils.confirm("You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch)

        servers.checkout_latest(remote)

        servers.fabcast('copytext.update')
        servers.fabcast('assets.sync')
        servers.fabcast('data.update')

        if app_config.DEPLOY_CRONTAB:
            servers.install_crontab()

        if app_config.DEPLOY_SERVICES:
            servers.deploy_confs()

    update()
    render.render_all()
    _gzip('www', '.gzip')
    _deploy_to_s3()
예제 #4
0
파일: playing.py 프로젝트: mm11wils/world
def play_game():
    global key, mouse
 
    player_action = None
 
    mouse = ltc.Mouse()
    key = ltc.Key()
    #main loop
    while not ltc.console_is_window_closed():
        ltc.sys_check_for_event(ltc.EVENT_KEY_PRESS | ltc.EVENT_MOUSE, key, mouse)
        #render the screen
        r.render_all()
 
        ltc.console_flush()
 
        #level up if needed
        check_level_up()
 
        #erase all objects at their old locations, before they move
        for object in objects:
            object.clear()
 
        #handle keys and exit game if needed
        player_action = handle_keys()
        if player_action == 'exit':
            save_game()
            break
 
        #let monsters take their turn
        if game_state == 'playing' and player_action != 'didnt-take-turn':
            for object in objects:
                if object.ai:
                    object.ai.take_turn()
예제 #5
0
def update_objects(render_bullets_flying=False):
    # update all objects
    for list in terrain.map.objectlists[:-1]:
        for object in list[:]:
            #only update living objects
            if not object.dead:
                object.update()
            if player.dead:
                #if player dies, immediately end gameplay
                break

    for i in range(mob.Bullet.speed):
        for bullet in terrain.map.bullets[:]:
            if not bullet.dead:
                bullet.update()
            if bullet.dead:
                terrain.map.bullets.remove(bullet)
        if render_bullets_flying:
            render.render_all()


    #also update objects in player inventory
    #e.g. passive items may do stuff here
    if not player.dead:
        for object in player.inventory:
            object.update()
    purge_dead_objects()
예제 #6
0
파일: __init__.py 프로젝트: onyxfish/median
def deploy(remote='origin', reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    if app_config.DEPLOY_TO_SERVERS:
        require('branch', provided_by=[stable, master, branch])

        if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'):
            utils.confirm(
                colored("You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch, "red")
            )

        servers.checkout_latest(remote)

        if app_config.DEPLOY_CRONTAB:
            servers.install_crontab()

        if app_config.DEPLOY_SERVICES:
            servers.deploy_confs()

    update()
    render.render_all()

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www',
        app_config.PROJECT_SLUG,
        headers={
            'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
        },
        ignore=[]
    )
예제 #7
0
def deploy(quick=None, remote='origin', reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[random_prod, production, staging])

    if app_config.DEPLOYMENT_TARGET == 'production' or app_config.DEPLOYMENT_TARGET == 'random_prod':
        utils.confirm(
            colored(
                "You are trying to deploy to production this project %s.\nDo you know what you're doing?"
                % app_config.PROJECT_SLUG, "red"))

    if app_config.DEPLOY_TO_SERVERS:
        require('branch', provided_by=[stable, master, branch])

        if (app_config.DEPLOYMENT_TARGET == 'production'
                and env.branch != 'stable'):
            utils.confirm(
                colored(
                    "You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?"
                    % env.branch, "red"))

        servers.checkout_latest(remote)

        servers.fabcast('text.update')
        servers.fabcast('data.update')
        servers.fabcast('assets.sync')

        if app_config.DEPLOY_CRONTAB:
            servers.install_crontab()

        if app_config.DEPLOY_SERVICES:
            servers.deploy_confs()

    if quick != 'quick':
        update()

    render.render_all()

    # Clear files that should never be deployed
    local('rm -rf www/live-data')

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www',
        app_config.PROJECT_SLUG,
        headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE},
        ignore=['www/assets/*', 'www/live-data/*'])

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/assets',
        '%s/assets' % app_config.PROJECT_SLUG,
        headers={'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE})

    if reload:
        reset_browsers()

    if not check_timestamp():
        reset_browsers()
예제 #8
0
def deploy(remote='origin', reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    update()
    render.render_all()

    # Clear files that should never be deployed
    local('rm -rf www/live-data')

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www',
        app_config.PROJECT_SLUG,
        headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE},
        ignore=['www/assets/*', 'www/live-data/*'])

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/assets',
        '%s/assets' % app_config.PROJECT_SLUG,
        headers={'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE})

    if reload:
        reset_browsers()

    if not check_timestamp():
        reset_browsers()
예제 #9
0
def build_electron():
    require('settings', provided_by=[production, staging])

    render.render_all()
    if not os.path.exists('electron'):
        os.makedirs('electron')

    local('npm run-script pack')
예제 #10
0
def build_electron():
    require('settings', provided_by=[production, staging])

    render.render_all()
    if not os.path.exists('electron'):
        os.makedirs('electron')

    local('npm run-script pack')
예제 #11
0
def deploy(quick=None, remote='origin', reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    if app_config.DEPLOY_TO_SERVERS:
        require('branch', provided_by=[stable, master, branch])

        if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'):
            utils.confirm(
                colored("You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch, "red")
            )

        servers.checkout_latest(remote)

        servers.fabcast('text.update')
        servers.fabcast('assets.sync')
        servers.fabcast('data.update')

        if app_config.DEPLOY_CRONTAB:
            servers.install_crontab()

        if app_config.DEPLOY_SERVICES:
            servers.deploy_confs()

    if quick != 'quick':
        update()

    render.render_all()

    # Clear files that should never be deployed
    local('rm -rf www/live-data')

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www',
        app_config.PROJECT_SLUG,
        headers={
            'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
        },
        ignore=['www/assets/*', 'www/live-data/*']
    )

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/assets',
        '%s/assets' % app_config.PROJECT_SLUG,
        headers={
            'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE
        }
    )

    if reload:
        reset_browsers()

    if not check_timestamp():
        reset_browsers()
예제 #12
0
파일: __init__.py 프로젝트: wbez/debates
def deploy(remote='origin', reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])
    if app_config.DEPLOY_TO_SERVERS:
        require('branch', provided_by=[stable, master, branch])

        if (app_config.DEPLOYMENT_TARGET == 'production'
                and env.branch != 'stable'):
            utils.confirm(
                colored(
                    "You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?"
                    % env.branch, "red"))

        servers.checkout_latest(remote)

        # servers.fabcast('text.update')
        # servers.fabcast('assets.sync')
        # servers.fabcast('data.update')

        if app_config.DEPLOY_CRONTAB:
            servers.install_crontab()

        if app_config.DEPLOY_SERVICES:
            servers.deploy_confs()

    update()
    render.render_all()

    # Clear files that should never be deployed
    local('rm -rf www/live-data')

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www',
        '%s%s' %
        (app_config.DEBATE_DIRECTORY_PREFIX, app_config.CURRENT_DEBATE),
        headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE},
        ignore=['www/assets/*', 'www/live-data/*'])

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/assets',
        '%s%s/assets' %
        (app_config.DEBATE_DIRECTORY_PREFIX, app_config.CURRENT_DEBATE),
        headers={'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE})

    # DEPLOY STATIC FACTCHECK FROM LOCAL ENVIRONMENT
    if app_config.DEPLOY_STATIC_FACTCHECK:
        execute('deploy_factcheck')

    if reload:
        reset_browsers()

    if not check_timestamp():
        reset_browsers()
예제 #13
0
def deploy_client(remote='origin'):
    """
    Render and deploy app to S3.
    """
    require('settings', provided_by=[production, staging])

    update()
    render.render_all()
    utils._gzip('www', '.gzip')
    utils._deploy_to_s3()
예제 #14
0
파일: __init__.py 프로젝트: nprapps/books14
def deploy(quick=False):
    """
    Deploy the latest app to S3
    """
    require('settings', provided_by=[production, staging])
    if not quick == 'quick':
        update()
    render.render_all()
    _gzip('www', '.gzip')
    _deploy_to_s3()
예제 #15
0
def deploy_client(remote='origin'):
    """
    Render and deploy app to S3.
    """
    require('settings', provided_by=[production, staging])

    update()
    render.render_all()
    utils._gzip('www', '.gzip')
    utils._deploy_to_s3()
예제 #16
0
def deploy(quick=False):
    """
    Deploy the latest app to S3
    """
    require('settings', provided_by=[production, staging])
    if not quick == 'quick':
        update()
    render.render_all()
    _gzip('www', '.gzip')
    _deploy_to_s3()
예제 #17
0
def deploy_test():
    require('settings', provided_by=[production, staging])
    render.render_all()

    # Clear files that should never be deployed
    local('rm -rf www/live-data')

    flat.deploy_folder(
        'www',
        app_config.PROJECT_SLUG,
        headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE},
        ignore=['www/assets/*'])
예제 #18
0
def deploy(remote='origin'):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    if app_config.DEPLOY_TO_SERVERS:
        require('branch', provided_by=[stable, master, branch])

        if (app_config.DEPLOYMENT_TARGET == 'production'
                and env.branch != 'stable'):
            utils.confirm(
                colored(
                    "You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?"
                    % env.branch, "red"))

        servers.checkout_latest(remote)

        servers.fabcast('text.update')
        #servers.fabcast('assets.sync')
        servers.fabcast('data.update')

        if app_config.DEPLOY_CRONTAB:
            # servers.install_crontab()
            _servers.install_crontab()

        if app_config.DEPLOY_SERVICES:
            servers.deploy_confs()

    update()
    render.render_all()

    # # Clear files that should never be deployed
    # local('rm -rf www/live-data')

    # flat.deploy_folder(
    #     'www',
    #     app_config.PROJECT_SLUG,
    #     headers={
    #         'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
    #     },
    #     ignore=['www/assets/*', 'www/live-data/*']
    # )

    # flat.deploy_folder(
    #     'www/assets',
    #     '%s/assets' % app_config.PROJECT_SLUG,
    #     headers={
    #         'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE
    #     }
    # )
    _deploy_to_graphics()
예제 #19
0
def deploy(remote='origin'):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    update()
    render.render_all()

    # Clear files that should never be deployed
    local('rm -rf www/live-data')

    local('rsync -vr www/ ubuntu@%s:~/www/%s' % (app_config.FILE_SERVER, app_config.PROJECT_SLUG))
예제 #20
0
def target_tile(max_range=None):
    # return the position of a tile left-clicked in player's FOV (optionally
    # in a range), or (None,None) if right-clicked.
    message("Use the mouse or the keyboard to select a tile...", tcod.blue)
    prevcolor = tcod.black
    mouse_lastx, mouse_lasty = (x, y) = render.prev_mouse_pos

    while True:
        # render the screen. this erases the inventory and shows the names of
        # objects under the mouse.
        render.render_all()
        tcod.console_flush()

        tcod.console_set_char_background(
            render.con, x, y, prevcolor, tcod.BKGND_SET
        )  # set last tile's bg color to normal

        tcod.sys_check_for_event(tcod.EVENT_MOUSE | tcod.EVENT_KEY_PRESS, key, mouse)

        if mouse.dx or mouse.dy:
            (mouse_lastx, mouse_lasty) = (x, y) = (mouse.cx, mouse.cy)
            x = mouse.cx
            y = mouse.cy
            x = x + render.camera_x
            y = y + render.camera_y

        key_pressed = game.get_key(key)
        if key_pressed in direction_keys:
            direction = direction_keys[key_pressed]
            x += direction[0]
            y += direction[1]
        if tcod.map_is_in_fov(terrain.map.fov_map, x, y):
            prevcolor = tcod.console_get_char_background(render.con, x, y)  # for resetting the color later
            tcod.console_set_char_background(render.con, x, y, tcod.sky, tcod.BKGND_SET)  # visualising the target tile
        else:
            x, y = game.player.x, game.player.y  # if not in fov, reset it to the player coords

        if mouse.rbutton_pressed or key.vk == tcod.KEY_ESCAPE:
            tcod.console_set_char_background(render.con, x, y, prevcolor, tcod.BKGND_SET)
            return (None, None)  # cancel if the player right-clicked or pressed Escape

        # accept the target if the player clicked in FOV, and in case a range
        # is specified, if it's in that range
        if (
            (mouse.lbutton_pressed or key.vk == tcod.KEY_ENTER)
            and tcod.map_is_in_fov(terrain.map.fov_map, x, y)
            and (max_range is None or game.player.distance(x, y) <= max_range)
        ):
            tcod.console_set_char_background(render.con, x, y, prevcolor, tcod.BKGND_SET)
            return (x, y)
예제 #21
0
def deploy(remote='origin'):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    if app_config.DEPLOY_TO_SERVERS:
        require('branch', provided_by=[stable, master, branch])

        if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'):
            utils.confirm(
                colored("You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch, "red")
            )

        servers.checkout_latest(remote)

        servers.fabcast('text.update')
        #servers.fabcast('assets.sync')
        servers.fabcast('data.update')

        if app_config.DEPLOY_CRONTAB:
            # servers.install_crontab()
            _servers.install_crontab()

        if app_config.DEPLOY_SERVICES:
            servers.deploy_confs()

    update()
    render.render_all()

    # # Clear files that should never be deployed
    # local('rm -rf www/live-data')

    # flat.deploy_folder(
    #     'www',
    #     app_config.PROJECT_SLUG,
    #     headers={
    #         'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
    #     },
    #     ignore=['www/assets/*', 'www/live-data/*']
    # )

    # flat.deploy_folder(
    #     'www/assets',
    #     '%s/assets' % app_config.PROJECT_SLUG,
    #     headers={
    #         'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE
    #     }
    # )
    _deploy_to_graphics()
예제 #22
0
def run():
    global current_turn
    while alive and not tcod.console_is_window_closed():
        action = handle_keys()
        if action:
            compute_fov()
            update_objects()
            randomly_spawn_enemies()
            current_turn += 1
            if player.x + terrain.map.scroll_amount >= VICTORY_DISTANCE:
                ui.message(
                    'Congratulations, you win! Press escape to exit.', tcod.cyan)
                global state
                state = 'dead'
        render.render_all()
예제 #23
0
def deploy(remote="origin"):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require("settings", provided_by=[production, staging])

    if app_config.DEPLOY_TO_SERVERS:
        require("branch", provided_by=[stable, master, branch])

        if app_config.DEPLOYMENT_TARGET == "production" and env.branch != "stable":
            utils.confirm(
                colored(
                    "You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?"
                    % env.branch,
                    "red",
                )
            )

        servers.checkout_latest(remote)

        servers.fabcast("text.update")
        servers.fabcast("assets.sync")
        servers.fabcast("data.update")

        if app_config.DEPLOY_CRONTAB:
            servers.install_crontab()

        if app_config.DEPLOY_SERVICES:
            servers.deploy_confs()

    update()
    render.render_all()

    # Clear files that should never be deployed
    local("rm -rf www/live-data")

    flat.deploy_folder(
        "www",
        app_config.PROJECT_SLUG,
        headers={"Cache-Control": "max-age=%i" % app_config.DEFAULT_MAX_AGE},
        ignore=["www/assets/*", "www/live-data/*"],
    )

    flat.deploy_folder(
        "www/assets",
        "%s/assets" % app_config.PROJECT_SLUG,
        headers={"Cache-Control": "max-age=%i" % app_config.ASSETS_MAX_AGE},
    )
def deploy(remote='origin'):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    if app_config.DEPLOY_TO_SERVERS:
        require('branch', provided_by=[stable, master, branch])

    if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'):
        utils.confirm("You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch)

    if app_config.DEPLOY_TO_SERVERS:
        checkout_latest(remote)

        fabcast('update_copy')
        fabcast('assets_sync')
        fabcast('update_data')

        if app_config.DEPLOY_CRONTAB:
            install_crontab()

        if app_config.DEPLOY_SERVICES:
            deploy_confs()

    compiled_includes = render.render_all()
    render.render_dorms(compiled_includes)
    sass()
    # _gzip('www', '.gzip')
    # _deploy_to_s3()
    # _gzip('.dorms_html', '.dorms_gzip')
    # _deploy_to_s3('.dorms_gzip')
    local('rm -rf dist')
    local('cp -r .dorms_html dist')
    local('cp -r www/ dist/')
def deploy(remote='origin'):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    if app_config.DEPLOY_TO_SERVERS:
        require('branch', provided_by=[stable, master, branch])

    if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'):
        utils.confirm("You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch)

    if app_config.DEPLOY_TO_SERVERS:
        checkout_latest(remote)

        fabcast('update_copy')
        fabcast('assets_sync')
        fabcast('update_data')

        if app_config.DEPLOY_CRONTAB:
            install_crontab()

        if app_config.DEPLOY_SERVICES:
            deploy_confs()

    compiled_includes = render.render_all()
    render.render_dorms(compiled_includes)
    sass()
    # _gzip('www', '.gzip')
    # _deploy_to_s3()
    # _gzip('.dorms_html', '.dorms_gzip')
    # _deploy_to_s3('.dorms_gzip')
    local('rm -rf dist')
    local('cp -r .dorms_html dist')
    local('cp -r www/ dist/')
예제 #26
0
def play_game(game):
    while not libtcod.console_is_window_closed():
        render.render_all(game)

        if game.state == 'pathing':
            if game.player.mover.takepath() == 'empty':
                game.state = 'playing'
            game.map_movement = True


        player_action = input.handle_keys(game)

        # If 'tookturn' is added, fov_recompute should be true.

        if player_action == "exit":
            break
예제 #27
0
def main():
    message_log, key, mouse = init_ui()
    show_popup((
        "You are a killer robot, sent from the future on a vital mission.\n"
        "Your only job -- to defeat the humans who threaten your very existence with their foolish schemes.\n"
        "They cannot be allowed to wipe out the peaceful race of killer robots before they're even created!"
    ), 'THE STORY SO FAR')
    turn_state, game_map, map_knowledge = init_game()

    while not tcod.console_is_window_closed():
        if game_map.los_changed:
            compute_los(game_map.los_map, game_map.get_active_player().pos)
            game_map.los_changed = False

        map_knowledge.update(game_map)

        render_all(map_knowledge, game_map.los_map,
                   game_map.get_active_player(), message_log, turn_state)

        turn_state.progress = TurnProgress.Ongoing

        for actor in game_map.actors:
            actor.energy += 100

        active_actors = [
            actor for actor in game_map.actors if actor.energy > 0
        ]
        while len(active_actors) != 0:
            # sort to always let the player go first
            active_actors.sort(
                key=lambda act: 0 if act.is_active_player else 1)
            for actor in active_actors:
                command = actor.ai.next_move(
                    target=game_map.get_active_player(), game_map=game_map)
                results = actor.execute(command, game_map)
                end_game = process_results(results, actor, game_map,
                                           message_log,
                                           turn_state.current_turn)
                if end_game:
                    return True

            # if only python had do-while
            active_actors = [
                actor for actor in game_map.actors if actor.energy > 0
            ]

        turn_state.next_turn()
예제 #28
0
def play_game(game):
    while not libtcod.console_is_window_closed():
        render.render_all(game)

        #In the case of pathing, follow the path or switch back to normal playing when done.
        if game.state == 'pathing':
            if game.player.mover.takepath(game) == 'empty':
                game.state = 'playing'
            game.map_movement = True

        if game.map_movement:
            pass # Here we can check to see if player movement has occurred and see if an event should come up.

        player_action = input.handle_keys(game)

        # If 'tookturn' is added, fov_recompute should be true.

        if player_action == "exit":
            break
def play_game():
    """ Main Loop """
    player_action = None

    #Main Loop
    while not libtcod.console_is_window_closed():
        render.render_all()
        libtcod.console_flush()
        map = gvar.game.player.currentmap()
        for object in map.objects:
            object.clear()
            if object.fighter is not None and libtcod.map_is_in_fov(
                    gvar.foh_map, object.x,
                    object.y) and not gvar.game.ticks.contains(object):
                object.fighter.join_battle()

        #handle death state
        if gvar.game.game_state == 'dead':
            player_action = input.handle_keys()
            if player_action == 'exit':
                save.save_game()
                break
            else:
                continue

        else:
            actor = gvar.game.ticks.getWithPriority()
            if actor[1] == gvar.game.player:
                #handle keys and exit game if needed
                player_action = input.handle_keys()
                if player_action == 'exit':
                    save.save_game()
                    main_menu()
                    break
                gvar.game.ticks.put(actor[1], int(player_action + actor[0]))

            else:
                #let mobs take their turn
                if gvar.game.game_state == 'playing':
                    if actor[1].ai:
                        speed = actor[1].ai.take_turn()
                        gvar.game.ticks.put(actor[1], int(speed + actor[0]))
예제 #30
0
def deploy(slug=''):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[staging, production])
    require('slug', provided_by=[post])

    update()
    render.render_all()

    flat.deploy_folder('%s/www' % env.static_path,
                       '%s/%s' % (env.post_root, env.post_config.DEPLOY_SLUG),
                       max_age=app_config.DEFAULT_MAX_AGE,
                       ignore=['%s/www/assets/*' % env.static_path])

    flat.deploy_folder('%s/www/assets' % env.static_path,
                       '%s/%s/assets' %
                       (env.post_root, env.post_config.DEPLOY_SLUG),
                       max_age=app_config.ASSETS_MAX_AGE,
                       warn_threshold=app_config.WARN_THRESHOLD)
예제 #31
0
def deploy(remote='origin', reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging, electron])

    render.render_all()

    if env.settings == 'electron':
        if not os.path.exists('electron'):
            os.makedirs('electron')

        local('npm run-script pack')

    if env.settings == 'fileserver':
        local('rsync -vr www/ %s@%s:%s/%s' % (
            app_config.FILE_SERVER_USER,
            app_config.FILE_SERVER,
            app_config.FILE_SERVER_PATH,
            app_config.PROJECT_SLUG
        ))

    if env.settings == 'production' or env.settings == 'staging':
        flat.deploy_folder(
            app_config.S3_BUCKET,
            'www',
            app_config.PROJECT_SLUG,
            headers={
                'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
            },
            ignore=['www/img/*', 'www/live-data/*']
        )

        flat.deploy_folder(
            app_config.S3_BUCKET,
            'www/img',
            '%s/img' % app_config.PROJECT_SLUG,
            headers={
                'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE
            }
        )
예제 #32
0
def deploy(remote='origin', reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging, electron])

    render.render_all()

    if env.settings == 'electron':
        if not os.path.exists('electron'):
            os.makedirs('electron')

        local('npm run-script pack')

    if env.settings == 'fileserver':
        local('rsync -vr www/ %s@%s:%s/%s' % (
            app_config.FILE_SERVER_USER,
            app_config.FILE_SERVER,
            app_config.FILE_SERVER_PATH,
            app_config.PROJECT_SLUG
        ))

    if env.settings == 'production' or env.settings == 'staging':
        flat.deploy_folder(
            app_config.S3_BUCKET,
            'www',
            app_config.PROJECT_SLUG,
            headers={
                'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
            },
            ignore=['www/img/*', 'www/live-data/*']
        )

        flat.deploy_folder(
            app_config.S3_BUCKET,
            'www/img',
            '%s/img' % app_config.PROJECT_SLUG,
            headers={
                'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE
            }
        )
예제 #33
0
def play_game():
	""" Main Loop """
	player_action = None

	#Main Loop
	while not libtcod.console_is_window_closed():
		render.render_all()
		libtcod.console_flush()
		map = gvar.game.player.currentmap()
		for object in  map.objects:
			object.clear()
			if object.fighter is not None and libtcod.map_is_in_fov(gvar.foh_map, object.x, object.y) and not gvar.game.ticks.contains(object):
				object.fighter.join_battle()

		#handle death state
		if gvar.game.game_state == 'dead':
			player_action = input.handle_keys()
			if player_action == 'exit':
				save.save_game()
				break
			else:
				continue

		else:
			actor = gvar.game.ticks.getWithPriority()
			if actor[1] == gvar.game.player:
				#handle keys and exit game if needed
				player_action = input.handle_keys()
				if player_action == 'exit':
					save.save_game()
					main_menu()
					break
				gvar.game.ticks.put(actor[1], int(player_action + actor[0]))

			else:
				#let mobs take their turn
				if gvar.game.game_state == 'playing':
					if actor[1].ai:
						speed = actor[1].ai.take_turn()
						gvar.game.ticks.put(actor[1], int(speed + actor[0]))
예제 #34
0
def deploy(remote="origin", reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require("settings", provided_by=[production, staging, electron])

    render.render_all()

    if env.settings == "electron":
        if not os.path.exists("electron"):
            os.makedirs("electron")

        local("npm run-script pack")

    if env.settings == "fileserver":
        local(
            "rsync -vr www/ %s@%s:%s/%s"
            % (
                app_config.FILE_SERVER_USER,
                app_config.FILE_SERVER,
                app_config.FILE_SERVER_PATH,
                app_config.PROJECT_SLUG,
            )
        )

    if env.settings == "production" or env.settings == "staging":
        flat.deploy_folder(
            app_config.S3_BUCKET,
            "www",
            app_config.PROJECT_SLUG,
            headers={"Cache-Control": "max-age=%i" % app_config.DEFAULT_MAX_AGE},
            ignore=["www/img/*", "www/live-data/*"],
        )

        flat.deploy_folder(
            app_config.S3_BUCKET,
            "www/img",
            "%s/img" % app_config.PROJECT_SLUG,
            headers={"Cache-Control": "max-age=%i" % app_config.ASSETS_MAX_AGE},
        )
예제 #35
0
def deploy(slug=''):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[staging, production])
    require('slug', provided_by=[post])

    update()
    render.render_all()

    flat.deploy_folder(
        '%s/www' % env.static_path,
        '%s/%s' % (env.post_root, env.post_config.DEPLOY_SLUG),
        max_age=app_config.DEFAULT_MAX_AGE,
        ignore=['%s/www/assets/*' % env.static_path]
    )

    flat.deploy_folder(
        '%s/www/assets' % env.static_path,
        '%s/%s/assets' % (env.post_root, env.post_config.DEPLOY_SLUG),
        max_age=app_config.ASSETS_MAX_AGE,
        warn_threshold=app_config.WARN_THRESHOLD
    )
예제 #36
0
def deploy_client(reload=False):
    """
    Deploy the latest app to S3.
    """
    require('settings', provided_by=[production, staging])

    update()
    render.render_all()
    render.render_current_state(folder='www')

    # Clear files that should never be deployed
    local('rm -rf www/live-data')

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www',
        '',
        headers={
            'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
        },
        ignore=['www/assets/*', 'www/live-data/*']
    )

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/assets',
        'assets',
        headers={
            'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE
        }
    )

    if reload:
        reset_browsers()

    if not check_timestamp():
        reset_browsers()
예제 #37
0
def deploy(remote='origin', reload=False):
    """
    Deploy the latest app to S3 and, if configured, to our servers.
    """
    require('settings', provided_by=[production, staging])

    update()
    render.render_all()

    # Clear files that should never be deployed
    local('rm -rf www/live-data')

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www',
        app_config.PROJECT_SLUG,
        headers={
            'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE
        },
        ignore=['www/assets/*', 'www/live-data/*']
    )

    flat.deploy_folder(
        app_config.S3_BUCKET,
        'www/assets',
        '%s/assets' % app_config.PROJECT_SLUG,
        headers={
            'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE
        }
    )

    if reload:
        reset_browsers()

    if not check_timestamp():
        reset_browsers()
예제 #38
0
파일: scene.py 프로젝트: ld-cd/dancingdots
 def scenemaker():
     render.render_all(dot_list=dots, start=start_time)
예제 #39
0
파일: rogue.py 프로젝트: Enojia/Game
libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, '~//Documents//rogue ', False)
libtcod.sys_set_fps(LIMIT_FPS)
con = libtcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT)

dongeon = mapGen.Dongeon(80, 45)
player = gameObject.Player(SCREEN_WIDTH/2, SCREEN_HEIGHT/2, "@", libtcod.white, dongeon)
player.x = 25
player.y = 23
npc = gameObject.Object(SCREEN_WIDTH/2 - 5, SCREEN_HEIGHT/2, "@", libtcod.yellow, dongeon) ##change this later
objects = [player, npc]
##main loop


while not libtcod.console_is_window_closed():
    
    render.render_all(objects, dongeon, con)

    libtcod.console_blit(con, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,0, 0, 0)
    libtcod.console_flush() ##redraw the scene
    
    for obj in objects:
        obj.clear(con)
        
    def handle_keys():
        key = libtcod.console_wait_for_keypress(False)
        if key.vk == libtcod.KEY_ENTER and key.lalt:
            libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())
        elif key.vk == libtcod.KEY_ESCAPE:
            return True ## exit function
    exit = handle_keys()
    if exit:
예제 #40
0
파일: game.py 프로젝트: TeaTrey/RoguePy
def play_game(player, entities, game_map, message_log, game_state, con, panel,
              constants):
    fov_recompute = True

    fov_map = initialize_fov(game_map)

    key = tcod.Key()
    mouse = tcod.Mouse()

    game_state = GameStates.PLAYERS_TURN
    previous_game_state = game_state

    targeting_item = None

    while not tcod.console_is_window_closed():
        tcod.sys_check_for_event(tcod.EVENT_KEY_PRESS | tcod.EVENT_MOUSE, key,
                                 mouse)

        if fov_recompute:
            recompute_fov(fov_map, player.x, player.y, constants['fov_radius'],
                          constants['fov_light_walls'],
                          constants['fov_algorithm'])

        render_all(con, panel, entities, player, game_map, fov_map,
                   fov_recompute, message_log, constants['screen_width'],
                   constants['screen_height'], constants['bar_width'],
                   constants['panel_height'], constants['panel_y'], mouse,
                   constants['colors'], game_state)

        fov_recompute = False

        tcod.console_flush()

        clear_all(con, entities)

        action = handle_keys(key, game_state)
        mouse_action = handle_mouse(mouse)

        move = action.get('move')
        pickup = action.get('pickup')
        show_inventory = action.get('show_inventory')
        drop_inventory = action.get('drop_inventory')
        inventory_index = action.get('inventory_index')
        exit = action.get('exit')
        fullscreen = action.get('fullscreen')

        left_click = mouse_action.get('left_click')
        right_click = mouse_action.get('right_click')

        player_turn_results = []

        if move and game_state == GameStates.PLAYERS_TURN:
            dx, dy = move
            destination_x = player.x + dx
            destination_y = player.y + dy

            if not game_map.is_blocked(destination_x, destination_y):
                target = get_blocking_entities_at_location(
                    entities, destination_x, destination_y)

                if target:
                    attack_results = player.fighter.attack(target)
                    player_turn_results.extend(attack_results)
                else:
                    player.move(dx, dy)

                    fov_recompute = True

                game_state = GameStates.ENEMY_TURN

        elif pickup and game_state == GameStates.PLAYERS_TURN:
            for entity in entities:
                if entity.item and entity.x == player.x and entity.y == player.y:
                    pickup_results = player.inventory.add_item(entity)
                    player_turn_results.extend(pickup_results)

                    break
            else:
                message_log.add_message(
                    Message('There is nothing here to pick up.', tcod.yellow))

        if show_inventory:
            previous_game_state = game_state
            game_state = GameStates.SHOW_INVENTORY

        if drop_inventory:
            previous_game_state = game_state
            game_state = GameStates.DROP_INVENTORY

        if inventory_index is not None and previous_game_state != GameStates.PLAYER_DEAD and inventory_index < len(
                player.inventory.items):
            item = player.inventory.items[inventory_index]

            if game_state == GameStates.SHOW_INVENTORY:
                player_turn_results.extend(
                    player.inventory.use(item,
                                         entities=entities,
                                         fov_map=fov_map))
            elif game_state == GameStates.DROP_INVENTORY:
                player_turn_results.extend(player.inventory.drop_item(item))

        if game_state == GameStates.TARGETING:
            if left_click:
                target_x, target_y = left_click

                item_use_results = player.inventory.use(targeting_item,
                                                        entities=entities,
                                                        fov_map=fov_map,
                                                        target_x=target_x,
                                                        target_y=target_y)
                player_turn_results.extend(item_use_results)
            elif right_click:
                player_turn_results.append({'targeting_cancelled': True})

        if exit:
            if game_state in (GameStates.SHOW_INVENTORY,
                              GameStates.DROP_INVENTORY):
                game_state = previous_game_state
            elif game_state == GameStates.TARGETING:
                player_turn_results.append({'targeting_cancelled': True})
            else:
                save_game(player, entities, game_map, message_log, game_state)

                return True

        if fullscreen:
            tcod.console_set_fullscreen(not tcod.console_is_fullscreen())

        for player_turn_result in player_turn_results:
            message = player_turn_result.get('message')
            dead_entity = player_turn_result.get('dead')
            item_added = player_turn_result.get('item_added')
            item_consumed = player_turn_result.get('consumed')
            item_dropped = player_turn_result.get('item_dropped')
            targeting = player_turn_result.get('targeting')
            targeting_cancelled = player_turn_result.get('targeting_cancelled')

            if message:
                message_log.add_message(message)

            if dead_entity:
                if dead_entity == player:
                    message, game_state = kill_player(dead_entity)
                else:
                    message = kill_monster(dead_entity)

                message_log.add_message(message)

            if item_added:
                entities.remove(item_added)

                game_state = GameStates.ENEMY_TURN

            if item_consumed:
                game_state = GameStates.ENEMY_TURN

            if item_dropped:
                entities.append(item_dropped)

                game_state = GameStates.ENEMY_TURN

            if targeting:
                previous_game_state = GameStates.PLAYERS_TURN
                game_state = GameStates.TARGETING

                targeting_item = targeting

                message_log.add_message(targeting_item.item.targeting_message)

            if targeting_cancelled:
                game_state = previous_game_state

                message_log.add_message(Message('Targeting cancelled'))

        if game_state == GameStates.ENEMY_TURN:
            for entity in entities:
                if entity.ai:
                    enemy_turn_results = entity.ai.take_turn(
                        player, fov_map, game_map, entities)

                    for enemy_turn_result in enemy_turn_results:
                        message = enemy_turn_result.get('message')
                        dead_entity = enemy_turn_result.get('dead')

                        if message:
                            message_log.add_message(message)

                        if dead_entity:
                            if dead_entity == player:
                                message, game_state = kill_player(dead_entity)
                            else:
                                message = kill_monster(dead_entity)

                            message_log.add_message(message)

                            if game_state == GameStates.PLAYER_DEAD:
                                break

                    if game_state == GameStates.PLAYER_DEAD:
                        break
            else:
                game_state = GameStates.PLAYERS_TURN
예제 #41
0
app.url_map.strict_slashes = False

# https://flask.palletsprojects.com/en/1.1.x/config/
app.config.from_pyfile("config.py")

try:
    with open("raw/config.yml") as yaml_config:
        user_config = safe_load(yaml_config)
    print(user_config)
    app.config.update(user_config)
except:
    pass

os.environ.setdefault('PYPANDOC_PANDOC', app.config["PANDOC_PATH"])

notes, tag_set, static_pages = render_all()

@app.route("/")
def index():

    return render_template("index.html", notes=notes, tag_set=tag_set)

@app.route("/tags")
def tags():

    tag = request.args.get("tag")

    matching_articles = [note for note in notes if tag in note.tags]

    return render_template("index.html", notes=matching_articles, tag_set=tag_set)
예제 #42
0
def target_tile(max_range=None, radius=0):
	"""	|  Target a distant tile
		|  For Ranged Attacks, like Archery, Thrown
		|  Also Fireballs or similar projectiles with Radius
	"""
	from components import Object
	from mapcreation import Circle
	from render import render_all

	# Spawn a Target Object that can be moved with arrow Keys
	(x, y) = (gvar.game.player.x, gvar.game.player.y)
	target = Object(x, y, 'X', color=libtcod.red, name='target', blocks=False)
	gvar.game.objects.append(target)

	while True:
		target.send_to_front()
		render_all()

		#Render Splash
		libtcod.console_clear(gvar.overlay)
		if radius > 0:
			target.splash = Circle(target.x, target.y, radius)
			for point in target.splash.circle:
				libtcod.console_set_char_background(gvar.overlay, point[0], point[1], libtcod.yellow)
		libtcod.console_blit(gvar.overlay, 0, 0, gvar.SCREEN_WIDTH, gvar.SCREEN_HEIGHT, 0, 0, 0, 1.0, 0.5)
		libtcod.console_flush()

		#Move the Target around
		key = libtcod.Key()
		mouse = libtcod.Mouse()
		key_pressed = libtcod.sys_wait_for_event(libtcod.EVENT_KEY_PRESS,key,mouse,True)
		if not key_pressed:
			return 'cancelled'

		if key.vk == libtcod.KEY_UP or key.vk == libtcod.KEY_KP8:
			if libtcod.map_is_in_fov(gvar.fov_map, target.x, target.y-1):
				target.y -= 1
		elif key.vk == libtcod.KEY_DOWN or key.vk == libtcod.KEY_KP2:
			if libtcod.map_is_in_fov(gvar.fov_map, target.x, target.y+1):
				target.y += 1
		elif key.vk == libtcod.KEY_LEFT or key.vk == libtcod.KEY_KP4:
			if libtcod.map_is_in_fov(gvar.fov_map, target.x-1, target.y):
				target.x -= 1
		elif key.vk == libtcod.KEY_RIGHT or key.vk == libtcod.KEY_KP6:
			if libtcod.map_is_in_fov(gvar.fov_map, target.x+1, target.y):
				target.x += 1
		elif key.vk == libtcod.KEY_KP7:
			if libtcod.map_is_in_fov(gvar.fov_map, target.x-1, target.y-1):
				target.x -= 1
				target.y -= 1
		elif key.vk == libtcod.KEY_KP9:
			if libtcod.map_is_in_fov(gvar.fov_map, target.x+1, target.y-1):
				target.x += 1
				target.y -= 1
		elif key.vk == libtcod.KEY_KP3:
			if libtcod.map_is_in_fov(gvar.fov_map, target.x+1, target.y+1):
				target.x += 1
				target.y += 1
		elif key.vk == libtcod.KEY_KP1:
			if libtcod.map_is_in_fov(gvar.fov_map, target.x-1, target.y+1):
				target.x -= 1
				target.y += 1
		elif key.vk == libtcod.KEY_ENTER:
			gvar.game.objects.remove(target)
			return target
			break
		elif key.vk == libtcod.KEY_ESCAPE:
			gvar.game.objects.remove(target)
			return 'cancelled'
			break
		elif chr(key.c) == 's':
			# Returns String 'closest' for further evaluation by the calling function, e.g. for targeting the closest mob
			gvar.game.objects.remove(target)
			return 'closest'
			break
예제 #43
0
def main():
    # initialise screen dimensions
    screen_width = 80
    screen_height = 50
    # initialise map dimensions
    map_width = 80
    map_height = 45

    # room limits and dimensions
    max_room_size = 10
    min_room_size = 6
    total_room_limit = 30

    colours = {
        'dark_wall': libtcod.Color(60, 49, 32),
        'dark_ground': libtcod.Color(96, 128, 56),
        'npc_colour': libtcod.Color(80, 80, 80)
    }

    # declare player and npcs, put them into a list
    player = Entity(int(screen_width / 2), int(screen_height / 2), '@',
                    libtcod.white)
    npc = Entity(int(screen_width - 10 / 2), int(screen_height / 2), '$',
                 colours.get('npc_colour'))
    entities = [player, npc]

    # initialise the map
    game_map = Map(map_width, map_height)
    game_map.create_map(total_room_limit, min_room_size, max_room_size,
                        map_width, map_height, player)

    # choose font for rendering
    libtcod.console_set_custom_font(
        'arial10x10.png',
        libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    # initialise console
    libtcod.console_init_root(screen_width, screen_height, 'Omars Roguelike',
                              False)

    con = libtcod.console_new(screen_width, screen_height)
    # key and mouse presses
    key = libtcod.Key()
    mouse = libtcod.Mouse()

    while not libtcod.console_is_window_closed():
        # checks for mouse or key interrupt
        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS, key, mouse)
        # renders all entities
        render_all(con, entities, screen_width, screen_height, colours,
                   game_map)
        libtcod.console_flush()

        clear_all(con, entities)
        # checks what action has to be done
        action = handle_keys(key)

        move = action.get('move')
        exit = action.get('exit')
        fullscreen = action.get('fullscreen')

        if move:
            dx, dy = move
            if not game_map.is_blocked(player.x + dx, player.y + dy) and map_width-1 > player.x + dx > 0 and map_height-1 > \
                    player.y + dy > 0:
                player.move(dx, dy)

        if exit:
            return True

        if fullscreen:
            libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())
예제 #44
0
import render

#######################################
# Initialization and main loop
#######################################
tcod.console_set_custom_font(data.font, tcod.FONT_TYPE_GREYSCALE |
                             tcod.FONT_LAYOUT_TCOD)
tcod.console_init_root(
    data.screen_width, data.screen_height, 'frogue!!', False)

maps.make_bsp_dungeon(6, 10, 30)
# maps.build_prefab()
engine.start()

recompute_field_of_view = True
render.initialize_field_of_view()

while not tcod.console_is_window_closed():
    # Render the screen...
    render.render_all()

    tcod.console_flush()

    # Clear objects from old location, before they move
    for object in data.objects:
        object.clear()

    exit = control.input()
    if exit:
        break
예제 #45
0
파일: engine.py 프로젝트: Gazhole/7DRL2019
def main():
    tdl.set_font('terminal16x16.png', greyscale=True,
                 altLayout=False)  # Load the font from a png.
    tdl.set_fps(100)

    map_width = 20
    map_height = 20

    room_width = 30
    room_height = 30

    screen_width = room_width + 22
    screen_height = room_height + 22

    root_console = tdl.init(screen_width, screen_height, title='7DRL 2019')
    top_panel_console = tdl.Console(screen_width, 10)
    view_port_console = tdl.Console(room_width, room_height)
    bottom_panel_console = tdl.Console(screen_width, 10)
    message_log = MessageLog(0, 0, screen_width, 9)

    entities = []

    game_map = GameMap(map_width, map_height)

    sword_stats = Weapon(2, 10)
    player_weapon = Item(game_map,
                         "0x0",
                         0,
                         0,
                         "Sword",
                         "|", (255, 255, 255),
                         weapon=sword_stats)
    player_stats = Fighter(hits=10, left_hand=player_weapon)
    player = Actor(game_map,
                   "2x2",
                   15,
                   10,
                   "Player",
                   "@", (255, 255, 255),
                   fighter=player_stats)
    entities.append(player)

    generate_map(game_map, entities, player)

    all_consoles = [
        root_console, view_port_console, bottom_panel_console,
        top_panel_console
    ]

    fov_algorithm = "BASIC"
    fov_light_walls = True
    fov_radius = 50
    fov_recompute = True

    game_state = GameStates.PLAYER_TURN

    while not tdl.event.is_window_closed():
        if fov_recompute:  # Compute the field of view to show changes.
            game_map.rooms[player.map_x][player.map_y]\
                .compute_fov(player.room_x, player.room_y,
                             fov=fov_algorithm, radius=fov_radius, light_walls=fov_light_walls, sphere=True)

            render_all(all_consoles, game_map, entities, player, fov_recompute,
                       message_log)
            tdl.flush()
            clear_all(view_port_console, entities)
            fov_recompute = False

        for event in tdl.event.get():
            if event.type == 'KEYUP':
                user_input = event
                break

        else:
            user_input = None

        if not user_input:
            continue

        action = handle_keys(user_input)

        move = action.get('move')
        exit_game = action.get('exit_game')
        select_hand = action.get('select_hand')
        drop_item = action.get('drop_item')
        pickup_item = action.get('pickup_item')
        shuffle_rooms = action.get('shuffle_rooms')

        player_turn_results = []

        if shuffle_rooms:
            message = game_map.shuffle_rooms(player, entities)
            message_log.add_message(message)
            fov_recompute = True

        # TODO at the moment these functions are doing all the leg work and player_turn_results isn't used. Rectify.

        if select_hand and game_state == GameStates.PLAYER_TURN:
            player.fighter.selected_hand = select_hand
            fov_recompute = True

        if drop_item and game_state == GameStates.PLAYER_TURN:
            message = player.fighter.drop_item(game_map, entities)
            message_log.add_message(message)
            game_state = GameStates.ENEMY_TURN
            fov_recompute = True

        if pickup_item and game_state == GameStates.PLAYER_TURN:
            message = player.fighter.pickup_item(entities)
            message_log.add_message(message)
            game_state = GameStates.ENEMY_TURN
            fov_recompute = True

        if move and game_state == GameStates.PLAYER_TURN:
            dx, dy = move
            destination_room_x = player.room_x + dx
            destination_room_y = player.room_y + dy

            if destination_room_x < 0:
                dx = 0

                if player.map_x - 1 < 0:
                    player.map_x = map_width - 1
                else:
                    player.map_x -= 1

                player.room_x = room_width - 1

            if destination_room_x == room_width:
                destination_room_x -= 1
                dx = 0

                if player.map_x + 1 > map_width - 1:
                    player.map_x = 0
                else:
                    player.map_x += 1

                player.room_x = 0

            if destination_room_y < 0:
                dy = 0

                if player.map_y - 1 < 0:
                    player.map_y = map_height - 1
                else:
                    player.map_y -= 1

                player.room_y = room_height - 1

            if destination_room_y == room_height:
                destination_room_y -= 1
                dy = 0

                if player.map_y + 1 > map_height - 1:
                    player.map_y = 0
                else:
                    player.map_y += 1

                player.room_y = 0

            if game_map.rooms[player.map_x][player.map_y].walkable[
                    destination_room_x, destination_room_y]:
                target = get_blocking_entities_at_location(
                    entities, player.map_x, player.map_y, destination_room_x,
                    destination_room_y)

                if target:  # Combat here
                    attack_results = player.fighter.attack(target)
                    player_turn_results.extend(
                        attack_results
                    )  # Add the result of the last turn to the list
                    fov_recompute = True

                else:
                    player.move(dx, dy)  # Or just move
                    player.set_current_room(game_map)

                    # TODO: Bug with the new room layouts - some cause change of room to break.
                    print("MapPos: ",
                          player.map_x,
                          ",",
                          player.map_y,
                          end=" / ")
                    print("RoomPos: ", player.room_x, ",", player.room_y)
                    fov_recompute = True

                game_state = GameStates.ENEMY_TURN  # Switch over the enemy's turn.

        if exit_game:
            return True

        for player_turn_result in player_turn_results:
            message = player_turn_result.get("message")  # Pull any messages
            dead_entity = player_turn_result.get(
                "dead")  # Or anything that died

            if message:
                message_log.add_message(
                    message
                )  # Add the message (if any) to the message log to print on screen.

            if dead_entity:  # If anything died...
                if dead_entity == player:
                    message, game_state = kill_player(dead_entity)  # Game over
                else:
                    message = kill_monster(
                        dead_entity
                    )  # Print a death message for monster, add exp

                message_log.add_message(message)  # Print messages to screen.

        player_turn_results.clear()  # Clear ready for next turn.

        if game_state == GameStates.ENEMY_TURN:
            for entity in entities:
                if entity.map_x == player.map_x and entity.map_y == player.map_y:
                    if entity.ai:  # If the entity has some intelligence (monsters, npc)
                        enemy_turn_results = entity.ai.take_turn(
                            player, game_map, entities)

                        for enemy_turn_result in enemy_turn_results:  # Same deal as the player turns
                            message = enemy_turn_result.get("message")
                            dead_entity = enemy_turn_result.get("dead")

                            if message:
                                message_log.add_message(message)

                            if dead_entity:
                                if dead_entity == player:
                                    message, game_state = kill_player(
                                        dead_entity)
                                else:
                                    message = kill_monster(dead_entity)

                                message_log.add_message(message)

                            if game_state == GameStates.PLAYER_DEAD:
                                break

                        enemy_turn_results.clear()

                    if game_state == GameStates.PLAYER_DEAD:
                        break

            else:
                game_state = GameStates.PLAYER_TURN
예제 #46
0
def main(map, entities, player, fov_radius, light_walls, health_boost,
         spell_dict):
    # defining game display parameters and creating consoles
    panel_height = 10
    screen_width = max(map.width, 80)
    screen_height = map.height + panel_height

    map_con = libtcod.console_new(map.width, map.height)
    panel_con = libtcod.console_new(screen_width, panel_height)

    fov_recompute = True
    fov_map = initialize_fov(map)

    msg_log = MessageLog(25, 50, panel_height - 1)

    gamestate = GameStates.PLAYER
    recompute_fov(fov_map, player.x, player.y, fov_radius, light_walls)
    while not libtcod.console_is_window_closed():
        render_all(map_con, panel_con, map, fov_map, fov_recompute, entities,
                   player, msg_log, screen_width, screen_height, panel_height)

        # Keyboard input
        key = libtcod.console_wait_for_keypress(True)

        action = handle_keys(key, spell_dict, gamestate)

        move = action.get('move')
        fullscreen = action.get('fullscreen')
        exit = action.get('exit')
        display = action.get('display')
        spell = action.get('spell')
        dirn = action.get('dirn')

        turn_results = []

        if move and gamestate == GameStates.PLAYER:
            dx, dy = move
            dest_x, dest_y = player.x + dx, player.y + dy
            if not map.is_blocked(dest_x, dest_y):
                # attack if a monster is present else just move
                target = map.get_entity(dest_x, dest_y, entities[1:-1])
                if target:
                    player.attack(target, turn_results)
                else:
                    player.move(dx, dy, map)
                    fov_recompute = True
                    for entity in entities[:-1]:
                        # get health_boost if standing on a corpse
                        if entity.behav is None and entity.x == player.x and entity.y == player.y:
                            player.hp += health_boost
                            if player.hp > player.max_hp:
                                player.hp = player.max_hp
                            entities.remove(entity)

                # check if reached stairs
                if entities[0].x == player.x and entities[0].y == player.y:
                    msg_log.add_msg(
                        Message(
                            'You\'ve reached the stairs. Setting up new map.'.
                            format(player.name), 'red'))
                    render_all(map_con, panel_con, map, fov_map, fov_recompute,
                               entities, player, msg_log, screen_width,
                               screen_height, panel_height)
                    time.sleep(5)
                    return False

                gamestate = GameStates.ENEMY

        if spell is not None and gamestate == GameStates.PLAYER:
            # Check whether spell is directional
            if spell['dirn']:
                gamestate = GameStates.DIRECTION
                active_spell = spell
                turn_results.append({
                    'message':
                    Message(
                        'Targeting active for {}. Choose direction.'.format(
                            active_spell['name']), 'silver')
                })
            else:
                if player.do_spell(spell, map, fov_map, entities,
                                   turn_results):
                    gamestate = GameStates.ENEMY

        if gamestate == GameStates.DIRECTION and dirn:
            if dirn < 5:
                # execute only if valid direction selected
                if player.do_spell(active_spell, map, fov_map, entities,
                                   turn_results, dirn):
                    gamestate = GameStates.ENEMY
                else:
                    gamestate = GameStates.PLAYER
            else:
                turn_results.append(
                    {'message': Message('Targeting cancelled.', 'silver')})
                gamestate = GameStates.PLAYER

        if fullscreen:
            libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())

        if exit:
            return True

        if display:
            render_display(map_con, panel_con, map, fov_map, entities,
                           screen_width, screen_height, panel_height)

        for result in turn_results:
            message = result.get('message')
            dead = result.get('dead')

            if message:
                msg_log.add_msg(message)

            if dead:
                if dead is player:
                    msg_log.add_msg(dead.die())
                    gamestate = GameStates.DEAD
                else:
                    msg_log.add_msg(dead.die())
                    map.tiles[dead.x][dead.y].has_entity = 0

        if fov_recompute:
            recompute_fov(fov_map, player.x, player.y, fov_radius, light_walls)

        render_all(map_con, panel_con, map, fov_map, fov_recompute, entities,
                   player, msg_log, screen_width, screen_height, panel_height)
        time.sleep(0.2)

        fov_recompute == False

        # enemy turn
        if gamestate == GameStates.ENEMY:
            for entity in entities[1:-1]:
                if libtcod.map_is_in_fov(fov_map, entity.x,
                                         entity.y) and entity.behav:
                    entity_results = []
                    entity.take_turn(player, map, entity_results)
                    for result in entity_results:
                        message = result.get('message')
                        dead = result.get('dead')

                        if message:
                            msg_log.add_msg(message)

                        if dead:
                            if dead is player:
                                msg_log.add_msg(dead.die())
                                gamestate = GameStates.DEAD
                            else:
                                msg_log.add_msg(dead.die())

                if gamestate == GameStates.DEAD:
                    break
            else:
                gamestate = GameStates.PLAYER
    return True
예제 #47
0
import os

from git import clone
from prompt import interact
from render import render_all
from helper import schema_path

template = 'https://github.com/deepankarm/pod-template.git'


if __name__ == '__main__':
    try:
        repo_dir = clone(url=template)
        schema = schema_path(repo_dir=repo_dir)
        user_context = interact(filepath=schema)
        if not user_context:
            print('Something wrong')
        render_all(context=user_context,
                   project_directory=os.path.join(repo_dir, user_context['project_dir']))
    except KeyboardInterrupt:
        print('\nUser interrupted. Nothing to do. Bye!')
예제 #48
0
def target_tile(max_range=None, radius=0):
    """	|  Target a distant tile
		|  For Ranged Attacks, like Archery, Thrown
		|  Also Fireballs or similar projectiles with Radius
	"""
    from components import Object
    from mapcreation import Circle
    from render import render_all

    # Spawn a Target Object that can be moved with arrow Keys
    (x, y) = (gvar.game.player.x, gvar.game.player.y)
    target = Object(x, y, 'X', color=libtcod.red, name='target', blocks=False)
    gvar.game.objects.append(target)

    while True:
        target.send_to_front()
        render_all()

        #Render Splash
        libtcod.console_clear(gvar.overlay)
        if radius > 0:
            target.splash = Circle(target.x, target.y, radius)
            for point in target.splash.circle:
                libtcod.console_set_char_background(gvar.overlay, point[0],
                                                    point[1], libtcod.yellow)
        libtcod.console_blit(gvar.overlay, 0, 0, gvar.SCREEN_WIDTH,
                             gvar.SCREEN_HEIGHT, 0, 0, 0, 1.0, 0.5)
        libtcod.console_flush()

        #Move the Target around
        key = libtcod.Key()
        mouse = libtcod.Mouse()
        key_pressed = libtcod.sys_wait_for_event(libtcod.EVENT_KEY_PRESS, key,
                                                 mouse, True)
        if not key_pressed:
            return 'cancelled'

        if key.vk == libtcod.KEY_UP or key.vk == libtcod.KEY_KP8:
            if libtcod.map_is_in_fov(gvar.fov_map, target.x, target.y - 1):
                target.y -= 1
        elif key.vk == libtcod.KEY_DOWN or key.vk == libtcod.KEY_KP2:
            if libtcod.map_is_in_fov(gvar.fov_map, target.x, target.y + 1):
                target.y += 1
        elif key.vk == libtcod.KEY_LEFT or key.vk == libtcod.KEY_KP4:
            if libtcod.map_is_in_fov(gvar.fov_map, target.x - 1, target.y):
                target.x -= 1
        elif key.vk == libtcod.KEY_RIGHT or key.vk == libtcod.KEY_KP6:
            if libtcod.map_is_in_fov(gvar.fov_map, target.x + 1, target.y):
                target.x += 1
        elif key.vk == libtcod.KEY_KP7:
            if libtcod.map_is_in_fov(gvar.fov_map, target.x - 1, target.y - 1):
                target.x -= 1
                target.y -= 1
        elif key.vk == libtcod.KEY_KP9:
            if libtcod.map_is_in_fov(gvar.fov_map, target.x + 1, target.y - 1):
                target.x += 1
                target.y -= 1
        elif key.vk == libtcod.KEY_KP3:
            if libtcod.map_is_in_fov(gvar.fov_map, target.x + 1, target.y + 1):
                target.x += 1
                target.y += 1
        elif key.vk == libtcod.KEY_KP1:
            if libtcod.map_is_in_fov(gvar.fov_map, target.x - 1, target.y + 1):
                target.x -= 1
                target.y += 1
        elif key.vk == libtcod.KEY_ENTER:
            gvar.game.objects.remove(target)
            return target
            break
        elif key.vk == libtcod.KEY_ESCAPE:
            gvar.game.objects.remove(target)
            return 'cancelled'
            break
        elif chr(key.c) == 's':
            # Returns String 'closest' for further evaluation by the calling function, e.g. for targeting the closest mob
            gvar.game.objects.remove(target)
            return 'closest'
            break
예제 #49
0
def js_tests():
    """
    Run Karma/Jasmine unit tests.
    """
    render.render_all()
    local('node_modules/karma/bin/karma start www/js/test/karma.conf.js')