From 1f56c632001d4f8e2aee4f3db2e4bc8deabb3bea Mon Sep 17 00:00:00 2001 From: cparlette Date: Wed, 30 Jan 2013 09:15:11 -0500 Subject: [PATCH 1/4] Added money attribute to players. --- player.py | 1 + 1 file changed, 1 insertion(+) diff --git a/player.py b/player.py index eb9d613..95ff1ff 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) From a18f433d4a1acc28284818a5791756cb391c1a2d Mon Sep 17 00:00:00 2001 From: cparlette Date: Wed, 30 Jan 2013 09:30:40 -0500 Subject: [PATCH 2/4] Working at job increases the player's money by the job's wages. --- game.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/game.py b/game.py index e23b62f..c730091 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 From 9e09c1cbbd84f025a804302f0046ca8fe2845038 Mon Sep 17 00:00:00 2001 From: cparlette Date: Wed, 30 Jan 2013 09:34:31 -0500 Subject: [PATCH 3/4] Add total money to info_display. --- player.py | 1 + 1 file changed, 1 insertion(+) diff --git a/player.py b/player.py index 95ff1ff..a2e98ef 100644 --- a/player.py +++ b/player.py @@ -49,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 From c97365f1a36afbbfa8f88703cd8adc66bcbddaf4 Mon Sep 17 00:00:00 2001 From: cparlette Date: Wed, 30 Jan 2013 09:43:55 -0500 Subject: [PATCH 4/4] Courses now cost money. There's a check in place to see if the player has enough money to take the course. If they don't, it prints a message and the player doesn't enroll. --- game.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/game.py b/game.py index c730091..fac3b78 100644 --- a/game.py +++ b/game.py @@ -197,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: