More work on quests

This commit is contained in:
2025-11-19 14:42:59 -05:00
parent 379fa4bd70
commit 4ed4ab95f3
36 changed files with 3911 additions and 75 deletions

View File

@@ -1,5 +1,21 @@
class_name Enemy extends QuestSprite
static var list : Dictionary[String, PackedScene] = {}
static func load_enemy_list() -> void:
var folder_path = "res://templates/enemies"
var dir = DirAccess.open(folder_path)
if dir:
dir.list_dir_begin()
var filename = dir.get_next()
while filename != "":
if not dir.current_is_dir():
var template : PackedScene = ResourceLoader.load(folder_path.path_join(filename))
if template:
list[template.name] = template
filename = dir.get_next()
dir.list_dir_end()
func attack(target : QuestSprite) -> void:
print("Attack by %s to %s" % [name, target.name])

View File

@@ -1,5 +1,6 @@
extends Node
var player_data : Adventurer = null
var player : Player = null
var panel : GamePanel = null
@@ -28,7 +29,10 @@ func _process(delta: float) -> void:
confirm_end_shift()
if Input.is_action_just_pressed("test"):
test_save()
func add_quest_progress_bar(quest : Quest) -> void:
panel.add_quest_progress_bar(quest)

View File

@@ -2,21 +2,23 @@ extends Control
var quest : Quest
var selected_location : Quest.Locations = -1
var min_difficulty : int = 0
var max_difficulty : int = 5
@onready var map : QuestMap = $Map
func generate_quest() -> void:
quest = Quest.new()
quest.name = "A Test Quest"
quest.location = Quest.Locations.NESTORS_WOODS
quest.difficulty = 1
quest.length = 60
quest.rewards = {"exp":100,"gold":1}
quest = Quest.generate({
"location":selected_location,
"min_difficulty": min_difficulty,
"max_difficulty": max_difficulty,
})
func update_quest_window() -> void:
if quest:
%NameField.text = quest.name
%DifficultyField.text = quest.difficulty_name()
%LocationField.text = quest.location_name()
%LocationField.text = quest.get_location_name()
#for reward in quest.rewards.:
func reset() -> void:
@@ -45,3 +47,15 @@ func _on_post_back_button_pressed() -> void:
func _on_generate_back_button_pressed() -> void:
hide()
reset()
func _on_location_options_pressed() -> void:
map.visible = true
func _on_map_location_selected(location: Quest.Locations) -> void:
selected_location = location
%LocationOptions.text = Quest.location_name(location)
map.visible = false
#TODO: Make Location show up correctly

12
scripts/map.gd Normal file
View File

@@ -0,0 +1,12 @@
class_name QuestMap extends Control
signal location_selected(location : Quest.Locations)
func _ready() -> void:
for child in get_children():
if child is MapPoint:
child.selected.connect(_on_location_pressed)
func _on_location_pressed(location : Quest.Locations):
location_selected.emit(location)

1
scripts/map.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://c2jtg58mno7fj

View File

@@ -1,5 +1,5 @@
@tool
extends TextureButton
class_name MapPoint extends TextureButton
@onready var panel : PanelContainer = %BriefPanel
@@ -20,9 +20,12 @@ var thickness : float = 5
var max_circle_size : float = 200
@export var label : String = ""
@export var id : Quest.Locations
@export var locked_brief : String = ""
@export var unlocked_brief : String = ""
signal selected(location : Quest.Locations)
func _ready() -> void:
#TODO: Add a nine-patch and resize the banner based on the label contents
%Label.text = label
@@ -61,6 +64,8 @@ func _on_mouse_entered() -> void:
func _buttonn_pressed() -> void:
if primed:
unlock()
elif !locked:
selected.emit(id)
func _on_mouse_exited() -> void:
if panel_shown:

View File

@@ -16,7 +16,7 @@ func setup(qst : Quest) -> void:
func update() -> void:
nameLabel.text = quest.name
difficultyLabel.text = quest.difficulty_name()
locationLabel.text = quest.location_name()
locationLabel.text = quest.get_location_name()
#TODO: Show the current status of the quest
func close() -> void: