예제 #1
0
파일: Shield.py 프로젝트: gabrieljsch/gng
    def __init__(self,
                 game,
                 name,
                 rep,
                 color_tone,
                 hands,
                 armor_rating,
                 encumbrance,
                 enchantment,
                 loc,
                 brand=None):
        self.rep, self.color, self.hands, self.armor_rating, self.encumbrance, self.enchantment, self.loc, self.brand = rep, color_tone, hands, armor_rating, encumbrance, enchantment, loc, brand
        self.wclass = "shield"

        self.name, self.base_string = Colors.color(name, self.color), name

        # Legendary
        if self.base_string in Weapons.legendaries:
            self.legendary = True
            try:
                game.legendaries_to_spawn.remove(self.base_string)
            except:
                pass
        else:
            self.legendary = False

        # Magic Damage
        self.mdamage = 0
예제 #2
0
파일: Ammo.py 프로젝트: gabrieljsch/gng
 def __init__(self,
              game,
              name,
              rep,
              color_tone,
              wclass,
              number,
              damage,
              loc,
              brand=None):
     self.rep, self.color, self.wclass, self.damage, self.number, self.loc, self.brand = rep, color_tone, wclass, damage, number, loc, brand
     self.name, self.base_string = Colors.color(name, self.color), name
     self.game = game
예제 #3
0
파일: Tome.py 프로젝트: gabrieljsch/gng
	def __init__(self, spells, name, rep, color_tone, hands, loc, brand=None):
		self.rep, self.color, self.hands, self.loc, self.brand, self.wclass = rep, color_tone, hands, loc, brand, "tome"

		# Purchasable Skills
		self.spells = spells

		self.name, self.base_string = Colors.color(name, self.color), name

		# Magic Damage
		self.mdamage = 2

		# Legendary
		if self.base_string in Weapons.legendaries:
			self.legendary = True
			try: game.legendaries_to_spawn.remove(self.base_string)
			except: pass
		else:
			self.legendary = False
예제 #4
0
	def __init__(self, game, name, char, color_tone, etype, behavior_type, tier,    con, st, dex, int, cha, mspeed, reg, xp,   resistances,  loc, other_items=None):

		self.game = game
		self.equipped_armor = None

		# Initialize Representation
		self.rep, self.color, self.etype, self.behavior_type, self.tier = char, color_tone, etype, behavior_type, tier

		# Mount?
		self.mount, self.rider = None, None

		self.name, self.namestring = Colors.color(name, self.color), name
		self.info = ('the ' + self.name, 'the ' + self.name + "'s", 'its', 'The ' + self.name, 'The ' + self.name + "'s") if self.namestring not in Monsters.uniques else (self.name, self.name + "'s", 'its', self.name, self.name + "'s")

		# Initialize Health
		bonushp = md(6,self.tier)
		self.maxhp = 6 * con + bonushp
		self.hp = 6 * con + bonushp

		# Initialize Mana
		self.mana, self.maxmana = 5 * int + self.tier, 5 * int + self.tier

		# Regen
		self.hregen, self.mregen, self.innate_ac = 0, 0, 0

		# Coordinates
		self.loc, self.time = loc, 1
		self.passives, self.spells, self.traits = [], [], []

		# Initialize Range
		self.range_from_player = 100

		# Initialize Stats
		self.con, self.str, self.dex, self.int, self.cha, self.mspeed, self.reg, self.xp = con, st, dex, int, cha, mspeed, reg, xp

		# Initialize Resistances
		self.frostr, self.firer, self.poisonr, self.acidr, self.shockr, self.expr = resistances

		# Monster's Equipment
		self.hands = 2
		self.wielding , self.other_items, self.quivered, self.inventory = [], other_items, None, []

		# Manage God-Cleaver Passive
		self.god_cleaver_hits = 0
예제 #5
0
    def __init__(self,
                 name,
                 rep,
                 color_tone,
                 aclass,
                 armor_rating,
                 encumbrance,
                 enchantment,
                 loc,
                 brand=None):
        self.rep, self.color, self.aclass, self.armor_rating, self.encumbrance, self.enchantment, self.loc, self.brand = rep, color_tone, aclass, armor_rating, encumbrance, enchantment, loc, brand

        self.name, self.base_string = Colors.color(name, self.color), name

        # Initialize Resistances
        self.frostr, self.firer, self.poisonr, self.acidr, self.shockr, self.expr = 0, 0, 0, 0, 0, 0

        # Legendary
        if self.base_string in Weapons.legendaries:
            self.legendary = True
            try:
                game.legendaries_to_spawn.remove(self.base_string)
            except:
                pass
        else:
            self.legendary = False

        # Armor Types mdefense
        if aclass == 'garments': self.mdefense = 0
        elif aclass == 'robes': self.mdefense = 3
        elif aclass == 'hide': self.mdefense = 2
        elif aclass == 'scale': self.mdefense = 1
        elif aclass == 'chainmail': self.mdefense = 1
        elif aclass == 'plate': self.mdefense = 1

        # Manage Icy, Tempered, Insulated, Voidforged
        if self.brand == 'tempered': self.firer += 2
        if self.brand == 'icy': self.frostr += 2
        if self.brand == 'insulated': self.shockr += 2
        if self.brand == 'voidforged': self.mdefense += 2
예제 #6
0
    def __str__(self):

        enchantment_string = "+" + str(
            self.enchantment) if self.enchantment >= 0 else str(
                self.enchantment)

        if self.brand is not None:
            if self.base_string[:4].lower() == 'the ':
                return Colors.color(
                    self.base_string[:4], self.color) + Colors.color(
                        self.brand, Brands.colors[self.brand]
                    ) + " " + enchantment_string + ' ' + Colors.color(
                        self.base_string[4:], self.color)
            else:
                return Colors.color(self.brand, Brands.colors[
                    self.brand]) + " " + enchantment_string + ' ' + self.name
        else:
            if self.base_string[:4].lower() == 'the ':
                return Colors.color(
                    self.base_string[:4],
                    self.color) + enchantment_string + ' ' + Colors.color(
                        self.base_string[4:], self.color)
            else:
                return enchantment_string + ' ' + self.name
예제 #7
0
파일: Tome.py 프로젝트: gabrieljsch/gng
	def __str__(self):

		if self.brand is not None: return Colors.color(self.brand,Brands.colors[self.brand]) + ' ' + self.name
		else: return self.name
예제 #8
0
파일: Ammo.py 프로젝트: gabrieljsch/gng
 def __str__(self):
     if self.brand is not None:
         return Colors.color(self.brand, Brands.colors[
             self.brand]) + ' ' + self.name + ' (' + str(self.number) + ')'
     else:
         return self.name + ' (' + str(self.number) + ')'
예제 #9
0
    def __init__(self, name, color_tone, loc, number=1):
        self.rep, self.color, self.number, self.loc = '!', color_tone, number, loc

        self.name, self.base_string = Colors.color(name, self.color), name
