commit 8ceb9a2dd8d39872b5e938a69e814fca0b69edd3 Author: Tanner Van Teeffelen Date: Thu Jul 10 05:05:12 2025 +0000 Initial commit. diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..8225ba4 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/bin/Debug/net8.0/MiniRPG.dll", + "args": [], + "cwd": "${workspaceFolder}", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..c954827 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/MiniRPG.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/MiniRPG.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/MiniRPG.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Main.cs b/Main.cs new file mode 100644 index 0000000..55fc8c1 --- /dev/null +++ b/Main.cs @@ -0,0 +1,43 @@ +using System; +using System.Linq; +using System.Collections.Generic; +using Microsoft.VisualBasic; + +class Program +{ + static void Main() + { + List allItems = ItemLoader.LoadAllItems("data/items.json"); + + Player user = new("Tanner", [], 100, 90, 20, 20); + Console.WriteLine($"{user.Name} has {user.CurrentHealth}/{user.MaxHealth} Hit Points.\n"); + Console.WriteLine($"{user.Name} has {user.CurrentMPoints}/{user.MaxMPoints} Mana Points.\n"); + + user.Inventory.Add(allItems.FirstOrDefault(m => m.Name == "Potion")); + user.Inventory.Add(allItems.FirstOrDefault(m => m.Name == "Potion")); + user.Inventory.Add(allItems.FirstOrDefault(m => m.Name == "Potion")); + user.Inventory.Add(allItems.FirstOrDefault(m => m.Name == "Elixir")); + + Console.WriteLine($"{user.Name}'s current inventory:"); + foreach (var inv in user.RetrieveInventory()) + { + Console.WriteLine($"{inv.Key}: {inv.Value}"); + } + + Console.WriteLine("Do you want to use your Potion? (Y/N)"); + string input = Console.ReadLine().ToUpper(); + + if (input == "Y") + { + user.UseHealingItem((HealingItem)user.Inventory.FirstOrDefault(m => m.Name == "Potion")); + user.Inventory.Remove(user.Inventory.FirstOrDefault(m => m.Name == "Potion")); + } + + Console.WriteLine($"{user.Name} has {user.CurrentHealth}/{user.MaxHealth} Hit Points.\n"); + Console.WriteLine($"\n{user.Name}'s current inventory:"); + foreach (var inv in user.RetrieveInventory()) + { + Console.WriteLine($"{inv.Key}: {inv.Value}"); + } + } +} diff --git a/MiniRPG.csproj b/MiniRPG.csproj new file mode 100644 index 0000000..864c7c4 --- /dev/null +++ b/MiniRPG.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/bin/Debug/net8.0/MiniRPG b/bin/Debug/net8.0/MiniRPG new file mode 100755 index 0000000..3f3ff2f Binary files /dev/null and b/bin/Debug/net8.0/MiniRPG differ diff --git a/bin/Debug/net8.0/MiniRPG.deps.json b/bin/Debug/net8.0/MiniRPG.deps.json new file mode 100644 index 0000000..6e2333b --- /dev/null +++ b/bin/Debug/net8.0/MiniRPG.deps.json @@ -0,0 +1,41 @@ +{ + "runtimeTarget": { + "name": ".NETCoreApp,Version=v8.0", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETCoreApp,Version=v8.0": { + "MiniRPG/1.0.0": { + "dependencies": { + "Newtonsoft.Json": "13.0.3" + }, + "runtime": { + "MiniRPG.dll": {} + } + }, + "Newtonsoft.Json/13.0.3": { + "runtime": { + "lib/net6.0/Newtonsoft.Json.dll": { + "assemblyVersion": "13.0.0.0", + "fileVersion": "13.0.3.27908" + } + } + } + } + }, + "libraries": { + "MiniRPG/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + }, + "Newtonsoft.Json/13.0.3": { + "type": "package", + "serviceable": true, + "sha512": "sha512-HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==", + "path": "newtonsoft.json/13.0.3", + "hashPath": "newtonsoft.json.13.0.3.nupkg.sha512" + } + } +} \ No newline at end of file diff --git a/bin/Debug/net8.0/MiniRPG.dll b/bin/Debug/net8.0/MiniRPG.dll new file mode 100644 index 0000000..689b2dc Binary files /dev/null and b/bin/Debug/net8.0/MiniRPG.dll differ diff --git a/bin/Debug/net8.0/MiniRPG.pdb b/bin/Debug/net8.0/MiniRPG.pdb new file mode 100644 index 0000000..1de3906 Binary files /dev/null and b/bin/Debug/net8.0/MiniRPG.pdb differ diff --git a/bin/Debug/net8.0/MiniRPG.runtimeconfig.json b/bin/Debug/net8.0/MiniRPG.runtimeconfig.json new file mode 100644 index 0000000..becfaea --- /dev/null +++ b/bin/Debug/net8.0/MiniRPG.runtimeconfig.json @@ -0,0 +1,12 @@ +{ + "runtimeOptions": { + "tfm": "net8.0", + "framework": { + "name": "Microsoft.NETCore.App", + "version": "8.0.0" + }, + "configProperties": { + "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false + } + } +} \ No newline at end of file diff --git a/bin/Debug/net8.0/Newtonsoft.Json.dll b/bin/Debug/net8.0/Newtonsoft.Json.dll new file mode 100755 index 0000000..d035c38 Binary files /dev/null and b/bin/Debug/net8.0/Newtonsoft.Json.dll differ diff --git a/data/items.json b/data/items.json new file mode 100644 index 0000000..6f1bb51 --- /dev/null +++ b/data/items.json @@ -0,0 +1,25 @@ +[ + { + "Name": "Potion", + "Description": "Restores HP that have been lost in battle by 20 HP.", + "Type": "Healing", + "HealingAmount": 20 + }, + { + "Name": "Super Potion", + "Description": "Restores HP that have been lost in battle by 50 HP.", + "Type": "Healing", + "HealingAmount": 50 + }, + { + "Name": "Hyper Potion", + "Description": "Restores HP that have been lost in battle by 200 HP.", + "Type": "Healing", + "HealingAmount": 200 + }, + { + "Name": "Elixir", + "Description": "A simple potion.", + "Type": "Support" + } +] \ No newline at end of file diff --git a/data/moves.json b/data/moves.json new file mode 100644 index 0000000..88f0891 --- /dev/null +++ b/data/moves.json @@ -0,0 +1,24 @@ +[ + { + "Name": "Fireball", + "Description": "A burst of fire that burns the enemy.", + "Power": 40, + "ManaCost": 10, + "Type": "Attack" + }, + { + "Name": "Heal", + "Description": "Restores a small amount of HP.", + "Power": 25, + "ManaCost": 5, + "Type": "Heal" + }, + { + "Name": "Lightning Bolt", + "Description": "A shocking magical strike.", + "Power": 50, + "ManaCost": 15, + "Type": "Attack" + } + ] + \ No newline at end of file diff --git a/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs b/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs new file mode 100644 index 0000000..dca70aa --- /dev/null +++ b/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")] diff --git a/obj/Debug/net8.0/MiniRPG.AssemblyInfo.cs b/obj/Debug/net8.0/MiniRPG.AssemblyInfo.cs new file mode 100644 index 0000000..b07493a --- /dev/null +++ b/obj/Debug/net8.0/MiniRPG.AssemblyInfo.cs @@ -0,0 +1,22 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("MiniRPG")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] +[assembly: System.Reflection.AssemblyProductAttribute("MiniRPG")] +[assembly: System.Reflection.AssemblyTitleAttribute("MiniRPG")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/obj/Debug/net8.0/MiniRPG.AssemblyInfoInputs.cache b/obj/Debug/net8.0/MiniRPG.AssemblyInfoInputs.cache new file mode 100644 index 0000000..dff91e9 --- /dev/null +++ b/obj/Debug/net8.0/MiniRPG.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +349b459bf4ade14fe01ed0c61903f28e8cbcd46aba882e73f23e247e57494e25 diff --git a/obj/Debug/net8.0/MiniRPG.GeneratedMSBuildEditorConfig.editorconfig b/obj/Debug/net8.0/MiniRPG.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 0000000..ff33d6c --- /dev/null +++ b/obj/Debug/net8.0/MiniRPG.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,13 @@ +is_global = true +build_property.TargetFramework = net8.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property.EnforceExtendedAnalyzerRules = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = MiniRPG +build_property.ProjectDir = /data/repos/MiniRPG/ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = diff --git a/obj/Debug/net8.0/MiniRPG.GlobalUsings.g.cs b/obj/Debug/net8.0/MiniRPG.GlobalUsings.g.cs new file mode 100644 index 0000000..8578f3d --- /dev/null +++ b/obj/Debug/net8.0/MiniRPG.GlobalUsings.g.cs @@ -0,0 +1,8 @@ +// +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Threading; +global using global::System.Threading.Tasks; diff --git a/obj/Debug/net8.0/MiniRPG.assets.cache b/obj/Debug/net8.0/MiniRPG.assets.cache new file mode 100644 index 0000000..3a3360b Binary files /dev/null and b/obj/Debug/net8.0/MiniRPG.assets.cache differ diff --git a/obj/Debug/net8.0/MiniRPG.csproj.AssemblyReference.cache b/obj/Debug/net8.0/MiniRPG.csproj.AssemblyReference.cache new file mode 100644 index 0000000..23bf494 Binary files /dev/null and b/obj/Debug/net8.0/MiniRPG.csproj.AssemblyReference.cache differ diff --git a/obj/Debug/net8.0/MiniRPG.csproj.CoreCompileInputs.cache b/obj/Debug/net8.0/MiniRPG.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..7283e83 --- /dev/null +++ b/obj/Debug/net8.0/MiniRPG.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +552d7776ba252b8ba7a98c694923b3d159470fb983c96ce88fa765b810f80c32 diff --git a/obj/Debug/net8.0/MiniRPG.csproj.FileListAbsolute.txt b/obj/Debug/net8.0/MiniRPG.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..65e8ac8 --- /dev/null +++ b/obj/Debug/net8.0/MiniRPG.csproj.FileListAbsolute.txt @@ -0,0 +1,17 @@ +/data/repos/MiniRPG/bin/Debug/net8.0/MiniRPG +/data/repos/MiniRPG/bin/Debug/net8.0/MiniRPG.deps.json +/data/repos/MiniRPG/bin/Debug/net8.0/MiniRPG.runtimeconfig.json +/data/repos/MiniRPG/bin/Debug/net8.0/MiniRPG.dll +/data/repos/MiniRPG/bin/Debug/net8.0/MiniRPG.pdb +/data/repos/MiniRPG/bin/Debug/net8.0/Newtonsoft.Json.dll +/data/repos/MiniRPG/obj/Debug/net8.0/MiniRPG.csproj.AssemblyReference.cache +/data/repos/MiniRPG/obj/Debug/net8.0/MiniRPG.GeneratedMSBuildEditorConfig.editorconfig +/data/repos/MiniRPG/obj/Debug/net8.0/MiniRPG.AssemblyInfoInputs.cache +/data/repos/MiniRPG/obj/Debug/net8.0/MiniRPG.AssemblyInfo.cs +/data/repos/MiniRPG/obj/Debug/net8.0/MiniRPG.csproj.CoreCompileInputs.cache +/data/repos/MiniRPG/obj/Debug/net8.0/MiniRPG.csproj.Up2Date +/data/repos/MiniRPG/obj/Debug/net8.0/MiniRPG.dll +/data/repos/MiniRPG/obj/Debug/net8.0/refint/MiniRPG.dll +/data/repos/MiniRPG/obj/Debug/net8.0/MiniRPG.pdb +/data/repos/MiniRPG/obj/Debug/net8.0/MiniRPG.genruntimeconfig.cache +/data/repos/MiniRPG/obj/Debug/net8.0/ref/MiniRPG.dll diff --git a/obj/Debug/net8.0/MiniRPG.csproj.Up2Date b/obj/Debug/net8.0/MiniRPG.csproj.Up2Date new file mode 100644 index 0000000..e69de29 diff --git a/obj/Debug/net8.0/MiniRPG.dll b/obj/Debug/net8.0/MiniRPG.dll new file mode 100644 index 0000000..689b2dc Binary files /dev/null and b/obj/Debug/net8.0/MiniRPG.dll differ diff --git a/obj/Debug/net8.0/MiniRPG.genruntimeconfig.cache b/obj/Debug/net8.0/MiniRPG.genruntimeconfig.cache new file mode 100644 index 0000000..535ea89 --- /dev/null +++ b/obj/Debug/net8.0/MiniRPG.genruntimeconfig.cache @@ -0,0 +1 @@ +63738d25709d41611ed29f640f81025116589b3756c1a110496abf35e5d4d7d2 diff --git a/obj/Debug/net8.0/MiniRPG.pdb b/obj/Debug/net8.0/MiniRPG.pdb new file mode 100644 index 0000000..1de3906 Binary files /dev/null and b/obj/Debug/net8.0/MiniRPG.pdb differ diff --git a/obj/Debug/net8.0/apphost b/obj/Debug/net8.0/apphost new file mode 100755 index 0000000..3f3ff2f Binary files /dev/null and b/obj/Debug/net8.0/apphost differ diff --git a/obj/Debug/net8.0/ref/MiniRPG.dll b/obj/Debug/net8.0/ref/MiniRPG.dll new file mode 100644 index 0000000..b558fd7 Binary files /dev/null and b/obj/Debug/net8.0/ref/MiniRPG.dll differ diff --git a/obj/Debug/net8.0/refint/MiniRPG.dll b/obj/Debug/net8.0/refint/MiniRPG.dll new file mode 100644 index 0000000..b558fd7 Binary files /dev/null and b/obj/Debug/net8.0/refint/MiniRPG.dll differ diff --git a/obj/MiniRPG.csproj.nuget.dgspec.json b/obj/MiniRPG.csproj.nuget.dgspec.json new file mode 100644 index 0000000..2f4364c --- /dev/null +++ b/obj/MiniRPG.csproj.nuget.dgspec.json @@ -0,0 +1,72 @@ +{ + "format": 1, + "restore": { + "/data/repos/MiniRPG/MiniRPG.csproj": {} + }, + "projects": { + "/data/repos/MiniRPG/MiniRPG.csproj": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "/data/repos/MiniRPG/MiniRPG.csproj", + "projectName": "MiniRPG", + "projectPath": "/data/repos/MiniRPG/MiniRPG.csproj", + "packagesPath": "/config/.nuget/packages/", + "outputPath": "/data/repos/MiniRPG/obj/", + "projectStyle": "PackageReference", + "configFilePaths": [ + "/config/.nuget/NuGet/NuGet.Config" + ], + "originalTargetFrameworks": [ + "net8.0" + ], + "sources": { + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net8.0": { + "targetAlias": "net8.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + }, + "restoreAuditProperties": { + "enableAudit": "true", + "auditLevel": "low", + "auditMode": "direct" + } + }, + "frameworks": { + "net8.0": { + "targetAlias": "net8.0", + "dependencies": { + "Newtonsoft.Json": { + "target": "Package", + "version": "[13.0.3, )" + } + }, + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "/data/dotnet/sdk/8.0.411/PortableRuntimeIdentifierGraph.json" + } + } + } + } +} \ No newline at end of file diff --git a/obj/MiniRPG.csproj.nuget.g.props b/obj/MiniRPG.csproj.nuget.g.props new file mode 100644 index 0000000..178c76b --- /dev/null +++ b/obj/MiniRPG.csproj.nuget.g.props @@ -0,0 +1,15 @@ + + + + True + NuGet + $(MSBuildThisFileDirectory)project.assets.json + /config/.nuget/packages/ + /config/.nuget/packages/ + PackageReference + 6.11.1 + + + + + \ No newline at end of file diff --git a/obj/MiniRPG.csproj.nuget.g.targets b/obj/MiniRPG.csproj.nuget.g.targets new file mode 100644 index 0000000..3dc06ef --- /dev/null +++ b/obj/MiniRPG.csproj.nuget.g.targets @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/obj/project.assets.json b/obj/project.assets.json new file mode 100644 index 0000000..c36e7e6 --- /dev/null +++ b/obj/project.assets.json @@ -0,0 +1,124 @@ +{ + "version": 3, + "targets": { + "net8.0": { + "Newtonsoft.Json/13.0.3": { + "type": "package", + "compile": { + "lib/net6.0/Newtonsoft.Json.dll": { + "related": ".xml" + } + }, + "runtime": { + "lib/net6.0/Newtonsoft.Json.dll": { + "related": ".xml" + } + } + } + } + }, + "libraries": { + "Newtonsoft.Json/13.0.3": { + "sha512": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==", + "type": "package", + "path": "newtonsoft.json/13.0.3", + "files": [ + ".nupkg.metadata", + ".signature.p7s", + "LICENSE.md", + "README.md", + "lib/net20/Newtonsoft.Json.dll", + "lib/net20/Newtonsoft.Json.xml", + "lib/net35/Newtonsoft.Json.dll", + "lib/net35/Newtonsoft.Json.xml", + "lib/net40/Newtonsoft.Json.dll", + "lib/net40/Newtonsoft.Json.xml", + "lib/net45/Newtonsoft.Json.dll", + "lib/net45/Newtonsoft.Json.xml", + "lib/net6.0/Newtonsoft.Json.dll", + "lib/net6.0/Newtonsoft.Json.xml", + "lib/netstandard1.0/Newtonsoft.Json.dll", + "lib/netstandard1.0/Newtonsoft.Json.xml", + "lib/netstandard1.3/Newtonsoft.Json.dll", + "lib/netstandard1.3/Newtonsoft.Json.xml", + "lib/netstandard2.0/Newtonsoft.Json.dll", + "lib/netstandard2.0/Newtonsoft.Json.xml", + "newtonsoft.json.13.0.3.nupkg.sha512", + "newtonsoft.json.nuspec", + "packageIcon.png" + ] + } + }, + "projectFileDependencyGroups": { + "net8.0": [ + "Newtonsoft.Json >= 13.0.3" + ] + }, + "packageFolders": { + "/config/.nuget/packages/": {} + }, + "project": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "/data/repos/MiniRPG/MiniRPG.csproj", + "projectName": "MiniRPG", + "projectPath": "/data/repos/MiniRPG/MiniRPG.csproj", + "packagesPath": "/config/.nuget/packages/", + "outputPath": "/data/repos/MiniRPG/obj/", + "projectStyle": "PackageReference", + "configFilePaths": [ + "/config/.nuget/NuGet/NuGet.Config" + ], + "originalTargetFrameworks": [ + "net8.0" + ], + "sources": { + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net8.0": { + "targetAlias": "net8.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + }, + "restoreAuditProperties": { + "enableAudit": "true", + "auditLevel": "low", + "auditMode": "direct" + } + }, + "frameworks": { + "net8.0": { + "targetAlias": "net8.0", + "dependencies": { + "Newtonsoft.Json": { + "target": "Package", + "version": "[13.0.3, )" + } + }, + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "/data/dotnet/sdk/8.0.411/PortableRuntimeIdentifierGraph.json" + } + } + } +} \ No newline at end of file diff --git a/obj/project.nuget.cache b/obj/project.nuget.cache new file mode 100644 index 0000000..aba879f --- /dev/null +++ b/obj/project.nuget.cache @@ -0,0 +1,10 @@ +{ + "version": 2, + "dgSpecHash": "JYcCbyoSKTw=", + "success": true, + "projectFilePath": "/data/repos/MiniRPG/MiniRPG.csproj", + "expectedPackageFiles": [ + "/config/.nuget/packages/newtonsoft.json/13.0.3/newtonsoft.json.13.0.3.nupkg.sha512" + ], + "logs": [] +} \ No newline at end of file diff --git a/scripts/Player.cs b/scripts/Player.cs new file mode 100644 index 0000000..c1eed88 --- /dev/null +++ b/scripts/Player.cs @@ -0,0 +1,38 @@ +public class Player +{ + public string Name { get; set; } + public List Inventory { get; set; } + public int MaxHealth { get; set; } + public int CurrentHealth { get; set; } + public int MaxMPoints { get; set; } + public int CurrentMPoints { get; set; } + + public Player(string name, List inventory, int maxhealth, int currenthealth, int maxmpoints, int currentmpoints) + { + Name = name; + Inventory = inventory; + MaxHealth = maxhealth; + CurrentHealth = currenthealth; + MaxMPoints = maxmpoints; + CurrentMPoints = currentmpoints; + } + + //Returns the players inventory in a Dictionary. + public Dictionary RetrieveInventory() + { + return Inventory + .GroupBy(item => item.Name) + .ToDictionary(group => group.Key, group => group.Count()); + } + + //For using a healing item. Doesn't allow you to overheal. + public void UseHealingItem(HealingItem item) + { + if ((CurrentHealth + item.HealingAmount) > MaxHealth) + { + CurrentHealth = MaxHealth; + } else { + CurrentHealth += item.HealingAmount; + } + } +} \ No newline at end of file diff --git a/scripts/loaders/ItemConverter.cs b/scripts/loaders/ItemConverter.cs new file mode 100644 index 0000000..d0c4b08 --- /dev/null +++ b/scripts/loaders/ItemConverter.cs @@ -0,0 +1,44 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +public class ItemConverter : JsonConverter +{ + //Overrides the ReadJson function. + public override Item ReadJson(JsonReader reader, Type objectType, Item? existingValue, bool hasExistingValue, JsonSerializer serializer) + { + //Load the raw JSON object from the reader. + JObject obj = JObject.Load(reader); + + // Read the "Type" field + string? type = obj["Type"]?.ToString(); + + //Create a temporary item object. + Item item; + + //Uses the Type field to determine what kind of object to create, to allow for a mixed list. + switch (type) + { + case "Healing": + item = new HealingItem("", "", 0); + break; + + case "Support": + item = new SupportItem("", ""); + break; + + default: + throw new JsonSerializationException($"Unknown item type: {type}"); + } + + // Populate the item with values from JSON + serializer.Populate(obj.CreateReader(), item); + return item; + } + + //Overrides the default WriteJson method to allow for our different items. + public override void WriteJson(JsonWriter writer, Item? value, JsonSerializer serializer) + { + JObject obj = JObject.FromObject(value, serializer); + obj.WriteTo(writer); + } +} diff --git a/scripts/loaders/ItemLoader.cs b/scripts/loaders/ItemLoader.cs new file mode 100644 index 0000000..22cd725 --- /dev/null +++ b/scripts/loaders/ItemLoader.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +public static class ItemLoader +{ + public static List LoadAllItems(string path) + { + //Check to see if the file exists. If not, just create a blank List. + if (!File.Exists(path)) + { + return new List(); + } + + //Dump the entirely of the file into a string. + string json = File.ReadAllText(path); + + //Create a new variable with our custom JSON serializer settings that allows us to make mixed Lists. + var settings = new JsonSerializerSettings + { + Converters = { new ItemConverter() } + }; + + //Return a list with different Items mixed in, or return a blank list. + return JsonConvert.DeserializeObject>(json, settings) ?? new List(); + } + + //Returns all the HealingItems in a list. + public static List LoadHealingItemsFromList(List input) + { + List healingitems = input + .OfType() + .ToList(); + return healingitems; + } +} \ No newline at end of file diff --git a/scripts/loaders/MoveLoader.cs b/scripts/loaders/MoveLoader.cs new file mode 100644 index 0000000..3d0642c --- /dev/null +++ b/scripts/loaders/MoveLoader.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Newtonsoft.Json; + +public static class MoveLoader +{ + public static List LoadMoves(string path) + { + if (!File.Exists(path)){ + Console.WriteLine("Move data file not found!"); + return new List(); + } + + string json = File.ReadAllText(path); + List moves = JsonConvert.DeserializeObject>(json) ?? new List(); + return moves ?? new List(); + } +} \ No newline at end of file diff --git a/scripts/objects/Move.cs b/scripts/objects/Move.cs new file mode 100644 index 0000000..6e404b2 --- /dev/null +++ b/scripts/objects/Move.cs @@ -0,0 +1,22 @@ +public class Move +{ + public string Name { get; set; } + public string Description { get; set; } + public int Power { get; set; } + public int MPCost { get; set; } + public MoveType Type { get; set; } + + public enum MoveType { + Attack, + Heal, + Buff + } + + public Move(string name, string description, int power, int mpcost, MoveType type){ + Name = name; + Description = description; + Power = power; + MPCost = mpcost; + Type = type; + } +} diff --git a/scripts/objects/items/HealingItem.cs b/scripts/objects/items/HealingItem.cs new file mode 100644 index 0000000..945f843 --- /dev/null +++ b/scripts/objects/items/HealingItem.cs @@ -0,0 +1,13 @@ +public class HealingItem : Item +{ + public int HealingAmount { get; set; } + public override string Type => "Healing"; + public HealingItem(string name, string description, int healingamount) : base(name, description){ + HealingAmount = healingamount; + } + + public override void Action() + { + Console.WriteLine("Healing item has been used"); + } +} \ No newline at end of file diff --git a/scripts/objects/items/Item.cs b/scripts/objects/items/Item.cs new file mode 100644 index 0000000..0f32f39 --- /dev/null +++ b/scripts/objects/items/Item.cs @@ -0,0 +1,17 @@ +public class Item +{ + public string Name { get; set; } + public string Description { get; set; } + public int Amount { get; set; } + public virtual string Type { get; set; } + + public virtual void Action() + { + Console.WriteLine("Item has been used"); + } + + public Item(string name, string description){ + Name = name; + Description = description; + } +} \ No newline at end of file diff --git a/scripts/objects/items/SupportItem.cs b/scripts/objects/items/SupportItem.cs new file mode 100644 index 0000000..229fb49 --- /dev/null +++ b/scripts/objects/items/SupportItem.cs @@ -0,0 +1,13 @@ +public class SupportItem : Item +{ + public override string Type => "Support"; + public SupportItem(string name, string description) : base(name, description) + { + + } + + public override void Action() + { + Console.WriteLine("Healing item has been used"); + } +} \ No newline at end of file