Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ verify_ssl = true
name = "pypi"

[packages]
colorama = "*"

[dev-packages]
pylint = "*"
Expand Down
112 changes: 55 additions & 57 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions examples/calendar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import sys
import calendar
from datetime import datetime

args = sys.argv


month = datetime.today().month
year = datetime.today().year


if len(args) == 1:
pass

if len(args) == 2:
month = args[0]
34 changes: 34 additions & 0 deletions examples/latlon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class LatLon:
def __init__(self, lat, lon):
self.lat = lat
self.lon = lon


class Waypoint(LatLon):
def __init__(self, name, lat, lon):
super().__init__(lat, lon)
self.name = name

def __str__(self):
return f"{self.name}, {self.lat}, {self.lon}"


class Geocache(Waypoint):
def __init__(self, name, difficulty, size, lat, lon):
super().__init__(name, lat, lon)
self.difficulty = difficulty
self.size = size

def new_property_test(self):
self.new = "Exists"

def __str__(self):
return f"{self.name}, diff: {self.difficulty}, size: {self.size}, lat: {self.lat}, lon: {self.lon}"


gc = Geocache("Geo Test", 10, 3, 24, 26)


w = Waypoint("cool", 10, 10)
print(w.name)
print(gc)
44 changes: 44 additions & 0 deletions examples/rps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@


import random

wins = 0
losses = 0
ties = 0

cmds = ["r", "p", "s"]


def compare_answers(player_choice, computer_choice):
if player_choice == computer_choice:
return 0
elif (player_choice == "r" and computer_choice == "s") or \
(player_choice == "p" and computer_choice == "r") or \
(player_choice == "s" and computer_choice == "p"):
return 1
else:
return -1


while True:
print(f"\n{wins} - {losses} - {ties}")
cmd = input("Please input r/p/s: ")
opponent_cmd = random.choice(cmds)
print(f"Opponent picks {opponent_cmd}")
if cmd == "q":
break
elif cmd in cmds:
results = compare_answers(cmd, opponent_cmd)
else:
print("I did not understand that command")
continue
if results == 1:
print("You win!")
wins += 1
elif results == 0:
print("You tie")
ties += 1
else:
print("You lose")
losses += 1
print("Thank you for playing RPS!")
99 changes: 67 additions & 32 deletions src/adv.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
from room import Room
from player import Player
from item import Item
from colorama import Fore, Back, Style
import textwrap
import os

# Eileen's Birthday Adventure
# Eileen needs to find all her pals and cool dudes and gamer ladies, and have an awesome birthday bash.
# Overall goal is to reach the quarentine room, and free Nedim.
# We have to collect Bondor, and Laryna and Carlo, and Kai
# Declare all the rooms whoo
# remember, you defined Room as first having a name, which for Outside would be "Outside Cave Entrance", and then there is a description.
room = {
'outside': Room("Outside Cave Entrance",
"North of you, the cave mountain beckons."),
'outside': Room("Terria Fandango",
"""North of you, Nedim's quarentine towers over you. Only then will Eileen's birthday bash be complete and fufilling."""),

'foyer': Room("Foyer", """Dim light filters in from the south. Dusty
passages run north and east."""),
'foyer': Room("Fancy Hallway", """Light noise filters through the door behind you, until it closes onimously with a clank. You spot in front of you a clearing that seems to jut over a endless expanse. To the east of you, there is a narrow pathway to some silky darkness."""),

'overlook': Room("Grand Overlook", """A steep cliff appears before you, falling
into the darkness. Ahead to the north, a light flickers in
the distance, but there is no way across the chasm."""),
'overlook': Room("Grand Overlook", """You look down, and you instantly regret doing so. There seems to be glistening objects somewhere far below you, but you don't think that Nedim is waiting for you down there. However, a wild Bondor appears, and jumps on your back. You are stuck with him for now."""),

'narrow': Room("Narrow Passage", """The narrow passage bends here from west
to north. The smell of gold permeates the air."""),
Expand All @@ -37,49 +39,82 @@
room['narrow'].n_to = room['treasure']
room['treasure'].s_to = room['narrow']

# add some items

#
# Main
#
rock = Item(
"Rock", "This is a rock. Pointy, rough, and can be a makeshift weapon in times of need.")
cookie = Item(
"Cookie", "Cookies are awesome. Put one in your mount and chew. It's going to be great.")
bondor = Item("Mini Bondor",
"Bondor has jumped on you back, but quickly tires of it and hops into your backpack.")
room['outside'].items.append(rock)

# Make a new player object that is currently in the 'outside' room.
items = [rock, cookie]
items_names = [item.name for item in items]

# Write a loop that:
#
# * Prints the current room name
# * Prints the current description (the textwrap module might be useful here).
# * Waits for user input and decides what to do.
#
# If the user enters a cardinal direction, attempt to move to the room there.
# Print an error message if the movement isn't allowed.
#
# If the user enters "q", quit the game.

# Let's begin the game loop!
# welcome message
item_to_find_name = "Rock"
# should put this into the item.py class, will refactor
for i in range(len(items)):
if items[i].name.lower() == item_to_find_name.lower():
item = items.pop(i)
break

print(item.name)

#######################################################

############### Main Game Loop #######################
valid_directions = ['n', 's', 'e', 'w']
take = 't'
drop = 'd'
print(Fore.BLUE + '====================================\n' + Style.RESET_ALL)
print(Fore.YELLOW + Back.BLACK + "Welcome to the Treasure Hunt, \n a game designed by tryingtokeepup. \nI hope you can, *snicker, ... keep up. Oh my I chottle myself unduly, yes.")

print(Fore.BLUE + '====================================\n' + Style.RESET_ALL)

player_name = input(Fore.YELLOW + Back.BLACK +
'Hello traveler, what is your name? : ')
'Hello traveler, what is your name? : \n')
# let's start everyone off at the outside room.
current_room = room['outside']
# let's ask the player what their name is, and then store that, along with the current_room, outside, inside a new instance of Player
player = Player(player_name, current_room)

print(
f'Gotcha! So, your name is {player.name}. You are currently {player.current_room.name}')
f"Gotcha! So, your name is {player.name}. You are currently {player.current_room.name}. \n")

print(f"{player.current_room}")
# while True:
# cmd = input("-->")
# if cmd in valid_directions:
# current_room = player.current_room
# player.travel(cmd)
# elif cmd == take:
# # this is fine. everything is on fire but life is fine
# # i am not currently pancaking help me i dont actually know how to program
# player.get_item(player.current_room.items[0])
# elif cmd == drop:
# player.current_room.add_item(player.items[0])

# elif cmd == "q":
# print('Ahhh man, alright. See you in the next world.')
# break
# else:
# print('Didn\'t catch that. Try again?')

# gamplay loop

while True:
# First, let's ask the player what their name is, and then store that, along with the current_room, outside, inside a new instance of Player
player = Player(player_name, current_room)
print(
f'You examine the room you are in. {player.current_room.description}')

cmd = input(
"Alright, so ... make a move. \n To go north, enter n. \n To go east, enter e. \n To go south, enter s. \n To go west, enter s. \n If you need to quit, just enter q to quit out. \n ... Yah wuss. \n")
if cmd == "n":
current_room = current_room.n_to
"Alright, so ... make a move. Input a cardinal direction please. \n").lower()

if cmd == "i":
print("\n To go north, enter n. \n To go east, enter e. To go south, enter s. \n To go west, enter s. \n If you need to quit, just enter q to quit out. \n ... Yah wuss. \n")

elif cmd in ["n", "s", "e", "w"]:
player.travel(cmd)
elif cmd == "q":
print('Ahhh man, alright. See you in the next world.')
break
# quick commit
Loading