Skip to content
Merged
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
27 changes: 20 additions & 7 deletions game.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, map = None, debug = False):
self.id = uuid4()
self.debug = debug
#Valid commands this game class will accept
self.commands = ["move","end","job_apply", "course_enroll"]
self.commands = ["move","end","job_apply", "job_work", "course_enroll"]
#Has the game been started?
self.started = False
#List of player objects
Expand Down Expand Up @@ -110,7 +110,7 @@ def run(self):
if selection == 'a':
self.command('job_apply',{'player':player, 'job_rank':JobMenu().display(job_list=player.location.jobs)})
if selection == 'w':
pass
self.command('job_work',{'player':player})
if selection == 'i':
print player.info_display()
if selection == 'c':
Expand Down Expand Up @@ -175,6 +175,14 @@ def command(self,command,parameters = None):
else:
self.log_error("Inavlid parameters for apply command")

if command is "job_work":
#Work at the players job
if parameters:
if set(['player']).issubset(parameters):
player = parameters['player']
player.money += player.job.pay
print "You've earned $%s" % (player.job.pay)

if command is "end":
#End Turn
return True
Expand All @@ -189,11 +197,16 @@ def command(self,command,parameters = None):
course = player.location.get_course_by_number(parameters['course_choice'])
self.log_debug("Course %s being taken" % (course.name))
if course:
self.log_debug("Player %s taking course %s at %s" % (player,course.name,player.location.name))
player.knowledge += course.knowledge_value
player.completed_education.append(course.name)
self.log_debug("Player %s now has knowledge %s" % (player,player.knowledge))
#TODO will need to subtract the time the course takes as well
#Check if the player has enough money to pay for the course
if player.money >= course.cost:
self.log_debug("Player %s taking course %s at %s" % (player,course.name,player.location.name))
player.knowledge += course.knowledge_value
player.completed_education.append(course.name)
self.log_debug("Player %s now has knowledge %s" % (player,player.knowledge))
player.money -= course.cost
#TODO will need to subtract the time the course takes as well
else:
print "You don't have enough money to enroll in this course!"
else:
self.log_error("Course %s not found in %s" % (parameters['course_choice'],player.location.name))
else:
Expand Down
2 changes: 2 additions & 0 deletions player.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self,name = "Player"):
self.turns = 0
self.knowledge = 0
self.completed_education = []
self.money = 0

def __repr__(self):
return str(self.name)
Expand All @@ -48,5 +49,6 @@ def info_display(self):
s += "Job:\t\t%s ($%s pay per unit)\n" % (str(self.job),str(self.job.pay))
else:
s += "Job:\t\tNone\n"
s += "Current money:\t$%s\n" % (str(self.money))
s += "Knowledge:\t%s\nClasses:\n\t%s\n" % (str(self.knowledge),"\n\t".join(self.completed_education))
return s