Commit d03ff149 authored by Adam Blank's avatar Adam Blank
Browse files

Initial commit

parents
No related merge requests found
Showing with 169 additions and 0 deletions
+169 -0
# The command that runs the program. Commented out because it is not run when the interpreter command is set
# run = ["python3", "main.py"]
# The primary language of the repl. There can be others, though!
language = "python3"
# The main file, which will be shown by default in the editor.
entrypoint = "main.py"
# A list of globs that specify which files and directories should
# be hidden in the workspace.
hidden = ["venv", ".config", "**/__pycache__", "**/.mypy_cache", "**/*.pyc"]
# Specifies which nix channel to use when building the environment.
[nix]
channel = "stable-21_11"
# Per-language configuration: python3
[languages.python3]
# Treats all files that end with `.py` as Python.
pattern = "**/*.py"
# Tells the workspace editor to syntax-highlight these files as
# Python.
syntax = "python"
# The command needed to start the Language Server Protocol. For
# linting and formatting.
[languages.python3.languageServer]
start = ["pylsp"]
# The command to start the interpreter.
[interpreter]
[interpreter.command]
args = [
"stderred",
"--",
"prybar-python3",
"-q",
"--ps1",
"\u0001\u001b[33m\u0002\u0001\u001b[00m\u0002 ",
"-i",
]
env = { LD_LIBRARY_PATH = "$PYTHON_LD_LIBRARY_PATH" }
# The environment variables needed to correctly start Python and use the
# package proxy.
[env]
VIRTUAL_ENV = "/home/runner/${REPL_SLUG}/venv"
PATH = "${VIRTUAL_ENV}/bin"
PYTHONPATH="${VIRTUAL_ENV}/lib/python3.8/site-packages"
REPLIT_POETRY_PYPI_REPOSITORY="https://package-proxy.replit.com/pypi/"
MPLBACKEND="TkAgg"
# Enable unit tests. This is only supported for a few languages.
[unitTest]
language = "python3"
# Add a debugger!
[debugger]
support = true
# How to start the debugger.
[debugger.interactive]
transport = "localhost:0"
startCommand = ["dap-python", "main.py"]
# How to communicate with the debugger.
[debugger.interactive.integratedAdapter]
dapTcpAddress = "localhost:0"
# How to tell the debugger to start a debugging session.
[debugger.interactive.initializeMessage]
command = "initialize"
type = "request"
[debugger.interactive.initializeMessage.arguments]
adapterID = "debugpy"
clientID = "replit"
clientName = "replit.com"
columnsStartAt1 = true
linesStartAt1 = true
locale = "en-us"
pathFormat = "path"
supportsInvalidatedEvent = true
supportsProgressReporting = true
supportsRunInTerminalRequest = true
supportsVariablePaging = true
supportsVariableType = true
# How to tell the debugger to start the debuggee application.
[debugger.interactive.launchMessage]
command = "attach"
type = "request"
[debugger.interactive.launchMessage.arguments]
logging = {}
# Configures the packager.
[packager]
# Search packages in PyPI.
language = "python3"
# Never attempt to install `unit_tests`. If there are packages that are being
# guessed wrongly, add them here.
ignoredPackages = ["unit_tests"]
[packager.features]
enabledForHosting = false
# Enable searching packages from the sidebar.
packageSearch = true
# Enable guessing what packages are needed from the code.
guessImports = true
# Instructions
In this assignment, you will write a [text adventure game](https://en.wikipedia.org/wiki/Interactive_fiction) of your choice. This assignment focuses on the `input` function, writing `if` statements, and writing `while` loops!
## Required Task (`boring_adverture.py` file)
Your first task is to change the existing text adventure (in the file `boring_adverture.py`) to add an extra required "action" before the user is allowed to "sleep". We recommend an action like "go to interhouse" or something like that. The user should be required to both do your task and "do work" before the "sleep" option works.
## Creative Task (`fun_adventure.py` file)
Now, we'd like you to completely change the adventure so it's actually something interesting. You should write this FUN adventure in the `fun_adventure.py` file! Choose a theme and a story and make your own adventure! It can be as interesting or complicated as you like, but it must have at least **six** "actions" total!
from termcolor import colored
from utils import choices_to_str
choices = ["sleep", "cheer", "dowork"]
inventory = []
# The `colored` function prints out text in the color provided!
print(colored("Hello! Welcome to a boring adventure!", "green"))
print(colored("You are in a dark room. Choose one of the following:", "blue"))
# done is a "boolean variable" (i.e., either True or False)
# We use it to control when the `while` loop should end!
done = False
while not done:
# `choices_to_str` is a function we wrote to turn a choices
# list into a string where each choice is underlined. If you
# want to check it out, it's in `utils.py` on the left!
prompt = choices_to_str(choices)
action = input(prompt + " >>> ")
if action == "sleep" and "work" in inventory:
print(colored("ZZZZ...zzzz", "blue"))
done = True
elif action == "sleep":
print(colored("You still have work to do!", "red"))
elif action == "dowork":
inventory.append("work")
print(colored("You're done with your work now!", "green"))
elif action == "cheer":
print("Hip hip hooray!! You're still tired!")
print(colored("The adventure is over!", "green"))
from termcolor import colored
from utils import choices_to_str
print(colored("Uh oh! You haven't written this adventure yet!", "red"))
\ No newline at end of file
print("First, you should play the boring adventure!")
import boring_adventure
print("Second, you should play the fun adventure!")
import fun_adventure
print("Uh oh! There's no more adventures to play!")
\ No newline at end of file
from termcolor import colored
def choices_to_str(choices):
prompt = "["
for choice in choices:
prompt += colored(choice, attrs=[]) + ", "
prompt = prompt[:-2]
prompt += "]"
return prompt
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment