# Text Adventure -- main loop (starter).
#
# Finish the TODOs so the game plays as described in the chapter
# page.
#
# Run from this folder:
#   cd projects/04-text-adventure/starter
#   python main.py

import world

current_room_id = world.start_id
inventory = []

# TODO: write `describe(room)` that prints:
#   -- <room["name"]> --
#   <room["description"]>
#   Items here: <comma-separated items>     (only if room has items)
#   Exits: <comma-separated exit names>
def describe(room):
    # your code here
    pass

# TODO: write `go(direction)` that looks up the exit on the current
# room. If the exit exists, change current_room_id and describe the
# new room. Otherwise print "You cannot go that way."
def go(direction):
    # your code here
    pass

# TODO: write `take(item_name)` that looks for item_name in the
# current room's items list. If found, remove it from the room and
# add it to inventory. Print confirmation. If not found, print
# "There is no <item> here." Return True if the player just picked
# up the gold coin so the main loop can end.
def take(item_name):
    # your code here
    return False

# TODO: write `show_inventory()` that prints inventory items
# separated by commas. If empty, print "You are carrying nothing."
def show_inventory():
    # your code here
    pass

# Helper: split a typed line into a verb and an argument.
def parse(line):
    words = line.split()
    if not words:
        return None, None
    verb = words[0]
    arg = words[1] if len(words) > 1 else None
    # Items like "gold coin" are two words. Join everything after the
    # verb into one argument string.
    if len(words) > 2:
        arg = " ".join(words[1:])
    return verb, arg

describe(world.rooms[current_room_id])

while True:
    try:
        line = input("> ")
    except EOFError:
        break

    verb, arg = parse(line)

    # TODO: dispatch the verb to the right function.
    # Suggested verbs: look, go, take, inv, quit.
    # Remember to break out of the loop after quit or after take()
    # returns True (gold coin picked up).
