Initial commit.
This commit is contained in:
commit
8ceb9a2dd8
41 changed files with 720 additions and 0 deletions
26
.vscode/launch.json
vendored
Normal file
26
.vscode/launch.json
vendored
Normal file
|
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
41
.vscode/tasks.json
vendored
Normal file
41
.vscode/tasks.json
vendored
Normal file
|
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
43
Main.cs
Normal file
43
Main.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.VisualBasic;
|
||||||
|
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
List<Item> 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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
MiniRPG.csproj
Normal file
14
MiniRPG.csproj
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
BIN
bin/Debug/net8.0/MiniRPG
Executable file
BIN
bin/Debug/net8.0/MiniRPG
Executable file
Binary file not shown.
41
bin/Debug/net8.0/MiniRPG.deps.json
Normal file
41
bin/Debug/net8.0/MiniRPG.deps.json
Normal file
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
bin/Debug/net8.0/MiniRPG.dll
Normal file
BIN
bin/Debug/net8.0/MiniRPG.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/MiniRPG.pdb
Normal file
BIN
bin/Debug/net8.0/MiniRPG.pdb
Normal file
Binary file not shown.
12
bin/Debug/net8.0/MiniRPG.runtimeconfig.json
Normal file
12
bin/Debug/net8.0/MiniRPG.runtimeconfig.json
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"runtimeOptions": {
|
||||||
|
"tfm": "net8.0",
|
||||||
|
"framework": {
|
||||||
|
"name": "Microsoft.NETCore.App",
|
||||||
|
"version": "8.0.0"
|
||||||
|
},
|
||||||
|
"configProperties": {
|
||||||
|
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
bin/Debug/net8.0/Newtonsoft.Json.dll
Executable file
BIN
bin/Debug/net8.0/Newtonsoft.Json.dll
Executable file
Binary file not shown.
25
data/items.json
Normal file
25
data/items.json
Normal file
|
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
24
data/moves.json
Normal file
24
data/moves.json
Normal file
|
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
// <autogenerated />
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
|
||||||
22
obj/Debug/net8.0/MiniRPG.AssemblyInfo.cs
Normal file
22
obj/Debug/net8.0/MiniRPG.AssemblyInfo.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
1
obj/Debug/net8.0/MiniRPG.AssemblyInfoInputs.cache
Normal file
1
obj/Debug/net8.0/MiniRPG.AssemblyInfoInputs.cache
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
349b459bf4ade14fe01ed0c61903f28e8cbcd46aba882e73f23e247e57494e25
|
||||||
|
|
@ -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 =
|
||||||
8
obj/Debug/net8.0/MiniRPG.GlobalUsings.g.cs
Normal file
8
obj/Debug/net8.0/MiniRPG.GlobalUsings.g.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
// <auto-generated/>
|
||||||
|
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;
|
||||||
BIN
obj/Debug/net8.0/MiniRPG.assets.cache
Normal file
BIN
obj/Debug/net8.0/MiniRPG.assets.cache
Normal file
Binary file not shown.
BIN
obj/Debug/net8.0/MiniRPG.csproj.AssemblyReference.cache
Normal file
BIN
obj/Debug/net8.0/MiniRPG.csproj.AssemblyReference.cache
Normal file
Binary file not shown.
1
obj/Debug/net8.0/MiniRPG.csproj.CoreCompileInputs.cache
Normal file
1
obj/Debug/net8.0/MiniRPG.csproj.CoreCompileInputs.cache
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
552d7776ba252b8ba7a98c694923b3d159470fb983c96ce88fa765b810f80c32
|
||||||
17
obj/Debug/net8.0/MiniRPG.csproj.FileListAbsolute.txt
Normal file
17
obj/Debug/net8.0/MiniRPG.csproj.FileListAbsolute.txt
Normal file
|
|
@ -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
|
||||||
0
obj/Debug/net8.0/MiniRPG.csproj.Up2Date
Normal file
0
obj/Debug/net8.0/MiniRPG.csproj.Up2Date
Normal file
BIN
obj/Debug/net8.0/MiniRPG.dll
Normal file
BIN
obj/Debug/net8.0/MiniRPG.dll
Normal file
Binary file not shown.
1
obj/Debug/net8.0/MiniRPG.genruntimeconfig.cache
Normal file
1
obj/Debug/net8.0/MiniRPG.genruntimeconfig.cache
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
63738d25709d41611ed29f640f81025116589b3756c1a110496abf35e5d4d7d2
|
||||||
BIN
obj/Debug/net8.0/MiniRPG.pdb
Normal file
BIN
obj/Debug/net8.0/MiniRPG.pdb
Normal file
Binary file not shown.
BIN
obj/Debug/net8.0/apphost
Executable file
BIN
obj/Debug/net8.0/apphost
Executable file
Binary file not shown.
BIN
obj/Debug/net8.0/ref/MiniRPG.dll
Normal file
BIN
obj/Debug/net8.0/ref/MiniRPG.dll
Normal file
Binary file not shown.
BIN
obj/Debug/net8.0/refint/MiniRPG.dll
Normal file
BIN
obj/Debug/net8.0/refint/MiniRPG.dll
Normal file
Binary file not shown.
72
obj/MiniRPG.csproj.nuget.dgspec.json
Normal file
72
obj/MiniRPG.csproj.nuget.dgspec.json
Normal file
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
obj/MiniRPG.csproj.nuget.g.props
Normal file
15
obj/MiniRPG.csproj.nuget.g.props
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
|
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
|
||||||
|
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||||
|
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||||
|
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/config/.nuget/packages/</NuGetPackageRoot>
|
||||||
|
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/config/.nuget/packages/</NuGetPackageFolders>
|
||||||
|
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||||
|
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.11.1</NuGetToolVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
|
<SourceRoot Include="/config/.nuget/packages/" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
2
obj/MiniRPG.csproj.nuget.g.targets
Normal file
2
obj/MiniRPG.csproj.nuget.g.targets
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
|
||||||
124
obj/project.assets.json
Normal file
124
obj/project.assets.json
Normal file
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
obj/project.nuget.cache
Normal file
10
obj/project.nuget.cache
Normal file
|
|
@ -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": []
|
||||||
|
}
|
||||||
38
scripts/Player.cs
Normal file
38
scripts/Player.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
public class Player
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public List<Item> 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<Item> 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<string, int> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
44
scripts/loaders/ItemConverter.cs
Normal file
44
scripts/loaders/ItemConverter.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
public class ItemConverter : JsonConverter<Item>
|
||||||
|
{
|
||||||
|
//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);
|
||||||
|
}
|
||||||
|
}
|
||||||
38
scripts/loaders/ItemLoader.cs
Normal file
38
scripts/loaders/ItemLoader.cs
Normal file
|
|
@ -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<Item> LoadAllItems(string path)
|
||||||
|
{
|
||||||
|
//Check to see if the file exists. If not, just create a blank List.
|
||||||
|
if (!File.Exists(path))
|
||||||
|
{
|
||||||
|
return new List<Item>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//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<List<Item>>(json, settings) ?? new List<Item>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Returns all the HealingItems in a list.
|
||||||
|
public static List<HealingItem> LoadHealingItemsFromList(List<Item> input)
|
||||||
|
{
|
||||||
|
List<HealingItem> healingitems = input
|
||||||
|
.OfType<HealingItem>()
|
||||||
|
.ToList();
|
||||||
|
return healingitems;
|
||||||
|
}
|
||||||
|
}
|
||||||
19
scripts/loaders/MoveLoader.cs
Normal file
19
scripts/loaders/MoveLoader.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
public static class MoveLoader
|
||||||
|
{
|
||||||
|
public static List<Move> LoadMoves(string path)
|
||||||
|
{
|
||||||
|
if (!File.Exists(path)){
|
||||||
|
Console.WriteLine("Move data file not found!");
|
||||||
|
return new List<Move>();
|
||||||
|
}
|
||||||
|
|
||||||
|
string json = File.ReadAllText(path);
|
||||||
|
List<Move> moves = JsonConvert.DeserializeObject<List<Move>>(json) ?? new List<Move>();
|
||||||
|
return moves ?? new List<Move>();
|
||||||
|
}
|
||||||
|
}
|
||||||
22
scripts/objects/Move.cs
Normal file
22
scripts/objects/Move.cs
Normal file
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
13
scripts/objects/items/HealingItem.cs
Normal file
13
scripts/objects/items/HealingItem.cs
Normal file
|
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
17
scripts/objects/items/Item.cs
Normal file
17
scripts/objects/items/Item.cs
Normal file
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
13
scripts/objects/items/SupportItem.cs
Normal file
13
scripts/objects/items/SupportItem.cs
Normal file
|
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue