Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
17a56ad
:pushpin: Pin dependencies to specific versions
secantsquared Jul 10, 2019
60bc527
:construction: Create Room class
secantsquared Jul 10, 2019
24e4e49
:construction: Create Player class
secantsquared Jul 10, 2019
a505fb5
:sparkles: Meet MVP for Day 1 by providing cardinal movement for play…
secantsquared Jul 10, 2019
7202d94
:construction: Create Item class with attributes and on_take and on_d…
secantsquared Jul 10, 2019
57701cb
:construction: Extend the room class with ability to hold a list of i…
secantsquared Jul 10, 2019
ca46867
:construction: Extend the player class with the ability to hold a lis…
secantsquared Jul 10, 2019
d71eb55
:construction: Add printout of items in current room
secantsquared Jul 10, 2019
eec0ba1
:construction: Add items for player and room as well as a player inve…
secantsquared Jul 10, 2019
8da55c2
:sparkles: Hit Day 2 MVP by adding take and drop methods
secantsquared Jul 10, 2019
ffcb059
:alembic: Add new rooms to existing list of rooms
secantsquared Jul 10, 2019
5e84c59
:art: Fix issue with the 'no items in room' conditional
secantsquared Jul 10, 2019
07b3ca1
:construction: Begin major overhaul of game
secantsquared Jul 11, 2019
8765e3d
:construction: Establish cardinal movement again
secantsquared Jul 11, 2019
56f4c5a
:construction: Add items to rooms
secantsquared Jul 11, 2019
1946f20
:sparkles: Establish MVP for Day 1 and 2 with refactor
secantsquared Jul 11, 2019
68b2c40
:sparkles: Add puzzles to random turns.
secantsquared Jul 11, 2019
92ddb49
:building_construction: Arrange directory
secantsquared Jul 11, 2019
4b543c8
:sparkles: Add different fonts to puzzles
secantsquared Jul 11, 2019
cb5a7a5
:art: Format main file
secantsquared Jul 11, 2019
757997f
:see_no_evil: Update gitignore
secantsquared Jul 11, 2019
b8887b5
:construction: Add more rooms for stretch
secantsquared Jul 11, 2019
113c6cd
:sparkles: Add monster class and random monster attacks
secantsquared Jul 11, 2019
75f07bf
:sparkles: Add new items and rooms to the map
secantsquared Jul 11, 2019
4ebc4f3
:art: Add message to treasure indicating new movement
secantsquared Jul 11, 2019
43e874a
:bento: Add more strings for mystery games
secantsquared Jul 11, 2019
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 .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PYTHONPATH=src
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.vscode
*.pyc
__pycache__
__pycache__
.env
notes.md
5 changes: 4 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ verify_ssl = true
name = "pypi"

[packages]
pyfiglet = "*"


[dev-packages]
autopep8 = "*"

[requires]
python_version = "3"
python_version = "3"
44 changes: 44 additions & 0 deletions Pipfile.lock

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

79 changes: 79 additions & 0 deletions notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Python crap

```py

welcome_msg = Fancytext("Welcome\nAdventure\nSeeker!", 'gothic')

welcome_msg.print_text()

player_name = input('Please enter your name!\n')

new_player = Player(player_name, room['outside'])

print(
f'Welcome, {new_player.name}!\nYour journey begins!\n')

user_input = ''

while not user_input == 'q':
line = Fancytext('-----', 'funky_dr')
line.print_text()
print(
f'You are currently located in {new_player.current_room.name}.\n')

print(

f'Description:\n{new_player.current_room.description}\n'
)

current_room_items = new_player.current_room.items

print('Current room items:')
for item in current_room_items:
print(item.name)

user_input = input('\nEnter a command.\n')

split_input = user_input.split(' ')

if split_input[0] == 'get' or split_input[0] == 'take':
room_items = new_player.current_room.items
for item in room_items:
if item.name == split_input[1]:
new_player.current_room.items.remove(item)
new_player.items.append(item)
item.on_take()

if split_input[0] == 'drop':
for item in new_player.items:
if item.name == split_input[1]:
new_player.items.remove(item)
new_player.current_room.items.append(item)
item.on_drop()

if user_input == 'n' or user_input == 'e' or user_input == 'w' or user_input == 's':
try:
if user_input == 'n':
new_room = new_player.current_room.n_to
if user_input == 'e':
new_room = new_player.current_room.e_to
if user_input == 's':
new_room = new_player.current_room.s_to
if user_input == 'w':
new_room = new_player.current_room.w_to
print(f'You entered the valid move - {user_input}!\n')
new_player.current_room = new_room

except:
print('Move was not valid for current location.\n Try again.\n')
elif user_input == 'inventory' or user_input == 'i':
print('This is your current inventory:\n')
for item in new_player.items:
print(item.name)
elif user_input == 'help':
print('\nEnter n, e, w, s to move to a new room.\nPick up items by using take `item name` or get `item name`\nDrop an item with drop `item name`.\n')


print(pyfiglet.figlet_format('The game has ended!'))

```
150 changes: 112 additions & 38 deletions src/adv.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,125 @@
from fancytext import Fancytext
from item import Item
from items import items
from room import Room
from rooms import room as room
from player import Player
from puzzle import Puzzle
from beginning import BeginGame
from status import CurrentStatus
from strings import strings
from monsters import Monster
from fonts import fonts
import random
import threading

