def do_turn(self,option):
		if option == self.options[0]:
			go=True
			while(go):
				mod_list = self.owner.inventory.get_list([self])
				item_index=base.make_choice([a.to_str() for a in mod_list])
				item_object=mod_list[item_index]
				option_index=base.make_choice(item_object.item_options)
				item_opt=item_object.item_options[option_index]
				if item_opt=='examine':
					# each item needs to define self.descr, which is what will be printed here.
					print item_object.examine()
				if item_opt=='equip':
					item_object.equip()


				# this isn't quiote implemented
				if item_opt == 'give':
					choice = base.make_choice(self.owner.party.inventory.get_list([self.owner]))
					other_player = self.owner.party.inventory.get_list([self.owner])[choice]


				print 'continue? (y/n)'
				ans = raw_input()
				if ans=='y':
					go=True
				else:
					go=False
Ejemplo n.º 2
0
    def equip(self):
        if self.info == 'one-handed':
            # this gets the name of the item in both hands, to let the player
            # know what they are going to equip
            if self.owner.equipment['left']:
                left = self.owner.equipment['left'].to_str()
            else:
                left = 'Nothing'

            if self.owner.equipment['right']:
                right = self.owner.equipment['right'].to_str()
            else:
                right = 'Nothing'

            side = base.make_choice(['left (%s)' % left, 'right (%s)' % right])
            try:
                if self.owner.equipment[['left',
                                         'right'][side]].info == 'one-handed':
                    self.owner.equipment[['left', 'right'][side]].unequip()
                else:
                    self.owner.equipment['left'].unequip()
                    self.owner.equipment['right'].unequip()
            except:
                pass
            try:
                if self.owner.equipment[['left',
                                         'right'][side]].info == 'one-handed':
                    self.owner.equipment[['left', 'right'][side]] = self
                else:
                    self.owner.equipment['left'] = None
                    self.owner.equipment['right'] = None
                    self.owner.equipment[['left', 'right'][side]] = self
            except:
                self.owner.equipment[['left', 'right'][side]] = self
        elif self.info == 'two-handed':
            try:
                self.owner.equipment['left'].unequip()
                self.owner.equipment['right'].unequip()
            except:
                try:
                    self.owner.equipment['right'].unequip()
                except:
                    pass
            self.owner.equipment['left'] = self
            self.owner.equipment['right'] = self
        else:
            if not self.owner.equipment[self.info]: name = 'Nothing'
            else: name = self.owner.equipment[self.info].to_str()

            # we want to equip something if we've done it in a test.
            if not base.IS_TEST:
                ans = base.make_choice(
                    ['replace %s with %s' % (name, self.to_str()), 'don\'t'])
            else:
                ans = 0
            if ans is 0:
                if self.owner.equipment[self.info]:
                    self.owner.equipment[self.info].unequip()
                self.owner.equipment[self.info] = self
        self.equipped = True
Ejemplo n.º 3
0
	def __init__(self,name,test_stats=None): # starting is for test cases
		super(Player,self).__init__()
		self.name = name
		self.party = None
		self.action_points = 2
		self.base_ap = 2
		self.options = ['leave','examine','dev-examine','map','inventory']
		self.alive = True

		self.health = 0
		self.max_health = 0
		self.armor = 1
		self.gold = 200
		self.equipment = {
			'left':None,
			'right':None,
			'helmet':None,
			'chest':None,
			'legs':None,
			'boots':None,
			'amulet':None,
			'gauntlet':None
		}

		#Please tell me i didn't mess this up.
		if not test_stats:
			option = base.make_choice(RACES.keys(),'race')
			self.race = RACES.keys()[option]
			# options will be the list all the potential dictionarys will be added to
			options = []
			for x in range(3):
				more_choices={}
				for attribute, dice in RACES[self.race]['rolls'].iteritems():
					rolls = [dice.roll() for a in range(1)]
					selection=0;

					selection = rolls[0]+RACES[self.race]['BaseStats'][attribute]
					# update more choices with the attribute value
					more_choices.update({attribute:selection})
				# when more choices is full, add it to options
				options.append(more_choices)
			# print str(options)

			ret = base.make_choice(options,'character setup!')
			#need your help displaying the choices for the player to pick his character.
			self.attributes = options[ret]

			# haha this looks so disgusting
			print self.race +' '+self.name+ '\'s final attributes:\n\t%s:%d\n\t%s:%d\n\t%s:%d\n\t%s:%d\n\t%s:%d\n\t' % ('agility',self.attributes['agility'],'intelligence',self.attributes['intelligence'],'strength',self.attributes['strength'],'luck',self.attributes['luck'],'mana',self.attributes['mana'])
		else:
			self.race = test_stats['race']
			self.attributes = test_stats['attributes']

		self.max_health = self.attributes['strength'] * 10
		self.health = self.max_health


		# THIS IS NOT FINAL- ITS A TEST
		self.inventory.append(weapons.Sword(self.level))
		self.inventory.append(inv.InventoryHandler())
Ejemplo n.º 4
0
 def do_turn(self, option):
     if option == self.options[0]:
         go = True
         while (go):
             mod_list = self.owner.inventory.get_list([self])
             new_li = [a for a in mod_list if isinstance(a, i.Item)]
             item_index = base.make_choice([a.to_str() for a in new_li])
             item_object = new_li[item_index]
             option_index = base.make_choice(item_object.item_options)
             if option_index is not None:
                 item_opt = item_object.item_options[option_index]
                 if item_opt == 'examine':
                     # each item needs to define self.descr, which is what will be printed here.
                     base.put(item_object.examine())
                 if item_opt == 'equip':
                     item_object.equip()
                 # this isn't quiote implemented
                 if item_opt == 'give':
                     choice = base.make_choice(
                         self.owner.party.inventory.get_list([self.owner]))
                     other_player = self.owner.party.inventory.get_list(
                         [self.owner])[choice]
             ans = base.make_choice(['continue', 'done'])
             if ans == 0:
                 go = True
             else:
                 go = False
Ejemplo n.º 5
0
	def enter_shop(self):
		print 'you have %d gold!' % (self.party.inventory[self.party.index].gold)
		shopping = base.make_choice(self.shop.keys(),'category')
		item = base.make_choice( ['%s for %d' % (a.to_str(),a.get_cost()) for a in self.shop[self.shop.keys()[shopping]]],'item',True)
		if(item is None):
			print 'You bought nothing!'
		else:
			item_object = self.shop[self.shop.keys()[shopping]][item]
			# remove the item from the shop afterwards
			# self.shop[self.shop.keys()[shopping]].remove(item_object)
			success = self.party.inventory[self.party.index].buy_item(item_object)
			if success:
				self.shop[self.shop.keys()[shopping]].remove(item_object)
				print 'successfully purchased a %s' % item_object.to_str()
Ejemplo n.º 6
0
	def equip(self):
		if self.info == 'one-handed':
			# this gets the name of the item in both hands, to let the player
			# know what they are going to equip
			if self.owner.equipment['left']:
				left = self.owner.equipment['left'].to_str()
			else:
				left = 'Nothing'

			if self.owner.equipment['right']:
				right = self.owner.equipment['right'].to_str()
			else:
				right = 'Nothing'

			side=base.make_choice(['left (%s)' % left,'right (%s)' % right])
			try:
				self.owner.equipment[['left','right'][side]].unequip()
			except:
				pass
			self.owner.equipment[['left','right'][side]] = self
		elif self.info =='two-handed':
			try:
				self.owner.equipment['left'].unequip()
			except:
				try:
					self.owner.equipment['right'].unequip()
				except:
					pass
			self.owner.equipment['left']=self
			self.owner.equipment['right']=self
		elif self.owner.equipment[self.info]:
			self.owner.equipment[self.info].unequip()
			self.owner.equipment[self.info] = self
		self.equipped = True
Ejemplo n.º 7
0
    def do_turn(self, option):
        self.damage = 1.0 * self.owner.level
        if self.owner.race is 'Ranger':
            self.damage = 7.0 * self.owner.level * 2.0
        if self.durability == 0:
            self.unequipWep()

        else:
            self.options = ['%s' % self.to_str()]
            if option == self.options[0]:
                p = base.make_choice([
                    'Shoot with %s' % self.to_str(),
                    'Fully draw the %s' % self.to_str(), 'Launch Volley'
                ])
                if p == 0:
                    target = self.owner.select_target()
                    if target:
                        for a in self.modifiers:
                            a.do_turn(
                                target,
                                self.damage *
                                (self.owner.attributes['agility'] +
                                 self.owner.attributes['strength'] / 10.0) +
                                base.D12.roll())
                elif p == 1:
                    target = self.owner.select_target()
                    if target:
                        self.aim(target)
                elif p == 2:
                    # THIS IS THE NEW AOE CODE.
                    self.owner.do_aoe_monster(self.volley)
