diff --git a/game.py b/game.py index e23b62f..fac3b78 100644 --- a/game.py +++ b/game.py @@ -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 @@ -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': @@ -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 @@ -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: diff --git a/player.py b/player.py index eb9d613..a2e98ef 100644 --- a/player.py +++ b/player.py @@ -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) @@ -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