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)
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)
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)