コード例 #1
0
ファイル: input.py プロジェクト: AxisAndAllies/risk
def attack_success_move_armies(player, game_master, origin, target):
    picasso = get_picasso()
    hint_asset = build_hint_asset(ATTACK_HINTS['success'])
    picasso.add_asset(LAYER, hint_asset)
    dialog = BlockingSliderDialogAsset(DIALOG_X, DIALOG_Y, 'Attack Move', 1,
                                       origin.armies, slider_update, [origin, target])
    dialog.add_text(16, 16, "Attack was successful!")
    dialog.add_text(16, 32, "How many armies to move?")
    disable_all_clickables()
    picasso.add_asset(DIALOG_LAYER, dialog)
    done = False
    while not done:
        number_to_move = dialog.get_result(INPUT_POLL_SLEEP)
        try:
            game_master.player_move_armies(player, origin.name, target.name,
                                           number_to_move)
            done = True
        except GameMasterError as e:
            print(e)
            dialog.reset()
        except ValueError:
            # we really shouldn't get a parsing error from numeric dialog
            raise
    enable_all_clickables()
    picasso.remove_asset(DIALOG_LAYER, dialog)
    picasso.remove_asset(LAYER, hint_asset)
コード例 #2
0
ファイル: input.py プロジェクト: anthony-cervantes/risk-1
def attack_success_move_armies(player, game_master, origin, target):
    picasso = get_picasso()
    hint_asset = build_hint_asset(ATTACK_HINTS['success'])
    picasso.add_asset(LAYER, hint_asset)
    dialog = BlockingSliderDialogAsset(DIALOG_X, DIALOG_Y, 'Attack Move', 1, 
            origin.armies, slider_update, [origin, target])
    dialog.add_text(16, 16, "Attack was successful!")
    dialog.add_text(16, 32, "How many armies to move?")
    disable_all_clickables()
    picasso.add_asset(DIALOG_LAYER, dialog)
    done = False
    while not done:
        number_to_move = dialog.get_result(INPUT_POLL_SLEEP)
        try:
            game_master.player_move_armies(player, origin.name, target.name,
                    number_to_move)
            done = True
        except GameMasterError as e:
            print e
            dialog.reset()
        except ValueError:
            # we really shouldn't get a parsing error from numeric dialog
            raise 
    enable_all_clickables()
    picasso.remove_asset(DIALOG_LAYER, dialog)
    picasso.remove_asset(LAYER, hint_asset)
コード例 #3
0
ファイル: input.py プロジェクト: AxisAndAllies/risk
def fortify_choose_armies_to_move(player, game_master, origin, target):
    picasso = get_picasso()
    dialog = BlockingSliderDialogAsset(DIALOG_X, DIALOG_Y, 'Fortify', 0,
                                       origin.armies, slider_update, [origin, target])
    dialog.add_text(16, 16, "Fortifying...")
    dialog.add_text(16, 35, "Select amount of armies to move")
    disable_all_clickables()
    picasso.add_asset(DIALOG_LAYER, dialog)
    try:
        number_to_move = dialog.get_result(INPUT_POLL_SLEEP)
        if number_to_move > 0:
            game_master.player_move_armies(player, origin.name,
                                           target.name, number_to_move)
    except GameMasterError as e:
        fortify_failed(player, origin, target, e)
    enable_all_clickables()
    picasso.remove_asset(DIALOG_LAYER, dialog)
コード例 #4
0
ファイル: input.py プロジェクト: anthony-cervantes/risk-1
def fortify_choose_armies_to_move(player, game_master, origin, target):
    picasso = get_picasso()
    dialog = BlockingSliderDialogAsset(DIALOG_X, DIALOG_Y, 'Fortify', 0, 
            origin.armies, slider_update, [origin, target])
    dialog.add_text(16, 16, "Fortifying...")
    dialog.add_text(16, 35, "Select amount of armies to move")
    disable_all_clickables()
    picasso.add_asset(DIALOG_LAYER, dialog)
    try:
        number_to_move = dialog.get_result(INPUT_POLL_SLEEP)
        if number_to_move > 0:
            game_master.player_move_armies(player, origin.name, 
                    target.name, number_to_move)
    except GameMasterError as e:
        fortify_failed(player, origin, target, e)
    enable_all_clickables()
    picasso.remove_asset(DIALOG_LAYER, dialog)