예제 #10
0
	def turn(self, game):

		# Manage Terrified
		for passive in self.passives:
			if passive[0] == "terrified":

				# Fear Radius
				spaces = []
				for x in range(-1,2):
					for y in range(-1,2):
						if self.loc[0] + x >= 0 and self.loc[1] + y >= 0: spaces.append((self.loc[0] + x, self.loc[1] + y))
				shuffle(spaces)

				# Move to random square
				for space in spaces:
					if game.map.can_move(space):
						self.loc = space
						break

				# Check for Traps
				for item in game.items:
					if type(item) == Trap and item.loc == self.loc:
						item.trip(game)

				self.time += self.mspeed
				return


		# Ally Unit
		if self in game.allies:
			enemy, mini = None, 100
			for unit in game.units:
				if unit in game.allies: continue
				los = ai.los(self.loc, unit.loc, Maps.rooms[game.map.map][0], game )
				if los is not None:
					if unit.name == "you": self.range_from_player = len(los)
					elif len(los) < mini: enemy, mini, minlos = unit, len(los), los

			# No enemies in room
			if enemy is None:
				move_towards(self, game.player, game.map)
				self.time += self.mspeed
				return

		# Enemy Unit
		else:
			minlos = ai.los(self.loc, game.player.loc, Maps.rooms[game.map.map][0], game )
			try: mini, enemy = len(minlos), game.player
			except: mini, enemy = 100, game.player
			for unit in game.allies:
				los = ai.los(self.loc, unit.loc, Maps.rooms[game.map.map][0], game )
				if los is not None:
					if unit.name == "you": self.range_from_player = len(los)
					if len(los) <= mini: enemy, mini, minlos = unit, len(los), los


		melee_attacked = False

		# MAGIC!!
		if len(self.spells) > 0:

			# Chance to use spells
			if d(10) + min(self.int, 7) >= 12:

				if minlos is not None:

					# Zap with spells
					for spell in self.spells:

						# Check for mana
						if self.mana >= Spells.spells[spell][1]:
							spell_fun = Spells.spells[spell][0]

							# If target
							if Spells.spells[spell][4]:

								# If in spell range
								if len(minlos) - 1 <= Spells.spells[spell][5]:

									# Player Resist spell
									if d(100) / 100 <= max(0.05, min(0.9, (enemy.cha / 2) / self.int)):
										self.time += Spells.spells[spell][2]
										self.mana -= Spells.spells[spell][1]
										if enemy.name == 'you': game.game_log.append("You resist the " + spell + " from " + self.info[0] + "!")
										else: game.game_log.append(enemy.info[3] + " resists the " + spell + " from " + self.info[0] + "!")

									elif spell_fun(spell, self, enemy, game, Maps.rooms[game.map.map][0], game.map.room_filler):
										self.time += Spells.spells[spell][2]
										self.mana -= Spells.spells[spell][1]

										if self.mount is not None: self.mount.unit.loc = self.loc
										if self.rider is not None: self.rider.loc = self.loc
							# No target
							else:
								if spell_fun(spell, self, enemy, game, Maps.rooms[game.map.map][0], game.map.room_filler):
									self.time += Spells.spells[spell][2]
									self.mana -= Spells.spells[spell][1]

									if self.mount is not None: self.mount.unit.loc = self.loc
									if self.rider is not None: self.rider.loc = self.loc

							# Manage the Black Cross 2
							for unit in self.game.units:
								for item in unit.wielding:
									if item.base_string == "the Black Cross":
										for school, spells in Spells.spell_schools.items():
											if spell in spells:
												if school in Spells.school_info:
													if Spells.school_info[school][1] is not None:
														self.game.game_log.append("Yet " + item.name + " condemns " + self.info[1] + " use of magic, it " + Colors.color("ignites", "fire") + " " + self.info[2] + " flesh!")
														apply(self, "aflame", 3)

							# Manage Longfang 2
							for weapon in self.wielding:
								if weapon.base_string == "Longfang":
									for school, spells in Spells.spell_schools.items():
										if spell in spells:
											if school in Spells.school_info:
												if Spells.school_info[school][1] is not None:
													weapon.passives = [[Spells.school_info[school][1] , 1]]
													weapon.brand = Spells.school_info[school][1]
													game.game_log.append(weapon.name + " absorbs the power of " + self.info[1] + " spell and becomes " + Colors.color(weapon.brand, Brands.colors[weapon.brand]) + "!")
													break

							# One spell per turn
							return



		# Melee Attack
		if adjacent_to(self, enemy):

			# Find weapons
			weaps = [item for item in self.wielding[::-1] if type(item) == Weapon and item.wclass not in Weapons.ranged_wclasses]


			maxas = 0
			for weapon in weaps:
				 if weapon.speed > maxas and weapon.wclass not in Weapons.ranged_wclasses: maxas = weapon.speed

			# Hit with melee
			for item in weaps:
				item.strike(self, enemy, game)
				if self in game.allies:
					# Enemy Well-being Statement
					try: game.player.well_being_statement(enemy, self, item)
					except: pass

			self.time += maxas
			melee_attacked = True

		# Add thrown weapon platform
		thrown = False
		if self.quivered is not None:
			if self.quivered.wclass in Ammos.thrown_amclasses:
				thrown = True
				Weapon.give_weapon(self, self.quivered.base_string)

		# Make Ranged attacks
		for item in self.wielding:
			if item.wclass in Weapons.ranged_wclasses or item.wclass in Ammos.thrown_amclasses:

				if self.quivered is not None or item.hands == 0:

					if item.hands > 0 and melee_attacked:
						if thrown: self.wielding.pop()
						return

					# los = los(self.loc, enemy.loc, Maps.rooms[game.map.map][0], game )
					if minlos is not None:

						# Ranged range
						if mini <= (2 * item.damage + item.to_hit):
							item.strike(self, enemy, game)
							if self in game.allies:
								# Enemy Well-being Statement
								try: game.player.well_being_statement(enemy, self, item)
								except: pass


							# Remove Ammo
							if thrown: self.wielding.pop()
							if item.hands > 0:
								self.quivered.number -= 1
								if self.quivered.number == 0: self.quivered = None
								self.time += item.speed
								return
						else:
							if thrown: self.wielding.pop()
					else:
						if thrown: self.wielding.pop()

		# If can't, move
		immobile = False
		for name, count in self.passives:
			if name == 'immobile': immobile = True

		if not melee_attacked and self.behavior_type != 'as':

			if not immobile:
				coordinates = self.loc
				if self.mount is None: smart_move_towards(self, enemy, game)

				# Check for Traps
				for item in game.items:
					if type(item) == Trap and item.loc == self.loc:
						item.trip()

				# Manage Furious Charge (enemies)
				if "furious charge" in self.traits:
					if self in game.allies:
						for unit in game.units:
							if unit in game.allies: continue
							if unit.loc == (coordinates[0] - 2 * (self.loc[0] - unit.loc[0]), self.loc[1] - 2 * (self.loc[1] - unit.loc[1])):
								for weapon in self.wielding: weapon.strike(self, unit, game, False)
								break
					else:
						for unit in game.allies:
							if unit.loc == (coordinates[0] - 2 * (self.loc[0] - unit.loc[0]), coordinates[1] - 2 * (self.loc[1] - unit.loc[1])):
								for weapon in self.wielding: weapon.strike(self, unit, game,  False)
								break

				# Manage Lance (enemies)
				if self.rider is not None:
					for weapon in self.rider.wielding:
						if weapon.wclass == 'lance':
							for unit in game.units:
								if unit.loc == (coordinates[0] - 2 * (self.loc[0] - unit.loc[0]), coordinates[1] - 2 * (self.loc[1] - unit.loc[1])):
									weapon.strike(self.rider, unit, game, False)
									break

			self.time += self.mspeed

			if self.rider is not None:
				self.rider.prev_loc = self.rider.loc
				self.rider.loc = self.loc