# Duane's Dungeon - a rogue-like game # Copyright (C) 2023 Duane Robertson # player.gd - the player character # 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 . extends Creature class_name Player signal show_message_hud(text, color) func _ready(): add_to_group('player') super() func die(_source=null) -> void: # var it = blessed_item() var it = true if it: var txt = 'Your %s\nrestored your life!' # txt = txt % [it.describe_short()] show_message(txt, Color.RED) # it.level -= 1 # it.rename() reset_stats() # emit_signal('update_gear_buttons') else: ########################################### is_dead = true show_message('You died!!!!', Color.RED) ########################################### func move(dir:Vector2i) -> bool: var good:bool = super(dir) get_rectangles() if good: G.debug('player moves to %s' % [grid_position]) elif dir: var nloc := grid_position + dir var ent = map.entity_at(nloc) if ent and ent.get_faction() != get_faction(): attack(ent) return good func place(loc: Vector2i, force:=false) -> bool: super(loc) map.position = map.map_off - position get_rectangles() return true func release_if_dead(): pass func set_species_attributes(): automated = false description = 'You are here.' energy_max = 10 faction = 'player' icon_fg = 'd0d0f0' icon_name = 'player' invulnerable = true name = 'Player' species = 'player' strength_max = 10 func show_message(text: String, color := Color.YELLOW) -> void: emit_signal("show_message_hud", text, color) G.debug('player: %s' % [text]) func turn(): # The creature turn() is about automation, so ignore it. pass