# Duane's Dungeon - a rogue-like game
# Copyright (C) 2023 Duane Robertson

# hydragon.gd - a monster

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.


extends Creature

func set_species_attributes():
	species = 'hydragon'
	damage_mult = 3.0
	defense = {
		fire_breath = 0.5,
		flame_breath = 0.5,
		fireburst = 0.5,
		magic = 0.5,
		weapon = 0.5,
	}
	description = 'As if dragons weren\'t bad enough, this one has %d heads, each of which may breathe one of fire, ice, or lightning.'
	icon_name = 'hydra1'
	icon_fg = 'd04c4c'
	faction = 'dragon'
	energy_max = 21
	extra_level = 1.0  # for extra heads
	regen_e = 2
	strength_max = 22  # based on adult
	size = 5
	spell_chance = {
		fire_breath = 8,
		fireburst = 8,
		ice_spear = 8,
		lightning = 8,
		}

	super()


func change_strength(amt: int, source=null) -> bool:
	if amt < -4 and damage_mult < 7:
		if source and source.is_in_group('creatures'):
			source.show_message('%s grows another head' % [species])
#			print('%s (%s) damage increases to %0.1f' % [species, name, damage_mult])
		damage_mult += 0.5
		amt = int(amt * 0.75)

		if damage_mult < 4.5:
			icon_name = 'hydra1'
			icon_fg = 'd04c4c'
		elif damage_mult < 5.5:
			icon_name = 'hydra2'
			icon_fg = 'e04c4c'
		else:
			icon_name = 'hydra3'
			icon_fg = 'f04c4c'

		var tex:ImageTexture = G.sprite_sheet.texture(icon_name, icon_fg)
		sprite.texture = tex

	return super(amt, source)


func get_description() -> String:
	return description % [int((damage_mult - 2) / 0.5)]