Ejemplo n.º 8
0
	def do_turn(self,option):
		# effectiveness coefficient
		ec = self.owner.attributes['mana'] / 5
		if option == self.options[0]:
			p = base.make_choice(['cast %s' % self.name,'rename %s' % self.name,'examine %s' % self.name])
			if p == 1:
				name = raw_input('enter a new name for %s' % self.name)
				self.name = name
				self.options = ['%s' % self.name]

			if p == 2:
				print self.descr()

			if p == 0:
				if not self.on_cooldown:
					if not self.aoe:
						targets = [self.owner.select_target()]
					else:
						targets = self.owner.party.current_dungeon.active_room.things
					for target in targets:
						# we have to make sure that the targets are monsters, because otherwise we would hit chests and leaveoptions
						if target and isinstance(target,r.Monster):
							if self.damage:
								target.take_damage(self.owner,self.damage*ec)
							if self.stuntime:
								target.statuses.append(s.Stun(math.ceil(self.stuntime*ec)))
							if self.poisontime and self.poisondamage:
								target.statuses.append(s.Poison(math.ceil(self.poisontime*ec),self.poisondamage*ec))
					self.owner.statuses.append(s.Cooldown(self,self.cooldown_time))
				else:
					print '%s is on cooldown!' % self.name
Ejemplo n.º 9
0
 def do_turn(self, option):
     if option == self.options[0]:
         inv = base.make_choice([i.to_str() for i in self.items])
         if inv is not None:
             self.owner.containing_dungeon.party.get_active_player().add(
                 self.items[inv])
             self.items = self.items[:inv] + self.items[inv + 1:]
Ejemplo n.º 10
0
	def do_turn(self,option):
		self.options = ['%s' % self.to_str()]
		if option == self.options[0]:
			p = base.make_choice(['attack with %s' % self.to_str()])
			if p == 0:
				target = self.owner.select_target()
				if target:
					self.swing(target)
Ejemplo n.º 11
0
	def do_turn(self,options):
		self.options = ['%s' % self.to_str()]
		# print options
		if self.options[0] in options:
			p = base.make_choice(['swing %s' % self.to_str()])
			if p == 0:
				target = self.owner.select_target()
				if target:
					self.swing(target)
Ejemplo n.º 12
0
	def do_turn(self,option):
		self.options = ['%s' % self.to_str()]
		if option == self.options[0]:
			p = base.make_choice(['Slash with %s' % self.to_str(),'Pierce Armor with %s'%self.to_str()])
			if p == 0:
				target = self.owner.select_target()
				if target:
					self.slash(target)
			elif p==1:
				target = self.owner.select_target()
				if target:
					self.pierce(target)
Ejemplo n.º 13
0
 def do_turn(self, option):
     if self.durability == 0:
         self.unequipWep()
     else:
         self.damage = 4.0 * self.owner.level
         self.options = ['%s' % self.to_str()]
         if option == self.options[0]:
             p = base.make_choice(['attack with %s' % self.to_str()])
             if p == 0:
                 target = self.owner.select_target()
                 if target:
                     for a in self.modifiers:
                         a.do_turn(target, self.standard_attack(target))
Ejemplo n.º 14
0
 def do_turn(self, options):
     if self.durability == 0:
         self.unequipWep()
     else:
         self.damage = 7.0 * self.owner.level
         self.options = ['%s' % self.to_str()]
         # print options
         if self.options[0] in options:
             p = base.make_choice(['swing %s' % self.to_str()])
             if p == 0:
                 target = self.owner.select_target()
                 if target:
                     for a in self.modifiers:
                         a.do_turn(target, self.standard_attack(target))
