Skip to content

Commit 3e01978

Browse files
committed
Implement cheat system and enhance game mechanics
- Updated `DataLoader.cs` to throw exceptions for missing location data and added `Experience` and `Gold` properties to the `Enemy` class with random gold rewards. - Revamped `GameEngine.cs` to introduce a comprehensive cheat system, including activation, processing, and effects on combat. - Modified `GameModels.cs` to include new properties for `Experience` and `Gold` in the `Enemy` class and added a `Key` property to the `Location` class. - Enhanced overall game structure with features like no-clip mode and improved enemy spawning and combat mechanics.
1 parent 9023ba8 commit 3e01978

File tree

3 files changed

+718
-50
lines changed

3 files changed

+718
-50
lines changed

src/Data/DataLoader.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
51
using System.Text.Json;
62

73
namespace WinFormsApp1
@@ -87,14 +83,15 @@ public Dictionary<string, Location> LoadLocations()
8783
var locationData = JsonSerializer.Deserialize<LocationData>(locationsJson);
8884

8985
if (locationData?.Locations == null)
90-
return new Dictionary<string, Location>();
86+
throw new Exception("No location data found");
9187

9288
var locations = new Dictionary<string, Location>();
9389

9490
foreach (var locationInfo in locationData.Locations)
9591
{
9692
var location = new Location
9793
{
94+
Key = locationInfo.Id,
9895
Name = locationInfo.Name,
9996
Description = locationInfo.Description,
10097
Exits = locationInfo.Exits.ToDictionary(
@@ -145,6 +142,13 @@ public Dictionary<string, Location> LoadLocations()
145142
enemyInfo.Defense
146143
);
147144

145+
// Set experience and gold from JSON data
146+
enemy.Experience = enemyInfo.ExperienceReward;
147+
148+
// Calculate gold reward (use random value between min and max)
149+
var random = new Random();
150+
enemy.Gold = random.Next(enemyInfo.GoldReward.Min, enemyInfo.GoldReward.Max + 1);
151+
148152
// Add loot table
149153
foreach (var lootItem in enemyInfo.LootTable)
150154
{

0 commit comments

Comments
 (0)