-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add interface for quest repo * add quest repo signals * Move away from brandonlamb dir
- Loading branch information
1 parent
d9d0b27
commit e90b512
Showing
15 changed files
with
134 additions
and
45 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
extends Reference | ||
|
||
signal quest_created(quest) | ||
signal quest_deleted(quest) | ||
signal quest_saved(quest) | ||
signal quests_cleared() | ||
|
||
""" | ||
Find quest by ID | ||
@param int id | ||
@return Quest | ||
""" | ||
func find_by_id(id): pass | ||
|
||
""" | ||
Find all quests | ||
@return Quest[] | ||
""" | ||
func find_all(): pass | ||
|
||
""" | ||
Clear all quests | ||
""" | ||
func clear(): pass | ||
|
||
""" | ||
Save quest | ||
@param Quest quest | ||
""" | ||
func save(quest): pass | ||
|
||
""" | ||
Delete quest | ||
@param Quest quest | ||
""" | ||
func delete(quest): pass | ||
|
||
""" | ||
Delete quest by ID | ||
@param int id | ||
""" | ||
func delete_by_id(id): pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
extends Reference | ||
|
||
const Goal = preload("res://addons/godot-quest-system/domain/goal.gd") | ||
const Quest = preload("res://addons/godot-quest-system/domain/quest.gd") | ||
const Requirement = preload("res://addons/godot-quest-system/domain/requirement.gd") | ||
const RequirementProcessor = preload("res://addons/godot-quest-system/domain/requirement_processor.gd") | ||
const Reward = preload("res://addons/godot-quest-system/domain/reward.gd") |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
extends "res://addons/godot-quest-system/domain/quest_repository.gd" | ||
|
||
const Quest = preload("res://addons/godot-quest-system/domain/quest.gd") | ||
|
||
const _quests = [] | ||
const _questsMap = {} | ||
|
||
""" | ||
Constructor - accepts an array of quests to initialize the repository with | ||
@param Quest[] quests | ||
""" | ||
func _init(quests): | ||
if typeof(quests) == TYPE_ARRAY: | ||
_load_from_array(quests) | ||
|
||
""" | ||
Load quests from array of quests | ||
@param Quest[] quests | ||
""" | ||
func _load_from_array(quests): | ||
for i in quests: | ||
_quests.append(i) | ||
_questsMap[i.id] = i | ||
|
||
""" | ||
@override | ||
""" | ||
func find_by_id(id): | ||
if _questsMap.has(id): | ||
return _questsMap[id] | ||
return Quest.new() | ||
|
||
""" | ||
@override | ||
""" | ||
func find_all(): | ||
return _quests | ||
|
||
""" | ||
@override | ||
""" | ||
func clear(): | ||
_quests = [] | ||
_questsMap = {} | ||
|
||
""" | ||
@override | ||
""" | ||
func save(quest): | ||
pass | ||
|
||
""" | ||
@override | ||
""" | ||
func delete(quest): | ||
for i in range(0, _quests.size()): | ||
if _quests[i].id == quest.id: | ||
_quests.remove(i) | ||
|
||
if _questsMap.has(quest.id): | ||
_questsMap.erase(quest.id) | ||
|
||
""" | ||
@override | ||
""" | ||
func delete_by_id(id): | ||
for i in range(0, _quests.size()): | ||
if _quests[i].id == id: | ||
_quests.remove(i) | ||
|
||
if _questsMap.has(id): | ||
_questsMap.erase(id) |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
addons/com.brandonlamb.quest/sqlite/test.gd → addons/godot-quest-system/sqlite/test.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ns/com.brandonlamb.quest/sqlite/test.tscn → addons/godot-quest-system/sqlite/test.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
extends Node2D | ||
|
||
const Quest = preload("res://addons/com.brandonlamb.quest/domain/quest.gd") | ||
const QuestStatus = Quest.Status | ||
const QuestRepo = preload("res://addons/com.brandonlamb.quest/memory/quest_repository.gd") | ||
const QuestFactory = preload("res://addons/com.brandonlamb.quest/memory/quest_factory.gd") | ||
|
||
func _ready(): | ||
var questRepo = QuestRepo.new(QuestFactory.create_from_static()) | ||
var quests = questRepo.find_all() | ||
|
||
for i in questRepo.find_all(): | ||
for i in quests: | ||
i.connect("started", self, "_on_quest_started") | ||
i.start() | ||
_debug_quest(i) | ||
|
||
var quest = questRepo.find_by_id(1) | ||
quest.status = QuestStatus.FINISHED | ||
_debug_quest(quest) | ||
quest.status = "finished" | ||
print(quest.to_string()) | ||
print("quest.to_string()=", quest.to_string()) | ||
|
||
quests[2].status = "started" | ||
|
||
for i in quests: | ||
print(i.to_string()) | ||
|
||
func _on_quest_started(e): | ||
print("_on_quest_started: ", e.name) | ||
|
||
func _debug_quest(q): | ||
print(q.to_string()) |