Ejemplo n.º 15
0
 def do_turn(self, option):
     self.options = ["%s" % self.to_str()]
     if self.defendin:
         for a in self.owner.party.inventory:
             a.armor -= self.level * 2
         self.defendin = False
     if self.blockin:
         self.owner.armor -= 3 * self.level
         self.blockin = False
     if option == self.options[0]:
         p = base.make_choice(["Block with %s" % self.to_str(), "Defend Allies with %s" % self.to_str()])
         if p == 0:
             self.block()
         if p == 1:
             self.defend()
Ejemplo n.º 16
0
	def do_turn(self,option):
		self.options = ['%s' % self.to_str()]
		if option == self.options[0]:
			p = base.make_choice(['Shoot with %s' % self.to_str(), 'Fully draw the %s' % self.to_str(), 'Launch Volley'])
			if p == 0:
				target = self.owner.select_target()
				if target:
					self.shoot(target)
			elif p == 1:
				target = self.owner.select_target()
				if target:
					self.aim(target)
			elif p == 2:
				for a in self.owner.party.current_dungeon.active_room.things:
					if(isinstance(a,r.Monster) and a.revealed):
						self.volley(a)
Ejemplo n.º 17
0
 def do_turn(self, option):
     self.armor = 12 * self.owner.level
     self.options = ['%s' % self.to_str()]
     if self.defendin:
         for a in self.owner.party.inventory:
             a.armor -= (self.level * 2)
         self.defendin = False
     if self.blockin:
         self.owner.armor -= (3 * self.level)
         self.blockin = False
     if option == self.options[0]:
         p = base.make_choice([
             'Block with %s' % self.to_str(),
             'Defend Allies with %s' % self.to_str()
         ])
         if p == 0:
             self.block()
         if p == 1:
             self.defend()
Ejemplo n.º 18
0
	def handle_player_turn(self):
		count=0
		for a in range(len(self.inventory)):
			if(self.inventory[self.index].alive==False):
				count=count+1
		if(count==len(self.inventory)):
			self.end=False
		for a in range(len(self.inventory)):
			if(self.end):
				print "------====%s's turn====------" % self.inventory[self.index].name
				print 'you have %d hp left' % self.inventory[self.index].health
				while((self.inventory[self.index].action_points > 0) and (self.inventory[self.index].alive==True)):
					selection = base.make_choice(self.return_options(),'option')
					self.do_turn(self.return_options()[selection])

			# set the ap back to start. the subtraction per turn is done in the player do_turn
			self.inventory[self.index].action_points = self.inventory[self.index].base_ap
			self.index += 1

			if self.index == len(self.inventory):
				self.index = 0
Ejemplo n.º 19
0
    def do_turn(self, option):
        # effectiveness coefficient
        ec = self.owner.attributes['mana'] / 5
        if option == self.options[0]:
            p = base.make_choice([
                'cast %s' % self.name,
                'rename %s' % self.name,
                'examine %s' % self.name
            ])
            if p == 1:
                name = base.get_input('enter a new name for %s' % self.name)
                self.name = name
                self.options = ['%s' % self.name]

            if p == 2:
                base.put(self.ploop())

            if p == 0:
                if not self.on_cooldown:
                    if not self.is_healing:
                        if not self.aoe:
                            self.murder(self.owner.select_target())
                            self.owner.statuses.append(
                                s.Cooldown(self, self.cooldown_time))
                        else:
                            self.owner.do_aoe_monster(self.murder)
                            self.owner.statuses.append(
                                s.Cooldown(self, self.cooldown_time))
                    else:
                        if not self.aoe:
                            self.murder(self.owner.select_player_target())
                            self.owner.statuses.append(
                                s.Cooldown(self, self.cooldown_time))
                        else:
                            self.owner.do_aoe_player(self.murder)
                            self.owner.statuses.append(
                                s.Cooldown(self, self.cooldown_time))

                else:
                    base.put('%s is on cooldown!' % self.name)
