Frodo's Adventure Functions

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/28

flashcard set

Earn XP

Description and Tags

Inputs, outputs, where the main calls it and why, and the AI/Team tag

29 Terms

1
New cards

aprint(text)

AI-assisted. Prints text one letter at a time, pausing longer on punctuation (typewriter effect). IN: the text. OUT: nothing (prints). CALLED BY: main, for the welcome, boss entrance, and win/lose messages.

2
New cards

ask_once(prompt)

Team-written. Shows a prompt and turns the typed answer into a whole number; try/except catches bad input (requirement 9). IN: prompt text. OUT: the number, or None if not a whole number. CALLED BY: main turn menu, choose_settings, fight, use_item, shop, shop_or_proceed.

3
New cards

show_status(detailed=False)

AI-assisted. Prints health, treats, damage, defense, difficulty, and rooms left before the boss. IN: detailed (True also lists items). OUT: nothing (prints). CALLED BY: main at the start of every turn, and for menu option 3 (detailed).

4
New cards

show_rules()

Team-written. Prints the rules, including the note to close chart windows to continue. IN: nothing. OUT: nothing (prints). CALLED BY: main, menu option 2.

5
New cards

random_room()

Team-written. Picks a random room from dict_room: Chest, Troy, Nicolas, Anthony, or Gerardo (requirement 3). IN: nothing. OUT: the room name. CALLED BY: main, when the player opens a door.

6
New cards

enter_room(room_name)

AI-assisted. Runs the chosen room: chest_room for a Chest, otherwise fight. Adds 1 to rooms cleared if Frodo survives. IN: room name. OUT: True if Frodo is still alive. CALLED BY: main, right after random_room.

7
New cards

chest_room()

AI-assisted. Gives Frodo a random item (Biscuit, Shampoo, or Dog Toy) using append, and logs it. IN: nothing. OUT: nothing. CALLED BY: enter_room, when the room is a Chest.

8
New cards

fight(enemy_name)

AI-assisted. Runs a whole fight: each round the player attacks or uses an item, then the enemy hits back. Records both health values each round, shows the Fight Recap chart, logs the result, gives treats on a win. IN: enemy name. OUT: True if Frodo won, False if he lost. CALLED BY: enter_room (normal enemies) and main directly (boss).

9
New cards

use_item()

AI-assisted. Lists Frodo's items, lets the player pick one, applies its boost, and removes it from the list (the remove for requirement 4). IN: nothing (uses player_items). OUT: True if an item was used; False if canceled or no items, so Frodo doesn't lose his turn. CALLED BY: fight, when the player picks 2.

10
New cards

shop_or_proceed()

AI-assisted. After a room, asks: visit shop (1) or move on (2). After 3 bad inputs it moves on automatically. This is the for/else loop for requirement 7: the else only runs if all 3 tries were bad. IN: nothing. OUT: nothing. CALLED BY: main, after every room Frodo survives.

11
New cards

shop()

AI-assisted. Shows upgrades (Nap, Trim, Collar) and lets the player buy until they choose 0; shows the Frodo's Stats chart when leaving. IN: nothing. OUT: nothing. CALLED BY: shop_or_proceed, when the player picks 1.

12
New cards

update_health(player, change)

AI-assisted. Adds or subtracts health, keeping it between 0 and MAX_HEALTH (100). IN: player dictionary, amount (+ heals, - hurts). OUT: new health. CALLED BY: fight (enemy damage) and update_status (items and Nap).

13
New cards

update_damage(player, buff)

AI-assisted. Adds to Frodo's damage. IN: player dictionary, amount. OUT: new damage. CALLED BY: update_status.

14
New cards

update_defense(player, buff)

AI-assisted. Adds to Frodo's defense. IN: player dictionary, amount. OUT: new defense. CALLED BY: update_status.

15
New cards

update_points(player, value)

AI-assisted. Adds or spends treats; won't let treats go below 0. IN: player dictionary, amount. OUT: new total, or None if there aren't enough treats. CALLED BY: fight (rewards) and shop (purchases; None blocks the purchase).

16
New cards

update_items(items, item, action)

AI-assisted. Adds an item to the list ("add") or removes it ("use"). IN: item list, item name, "add" or "use". OUT: the updated list. CALLED BY: chest_room (add) and use_item (use).

17
New cards

update_status(player, stat, change)

AI-assisted. Helper that sends the change to the right function for Health, Damage, or Defense. IN: player dictionary, stat name, amount. OUT: that stat's new value. CALLED BY: use_item and shop, so they don't need their own if/elif chains.

18
New cards

choose_settings()

AI-assisted. Asks for a difficulty (1-3) and sets the enemy multiplier and number of rooms (4, 6, or 8). IN: nothing. OUT: nothing (fills in settings). CALLED BY: main, for a new game or when loading fails.

19
New cards

save_game()

Team-written. Writes the current game to frodo_save.txt as name=value lines. IN: nothing. OUT: nothing (writes a file). CALLED BY: main, menu option 4.

20
New cards

load_savefile()

Team-written. Reads frodo_save.txt, converts values back to numbers and a list, and checks nothing is missing or invalid; try/except catches a missing or broken file (requirement 11). IN: nothing. OUT: dictionary of saved values, or None. CALLED BY: main, when the player chooses Load Saved Game.

21
New cards

apply_save(data)

AI-assisted. Copies the loaded values into the real game variables (settings, player_dict, player_items). IN: dictionary from load_savefile. OUT: nothing. CALLED BY: main, only if loading worked.

22
New cards

log_file(text)

Team-written. Adds one line to game_log.txt using "a" (append) mode. IN: the line of text. OUT: nothing (writes a file). CALLED BY: main (game start and every turn), fight, chest_room, shop, shop_or_proceed, final_summary (requirement 10).

23
New cards

final_summary(outcome)

AI-assisted. Calculates average treats per room, then prints and logs the game summary (the calculated summary for requirement 10). IN: "WON", "DEAD", or "QUIT". OUT: nothing. CALLED BY: main, when the game ends.

24
New cards

plot_stats()

AI-assisted. Draws the Frodo's Journey bar graph of health and treats for every turn (requirement 12). IN: nothing (uses health_history and treats_history). OUT: nothing (shows chart). CALLED BY: main, at the very end.

25
New cards

plot_fight(enemy_name, frodo_hp, enemy_hp)

AI-assisted. Draws the Fight Recap bar graph of Frodo's and the enemy's health after each round. IN: enemy name and two lists of health values. OUT: nothing (shows chart). CALLED BY: fight, when the fight ends.

26
New cards

plot_current_stats()

AI-assisted. Draws the Frodo's Stats bar graph of health, damage, defense, and treats. IN: nothing. OUT: nothing (shows chart). CALLED BY: shop, when the player leaves.

27
New cards

How a turn works (call chain)

The game shows Frodo's stats, the player picks 1–5, and the turn gets logged. 1 opens a random room: a chest gives an item, an enemy means a fight. If Frodo survives, he can shop or keep going, and after the last room comes the boss. 2 shows the rules, 3 shows status, 4 saves, 5 quits. If health hits 0, the game ends. Otherwise it repeats.

28
New cards

What happens when the game starts

Main asks New Game or Load. Load: load_savefile, then apply_save if it worked; otherwise choose_settings. Then the log is cleared with "w" mode and the turn loop begins.

29
New cards

Which functions read or write files?

Only save_game, load_savefile, and log_file - all Team-written, as the rubric requires.