This repository has been archived by the owner on Aug 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Weird game #53
Open
imml3457
wants to merge
3
commits into
master
Choose a base branch
from
weird-game
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Weird game #53
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,104 @@ | ||
#!/usr/bin/env python3 | ||
#------------------------------------------------ | ||
# it's a game | ||
# More programs at Bibou Ja | ||
#------------------------------------------------ | ||
#------------------------------------------------ | ||
# Challenge 1: Can you craft a tent and a firepit? | ||
# Challenge 2: Can you add more items? | ||
# Challenge 3: Can you create crafting rules | ||
# to make more items? | ||
# Challenge 4: Add comments to the code below! | ||
#------------------------------------------------ | ||
commands = { | ||
"i" : "see inventory", | ||
"c" : "see crafting options", | ||
"craft [item]" : "craft something from inventory items", | ||
} | ||
#an inventory of items | ||
items = { | ||
"flint" : 50, | ||
"grass" : 100, | ||
"hay" : 0, | ||
"tree" : 100, | ||
"log" : 0, | ||
"sapling" : 100, | ||
"twig" : 0, | ||
"boulder" : 30, | ||
"rock" : 0, | ||
"pickaxe" : 0, | ||
"axe" : 0, | ||
"firepit" : 0, | ||
"tent" : 0, | ||
"torch" : 0, | ||
} | ||
#rules to make new objects | ||
craft = { | ||
"hay" : { "grass" : 1 }, | ||
"twig" : { "sapling" : 1 }, | ||
"log" : { "axe" : 1, "tree" : 1 }, | ||
"axe" : { "twig" : 3, "flint" : 1 }, | ||
"tent" : { "twig" : 10, "hay" : 15 }, | ||
"firepit" : { "boulder" : 5, "log" : 3, "twig" : 1, "torch" : 1 }, | ||
"torch" : { "flint" : 1, "grass" : 1, "twig" : 1 }, | ||
"pickaxe" : { "flint" : 2, "twig" : 1 } | ||
} | ||
|
||
print("'Crafting Challenge' Game") | ||
print("More programs at Bibou Ja") | ||
print("-----------------------------------------\n") | ||
|
||
print("TRY TO SURVIVE BY CRAFTING A TENT AND A FIREPIT!") | ||
print("type '?' for help") | ||
while True: | ||
command = input(">").split() | ||
if len(command) == 0: | ||
continue | ||
if len(command) > 0: | ||
verb = command[0].lower() | ||
if len(command) > 1: | ||
item = command[1].lower() | ||
if verb == "?": | ||
for key in commands: | ||
print(key + " : " + commands[key]) | ||
print("\n") | ||
elif verb == "i": | ||
for key in items: | ||
print(key + " : " + str(items[key])) | ||
print("\n") | ||
elif verb == "c": | ||
for key in craft: | ||
print(key + " can be made with:") | ||
for i in craft[key]: | ||
print(str(craft[key][i]) + " " + i) | ||
print("\n") | ||
|
||
elif verb == "craft": | ||
print("making " + item + ":") | ||
if item in craft: | ||
for i in craft[item]: | ||
print(" you need : " + str(craft[item][i]) + " " + i + " and you have " + str(items[i])) | ||
canBeMade = True | ||
for i in craft[item]: | ||
if craft[item][i] > items[i]: | ||
print("item cannot be crafted\n") | ||
canBeMade = False | ||
break | ||
#made a change to make it reader | ||
if canBeMade == True: | ||
for i in craft[item]: | ||
items[i] -= craft[item][i] | ||
items[item] += 1 | ||
print("item crafted\n") | ||
|
||
if items["tent"] >= 1 and items["firepit"] >= 1: | ||
print("\n**YOU HAVE MANAGED TO SURVIVE!\nWELL DONE!") | ||
break | ||
else: | ||
print("you can't") | ||
else: | ||
print("you can't") | ||
|
||
def helloworld(): | ||
pass | ||
|
||
def add_numbers(x, y): | ||
pass | ||
|
||
if __name__ == '__main__': | ||
# do something! | ||
pass | ||
|
||
#copyright https://www.quora.com/Whats-the-most-beautiful-line-of-Python-code | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wow is this even open source licensed? |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oof you rekt my shebang :<