Change 2 for cleanup

This commit is contained in:
PersonGuyGit
2023-07-09 12:28:09 -06:00
parent 707e8a5b16
commit 2c971b6e7c
1741 changed files with 0 additions and 0 deletions

View File

@ -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)

View File

@ -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

View File

@ -0,0 +1,128 @@
#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:
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

View File

@ -0,0 +1,11 @@
#PLAYER CHARACTER:
# Unique handler script for root PC singleton. May be adapted for
# player loading and saving functionality
extends Node
var pc
func _ready() -> void:
pc = playerCharacterTemplate.new()

View File

@ -0,0 +1,10 @@
#gameCurrent:
# Simple singleton script for storing persistent game cene paths.
# These must then not be destroyed, but manually removed as a child of the
# node and they can always be re-added as needed.
extends Node
var gameCurrent_scene

View File

@ -0,0 +1,44 @@
extends Node
# Declare new settings template object
var settingsInstance = PlayerSettingsTemplate.new()
var settings_file = "res://_userFiles/PlayerPreferences.cfg"
func _ready() -> void:
load_settings_file()
#Config/ini:
func load_settings_file():
var config = ConfigFile.new()
# Load data from a file.
var err = config.load(settings_file)
# If the file didn't load, ignore it.
if err != OK:
return
#Preferences:
settingsInstance.inputName = config.get_value("player_preferences", "player_name")
settingsInstance.riskFactor = config.get_value("player_preferences", "risk_threshold")
#Controls:
settingsInstance.fontSize = config.get_value("visual_controls", "font_size")
settingsInstance.brightness = config.get_value("visual_controls", "brightness")
#General Settings:
settingsInstance.volume = config.get_value("general_settings", "volume")
settingsInstance.bClosedCaptions = config.get_value("general_settings", "closed_captions")
settingsInstance.bdevConsole = config.get_value("general_settings", "dev_console")
#Keyboard:
settingsInstance.visualKeyboardLayout = config.get_value("virtual_keyboard", "keyboard_layout")
#Theme:
settingsInstance.themeChoiceInt = config.get_value("theme", "theme_selection")
load_themeFile()
#DKM TEMP: working
print("Input name loaded as: " + str(settingsInstance.inputName))
print("Theme loaded as: " + str(settingsInstance.themeFile))
func load_themeFile() -> void:
#DKM TEMP: this shouldn't be hard-coded:
if(settingsInstance.themeChoiceInt == 1):
settingsInstance.themeFile = "res://assets/ui_controlNode_light_theme.tres"
else:
settingsInstance.themeFile = "res://assets/ui_controlNode_dark_theme.tres"

View File

@ -0,0 +1,31 @@
#HISTORY:
# Unique handler script for root history singleton. May be adapted for
# history loading and saving functionality
extends Node
#DKM TEMP: not a cfg?
var history_file = "user://history.tres"
var historyScreensSingleton
var testing = false
func _ready() -> void:
if(testing):
historyScreensSingleton = load_history_file()
if (historyScreensSingleton == null):
historyScreensSingleton = HistoryScreensTemplateSingleton.new()
#DKM temp:
print("Loaded history array size is: " + str(historyScreensSingleton.output_history_array.size()))
#DKM TEMP: load using tres format:
func load_history_file() -> HistoryScreensTemplateSingleton:
if ResourceLoader.exists(history_file):
var history = ResourceLoader.load(history_file)
if history is HistoryScreensTemplateSingleton:
return history
else: return null
else:
return null

View File

@ -0,0 +1,8 @@
#PLAYERSETTINGSTEMPLATE:
# Class for holding history screens
extends Resource
class_name HistoryScreensTemplateSingleton
var output_history_array = Array()

View File

@ -0,0 +1,57 @@
#PLAYER CHARACTER TEMPLATE:
# Template for holding loaded/current character
extends Resource
class_name playerCharacterTemplate
var pcText = ""
#BCO-RPG SRIS system (percentile):
var viableCharStats = ["AG",
"APP",
"CO",
"QU",
"MD",
"ST",
"CH",
"EM",
"IN",
"ME",
"MX",
"PR",
"RE",
"SD"]
var agility = 0
var appearance = 0
var constitution = 0
var quickness = 0
var manual_dexterity = 0
var strength = 0
var chutzpah = 0
var empathy = 0
var intuition = 0
var memory = 0
var moxie = 0
var presence = 0
var reasoning = 0
var self_discipline = 0
func toString() -> String:
return("pcText: " + str(pcText) +
"; Agility: " + str(agility) +
"; Appearance: " + str(appearance) +
"; Constitution: " + str(constitution) +
"; Quickness: " + str(quickness) +
"; Manual_dexterity: " + str(manual_dexterity) +
"; Strength: " + str(strength) +
"; Chutzpah: " + str(chutzpah) +
"; Empathy: " + str(empathy) +
"; Intuition: " + str(intuition) +
"; Memory: " + str(memory) +
"; Moxie: " + str(moxie) +
"; Presence: " + str(presence) +
"; Reasoning: " + str(reasoning) +
"; Self_discipline: " + str(self_discipline)
)

View File

@ -0,0 +1,26 @@
extends Node
class_name PlayerSettingsTemplate
# Declare Setting Options, to be used inside of the settings menu
var inputName = "none"
var riskFactor = 0
var brightness = 3
var fontSize = 11
var volume = 6
var bClosedCaptions = true
var bdevConsole = false
var bVirtualKeyboard = false
# Setting of 0 is Qwerty, Setting of 1 is Davorak, Setting of 2 is Alphabetical
var visualKeyboardLayout = 0
# Setting of 0 is dark, setting of 1 is light, and so on
var themeChoiceInt = 0
var themeFile = "res://assets/ui_controlNode_dark_theme.tres"
func _ready():
pass