# Declare all the rooms

room = {
'outside': Room("Outside Cave Entrance",
"North of you, the cave mount beckons"),
def main():
begin = BeginGame()
status = CurrentStatus()

'foyer': Room("Foyer", """Dim light filters in from the south. Dusty
passages run north and east."""),
curr_player = begin.current_player
curr_room = begin.current_player.current_room

'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."""),
begin.print_beginning()

'narrow': Room("Narrow Passage", """The narrow passage bends here from west
to north. The smell of gold permeates the air."""),
status.print_current_status(
curr_room.name, curr_room.description, curr_room.items)

'treasure': Room("Treasure Chamber", """You've found the long-lost treasure
chamber! Sadly, it has already been completely emptied by
earlier adventurers. The only exit is to the south."""),
}
command = ''

count = 0

# Link rooms together
# def create_monster():
# return Monster('Gelgrox', 'Pure evil energy', 100)

room['outside'].n_to = room['foyer']
room['foyer'].s_to = room['outside']
room['foyer'].n_to = room['overlook']
room['foyer'].e_to = room['narrow']
room['overlook'].s_to = room['foyer']
room['narrow'].w_to = room['foyer']
room['narrow'].n_to = room['treasure']
room['treasure'].s_to = room['narrow']
# def set_interval(func, sec):
# def func_wrapper():
# set_interval(func, sec)
# new_monster = func()
# print(f'{new_monster.name} attacks!')
# t = threading.Timer(sec, func_wrapper)
# t.start()
# return t
# set_interval(create_monster, 500)

#
# Main
#
while command != 'q':
command = input('\nEnter a command.\n')
if (count % 7 == 0):
print(
'You must solve this puzzle to continue. Fail it and the game is over.')
random.shuffle(strings)
random.shuffle(fonts)
puzzle = Puzzle(strings[0], fonts[0]).shuffle()
response = input()
if response == strings[0]:
print('Good work, carry on\n')
else:
print('Game is over better luck next time...')
break

# Make a new player object that is currently in the 'outside' room.
split_cmd = command.split(' ')

# 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.
if len(split_cmd) == 2:
if split_cmd[0] == 'get' or split_cmd[0] == 'take':
for item in curr_room.items:
if item.name == split_cmd[1]:
curr_room.items.remove(item)
curr_player.items.append(item)
item.on_take()
print('Your current items\n')
for item in curr_player.items:
print(item.name)
print('Room inventory:\n')
for item in curr_room.items:
print(item.name)

if split_cmd[0] == 'drop':
for item in curr_player.items:
if item.name == split_cmd[1]:
curr_player.items.remove(item)
curr_room.items.append(item)
item.on_drop()
print('Your current items\n')
for item in curr_player.items:
print(item.name)
print('Room inventory:\n')
for item in curr_room.items:
print(item.name)

elif command == 'inventory':
print('Current items:\n')
for item in curr_player.items:
print(item.name)

elif command == 'status':
status.print_current_status(
curr_room.name, curr_room.description, curr_room.items)

elif command == 'n' or command == 'e' or command == 'w' or command == 's':
try:
if command == 'n':
new_room = curr_room.n_to
if command == 'e':
new_room = curr_room.e_to
if command == 's':
new_room = curr_room.s_to
if command == 'w':
new_room = curr_room.w_to
curr_room = new_room
status.print_current_status(
curr_room.name, curr_room.description, curr_room.items)
count += 1
except:
print('Bad move!')

elif command == 'q':
print('Game over!')
break

else:
print('Illegal command.')


if __name__ == "__main__":
main()
15 changes: 15 additions & 0 deletions src/beginning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from fancytext import Fancytext
from player import Player
from rooms import room as room


class BeginGame:
def __init__(self):
self.welcome_msg = Fancytext('Welcome!', 'weird').print_text()
self.player_name = input('\nWhat is your name?\n')
self.current_player = Player(self.player_name, room['outside'])

def print_beginning(self):
self.welcome_msg
self.player_name
print(f'Welcome, {self.current_player.name}.\nLet\'s begin.\n')
12 changes: 12 additions & 0 deletions src/fancytext.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import random
from pyfiglet import Figlet


class Fancytext:
def __init__(self, str, font):
self.str = str
self.font = font

def print_text(self):
custom_fig = Figlet(font=self.font)
print(custom_fig.renderText(self.str))
10 changes: 10 additions & 0 deletions src/fonts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import random

fonts = [
'cosmic',
'weird',
'contessa',
'computer',
'cybermedium'
]

10 changes: 10 additions & 0 deletions src/item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Item:
def __init__(self, name, description):
self.name = name
self.description = description

def on_take(self):
print(f'You have picked up {self.name}.')

def on_drop(self):
print(f'You have dropped {self.name}.')
Loading