mirror of
https://github.com/RPG-Research/bcirpg.git
synced 2024-04-16 14:23:01 +00:00
Continued module-adding updates:
Incorporates Andrew's die roller as a singleton, and tests with JSON module code.
This commit is contained in:
parent
2f51e2228a
commit
c511015207
@ -0,0 +1,72 @@
|
||||
#COMMAND PROCESSOR:
|
||||
# Handles player input, including navigation on the map
|
||||
|
||||
extends Node
|
||||
|
||||
|
||||
var current_locale = null
|
||||
var current_opt1 = null
|
||||
var current_opt2 = null
|
||||
var current_opt3 = null
|
||||
|
||||
#Allows us to pass in the starting location
|
||||
func initialize(starting_locale) -> String:
|
||||
current_opt1 = get_node("../Background/MarginContainer/Rows/InputArea/VBoxContainer/option1")
|
||||
current_opt2 = get_node("../Background/MarginContainer/Rows/InputArea/VBoxContainer/option2")
|
||||
current_opt3 = get_node("../Background/MarginContainer/Rows/InputArea/VBoxContainer/option3")
|
||||
|
||||
current_opt1.grab_focus()
|
||||
return change_room(starting_locale)
|
||||
|
||||
#DKM TEMP: this must load from files written by toolset
|
||||
#Function that loads response from the option string chosen
|
||||
func process_command(option: String) -> String:
|
||||
var optCmd_Action = option.split(": ", false)
|
||||
if (optCmd_Action.size() < 2):
|
||||
return "Error: no valid command and action in option!"
|
||||
match optCmd_Action[0]:
|
||||
"Go":
|
||||
return go(optCmd_Action[1])
|
||||
"Wait":
|
||||
return "You rest a bit. Now what?"
|
||||
"Talk":
|
||||
return talk(optCmd_Action[1])
|
||||
"Examine":
|
||||
return examine(optCmd_Action[1])
|
||||
"Scream":
|
||||
return "You yell :'" + optCmd_Action[1].to_upper() +"'!!"
|
||||
_:
|
||||
return "Nothing happens! Command word was: " + optCmd_Action[0]
|
||||
|
||||
|
||||
|
||||
func go(action: String) -> String:
|
||||
var destination = action.split(" ", false)[0]
|
||||
if current_locale.exits.keys().has(destination):
|
||||
var change_response = change_room(current_locale.exits[destination])
|
||||
return PoolStringArray(["You go %s." % destination, change_response]).join("\n")
|
||||
else:
|
||||
return "That is not a valid place to go!"
|
||||
|
||||
#DKM TEMP: do an examination dictionary lookup here?
|
||||
func examine(action: String) -> String:
|
||||
return action.to_upper() + " looks about how you'd expect. [Dictionary lookup forthcoming]"
|
||||
|
||||
#DKM TEMP: dialog entry needed -- temp
|
||||
func talk(action: String) -> String:
|
||||
var target = action.split("to ", false)[0].to_upper()
|
||||
return target + " has little to say! [Dialog forthcoming]"
|
||||
|
||||
#Helper:
|
||||
func change_room(new_room: Locale) -> String:
|
||||
current_locale = new_room
|
||||
current_opt1.text = new_room.option1
|
||||
current_opt2.text = new_room.option2
|
||||
current_opt3.text = new_room.option3
|
||||
var exit_string = PoolStringArray(new_room.exits.keys()).join(" ")
|
||||
var strings = PoolStringArray([
|
||||
"You are now in: " + new_room.locale_name + ". " +
|
||||
new_room.locale_description,
|
||||
"Exits: " + exit_string
|
||||
]).join("\n")
|
||||
return strings;
|
@ -0,0 +1,18 @@
|
||||
#LOCALE MANAGER:
|
||||
# Temporary script holds connections between map items, using the two-way
|
||||
# connect_exit script available on Location class to wire up map.
|
||||
|
||||
extends Node
|
||||
|
||||
|
||||
#DKM TEMP: must load from toolset
|
||||
func _ready() -> void:
|
||||
#load_module()
|
||||
$Loc_Boat.connect_exit("east", $Loc_Shore)
|
||||
$Loc_Shore.connect_exit("north", $Loc_WoodsA1)
|
||||
$Loc_WoodsA1.connect_exit("north", $Loc_WoodsA2)
|
||||
$Loc_WoodsA2.connect_exit("east", $Loc_WoodsA3)
|
||||
$Loc_WoodsA3.connect_exit("north", $Loc_WoodsA4)
|
||||
|
||||
|
||||
|
@ -1,12 +1,20 @@
|
||||
{
|
||||
"Node_Boat1":{
|
||||
"Id":"Boat_001",
|
||||
"Node_Boat0":{
|
||||
"Id":"Boat_000",
|
||||
"Action":"ShowText",
|
||||
"A_Params":"",
|
||||
"Text":"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.",
|
||||
"Option_Labels":["Examine Ship","Climb out through hatch","Play the fiddle!","Rest","Meditate"],
|
||||
"Option_GoTos":["Boat_002","Shore_001","Misc_001","Misc_002","Misc_003"]
|
||||
},
|
||||
"Node_Boat1":{
|
||||
"Id":"Boat_001",
|
||||
"Action":"ShowText",
|
||||
"A_Params":"",
|
||||
"Text":"The boat rocks gently. You can leave the boat through a hatch. There is also now a test option.",
|
||||
"Option_Labels":["Examine Ship","Climb out through hatch","Play the fiddle!","Rest","Meditate", "Run die roll test"],
|
||||
"Option_GoTos":["Boat_002","Shore_001","Misc_001","Misc_002","Misc_003","Test_000"]
|
||||
},
|
||||
"Node_Boat_002":{
|
||||
"Id":"Boat_002",
|
||||
"Action":"ShowText",
|
||||
@ -46,5 +54,13 @@
|
||||
"Text":"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.",
|
||||
"Option_Labels":["Resume your quest"],
|
||||
"Option_GoTos":["Boat_001"]
|
||||
}
|
||||
},
|
||||
"Node_Test0":{
|
||||
"Id":"Test_000",
|
||||
"Action":"TestDieRollAction",
|
||||
"A_Params":[4,6],
|
||||
"Text":"NA",
|
||||
"Option_Labels":["NA"],
|
||||
"Option_GoTos":["Boat_001"]
|
||||
},
|
||||
}
|
@ -20,4 +20,4 @@ keyboard_layout=2
|
||||
|
||||
[theme]
|
||||
|
||||
theme_selection=1
|
||||
theme_selection=0
|
||||
|
@ -17,13 +17,8 @@ const TextOutput = preload("res://UserInterface/Response.tscn")
|
||||
const InputResponse = preload("res://UserInterface/InputResponse.tscn")
|
||||
const OptionOutput = preload("res://UserInterface/Option.tscn")
|
||||
|
||||
onready var command_processor = $CommandProcessor
|
||||
onready var current_text = $Background/MarginContainer/Rows/GameInfo/CurrentText
|
||||
onready var history_pager = $Background/MarginContainer/Rows/ItemList/But_History_Page
|
||||
onready var options_container = $Background/MarginContainer/Rows/InputArea/OptionsContainer
|
||||
onready var option_one = $Background/MarginContainer/Rows/InputArea/VBoxContainer/option1
|
||||
onready var option_two= $Background/MarginContainer/Rows/InputArea/VBoxContainer/option2
|
||||
onready var option_three = $Background/MarginContainer/Rows/InputArea/VBoxContainer/option3
|
||||
onready var options_container = $Background/MarginContainer/Rows/InputArea/ScrollContainer/OptionsContainer
|
||||
onready var pSingleton = get_node("/root/PlayerCharacter")
|
||||
onready var charSheet = $Con_charSheet/MarginContainer/VBoxContainer/CharacterSheet
|
||||
|
||||
@ -43,8 +38,8 @@ func _ready() -> void:
|
||||
|
||||
#DKM TEMP: this needs to be refactored to reposition this initialization
|
||||
var i = 0
|
||||
print("Looking for JSON at: " + module_file_path)
|
||||
print("Json returned as: " + str(moduleDict))
|
||||
#print("Looking for JSON at: " + module_file_path)
|
||||
#print("Json returned as: " + str(moduleDict))
|
||||
var initialNode = Locale.new()
|
||||
nodeArray = [initialNode]
|
||||
for moduleNode in moduleDict.values():
|
||||
@ -53,15 +48,19 @@ func _ready() -> void:
|
||||
nodeArray.append(newNode)
|
||||
nodeArray[i].locale_name = moduleNode.get("Id")
|
||||
nodeArray[i].locale_description = moduleNode.get("Text")
|
||||
nodeArray[i].locale_action = moduleNode.get("Action")
|
||||
var actionParameters = moduleNode.get("A_Params")
|
||||
for p in actionParameters:
|
||||
nodeArray[i].locale_action_params.append(p)
|
||||
var nodeOptions = moduleNode.get("Option_Labels")
|
||||
for option in nodeOptions:
|
||||
nodeArray[i].options_array.append(option)
|
||||
print("For #" + str(i) + ": appended option of: " + str(option))
|
||||
#print("For #" + str(i) + ": appended option of: " + str(option))
|
||||
var nodeDestinations = moduleNode.get("Option_GoTos")
|
||||
for dest in nodeDestinations:
|
||||
nodeArray[i].destinations_array.append(dest)
|
||||
print("For #" + str(i) + ": appended go to destination of: " + str(dest))
|
||||
print("Node array name for #" + str(i) + ": " + nodeArray[i].locale_name)
|
||||
#print("For #" + str(i) + ": appended go to destination of: " + str(dest))
|
||||
#print("Node array name for #" + str(i) + ": " + nodeArray[i].locale_name)
|
||||
i = i+1
|
||||
|
||||
current_text.show()
|
||||
@ -77,6 +76,7 @@ func _ready() -> void:
|
||||
var destArr = nodeArray[0].destinations_array
|
||||
create_option(option, destArr[i])
|
||||
i = i+1
|
||||
options_container.get_child(0).grab_focus()
|
||||
|
||||
#DKM TEMP: convert JSON file to dictionary for module import:
|
||||
func loadJSONToDict(filepath:String)->Dictionary:
|
||||
@ -88,16 +88,6 @@ func loadJSONToDict(filepath:String)->Dictionary:
|
||||
return moduleDict
|
||||
|
||||
|
||||
|
||||
#Below temporarily takes user selection and appends it to responses; adding new instances
|
||||
# of our input row with an input and response pair for each
|
||||
func handleUserInput(user_choice: String) -> void:
|
||||
var input_response = InputResponse.instance()
|
||||
var inputText = "User selected: " + user_choice
|
||||
var response = command_processor.process_command(user_choice)
|
||||
input_response.set_text(inputText, response)
|
||||
add_response_to_game(input_response)
|
||||
|
||||
#Handles input text
|
||||
func create_response(response_text: String):
|
||||
var response = TextOutput.instance()
|
||||
@ -126,7 +116,7 @@ func clear_prior_options() -> void:
|
||||
n.queue_free()
|
||||
|
||||
func create_option(option: String, dest: String) -> void:
|
||||
print("Received request to make option for label: " + option +"; and destination: " + dest)
|
||||
#print("Received request to make option for label: " + option +"; and destination: " + dest)
|
||||
var optionNew = OptionOutput.instance()
|
||||
optionNew.destinationLabel = dest
|
||||
optionNew.text = option
|
||||
@ -136,7 +126,7 @@ func add_option_to_game(optionNew: Control) -> void:
|
||||
options_container.add_child(optionNew)
|
||||
var newOptNumber = options_container.get_child_count()
|
||||
if newOptNumber-1 >= 0:
|
||||
print("New added opt is: " + str(newOptNumber-1))
|
||||
#print("New added opt is: " + str(newOptNumber-1))
|
||||
options_container.get_child(newOptNumber-1).connect("option_pressed", self, "_on_option_pressed")
|
||||
|
||||
#DKM TEMP: these need to be dynamically added with the options themselves
|
||||
@ -151,16 +141,44 @@ func get_node_by_name(nodeName: String) -> Locale:
|
||||
return n
|
||||
return nodeArray[0]
|
||||
|
||||
func change_node(destinationNode: String) -> void:
|
||||
func change_node(destinationNode: String, destinationParams: Array = []) -> void:
|
||||
var target_Locale = get_node_by_name(destinationNode)
|
||||
create_response(target_Locale.locale_description)
|
||||
#DKM TEMP: another that needs to be broken out when ready:
|
||||
clear_prior_options()
|
||||
var i = 0
|
||||
for option in target_Locale.options_array:
|
||||
var destArr = target_Locale.destinations_array
|
||||
create_option(option, destArr[i])
|
||||
i = i+1
|
||||
|
||||
#Run provided action:
|
||||
if target_Locale.locale_action == "ShowText":
|
||||
create_response(target_Locale.locale_description)
|
||||
#DKM TEMP: another that needs to be broken out when ready:
|
||||
clear_prior_options()
|
||||
var i = 0
|
||||
for option in target_Locale.options_array:
|
||||
var destArr = target_Locale.destinations_array
|
||||
create_option(option, destArr[i])
|
||||
i = i+1
|
||||
elif target_Locale.locale_action == "TestDieRollAction" && target_Locale.destinations_array.size() == 1:
|
||||
print("Running test action " + target_Locale.locale_action + "; with parameters of: ")
|
||||
var nodeParameters = []
|
||||
for param in target_Locale.locale_action_params:
|
||||
print(param)
|
||||
nodeParameters.append(param)
|
||||
#DKM TEST: testing the die roller with Andrew's code; randomly assigning percentage to pass.
|
||||
# Should this param be optional if you purely want to roll dice?
|
||||
var dieParams = nodeParameters
|
||||
DiceRoller.dieManager.clearData()
|
||||
DiceRoller.dieManager.setDieManager(dieParams, 0.5)
|
||||
var result = DiceRoller.dieManager.rollDice()
|
||||
print("Rolled values: " + str(result[0]))
|
||||
|
||||
#DKM TEMP: Andrew's code for ref:
|
||||
#assigning variable names to each of them for better clarity
|
||||
# var rolledValues = result[0]
|
||||
# var percentRolled = result[1]
|
||||
# var passResult = result[2]
|
||||
# var neededPercent = result[3]
|
||||
# var degreeOfSuccess = result[4]
|
||||
# var dice = result[5]
|
||||
|
||||
change_node(target_Locale.destinations_array[0])
|
||||
options_container.get_child(0).grab_focus()
|
||||
|
||||
|
||||
#DKM TEMP: saves the entire scene in one packed scene file
|
||||
|
@ -1,9 +1,8 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://gamePlay/But_Option.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://gamePlay/Game.gd" type="Script" id=2]
|
||||
[ext_resource path="res://assets/ui_controlNode_dark_theme.tres" type="Theme" id=3]
|
||||
[ext_resource path="res://gamePlay/CommandProcessor.gd" type="Script" id=4]
|
||||
[ext_resource path="res://gamePlay/But_MoreOptions.gd" type="Script" id=9]
|
||||
|
||||
[node name="Game" type="Control"]
|
||||
@ -15,9 +14,6 @@ __meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="CommandProcessor" type="Node" parent="."]
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="Background" type="PanelContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
@ -79,14 +75,19 @@ margin_right = 708.0
|
||||
margin_bottom = 568.0
|
||||
rect_min_size = Vector2( 0, 120 )
|
||||
|
||||
[node name="OptionsContainer" type="VBoxContainer" parent="Background/MarginContainer/Rows/InputArea"]
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="Background/MarginContainer/Rows/InputArea"]
|
||||
margin_left = 1.0
|
||||
margin_top = 1.0
|
||||
margin_right = 707.0
|
||||
margin_bottom = 119.0
|
||||
|
||||
[node name="OptionsContainer" type="VBoxContainer" parent="Background/MarginContainer/Rows/InputArea/ScrollContainer"]
|
||||
margin_right = 108.0
|
||||
margin_bottom = 36.0
|
||||
custom_constants/separation = 5
|
||||
|
||||
[node name="option1" parent="Background/MarginContainer/Rows/InputArea/OptionsContainer" instance=ExtResource( 1 )]
|
||||
[node name="option1" parent="Background/MarginContainer/Rows/InputArea/ScrollContainer/OptionsContainer" instance=ExtResource( 1 )]
|
||||
margin_right = 108.0
|
||||
|
||||
[node name="Con_charSheet" type="PanelContainer" parent="."]
|
||||
anchor_left = 1.0
|
||||
|
@ -0,0 +1,69 @@
|
||||
#This script is for the overarching node that will contain the diemanager singleton
|
||||
#It should be the only one of the die scripts that is attached onto a node.
|
||||
|
||||
extends Control
|
||||
|
||||
#desired dice types and needed percentage to pass are selected by game/user
|
||||
#desiredDice takes an int array representing the # sides on the die/dice
|
||||
#neededPercentageToPass takes a float that
|
||||
export var desiredDice: Array
|
||||
export var neededPercentageToPass: float
|
||||
|
||||
#Define dieManager variable
|
||||
var dieManager
|
||||
|
||||
func _ready():
|
||||
#create diemanager object
|
||||
dieManager = DieManager.new(desiredDice, neededPercentageToPass)
|
||||
|
||||
#function gets the result of the roll(s) and shows it in the UI
|
||||
func _on_Die_button_down():
|
||||
#rollDice function returns an array with the following elements in the following positions:
|
||||
#rollDice result: [[rolledValues], percentRolled, passResult, neededPercent, degreeOfSuccess, dice]
|
||||
var result = dieManager.rollDice()
|
||||
|
||||
|
||||
#assigning variable names to each of them for better clarity
|
||||
var rolledValues = result[0]
|
||||
var percentRolled = result[1]
|
||||
var passResult = result[2]
|
||||
var neededPercent = result[3]
|
||||
var degreeOfSuccess = result[4]
|
||||
var dice = result[5]
|
||||
|
||||
|
||||
#Check if passed or not
|
||||
if passResult:
|
||||
$Outcome.text = "Successful Roll!"
|
||||
else:
|
||||
$Outcome.text = "Failed Roll!"
|
||||
|
||||
var diceResultText = "Rolled Values:\n"
|
||||
|
||||
#Prints the integer calues of each die rolled in the form: "D(num faces): (value rolled)"
|
||||
for i in range(dice.size()):
|
||||
diceResultText += ("D" + str(dice[i]) + ": " + str(rolledValues[i]) + "\n")
|
||||
|
||||
#changing labels on screen
|
||||
$RolledValues.text = diceResultText
|
||||
$PercentNeeded.text = "Percent Needed to Pass: " + str(neededPercent * 100) + "%"
|
||||
$PercentRolled.text = "Percent Rolled: " + str(percentRolled * 100) + "%"
|
||||
$DegreeOfSuccess.text = "Degree of Success: " + str(degreeOfSuccess * 100) + "%"
|
||||
|
||||
#revealing labels to user
|
||||
$Outcome.show()
|
||||
$RolledValues.show()
|
||||
$PercentNeeded.show()
|
||||
$PercentRolled.show()
|
||||
$DegreeOfSuccess.show()
|
||||
|
||||
|
||||
#Calls the cleardata method for the diemanager and hides the text on screen
|
||||
func _on_Reset_button_down():
|
||||
$Outcome.hide()
|
||||
$PercentNeeded.hide()
|
||||
$PercentRolled.hide()
|
||||
$DegreeOfSuccess.hide()
|
||||
$RolledValues.hide()
|
||||
dieManager.clearData()
|
||||
dieManager.setDieManager(desiredDice, neededPercentageToPass)
|
@ -0,0 +1,24 @@
|
||||
#Die class
|
||||
extends Node2D
|
||||
|
||||
class_name Die
|
||||
|
||||
#value of selected die type
|
||||
var numFaces: int
|
||||
|
||||
#Class constructor
|
||||
func _init(value):
|
||||
numFaces = value
|
||||
|
||||
#returns an integer value of the rolled result (assuming the die is a valid type)
|
||||
func rollDie():
|
||||
randomize()
|
||||
|
||||
var rolledNum
|
||||
rolledNum = randi() % numFaces + 1
|
||||
return rolledNum
|
||||
|
||||
|
||||
#Returns the number of faces on this die
|
||||
func getNumFaces():
|
||||
return numFaces
|
@ -0,0 +1,130 @@
|
||||
#This is the diemanager script that controls the rolling of the die/dice as well as calculates
|
||||
#the end result
|
||||
|
||||
class_name DieManager
|
||||
|
||||
extends Node2D
|
||||
|
||||
#Array of the desired dice values to mod god wants
|
||||
var desiredDice: Array
|
||||
|
||||
#User can select the percentage needed for a successful roll
|
||||
var neededPercentageToPass: float
|
||||
|
||||
var validDieTypes = [4, 6, 8, 10, 12, 20]
|
||||
#boolean for if a percentageroll is taking place
|
||||
#we need a boolean for this because the way a percentage roll is calculated
|
||||
#with two D10s is different than if one were using other dice
|
||||
var isPercentageRoll = false
|
||||
|
||||
#diceUsed holds the dice objects that are rolled
|
||||
var diceUsed = []
|
||||
|
||||
#rolledValues holds the integer value rolled from each die
|
||||
var rolledValues = []
|
||||
|
||||
#boolean based on whether the overall roll passed or not
|
||||
var passedRoll
|
||||
|
||||
#float holding the degree of success (rolledVal - neededPercentageToPass)
|
||||
var degreeOfSuccess
|
||||
|
||||
#Constructor for diemanager class
|
||||
func _init(dice, percent):
|
||||
desiredDice = dice
|
||||
neededPercentageToPass = percent
|
||||
loadData()
|
||||
|
||||
#set values of diemanager
|
||||
func setDieManager(dice, percent):
|
||||
desiredDice = dice
|
||||
neededPercentageToPass = percent
|
||||
loadData()
|
||||
|
||||
#Load the diceInPlay array
|
||||
func loadData():
|
||||
for elem in desiredDice:
|
||||
if elem in validDieTypes:
|
||||
diceUsed.append(Die.new(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:
|
||||
isPercentageRoll = true
|
||||
|
||||
#Resets the data in the script
|
||||
func clearData():
|
||||
isPercentageRoll = false
|
||||
rolledValues = []
|
||||
desiredDice = []
|
||||
diceUsed = []
|
||||
neededPercentageToPass = 0
|
||||
|
||||
#Returns the percent value of an individual die
|
||||
#Stores the rolled value in rolledValues
|
||||
func returnDiePercentage(inputedDie):
|
||||
#In case this method is being called on no dice
|
||||
if len(diceUsed) == 0:
|
||||
push_error("Cannot roll without any dice!")
|
||||
|
||||
var rolledVal = inputedDie.rollDie()
|
||||
|
||||
#add rolled integer value to array
|
||||
rolledValues.append(rolledVal)
|
||||
|
||||
#Checks if a percentageroll is being done
|
||||
if isPercentageRoll:
|
||||
#This conditional is used to detemrine if the rolled value is
|
||||
#for the tens or ones digit
|
||||
return float(rolledVal % 10)
|
||||
|
||||
return float(rolledVal) / float(inputedDie.numFaces)
|
||||
|
||||
#Rolls all of the dice in diceUsed
|
||||
#returns the average of all the percentages
|
||||
func rollDice():
|
||||
#In case this method is being called on no dice
|
||||
if len(diceUsed) == 0:
|
||||
push_error("Cannot roll without any dice!")
|
||||
|
||||
#denominator will equal the total number of dice rolled
|
||||
var denominator = 0
|
||||
|
||||
#sum of floats of all rolled die percentages
|
||||
var sumOfPercentages = 0
|
||||
|
||||
if isPercentageRoll:
|
||||
sumOfPercentages += (returnDiePercentage(diceUsed[0]) / 10.0) + (returnDiePercentage(diceUsed[1]) / 100.0)
|
||||
else:
|
||||
#DKM TEMP: not percentage roll:
|
||||
print("TEMP: not percentage roll")
|
||||
for die in diceUsed:
|
||||
sumOfPercentages += returnDiePercentage(die)
|
||||
denominator += 1
|
||||
|
||||
var result = []
|
||||
|
||||
result.append(rolledValues)
|
||||
|
||||
if isPercentageRoll:
|
||||
#Percentage roll result remains the sum of the rolls
|
||||
result.append(sumOfPercentages)
|
||||
else:
|
||||
if denominator == 0:
|
||||
result.append(0)
|
||||
#result is average of sum of percentages otherwise rounded to 2 decimcal places
|
||||
|
||||
result.append(stepify((float(sumOfPercentages) / float(denominator)), 0.0001))
|
||||
|
||||
passedRoll = (result[1] >= neededPercentageToPass)
|
||||
#NOTE: degree of success is always calculated regardlesss of success/failure. Let me know if this should be changed
|
||||
degreeOfSuccess = result[1] - neededPercentageToPass
|
||||
result.append(passedRoll)
|
||||
result.append(neededPercentageToPass)
|
||||
result.append(degreeOfSuccess)
|
||||
result.append(desiredDice)
|
||||
|
||||
#rollDice result: [[rolledValues], percentRolled, passResult, neededPercent, degreeOfSuccess, dice]
|
||||
return result
|
||||
|
||||
|
@ -9,6 +9,16 @@
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ {
|
||||
"base": "Node2D",
|
||||
"class": "Die",
|
||||
"language": "GDScript",
|
||||
"path": "res://globalScripts/Die.gd"
|
||||
}, {
|
||||
"base": "Node2D",
|
||||
"class": "DieManager",
|
||||
"language": "GDScript",
|
||||
"path": "res://globalScripts/DieManager.gd"
|
||||
}, {
|
||||
"base": "Resource",
|
||||
"class": "HistoryScreensTemplateSingleton",
|
||||
"language": "GDScript",
|
||||
@ -30,6 +40,8 @@ _global_script_classes=[ {
|
||||
"path": "res://globalScripts/playerCharacterTemplate.gd"
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
"Die": "",
|
||||
"DieManager": "",
|
||||
"HistoryScreensTemplateSingleton": "",
|
||||
"Locale": "",
|
||||
"PlayerSettingsTemplate": "",
|
||||
@ -46,8 +58,9 @@ config/icon="res://icon.png"
|
||||
|
||||
History="*res://globalScripts/history.gd"
|
||||
PlayerCharacter="*res://globalScripts/PlayerCharacter.gd"
|
||||
GameCurrent="*res://globalScripts/gameCurrent.gd"
|
||||
DiceRoller="*res://globalScripts/DiceRoller.gd"
|
||||
GlobalSaveInstance="*res://globalScripts/globalSaveInstance.gd"
|
||||
GameCurrent="*res://globalScripts/gameCurrent.gd"
|
||||
|
||||
[physics]
|
||||
|
||||
|
@ -12,15 +12,13 @@ extends PanelContainer
|
||||
#Allows Godot to handle autocomplete and 'register' class
|
||||
class_name Locale
|
||||
|
||||
export (String) var locale_name = "Location Name"
|
||||
export (String) var locale_description = "This is the description of the location."
|
||||
var locale_name = "Location Name"
|
||||
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 = []
|
||||
|
||||
#DKM TEMP: assuming this gets set here
|
||||
export (String) var option1 = "Option 1"
|
||||
export (String) var option2 = "Option 2"
|
||||
export (String) var option3 = "Option 3"
|
||||
|
||||
var visited = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user