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
51 changes: 0 additions & 51 deletions src/adv.py

This file was deleted.

17 changes: 17 additions & 0 deletions src/adventure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import gameData.intro
import gameUtils.text as txt


def play():
#init
gameOver = False
player = gameData.intro.run()
#game loop
while not gameOver:
txt.printUI()
if player.locat.explored:
txt.venture(player)
else:
txt.explore(player)
play()

69 changes: 69 additions & 0 deletions src/gameData/intro.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from .player import Player
from .room import Room
import os
import sys

clear = lambda: os.system('cls')

# Declare all the rooms

room = {
'outside': Room("Outside Cave Entrance",
"South of you, the mouth of a narrow cave passage beckons.\nAll other directions only reveal steep drop offs into jagged cliffside.\nLooking from the treacherous ledges you can't manage to make out how high up you are.\nA thick and endless fog shrouds the distant lands below."),

'foyer': Room("Foyer",
"The cavern is covered with large pillars of stone and a small body of water bubbles in the center of the room.\nIt's hard to see but you can hear the howling of wind from the narrow entrance to the south and flickering orange lights reveal a wide passage to your north and a small dusty passage to your east."),

'overlook': Room("Grand Overlook",
"A steep cliff appears before you, falling into the darkness.\nAhead to the north, a light flickers in the distance, but there is no way across the chasm."),

'narrow': Room("Narrow Passage",
"The narrow passage bends here from west to north.\nThe smell of gold permeates the air."),

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


# Link rooms together

room['outside'].n_to = room['foyer']
room['outside'].n_journey = 'You make your way into the small cave passage.\nStrafing sideways to pass through it your shoulder blades slide across the cold stone wall and the howling winds of the cliffside begin to quiet.\nEventually the cave begins to open up and you find yourself in a small cavern.'

room['foyer'].s_to = room['outside']
room['foyer'].s_journey = 'You travel south and arrive at your destination.'

room['foyer'].n_to = room['overlook']
room['foyer'].n_journey = 'You travel north and arrive at your destination.'

room['foyer'].e_to = room['narrow']
room['foyer'].e_journey = 'Making your way through the dusty passage you tread eastward and stop when you begin to smell a strange scent.'

room['overlook'].s_to = room['foyer']
room['overlook'].s_journey = 'You travel south and arrive at your destination.'

room['narrow'].w_to = room['foyer']
room['narrow'].w_journey = 'You travel west and arrive at your destination.'

room['narrow'].n_to = room['treasure']
room['narrow'].n_journey = 'Heading towards the strange scent you spot a bright light at the end of the tunnel.\n You pass into it and shield your eys as they adjust.1'

room['treasure'].s_to = room['narrow']
room['treasure'].s_journey = 'You travel south and arrive at your destination.'

player = Player('defaultName', room['outside'])

def createPlayer(player):
clear()
while player.name == 'defaultName':
playerName = input('What is your name Adventurer? ')
player.name = playerName

def introText(player):
clear()
print(f'{player.name}, you have awoken on the edge of a towering cliffside.\nYou aren\'t quite sure how you got here and your memory is quite hazy.\nRunning your fingers across the back of your throbbing skull you are greeted with a stinging pain and the discovery of an open wound. ')

def run():
createPlayer(player)
introText(player)
return player
7 changes: 7 additions & 0 deletions src/gameData/player.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Write a class to hold player information, e.g. what room they are in
# currently.

class Player:
def __init__(self, name, locat):
self.name = name
self.locat = locat
27 changes: 27 additions & 0 deletions src/gameData/room.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Implement a class to hold room information. This should have name and
# description attributes.

class Room:
def __init__(self, name, desc, acts = 'default'):
self.name = name
self.desc = desc
self.explored = False
self.acts = acts
self.actions = []
'''if acts == 'default':
self.actions = '''
def getActions(self):
for name in [a for a in dir(self) if a.endswith('_to')]:
if name.startswith('n'):
self.actions.append('Go North')
elif name.startswith('e'):
self.actions.append('Go East')
elif name.startswith('s'):
self.actions.append('Go South')
elif name.startswith('w'):
self.actions.append('Go West')
return self.actions


#def connections(self):
# print('Hello, my name is ' + self.name + ' and I am ' + self.age + ' years old!')
11 changes: 11 additions & 0 deletions src/gameData/roomData/content.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Content:
def __init__(self, desc, inspection, entity):
self.desc = desc
self.inspection = inspection
self.entity = entity

class Secret(Content):
def __init__(self, desc, inspection, entity, requisite, isVisible = False):
self.requisite = requisite
self.isVisible = isVisible
super().__init__(desc, inspection, entity)
23 changes: 23 additions & 0 deletions src/gameData/roomData/item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Item:
def __init__(self, name, value, weight, size, desc, inspection):
self.name = name
self.value = value
self.weight = weight
self.size = size
self.desc = desc
self.inspection = inspection

class Tool(Item):
def __init__(self, name, value, weight, size, desc, inspection, quality, multiplier = 1):
self.quality = quality
self.multiplier = multiplier
super().__init__(name, value, weight, size, desc, inspection)

class Weapon(Item):
def __init__(self, name, value, weight, size, desc, inspection, quality, damageRange, damageType, speed, multiplier = 1):
self.quality = quality
self.damageRange = damageRange
self.damageType = damageType
self.speed = speed
self.multiplier = multiplier
super().__init__(name, value, weight, size, desc, inspection)
Empty file added src/gameData/roomData/npc.py
Empty file.
28 changes: 28 additions & 0 deletions src/gameUtils/playerInput.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
import sys

clear = lambda: os.system('cls')

def getPlayerInput(player):
currentLocat = player.locat
print()
playerCmd = input('Select an Action:')

for idx, val in enumerate(currentLocat.getActions(), start=1):
if playerCmd == str(idx):
if "North" in str(val):
player.locat = currentLocat.n_to
clear()
print(currentLocat.n_journey)
if "East" in str(val):
player.locat = currentLocat.e_to
clear()
print(currentLocat.e_journey)
if "South" in str(val):
player.locat = currentLocat.s_to
clear()
print(currentLocat.s_journey)
if "West" in str(val):
player.locat = currentLocat.w_to
clear()
print(currentLocat.w_journey)
44 changes: 44 additions & 0 deletions src/gameUtils/text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os
import sys
from .playerInput import getPlayerInput


clear = lambda: os.system('cls')

def gap():
print()
print()

def printUI():
gap()
print('Actions:')

def venture(player):
player.locat.actions = []

for idx, val in enumerate(player.locat.getActions(), start=1):
print(f"[{idx}]: {val}")

getPlayerInput(player)

def explore(player):
print('[1] Look around.')
print()
playerCmd = input('Select an Action:')

if playerCmd == 'QUIT':
gameOver = True
print('oof... Game Over...')

if playerCmd == '1':
player.locat.explored == True
describe(player)

def describe(player):
clear()
print("You look around...")
print(player.locat.desc)
gap()
print('Actions:')
venture(player)

2 changes: 0 additions & 2 deletions src/player.py

This file was deleted.

2 changes: 0 additions & 2 deletions src/room.py

This file was deleted.