Esempio n. 1
0
def main():
    os.system('clear')
    print_welcome()
    input()
    os.system('clear')
    goalie = disk.get_goalie()
    game = core.Game(
        core.Player(
            input('Player 1 Name: ').title(),
            input('Player 1 Team: ').title()),
        core.Player(
            input('Player 2 Name: ').title(),
            input('Player 2 Name: ').title()), 5, core.Ball())
    while game.keep_playing():
        os.system('clear')
        cprint('{} PRESS ENTER TO SHOOT'.format(
            game.p1.name.upper()).center(69),
               'yellow',
               attrs=['blink', 'reverse'])
        print(game)
        print(goalie, end="")
        input()
        score = game.p1.score
        game.ball.position = game.p1.shoot()
        cprint(game.ball, attrs=['bold'])
        if score < game.p1.score:
            cprint('{} SCORES!'.format(game.p1.name.upper()).center(69, ' '),
                   'green')
        else:
            cprint('{} misses...'.format(game.p1.name).center(69, ' '), 'red')
        input('press enter to continue')

        os.system('clear')
        cprint('{} PRESS ENTER TO SHOOT'.format(
            game.p2.name.upper()).center(69),
               'yellow',
               attrs=['blink', 'bold'])
        print(game)
        print(goalie, end="")
        input()
        score = game.p2.score
        game.ball.position = game.p2.shoot()
        cprint(game.ball, attrs=['bold'])
        if score < game.p2.score:
            cprint('{} SCORES!'.format(game.p2.name.upper()).center(69, ' '),
                   'green')
        else:
            cprint('{} misses...'.format(game.p2.name).center(69, ' '), 'red')
        input('press enter to continue')
        game.round += 1

    os.system('clear')
    game_end()
    cprint('{} WINS THE GAME!'.format(game.winner().upper()).center(41, ' '),
           'green',
           attrs=['blink', 'reverse'])
    def test_armed_attack_method(self):
        weapon = core.Dagger()
        player = core.Player()
        player.ATK = 10
        player.STR = 4
        player.Weapon = weapon

        expected = player.ATK + player.STR/4 + weapon.ATK

        self.assertEqual(expected, player.Armed_attack(weapon))
Esempio n. 3
0
def wheel_main():
    players = []
    decision = int(input('How many players are there?\n:'))
    if decision <= 4:
        num = 0
        while num != decision:
            name = input('what is your name?\n: ')
            player = core.Player(name)
            players.append(player)
            num += 1
    print(players)
    game = core.WheelofForturne()
Esempio n. 4
0
def newgame_init(game_obj):

    game_obj.player = core.Player(
        "Ark", game_obj, os.path.join(filepaths.image_path, "spr_ark2.png"))
    game_obj.load_scene(
        "scene1", os.path.join(filepaths.scene_path, "scene_cottage.tmx"))
    game_obj.camera.following = game_obj.player

    game_obj.obj_stack = [game_obj.scene_obj]

    game_obj.next_script = gameplay_loop
    game_obj.fader.fade_in()
Esempio n. 5
0
def test_tmx_init(game, filename):
    # eventually I want to replace this with a generic onion sprite
    pygame.display.set_caption(filename)
    game.player = core.Player(game, "hero_sprite.png")
    game.setup_scene(filename)
    #game.camera.setup(filename)
    game.camera.following = game.player
    game.debug_info_on = True
    
    game.obj_stack = [ game.scene ]
    game.scene.paused = False
    game.next_script = test_tmx_loop
    game.fader.fade_in()
Esempio n. 6
0
def test_tmx_init(game_obj, filename):

    pygame.display.set_caption(filename)
    game_obj.player = core.Player(
        "Ark", game_obj, os.path.join(filepaths.image_path, "spr_ark2.png"))
    game_obj.load_scene(filename, os.path.join(filepaths.scene_path, filename))
    game_obj.camera.following = game_obj.player
    game_obj.debugging = 1

    game_obj.obj_stack = [game_obj.scene_obj]
    game_obj.scene_obj.paused = False
    game_obj.next_script = test_tmx_loop
    game_obj.fader.fade_in()