Ejemplo n.º 20
0
	def do_turn(self):
		if base.IS_WEB_VERSION:
			base.put(self.get_info())
		for x in self.statuses:
			x.do_turn(None)
		ireallyhatemylife=len(self.owner.current_dungeon.things)
		for a in range(ireallyhatemylife):
			# im not entirely sure what's going on here, but 'a' is an int
			# so it will never be an instance of monster.
			if isinstance(a,Monster):
				if not a.alive:
					self.owner.current_dungeon.things.remove(a)
					a-=1
					ireallyhatemylife-=1
		# since action points can be removed in the statuses, we need to check it here
		if self.action_points > 0:
			args = self.return_options()[base.make_choice(self.return_options())]
			if args == 'save':
				if dill:
					name = base.get_input('enter the name of your save: ')
					if not os.path.exists('%s/saves/' % base.BASE_DIR):
						os.makedirs('%s/saves/' % base.BASE_DIR)

					path = '%s/saves/%s.dunce' % (base.BASE_DIR,name)
					# have to create the file before we take a dump in it
					with open(path,'w+'):
						pass
					dill.dump_session(path)

			if args == 'load':
				li = []
				if os.path.exists('%s/saves/' % base.BASE_DIR):
					for dirpath, dirname, filename in os.walk('%s/saves/' % base.BASE_DIR):
						for fi in filename:
							if '.dunce' in fi:
								li.append(fi)
				else:
					base.put('no saves to choose from!')
				op = base.make_choice(li,"savefile")
				if dill:
					if op is not None:
						go = False
						base.put('loading session')
						self.action_points = 0
						dill.load_session('%s/saves/%s' % (base.BASE_DIR,li[op]))
				else:
					base.put('save/load support is disabled because you haven\'t installed dill!')


			if args == 'exit room':
				# door should be the INDEX of the returned list, ie 0 1 2 3
				door = base.make_choice([a for a in self.party.current_dungeon.active_room.get_neighbors().keys()],'room')
				self.party.current_dungeon.active_room.move_to(door)

			## This is the examine method.
			if args == 'examine':
				s = ''
				for ind, a in enumerate(self.party.current_dungeon.active_room.things):
					if ind != len(self.party.current_dungeon.active_room.things) - 1:
						s+='a %s, ' % a.examine(self)
					else:
						s+='and a %s.' % a.examine(self)
				if not s:
					s = 'absolutely nothing.'
				base.put('you examine the room and notice %s' % s)


			# if p == 2:
			# 	base.put('you can\'t do that yet, lol')


			if args == 'shop':
				self.party.current_dungeon.enter_shop()

			if args == 'enter a dungeon':
				self.party.current_dungeon.leave_dungeon()

			if args == 'repair':
				self.party.current_dungeon.repair_items()

			for a in self.inventory:
				if isinstance(a,weapons.Weapon):
					if a.equipped: a.do_turn(args)
				else:
					a.do_turn(args)

			if not isinstance(self.party.current_dungeon,dungeon.Hub):
				for a in self.party.current_dungeon.active_room.things:
					if isinstance(a,thing.InteractiveObject):
						a.do_turn(args)
		self.action_points -= 1
Ejemplo n.º 21
0
	def select_target(self):
		target_ind = base.make_choice([a.to_str() for a in self.owner.current_dungeon.active_room.things if(isinstance(a,monster.Monster) and a.revealed)],'target')
		if target_ind != None:
			return self.owner.current_dungeon.active_room.things[target_ind]
		return None
