From c2ea759e6d708946ded602f569c81d7c69f9a84d Mon Sep 17 00:00:00 2001 From: Taylor Howell Date: Sat, 9 Dec 2023 01:34:39 -0600 Subject: [PATCH] updating variable factory and adding start and exit functions --- .../Function Definitions/ExitFunction.cs | 24 ++++++++++++ .../Function Definitions/StartFunction.cs | 23 ++++++++++++ .../VariableTypes/VariableFactory.cs | 37 ++++++++++++++++++- 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 State Machine/Function Definitions/ExitFunction.cs create mode 100644 State Machine/Function Definitions/StartFunction.cs diff --git a/State Machine/Function Definitions/ExitFunction.cs b/State Machine/Function Definitions/ExitFunction.cs new file mode 100644 index 0000000..fcd96c3 --- /dev/null +++ b/State Machine/Function Definitions/ExitFunction.cs @@ -0,0 +1,24 @@ +using ValkyrieFSMCore; + +namespace Valkyrie_Server.State_Machine.Function_Definitions +{ + public class ExitFunction : FunctionDefinition + { + + public ExitFunction() + { + DefineFunction(); + } + + protected override void DefineFunction() + { + + ///close or resolve anything that might be neccesary for the process to complete here... + + Function = () => + { + return 1; //exit the process + }; + } + } +} diff --git a/State Machine/Function Definitions/StartFunction.cs b/State Machine/Function Definitions/StartFunction.cs new file mode 100644 index 0000000..1670a36 --- /dev/null +++ b/State Machine/Function Definitions/StartFunction.cs @@ -0,0 +1,23 @@ +using ValkyrieFSMCore; + +namespace Valkyrie_Server.State_Machine.Function_Definitions +{ + public sealed class StartFunction : FunctionDefinition + { + public StartFunction() + { + DefineFunction(); + } + + protected override void DefineFunction() + { + + //do any setting up needed here if desired + + Function = () => + { + return 1; //boot the process and start normally. + }; + } + } +} diff --git a/State Machine/VariableTypes/VariableFactory.cs b/State Machine/VariableTypes/VariableFactory.cs index 3c408c6..050578b 100644 --- a/State Machine/VariableTypes/VariableFactory.cs +++ b/State Machine/VariableTypes/VariableFactory.cs @@ -27,12 +27,47 @@ public class VariableFactory /// void Register() { - VariableConstructors.Add("projects", ("this variable maps to a list of projects", (key, io) => + VariableConstructors.Add("projects", ("this type maps to a list of projects", (key, io) => { var x = VariableDefinition>.CreateCustom(key, "projects", new List(), io); return x; } )); + + VariableConstructors.Add("project", ("this is a project type", (key, io) => + { + var x = VariableDefinition.CreateCustom(key, "project", new Project(), io); + return x; + } + )); + + VariableConstructors.Add("string", ("this is a text type that can store words, special characters. and numbers (not the value of the number).", (key, io) => + { + var x = VariableDefinition.CreateCustom(key, "string", "", io); + return x; + } + )); + + VariableConstructors.Add("decimal", ("the type represents decimal values (ex. 1.0, 2.34, -32.355 ...)", (key, io) => + { + var x = VariableDefinition.CreateCustom(key, "decimal", 0, io); // 👈 I know this is not an actual decimal type value. human readability is what I am after... + return x; + } + )); + + VariableConstructors.Add("integer", ("this type represents whole number values (ex. 1, 5 ,-3 ...)", (key, io) => + { + var x = VariableDefinition.CreateCustom(key, "integer", 0, io); + return x; + } + )); + + VariableConstructors.Add("boolean", ("this type is either true or false", (key, io) => + { + var x = VariableDefinition.CreateCustom(key, "boolean", false, io); + return x; + } + )); } ///