Esempio n. 7
0
def check_for_args(args):
    #This code probably sucks too but if you think about it isn't it still
    #premature optimization if you're optimizing for readability before readability is
    #determined to definitely be a problem and you've isolated this function as the cause
    #of lack of readability? Checkmate atheists
    if args.cmd == 'get_player':
        return core.Player(args.region, args.player_name)
    if args.cmd == 'get_tournament':
        return core.Tournament(args.region, args.tournament_name)
    if args.cmd == 'get_all_players':
        return main.get_all_players(args.region)
    if args.cmd == 'get_attendance':
        start_date = parse_date(args.start_date)
        end_date = parse_date(args.end_date)
        if args.all_players_from_region:
            player_list = main.get_all_players(args.player_list)
        else:
            print('Borf borf borf unimplemented')
            player_list = []
        return main.get_tournament_attendance(player_list, args.game,
                                              start_date, end_date)

    return "I've done something horribly wrong  with " + repr(args)
Esempio n. 8
0
def start(filename=None):
    pygame.init()
    pygame.display.set_caption("rhombus 0.5.3 alpha")
    game = core.Game()

    theme = {
        "font": pygame.font.Font(None, 24),
        "debug_font": pygame.font.Font(None, 16),
        "font_sel": (0xff, 0xff, 0xff),
        "font_not": (0xa0, 0xa0, 0xa0),
        "bgcolour": (0, 0, 0),
        "alpha": 127
    }

    game.ui = ui.UserInterface(game, theme)

    if filename == None:
        # setup the title menu
        game.title_card = pygame.image.load(
            os.path.join(filepaths.image_path, "titlecard.png"))
        game.music_tracks["titletrack"] = pygame.mixer.Sound(
            os.path.join(filepaths.sound_path, "rstheme.ogg"))

        # setup the interface objects
        titleselect_labels = ["New Game", "Quit to Desktop"]
        game.ui["titleselect"] = core.Selector(game, (245, 300, 150, 54),
                                               titleselect_labels)

        game.ui["dialogue"] = core.Dialogue2(game, (170, 360, 300, 100))

        playermenu_labels = ["Inventory", "Status", "Gear", "Save", "Quit"]
        game.ui["playermenu"] = core.Selector(game, (105, 90, 120, 124),
                                              playermenu_labels)
        game.ui["menupane"] = core.MenuPane(game, (235, 90, 300, 300))
        game.ui["menupane"]["inventory"] = core.Inventory(game)

        quit_labels = ["No", "Yes"]
        game.ui["yesnobox"] = core.Selector(game, (170, 296, 54, 54),
                                            quit_labels)
        '''
        menu_bindings = { "Inventory": states.draw_inventory,
                          "Status": states.draw_status,
                          "Gear": states.draw_gear,
                          "Save": states.draw_save,
                          "Quit": states.quit_init }
        game.ui["playermenu"] = core.UI_PlayerMenu("playermenu", game, (105,90,120,124),
                                                   menu_bindings, states.gameplay_init)
        game.ui["childpane"] = core.UI_SubMenuPane("childpane", game, game.ui["playermenu"], (300,300))
        game.ui["inventory"] = core.UI_Inventory(game, "Inventory", game.ui["childpane"])
        game.ui["status"] = core.UI_Status("Status", game, game.ui["childpane"])'''

        # load item icons
        game.load_icon("potion_ico.png")

        # setup the player mob
        game.player = core.Player(game, "clyde_sprite.png")
        #game.sprite_db["barrel_sprite.png"].pattern = [0,1,2] # redefining the animation pattern; only for barrel
        #game.sprite_db["barrel_sprite.png"].reset = False
        # initialize to title screen and start game program
        #states.title_init(game)
        game.script = game.scripts.titlescreen
        game.script.init(game)
        #game["state_switch"] = states.State_Switch(game)
    else:
        states.test_tmx_init(game, filename)

    game.main()
Esempio n. 9
0
                epos,
                "gameover":
                board.check_gameover()
            },
            sort_keys=False,
            indent=4)

        self.send_response(200)
        self.send_header('Content-type', 'text/json')
        self.send_header('Access-Control-Allow-Origin', '*')
        self.end_headers()
        self.wfile.write(res)
        return


def decode_stones(stones_code):
    pass


def encode_stones(stones):
    pass


if __name__ == '__main__':

    evaluator = core.Evaluator()
    player = core.Player(evaluator)

    httpd = HTTPServer(('localhost', 8080), GetHandler)
    httpd.serve_forever()