Ejemplo n.º 22
0
	def do_turn(self, args):
		for x in self.statuses:
			x.do_turn(args)
		# since action points can be removed in the statuses, we need to check it here
		if self.action_points > 0:
			if args == 'save':
				self.party.current_dungeon.save_game()

			if args == 'leave':
				# door should be the INDEX of the returned list, ie 0 1 2 3
				door = base.make_choice([a for a in self.party.current_dungeon.active_room.get_neighbors().keys()],'room')
				self.party.current_dungeon.active_room.move_to(door)

			## This is the examine method.
			if args == 'examine':
				p = base.make_choice(['examine','dev_examine'])
				if p == 0:
					s = ''
					for ind, a in enumerate(self.party.current_dungeon.active_room.things):
						if ind != len(self.party.current_dungeon.active_room.things) - 1:
							s+='a %s, ' % a.examine(self)
						else:
							s+='and a %s.' % a.examine(self)
					if not s:
						s = 'absolutely nothing.'
					print 'you examine the room and notice %s' % s

				if p == 1:
					for a in self.party.current_dungeon.active_room.things:
						print a.dev_examine()

			# if p == 2:
			# 	print 'you can\'t do that yet, lol'


			if args == 'shop':
				self.party.current_dungeon.enter_shop()


			if args =='map':
				ret = ''
				for x, a in enumerate(self.party.current_dungeon.rooms):
					for y,b in enumerate(a):
						if isinstance(b,dungeon.Room) and self.party.current_dungeon.roomsmap[x][y]=='T':
							ret += 'R '
						elif(isinstance(b,dungeon.Room) and self.party.current_dungeon.roomsmap[x][y]=='?'):
							ret+='? '
						else:
							ret += 'E '
					ret += '\n'
				print ret

			if args == 'enter a dungeon':
				self.party.current_dungeon.leave_dungeon()



			for a in self.inventory:
				if isinstance(a,weapons.Weapon):
					if a.equipped: a.do_turn(args)
				else:
					a.do_turn(args)

		if not isinstance(self.party.current_dungeon,dungeon.Hub):
			for a in self.party.current_dungeon.active_room.things:
				if isinstance(a,thing.InteractiveObject):
					a.do_turn(args)
		self.action_points -= 1
Ejemplo n.º 23
0
	def do_turn(self,option):
		if option == self.options[0]:
			inv = base.make_choice([i.to_str() for i in self.items])
			if inv is not None:
				self.owner.containing_dungeon.party.get_active_player().inventory.append(self.items[inv])
				self.items = self.items[:inv] + self.items[inv+1:]
    def main(self, webbed=False):
        self.webbed = webbed
        if webbed:  # ha amphibian joke
            base.IS_WEB_VERSION = True
            base.SERVER = web.server
            web.server.party = PARTY
        print 'MOVED ON'
        base.BASE_DIR = os.path.dirname(os.path.abspath(__file__))
        ver = []
        with open('%s/version.dunce' % base.BASE_DIR, 'r+') as f:
            contents = f.read()
            if contents is '':
                base.put('writing')
                f.write(self.get_current_release().replace('.', ' ').replace(
                    'v', ''))

            ver = contents.split(' ')
        self.RELEASE_ID = ('v%s.%s.%s' % (ver[0], ver[1], ver[2])).strip()

        if not self.checked:
            self.update_check()
        go = True
        intro = """
 ______            _        _______  _______  _______
(  __  \ |\     /|( (    /|(  ____ \(  ____ \(  ____ \\
| (  \  )| )   ( ||  \  ( || (    \/| (    \/| (    \/
| |   ) || |   | ||   \ | || |      | (__    | (_____
| |   | || |   | || (\ \) || |      |  __)   (_____  )
| |   ) || |   | || | \   || |      | (            ) |
| (__/  )| (___) || )  \  || (____/\| (____/\/\____) |
(______/ (_______)|/    )_)(_______/(_______/\_______)
 _______  _        ______
(  ___  )( (    /|(  __  \\
| (   ) ||  \  ( || (  \  )
| (___) ||   \ | || |   ) |
|  ___  || (\ \) || |   | |
| (   ) || | \   || |   ) |
| )   ( || )  \  || (__/  )
|/     \||/    )_)(______/
 ______            _        _______  _______  _______  _        _______
(  __  \ |\     /|( (    /|(  ____ \(  ____ \(  ___  )( (    /|(  ____ \\
| (  \  )| )   ( ||  \  ( || (    \/| (    \/| (   ) ||  \  ( || (    \/
| |   ) || |   | ||   \ | || |      | (__    | |   | ||   \ | || (_____
| |   | || |   | || (\ \) || | ____ |  __)   | |   | || (\ \) |(_____  )
| |   ) || |   | || | \   || | \_  )| (      | |   | || | \   |      ) |
| (__/  )| (___) || )  \  || (___) || (____/\| (___) || )  \  |/\____) |
(______/ (_______)|/    )_)(_______)(_______/(_______)|/    )_)\_______)
copyleft (c) 2016 John Dikeman and Cameron Egger
		 """
        base.put(intro)
        cho = 0

        # most of this code is super redundant cause cho is hardcoded but do i care? nope lol.
        if cho is not None:
            if cho is 0:
                self.new_game()
            if cho is 1:
                li = []
                if os.path.exists('%s/saves/' % base.BASE_DIR):
                    for dirpath, dirname, filename in os.walk('%s/saves/' %
                                                              base.BASE_DIR):
                        for fi in filename:
                            if '.dunce' in fi:
                                li.append(fi)
                else:
                    base.put('no saves to choose from!')
                op = base.make_choice(li, "savefile")
                if dill:
                    if op is not None:
                        go = False
                        base.put('loading session')
                        dill.load_session('%s/saves/%s' %
                                          (base.BASE_DIR, li[op]))
                else:
                    base.put(
                        'save/load support is disabled because you haven\'t installed dill!'
                    )
Ejemplo n.º 25
0
	def leave_dungeon(self):
		he = [5,8,15,25]
		ind = base.make_choice(['smol','medium','large','goliath'],'size')
		self.party.current_dungeon = Dungeon(he[ind],self.party.get_avg_level(),self.party)
		self.party.current_dungeon.start()
Ejemplo n.º 26
0
	def select_target(self):
		opt = [a for a in self.owner.current_dungeon.active_room.things if(isinstance(a,monster.Monster) and a.revealed)]
		target_ind = base.make_choice([b.to_str() for b in opt],'target')
		if target_ind != None:
			return opt[target_ind]
		return None
Ejemplo n.º 27
0
	def __init__(self,name,test_stats=None): # for test cases
		super(Player,self).__init__()
		self.name = name
		self.party = None
		self.action_points = 2
		self.base_ap = 2
		self.options = ['exit room','examine','dev-examine','inventory']
		self.alive = True
		self.equipable=[]
		self.health = 0
		self.max_health = 0
		self.armor = 1
		self.gold = 200
		self.equipment = {
			'left':None,
			'right':None,
			'helmet':None,
			'chest':None,
			'legs':None,
			'boots':None,
			'amulet':None,
			'gauntlet':None
		}

		#Please tell me i didn't mess this up.
		if not test_stats:
			option = base.make_choice(RACES.keys(),'race')
			self.race = RACES.keys()[option]
			# options will be the list all the potential dictionarys will be added to
			options = []
			for x in range(3):
				more_choices={}
				for attribute, dice in RACES[self.race]['rolls'].iteritems():
					rolls = [dice.roll() for a in range(1)]
					selection=0;

					selection = rolls[0]+RACES[self.race]['BaseStats'][attribute]
					# update more choices with the attribute value
					more_choices.update({attribute:selection})
				# when more choices is full, add it to options
				options.append(more_choices)
			# base.put(str(options))
			pretty_options = []

			for attribute_set in options:
				# this is an ugly hack to make the string format that i copypasta'd from below work.
				# i have no shame
				self.attributes = attribute_set
				pretty_options.append('%s:%d\n\t%s:%d\n\t%s:%d\n\t%s:%d\n\t%s:%d\n\t' % ('agility',self.attributes['agility'],'intelligence',self.attributes['intelligence'],'strength',self.attributes['strength'],'luck',self.attributes['luck'],'mana',self.attributes['mana']))

			ret = base.make_choice(pretty_options,'character setup!')
			#need your help displaying the choices for the player to pick his character.
			self.attributes = options[ret]

			# haha this looks so disgusting
			base.put(self.race +' '+self.name+ '\'s final attributes:\n\t%s:%d\n\t%s:%d\n\t%s:%d\n\t%s:%d\n\t%s:%d\n\t' % ('agility',self.attributes['agility'],'intelligence',self.attributes['intelligence'],'strength',self.attributes['strength'],'luck',self.attributes['luck'],'mana',self.attributes['mana']))
		else:
			self.race = test_stats['race']
			self.attributes = test_stats['attributes']

		self.max_health = self.attributes['strength'] * 10
		self.health = self.max_health
		self.inventory.append(consumable.HealthSack())
		self.inventory.append(inv.InventoryHandler())
		# self.inventory.append(utils.Map())

		# add all the starting abilities
		for a in RACES[self.race]['abilities']:
			self.inventory.append(a())
Ejemplo n.º 28
0
	def select_player_target(self):
		opt = base.make_choice([a.to_str() for a in self.party.inventory])
		if opt != None:
			return self.party.inventory[opt]
		return None