Beispiel #1
0
	def do_action(self,s):
		print 'Enemy name: ' + self.enemy.getName()
		print 'HP remaining: ' + str(self.enemy.getHP())
		ability = self.player.getAbilityByName(s)
		if ability is None:
			print "You don't have an ability called " + s
		else:
			print "You used the " + ability.getName() + " ability!"
			print "You dealt " + magenta(str(ability.getDamage())) + " to " + red(self.enemy.getName())
			self.enemy.setHP(self.enemy.getHP() - ability.getDamage())
		if self.enemy.getHP() > 0:
			enemy_ability = self.enemy.getAbilities()[0]
			self.print_enemy_status(self.enemy)
			print red("--------- Enemy's Turn --------------")
			time.sleep(1.0)
			print self.enemy.getName() + " used " + self.enemy.getAbilities()[0].getName() + "!"
			time.sleep(1.0)
			self.player.setHP(self.player.getHP() - enemy_ability.getDamage())
			print self.enemy.getName() + " dealt " + magenta(str(enemy_ability.getDamage())) + " to you!"
			time.sleep(1.0)
			self.print_player_status()
			print red("--------- End Enemy's Turn --------------")
		else:
			time.sleep(1.0)
			print red("You defeated " + red(self.enemy.getName()))
			print "You gained " + magenta(str(self.enemy.getXP())) + " XP" + "!"
			self.player.setXP(self.player.getXP() + self.enemy.getXP())
			self.enemy.setHP(0)
			self.player
			return True
Beispiel #2
0
	def do_attack( self, s ):
		enemy_name_in = string.lower(s.strip())
		cur_room = self.map.getRooms()[self.player.getPos()]
		enemy = None
		for e_id in cur_room.getEnemies():
			if enemy_name_in == string.lower(self.map.getEnemies()[e_id].getName()):
				enemy = self.map.getEnemies()[e_id]
		if enemy is None:
			print "There's nothing with the name of " + red(s) + " that is attackable."
		else:
			if enemy.getHP() == 0:
				print enemy.getName() + " has already been defeated!"
			else:
				print green_bg(red("Entering combat with " + enemy.getName()))
				i = CombatCmdLine(self.player, enemy)
				i.cmdloop()
Beispiel #3
0
	def do_look(self, s):
		cur_room = self.map.getRooms()[self.player.getPos()]
		dir = s.lower()
		if s == '':
			print format_string(self.parser.parseDescription(cur_room.description))
		elif dir == 'north' or dir == 'n' or dir == 'forward' or dir == 'f':
			if cur_room.isAltDescActive('north'):
				print format_string(self.parser.parseDescription(cur_room.getAltDesc('north')))
			else:
				print format_string(self.parser.parseDescription(cur_room.north_desc))
			#print magenta(cur_room.north_desc)
		elif dir == 'south' or dir == 's' or dir == 'back' or dir == 'b':
			if cur_room.isAltDescActive('south'):
				print format_string(self.parser.parseDescription(cur_room.getAltDesc('south')))
			else:
				print format_string(self.parser.parseDescription(cur_room.south_desc))
		elif dir == 'east' or dir == 'e' or dir == 'right' or dir == 'r':
			if cur_room.isAltDescActive('east'):
				print format_string(self.parser.parseDescription(cur_room.getAltDesc('east')))
			else:
				print format_string(self.parser.parseDescription(cur_room.east_desc))
			#print magenta(cur_room.east_desc)
		elif dir == 'west' or dir == 'w' or dir == 'left' or dir == 'l':
			if cur_room.isAltDescActive('west'):
				print format_string(self.parser.parseDescription(cur_room.getAltDesc('west')))
			else:
				print format_string(self.parser.parseDescription(cur_room.west_desc))
		else:
			return
		## Print any items that have been dropped in this room
		if len(cur_room.getDroppedItems()) > 0:
			print "=== Dropped Items ==="
			for i in cur_room.getDroppedItems():
				print yellow(i.getName())
		## Print enemies
		#enemies = self.map.getEnemiesAtPos(self.player.getPos())
		enemy_bank = self.map.getEnemies()
		if len(cur_room.getEnemies()) > 0:
			print red("=== Enemies ===")
			for e_id in cur_room.getEnemies():
				if enemy_bank[e_id].getHP() > 0:
					print enemy_bank[e_id].getName()
				else:
					print enemy_bank[e_id].getName() + '   ' + red_bg('*DEFEATED*')
				print '  HP: ' + str(enemy_bank[e_id].getHP())
				print '  MP: ' + str(enemy_bank[e_id].getMP())
Beispiel #4
0
	def do_take( self, s ):
		cur_room = self.map.getRooms()[self.player.getPos()]
		for item in cur_room.getItems() + cur_room.getDroppedItems():
			if string.lower(item.getName()) == string.lower(s):
				if 'take' in item.getKeywords():
					print yellow(item.getName()) + ' added to your' + magenta(' inventory')
					self.player.addToInventory(item)
					# Either remove the item from the list of room items, or list of dropped room items
					try: cur_room.getItems().remove(item)
					except ValueError: cur_room.getDroppedItems().remove(item)
					## Check both items that were used to see if any alternate descriptions should be used
					if item.getAltDescDirection() is not None:
						cur_room.setAltDescBool(item.getAltDescDirection(), True)	
					return		
				else:
					print red("You can't take that.")
					return		
		print "You don't see anything that looks like a " + yellow(s) + '.' 
