diff --git a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/UserInterface/Locale.gd b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/UserInterface/Locale.gd index f034b3a..2f30da6 100644 --- a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/UserInterface/Locale.gd +++ b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/UserInterface/Locale.gd @@ -13,12 +13,13 @@ extends PanelContainer class_name Locale var locale_name = "Location Name" +var locale_type = "Space" var locale_description = "This is the description of the location." var locale_action = "Default action" var locale_action_params = [] var options_array = [] var destinations_array = [] - +var contained_subLocations = [] var visited = false; diff --git a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/Module_Demo_002.xml b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/Module_Demo_002.xml index e0f0b22..7a93222 100644 --- a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/Module_Demo_002.xml +++ b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/Module_Demo_002.xml @@ -70,7 +70,7 @@ Misc_003 ShowText - You find a quiet corner on the boat, put down your burden, and feel the rocking of the boat. You rest mind and body, and really I'm experimenting with options and sizes of them, added via JSON here. So in your meditation you have a vision: a sparrow flies high over the mountains and reveals a castle! After this reverie, you awake. + You find a quiet corner on the boat, put down your burden, and feel the rocking of the boat. You rest mind and body, and really I'm experimenting with options and sizes of them, added via XML here. So in your meditation you have a vision: a sparrow flies high over the mountains and reveals a castle! After this reverie, you awake. Resume your quest Boat_001 diff --git a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/Module_Demo_003_Loc.xml b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/Module_Demo_003_Loc.xml new file mode 100644 index 0000000..5495b92 --- /dev/null +++ b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/Module_Demo_003_Loc.xml @@ -0,0 +1,94 @@ + + + + Realm of Tempestia + A mystical fantasy landscape, where characters speak often in verse! + + Island of Sorrows + Setting for this module + + Boat_000 + ShowText + + The game has begun! You may select from the options below. You are in a boat. You have been shipwrecked. You can leave the boat through a hatch. + Examine Ship + Climb out through hatch + Play the fiddle! + Rest + Meditate + Boat_002 + Shore_001 + Misc_001 + Misc_002 + Misc_003 + + + Boat_001 + ShowText + + The boat rocks gently. You can leave the boat through a hatch. There is also now a test option. + Examine Ship + Climb out through hatch + Play the fiddle! + Rest + Meditate + Run die roll test + Boat_002 + Shore_001 + Misc_001 + Misc_002 + Misc_003 + Test_000 + + + Boat_002 + ShowText + + The boat is old and wrecked. + Continue + Boat_001 + + + Shore_001 + ShowText + + You've reached the shore! + Return to boat + Boat_001 + + + Misc_001 + ShowText + + You pull a fiddle from your sack and play it, while dancing around merrily. Great fun is had. + Resume your quest + Boat_001 + + + Misc_002 + ShowText + + You pull out a blanket, settle your burdens and take a short rest. + Resume your quest + Boat_001 + + + Misc_003 + ShowText + + You find a quiet corner on the boat, put down your burden, and feel the rocking of the boat. You rest mind and body, and really I'm experimenting with options and sizes of them, added via XML here. So in your meditation you have a vision: a sparrow flies high over the mountains and reveals a castle! After this reverie, you awake. + Resume your quest + Boat_001 + + + Test_000 + TestDieRollAction + 4 + 6 + NA + NA + Boat_001 + + + + \ No newline at end of file diff --git a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/game_01.tscn b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/game_01.tscn index a90b52e..b83d5fe 100644 --- a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/game_01.tscn +++ b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/_userFiles/game_01.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=6 format=2] [ext_resource path="res://gamePlay/Game.gd" type="Script" id=1] -[ext_resource path="res://gamePlay/But_MoreOptions.gd" type="Script" id=2] -[ext_resource path="res://gamePlay/But_Option.tscn" type="PackedScene" id=3] +[ext_resource path="res://gamePlay/But_Option.tscn" type="PackedScene" id=2] +[ext_resource path="res://gamePlay/But_MoreOptions.gd" type="Script" id=3] [ext_resource path="res://assets/ui_controlNode_dark_theme.tres" type="Theme" id=4] [ext_resource path="res://assets/liberation_serif_30pt.tres" type="DynamicFont" id=5] @@ -46,7 +46,7 @@ rect_min_size = Vector2( 0, 40 ) margin_right = 197.0 margin_bottom = 36.0 text = "More Options" -script = ExtResource( 2 ) +script = ExtResource( 3 ) __meta__ = { "_edit_use_anchors_": false } @@ -84,7 +84,7 @@ margin_right = 108.0 margin_bottom = 36.0 custom_constants/separation = 5 -[node name="option1" type="Button" parent="Background/MarginContainer/Rows/InputArea/ScrollContainer/OptionsContainer" instance=ExtResource( 3 )] +[node name="option1" type="Button" parent="Background/MarginContainer/Rows/InputArea/ScrollContainer/OptionsContainer" instance=ExtResource( 2 )] margin_right = 108.0 margin_bottom = 36.0 custom_fonts/font = ExtResource( 5 ) diff --git a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/gamePlay/Game.gd b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/gamePlay/Game.gd index 5ed70fc..5d1287d 100644 --- a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/gamePlay/Game.gd +++ b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/gamePlay/Game.gd @@ -9,7 +9,7 @@ extends Control #DKM TEMP: var module_file_path = "res://_userFiles/Module_Demo_001.json" #DKM TEMP: -var module_file_path_xml = "res://_userFiles/Module_Demo_002.xml" +var module_file_path_xml = "res://_userFiles/Module_Demo_003_Loc.xml" onready var history_source = get_node("/root/History").historyScreensSingleton onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance @@ -31,7 +31,7 @@ onready var module_map = "res://_userFiles/temp_map.save" #Name: nodeArray #Use: Contains the loaded module. Each array item is a -# Location instance, instantiated from the Location.gd script. +# Location instance, instantiated from the UserInterface/Location.gd script. var nodeArray func _ready() -> void: @@ -44,7 +44,7 @@ func _ready() -> void: #DKM TEMP: look at nodearry print("Temp: Looking at nodeArray:") for loc in nodeArray: - print ("Location named: " + loc.locale_name) + print ("Space named: " + loc.locale_name) current_text.show() #Load character sheet: @@ -62,14 +62,56 @@ func loadJSONToDict(filepath:String)->Dictionary: #DKM TEMP (XML version of JSON, manually imports and fills the nodeArray with locations): +# 4/21/24 (1454): In the middle of this refactor; while we're making connections we're +# just passing out the space array, but this will be fixed when finished to navigate whole +# regions, locations, and so on. func loadXMLDemo(filepath:String)->Array: + var spaceNode = Locale.new() - var nodeArray_XML - var parser = XMLParser.new() - var error = parser.open(filepath) + var parser_ext = XMLParser.new() + var error = parser_ext.open(filepath) if error != OK: print("Error opening XML file ", error) - return nodeArray_XML + return spaceNode.contained_subLocations + + while parser_ext.read() == OK: + if parser_ext.get_node_type() == XMLParser.NODE_ELEMENT: + var node_name = parser_ext.get_node_name() + + if node_name.strip_edges(true,true).to_upper() == "REGION": + var newNode = Locale.new() + newNode.locale_type = node_name.strip_edges(true,true).to_upper() + + while parser_ext.read() == OK: + if parser_ext.get_node_type() == XMLParser.NODE_ELEMENT: + var child_node_name_raw = parser_ext.get_node_name().strip_edges(true,true).to_upper() + var child_node_name = child_node_name_raw + match child_node_name: + "NAME": + parser_ext.read() + if parser_ext.get_node_type() == XMLParser.NODE_TEXT: + var id_node_data = parser_ext.get_node_data() + newNode.locale_name = id_node_data.strip_edges(true,true) + "DESCRIPTION": + parser_ext.read() + if parser_ext.get_node_type() == XMLParser.NODE_TEXT: + var id_node_data = parser_ext.get_node_data() + newNode.locale_description = id_node_data.strip_edges(true,true) + "LOCATION": + var subNode = Locale.new() + subNode.locale_type = child_node_name + newNode.contained_subLocations.append(subNode) + "SPACE": + spaceNode = loadGameNode(parser_ext) + "SCENE": + break + print("Found area of type: " + newNode.locale_type +"; with description: " + newNode.locale_description) + + return spaceNode.contained_subLocations + +func loadGameNode(parser:XMLParser)->Locale: + var gameNodeLocale = Locale.new() + var nodeArray_XML #Instantiate counter, initial locations for our module node of locations var i = 0 @@ -80,44 +122,104 @@ func loadXMLDemo(filepath:String)->Array: if parser.get_node_type() == XMLParser.NODE_ELEMENT: var node_name = parser.get_node_name() - if node_name.strip_edges(true,true).to_upper() == "LOCATION": + if node_name.strip_edges(true,true).to_upper() == "REGION": + var newNode = Locale.new() + newNode.locale_type = node_name.strip_edges(true,true).to_upper() + + while parser.read() == OK: + if parser.get_node_type() == XMLParser.NODE_ELEMENT: + var child_node_name_raw = parser.get_node_name().strip_edges(true,true).to_upper() + var child_node_name = child_node_name_raw + match child_node_name: + "NAME": + parser.read() + if parser.get_node_type() == XMLParser.NODE_TEXT: + var id_node_data = parser.get_node_data() + newNode.locale_name = id_node_data.strip_edges(true,true) + "DESCRIPTION": + parser.read() + if parser.get_node_type() == XMLParser.NODE_TEXT: + var id_node_data = parser.get_node_data() + newNode.locale_description = id_node_data.strip_edges(true,true) + "LOCATION": + var subNode = Locale.new() + subNode.locale_type = child_node_name + newNode.contained_subLocations.append(subNode) + "SPACE": + break + "SCENE": + break + print("Found area of type: " + newNode.locale_type +"; with description: " + newNode.locale_description) + + if node_name.strip_edges(true,true).to_upper() == "SPACE": if nodeArray_XML.size() <= i: print("Adding new node to array") var newNode = Locale.new() + newNode.locale_type = "SPACE" nodeArray_XML.append(newNode) while parser.read() == OK: if parser.get_node_type() == XMLParser.NODE_ELEMENT: - var child_node_name = parser.get_node_name().strip_edges(true,true).to_upper() - if "OPTION_LABELS" in child_node_name: + var child_node_name_raw = parser.get_node_name().strip_edges(true,true).to_upper() + var child_node_name = child_node_name_raw + + #DKM TEMP/TODO: Note that the code currently expects an even number of labels and go-tos, + # and in the correct order. Ideally we split on the underscore, match the numbers + # and handle cases of mismatches (by number mismatch or failure to match numbers of + # labels with numbers of gotos. But for now works as JSON version did. + # I'm using the child_node_name_raw to preserve the full name with suffix number if we + # want to use. + # NOTE: XMLParser throws errors on get node name and type if not within the expected + # type; these are being checked against in the match after read, but not output. + # + if "OPTION_LABELS" in child_node_name_raw: child_node_name = "OPTION_LABELS" - elif "OPTION_GOTOS" in child_node_name: + elif "OPTION_GOTOS" in child_node_name_raw: child_node_name = "OPTION_GOTOS" match child_node_name: "ID": parser.read() - var id_node_data = parser.get_node_data() - print("Found Id named: " + id_node_data + "; at i: " + str(i)) - if(i < nodeArray_XML.size()): - nodeArray_XML[i].locale_name = id_node_data.strip_edges(true,true) + if parser.get_node_type() == XMLParser.NODE_TEXT: + var id_node_data = parser.get_node_data() + print("Found Id named: " + id_node_data + "; at i: " + str(i)) + if(i < nodeArray_XML.size()): + nodeArray_XML[i].locale_name = id_node_data.strip_edges(true,true) "ACTION": parser.read() - var action_node_data = parser.get_node_data() - if(i < nodeArray_XML.size()): - nodeArray_XML[i].locale_action = action_node_data.strip_edges(true,true) + if parser.get_node_type() == XMLParser.NODE_TEXT: + var action_node_data = parser.get_node_data() + if(i < nodeArray_XML.size()): + nodeArray_XML[i].locale_action = action_node_data.strip_edges(true,true) "TEXT": parser.read() - var descr_node_data = parser.get_node_data() - if(i < nodeArray_XML.size()): - nodeArray_XML[i].locale_description = descr_node_data.strip_edges(true,true) - #"OPTION_LABELS": - #Break on ending tag for current location, increasing count - elif parser.get_node_name().strip_edges(true,true).to_upper() == "LOCATION" && parser.get_node_type() == XMLParser.NODE_ELEMENT_END: + if parser.get_node_type() == XMLParser.NODE_TEXT: + var descr_node_data = parser.get_node_data() + if(i < nodeArray_XML.size()): + nodeArray_XML[i].locale_description = descr_node_data.strip_edges(true,true) + "OPTION_LABELS": + parser.read() + if parser.get_node_type() == XMLParser.NODE_TEXT: + var action_node_data = parser.get_node_data() + if(i < nodeArray_XML.size()): + nodeArray_XML[i].options_array.append(action_node_data.strip_edges(true,true)) + "OPTION_GOTOS": + parser.read() + if parser.get_node_type() == XMLParser.NODE_TEXT: + var action_node_data = parser.get_node_data() + if(i < nodeArray_XML.size()): + nodeArray_XML[i].destinations_array.append(action_node_data.strip_edges(true,true)) + "A_PARAMS": + parser.read() + if parser.get_node_type() == XMLParser.NODE_TEXT: + var action_node_data = parser.get_node_data() + if(i < nodeArray_XML.size()): + nodeArray_XML[i].locale_action_params.append(action_node_data.strip_edges(true,true)) + elif parser.get_node_type() == XMLParser.NODE_ELEMENT_END && parser.get_node_name().strip_edges(true,true).to_upper() == "SPACE": #DKM_TEMP: - print("Found location break at i: " + str(i)) + print("Found space break at i: " + str(i)) i = i+1 break - - return nodeArray_XML + gameNodeLocale.contained_subLocations = nodeArray_XML + return gameNodeLocale diff --git a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/gamePlay/LocaleManager.gd b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/gamePlay/LocaleManager.gd index e0ba69c..a7d78be 100644 --- a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/gamePlay/LocaleManager.gd +++ b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/gamePlay/LocaleManager.gd @@ -5,7 +5,6 @@ extends Node -#DKM TEMP: must load from toolset func _ready() -> void: #load_module() $Loc_Boat.connect_exit("east", $Loc_Shore) diff --git a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/globalScripts/DieManager.gd b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/globalScripts/DieManager.gd index 6579982..c565d6b 100644 --- a/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/globalScripts/DieManager.gd +++ b/Phase2/Godot_GameCode/_MVP_Game_Demo/Doug/bcirpg_game_mvp_2024_0204A/globalScripts/DieManager.gd @@ -44,12 +44,16 @@ func setDieManager(dice, percent): #Load the diceInPlay array func loadData(): for elem in desiredDice: - if elem in validDieTypes: - diceUsed.append(Die.new(elem)) + if int(elem) in validDieTypes: + diceUsed.append(Die.new(int(elem))) #conditional to check if two D10s are being used #if so, we know that a percentage roll is taking place - if len(desiredDice) == 2 && desiredDice[0] == 10 && desiredDice[1] == 10: + #if len(desiredDice) == 2 && desiredDice[0] == 10 && desiredDice[1] == 10: + # isPercentageRoll = true + #DKM TEMP: this is crashing 4/21/24 with strings coming through unchecked. Not sure what happened to the check that + # was functional here before. TODO on this is type-safe this DieRoller entirely. + if desiredDice.size() == 2 && int(desiredDice[0]) == 10 && int(desiredDice[1]) == 10: isPercentageRoll = true #Resets the data in the script