def load_player(self, config): self.name = config['name'] # self.password = config['password'] self.description = config['description'] self.hp = config['hp'] self.strength = config['str'] self.dexterity = config['dex'] self.wallet = config['wallet'] self.team = config['team'] self.bank = config['bank'] # print "DEBUG==> Load" # print self.location.players_here # print self.team # print self.location self.location.players_here.remove(self) # print self.location.players_here if self.team == "red": self.location = self.game.red_start elif self.team == "blue": self.location = self.game.blue_start else: self.location = self.game.reborn_loc self.location.players_here.append(self) # print self.location # print self.location.players_here # print "DEBUG==> Load" # for item in config['items']: created = factory.create_object(item, self) self.inventory.append(created) self.location.items_here.remove(created)
def buy(self,player,noun): created = factory.create_object(noun, player) # print "DEBUG==> Buy" # print str(created.name) + str(created.item_type) + str(created.cost) if created == None: return ["That isn't available for sale here"] elif self.name == 'Vlad': result = self.do_buy(created) return result elif self.location.name == "Apothecary" and created.item_type == "DRINK": apothecary_check = [x for x in self.location.players_here if x.name == "Apothecary"] if apothecary_check: result = self.do_buy(created) else: result = ["No one here to buy that from."] elif self.location.name == "Armory" and created.item_type == "ARMOR": armorer_check = [x for x in self.location.players_here if x.name == "Armorer"] if armorer_check: result = self.do_buy(created) else: result = ["No one here to buy that from."] elif self.location.name == "Weapon Shop" and created.item_type == "WEAPON": blacksmith_check = [x for x in self.location.players_here if x.name == "Blacksmith"] if blacksmith_check: result = self.do_buy(created) else: result = ["No one here to buy that from."] else: del created result = ["You can't buy that here"] return result