From e479ffe174d3d495f08e8422836062480a4d3b34 Mon Sep 17 00:00:00 2001 From: PersonGuyGit Date: Sun, 10 Dec 2023 12:48:39 -0700 Subject: [PATCH] Revised Object for Special Abliities for Singletons --- .../conflictResults/conflictResults.gd | 2 - .../specialabliities/SpecialAbility.gd | 48 +++++++++++++++++++ .../specialabliities/specialabilities.gd | 24 ---------- .../middleware/specialabliities/testblank.gd | 8 ++++ .../specialabliities/testblank.tscn | 3 ++ Phase2/Godot_Toolset/Main/project.godot | 12 ++--- 6 files changed, 64 insertions(+), 33 deletions(-) create mode 100644 Phase2/Godot_Toolset/Main/middleware/specialabliities/SpecialAbility.gd delete mode 100644 Phase2/Godot_Toolset/Main/middleware/specialabliities/specialabilities.gd create mode 100644 Phase2/Godot_Toolset/Main/middleware/specialabliities/testblank.gd create mode 100644 Phase2/Godot_Toolset/Main/middleware/specialabliities/testblank.tscn diff --git a/Phase2/Godot_Toolset/Main/middleware/conflictResults/conflictResults.gd b/Phase2/Godot_Toolset/Main/middleware/conflictResults/conflictResults.gd index 74d2986..af7f2a5 100644 --- a/Phase2/Godot_Toolset/Main/middleware/conflictResults/conflictResults.gd +++ b/Phase2/Godot_Toolset/Main/middleware/conflictResults/conflictResults.gd @@ -5,11 +5,9 @@ class_name ConflictResultsProcess #This class is used to define the player and NPC order in combat. Also called Initiative in some game systems. #Rough Draft: 12/3/2023: Luke, Godot 3.5 - #How are we calculating initiatve. Are we going to pull the formula from the GSAL? var Initiative_Order : Array - #What do these two variables do? That was not clearly defined in the UML... var Action_Declared : Array diff --git a/Phase2/Godot_Toolset/Main/middleware/specialabliities/SpecialAbility.gd b/Phase2/Godot_Toolset/Main/middleware/specialabliities/SpecialAbility.gd new file mode 100644 index 0000000..ef322b6 --- /dev/null +++ b/Phase2/Godot_Toolset/Main/middleware/specialabliities/SpecialAbility.gd @@ -0,0 +1,48 @@ +extends Object + +#This class, is used to define special ability data. Such as for attacks like shooting fireballs. +#This is the middle ware, to define the structure of the data, before it is accesable by the character sheet. +#This class is also used to define the structure, as to make it normalized for the database / XML layers. + +# Luke, 12/10/2023, Godot 3.5+ + + +var Name: String + +var Attribute: Array + +var Cost: int + +var Damage: int + +var LevelRequirement: int + +var Duration: float + +var AffectedAttribute: String + +var DiceRules: Vector3 + +func _init(initName: String, initAttribute: Array, initCost: int, initDamage: int, +initLevelRequirement: int, initDuration: float, initAffectedAttribute: String, +initDiceRules: Vector3): + + Name = initName +# Attribute = initAttribute + Cost = initCost + Damage = initDamage + LevelRequirement = initLevelRequirement + Duration = initDuration + AffectedAttribute = initAffectedAttribute + DiceRules = initDiceRules + + Attribute = [] + for element in initAttribute: + if typeof(element) == TYPE_STRING: + Attribute.append(element) + else: + print("Warning: Ignoring non-string element in StringArray.") + +# Custom method to convert the object to a string +func to_string() -> String: + return "SpecialAbility(Name: {Name}, Attribute: {Attribute}, Cost: {Cost}, Damage: {Damage}, LevelRequirement: {LevelRequirement}, Duration: {Duration}, AffectedAttribute: {AffectedAttribute}, DiceRules: {DiceRules})" diff --git a/Phase2/Godot_Toolset/Main/middleware/specialabliities/specialabilities.gd b/Phase2/Godot_Toolset/Main/middleware/specialabliities/specialabilities.gd deleted file mode 100644 index baad14b..0000000 --- a/Phase2/Godot_Toolset/Main/middleware/specialabliities/specialabilities.gd +++ /dev/null @@ -1,24 +0,0 @@ -extends Object - -class_name SpecialAbility -#This class, is used to define special ability data. Such as for attacks like shooting fireballs. -#This is the middle ware, to define the structure of the data, before it is accesable by the character sheet. -#This class is also used to define the structure, as to make it normalized for the database / XML layers. - -# Luke, 12/9/2023, Godot 3.5+ - - -var Name: String - -#Add TypeCheck for arrays of only strings at some point. -var Attribute: Array - -var Cost: int - -var Damage: int - -func _init(initName: String, initAttribute: Array, initCost: int, initDamage: int): - Name = initName - Attribute = initAttribute - Cost = initCost - Damage = initDamage diff --git a/Phase2/Godot_Toolset/Main/middleware/specialabliities/testblank.gd b/Phase2/Godot_Toolset/Main/middleware/specialabliities/testblank.gd new file mode 100644 index 0000000..2c02799 --- /dev/null +++ b/Phase2/Godot_Toolset/Main/middleware/specialabliities/testblank.gd @@ -0,0 +1,8 @@ + + +extends Node + +func _ready(): + var SpecialAbility = preload("res://middleware/specialabliities/SpecialAbility.gd") + var special_ability = SpecialAbility.new("Fireball", ["Fire Type", "Projectile"], 1, 10, 0, 5.0, "strength", Vector3(1, 1, 1)) + print(special_ability.to_string()) diff --git a/Phase2/Godot_Toolset/Main/middleware/specialabliities/testblank.tscn b/Phase2/Godot_Toolset/Main/middleware/specialabliities/testblank.tscn new file mode 100644 index 0000000..b171e8d --- /dev/null +++ b/Phase2/Godot_Toolset/Main/middleware/specialabliities/testblank.tscn @@ -0,0 +1,3 @@ +[gd_scene format=2] + +[node name="Node2D" type="Node2D"] diff --git a/Phase2/Godot_Toolset/Main/project.godot b/Phase2/Godot_Toolset/Main/project.godot index ef2e30a..1a401c9 100644 --- a/Phase2/Godot_Toolset/Main/project.godot +++ b/Phase2/Godot_Toolset/Main/project.godot @@ -13,15 +13,9 @@ _global_script_classes=[ { "class": "ConflictResultsProcess", "language": "GDScript", "path": "res://middleware/conflictResults/conflictResults.gd" -}, { -"base": "Object", -"class": "SpecialAbility", -"language": "GDScript", -"path": "res://middleware/specialabliities/specialabilities.gd" } ] _global_script_class_icons={ -"ConflictResultsProcess": "", -"SpecialAbility": "" +"ConflictResultsProcess": "" } [application] @@ -29,6 +23,10 @@ _global_script_class_icons={ config/name="bcirpg_toolset" config/icon="res://icon.png" +[autoload] + +SpecialAbility="*res://middleware/specialabliities/SpecialAbility.gd" + [global] filters=false