Beispiel #5
0
	def help_save(self):
		print 'Save game.'
		print red('WARNING - If you give the name of a file that already exists, this file will be overwritten.')
Beispiel #6
0
	def help_quit(self):
		print 'Exit Game'
		print red('WARNING - Any unsaved changes will be lost.')
Beispiel #7
0
	def help_new(self):
		print 'Start a new game.' 
		print red('WARNING - You will lose any unsaved changes.')
Beispiel #8
0
	def do_move(self, s):
		global GLOBAL_TIME
		global OUTSIDE_PLANE
		global TIME_TO_DIE
		#print 'OUTSIDE_PLANE: ' + str(OUTSIDE_PLANE)
		#print 'GLOBAL_TIME: ' + str(GLOBAL_TIME)
		#global TURBULENCE
		#global TURBULENCE_START_TIME
		#global TURBULENCE_STOP_TIME
		if GLOBAL_TIME == TIME_TO_DIE:
			self.print_death()
			return True
		if OUTSIDE_PLANE:
			print "You're still flying!!! Or are you falling..."
			GLOBAL_TIME += 1
			return			
		
	#	player_x = self.player.getPos()[0]
	#	player_y = self.player.getPos()[1]
	#	print 'player_x: ' + str(player_x)
	#	print 'player_y: ' + str(player_y)
	
		#if (player_x == 6 and player_y == 3) or (player_x == 6 and player_y == 7):

		cur_room = self.map.getRooms()[self.player.getPos()]
		player_x = self.player.getPos()[0]
		player_y = self.player.getPos()[1]
		#print 'GLOBAL_TIME = ' + str(GLOBAL_TIME)
		#print 'TURBULENCE_START_TIME = ' + str(TURBULENCE_START_TIME)
		#print 'TURBULENCE_STOP_TIME = ' + str(TURBULENCE_STOP_TIME)
		#print 'TURBULENCE = ' + str(TURBULENCE)



		TURBULENCE = random.randint(1,10)
		if TURBULENCE < 2:
			self.print_turb()
			print 'Turbulence shakes you, forcing you to move in a random direction.'
			dirs = ['n', 's', 'e', 'w']
			s = dirs[random.randint(0,3)]

		if s == '':
			print red('You have to specify what direction to move!')
		elif s.lower() == 'north' or s.lower() == 'n' or s.lower() == 'forward' or s.lower() == 'f':
			if cur_room.north:
				self.player.setPos( (player_x, player_y - 1) )
				self.do_look('')
				GLOBAL_TIME += 1
				#if GLOBAL_TIME == TURBULENCE_START_TIME:
				#	TURBULENCE = True
				#if GLOBAL_TIME == TURBULENCE_STOP_TIME:
				#	TURBULENCE = False
			else:
				print red("You can't move in that direction.")
		elif s.lower() == 'south' or s.lower() == 's' or s.lower() == 'back' or s.lower() == 'b':
			if cur_room.south:
				self.player.setPos( (player_x, player_y + 1) )
				self.do_look('')
				GLOBAL_TIME += 1
				#if GLOBAL_TIME == TURBULENCE_START_TIME:
				#	TURBULENCE = True
				#if GLOBAL_TIME == TURBULENCE_STOP_TIME:
				#	TURBULENCE = False
			else:
				print red("You can't move in that direction.")
		elif s.lower() == 'east' or s.lower() == 'e' or s.lower() == 'right' or s.lower() == 'r':
			if player_x + 1 == 7 and player_y == 6:
				print "You're flying!!!!"
				OUTSIDE_PLANE = True
				GLOBAL_TIME += 1
				TIME_TO_DIE = GLOBAL_TIME + 3
				return
			if cur_room.east:
				self.player.setPos( (player_x + 1, player_y) )
				self.do_look('')
				GLOBAL_TIME += 1
				#if GLOBAL_TIME == TURBULENCE_START_TIME:
				#	TURBULENCE = True
				#if GLOBAL_TIME == TURBULENCE_STOP_TIME:
				#	TURBULENCE = False
			else:
				print red("You can't move in that direction.")
		elif s.lower() == 'west' or s.lower() == 'w' or s.lower() == 'left' or s.lower() == 'l':
			if player_x - 1 == 3 and player_y == 6:
				print "You're flying!!!!"
				OUTSIDE_PLANE = True
				GLOBAL_TIME += 1
				TIME_TO_DIE = GLOBAL_TIME + 3
				return
			if cur_room.west:
				self.player.setPos( (player_x - 1, player_y) )
				self.do_look('')
				GLOBAL_TIME += 1
				#if GLOBAL_TIME == TURBULENCE_START_TIME:
				#	TURBULENCE = True
				#if GLOBAL_TIME == TURBULENCE_STOP_TIME:
				#	TURBULENCE = False
			else:
				print red("You can't move in that direction.")
		else:
			return