Compare commits

..

13 Commits

Author SHA1 Message Date
650379e8f9 adding different thins 2026-03-27 09:20:21 +01:00
aqys
94bd4d1f05 Lidt Cleanup 2026-03-27 08:23:41 +01:00
0a3c20d687 update README 2026-03-26 14:19:05 +01:00
eb1b7ee688 cleanup 2026-03-26 14:09:29 +01:00
25b09b7c0d external lib 2026-03-26 14:08:11 +01:00
aqys
4315b709cb TODO Update 2026-03-26 13:51:48 +01:00
aqys
93945f4b77 UseLocation methods, and text updated. 2026-03-26 13:50:40 +01:00
61222df6d1 adding location stuff 2026-03-26 13:01:50 +01:00
aqys
22701bc529 Merge branch 'main' of https://github.com/smallbenji-org/HF2-peopleville 2026-03-26 12:55:41 +01:00
aqys
6a7399977d LocationBuilder 2026-03-26 12:55:30 +01:00
4def2b7d13 new names 2026-03-26 12:41:48 +01:00
aqys
3808fb0f1a Move Location case added 2026-03-26 12:13:00 +01:00
aqys
fa5d754ad6 TODO Update 2026-03-26 12:07:26 +01:00
19 changed files with 209 additions and 40 deletions

View File

@@ -0,0 +1,43 @@
using PeopleVille.Equipment;
using PeopleVille.Persons;
namespace PeopleVille.Extension.Mod1;
public class Snake : IEquipment
{
public string Name { get; set; } = "Snake";
public void Equip()
{
throw new NotImplementedException();
}
public void Unequip()
{
throw new NotImplementedException();
}
public void Use(Person person)
{
Console.WriteLine($"{person.Name} brugte en slange, lol");
}
}
public class Trumpet : IEquipment
{
public string Name { get; set; } = "Trumpet med 90 grader";
public void Equip()
{
throw new NotImplementedException();
}
public void Unequip()
{
throw new NotImplementedException();
}
public void Use(Person person)
{
Console.WriteLine($"{person.Name} brugte en trumpet, musik lyder i {person.CurrentLocation.Name}");
}
}

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../PeopleVille/PeopleVille.csproj" />
</ItemGroup>
</Project>

View File

@@ -20,7 +20,7 @@ namespace PeopleVille.Equipment
public void Use(Person person)
{
person.Health += HealthPoints;
Console.WriteLine($"{person.Name} ate food and healed {HealthPoints}");
Console.WriteLine($"{person.Name} spiste og healede {HealthPoints}");
person.Inventory.Remove(this);
}
}

View File

@@ -19,8 +19,14 @@ namespace PeopleVille.Equipment
public void Use(Person target)
{
target.Health -= this.Damage;
Console.WriteLine($"{target.Name} er blevet skudt og mistede {Damage} liv");
try
{
target.Health -= this.Damage;
Console.WriteLine($"{target.Name} er blevet skudt og mistede {Damage} liv");
} catch
{
Console.WriteLine($"{target.Name} prøvede at skyde, men det virkede ikke, øv bøv");
}
}
}
}

View File

@@ -1,5 +1,3 @@
using PeopleVille.Locations;
namespace PeopleVille
{
public class GameManager

View File

@@ -1,7 +1,14 @@
using PeopleVille.Persons;
namespace PeopleVille.Locations
{
public class Bank : Location
{
public override void UseLocation(Person person)
{
int amount = RNG.Range(100, 501);
person.Money += amount;
Console.WriteLine($"{person.Name} hæver {amount} kr. i {Name}");
}
}
}

View File

@@ -1,7 +1,24 @@
using PeopleVille.Equipment;
using PeopleVille.Persons;
namespace PeopleVille.Locations
{
public class EggStore : Store
{
public override void UseLocation(Person person)
{
if (person.Money >= 100)
{
person.Money -= 100;
person.Inventory.Add(new Food { Name = "Bakke Æg", HealthPoints = 60 });
Console.WriteLine($"{person.Name} køber Bakke Æg for 100 kr. i {Name}");
}
else if (person.Money >= 20)
{
person.Money -= 20;
person.Inventory.Add(new Food { Name = "Æg", HealthPoints = 10 });
Console.WriteLine($"{person.Name} køber Æg for 20 kr. i {Name}");
}
}
}
}

View File

@@ -1,7 +1,43 @@
using PeopleVille.Equipment;
using PeopleVille.Persons;
namespace PeopleVille.Locations
{
public class GunStore : Store
{
public GunStore()
{
Inventory = new Dictionary<object, int>
{
{ new Gun { Name = "Pistol", Damage = 15 }, 200 },
{ new Gun { Name = "Riffel", Damage = 30 }, 500 },
{ new Gun { Name = "Shotgun", Damage = 50 }, 800 },
};
}
public override void UseLocation(Person person)
{
if (person.Inventory.OfType<Gun>().Any())
return;
if (person.Money >= 800)
{
person.Money -= 800;
person.Inventory.Add(new Gun { Name = "Shotgun", Damage = 50 });
Console.WriteLine($"{person.Name} køber Shotgun for 800 kr. i {Name}");
}
else if (person.Money >= 500)
{
person.Money -= 500;
person.Inventory.Add(new Gun { Name = "Riffel", Damage = 30 });
Console.WriteLine($"{person.Name} køber Riffel for 500 kr. i {Name}");
}
else if (person.Money >= 200)
{
person.Money -= 200;
person.Inventory.Add(new Gun { Name = "Pistol", Damage = 15 });
Console.WriteLine($"{person.Name} køber Pistol for 200 kr. i {Name}");
}
}
}
}

View File

@@ -1,7 +1,11 @@
using PeopleVille.Persons;
namespace PeopleVille.Locations
{
public abstract class Location
{
public string Name { get; set; }
public virtual void UseLocation(Person person) {}
}
}

View File

@@ -0,0 +1,41 @@
namespace PeopleVille.Locations
{
public class LocationBuilder
{
readonly string[] bankNames = ["Nationalbanken", "Borgernes Bank", "Den Store Bank"];
readonly string[] gunStoreNames = ["Våben Salg", "Bangbang Butikken", "SkyderButikken"];
readonly string[] eggStoreNames = ["Gårdens Æg", "Æggehuset", "Byens Æg"];
public List<Location> CreateLocations(int number)
{
List<Location> locations = [];
for (var i = 0; i < number; i++)
{
switch (RNG.ThrowDice(Dices.D3))
{
case 1:
locations.Add(new Bank()
{
Name = bankNames[RNG.Range(0, bankNames.Length)]
});
break;
case 2:
locations.Add(new GunStore()
{
Name = gunStoreNames[RNG.Range(0, gunStoreNames.Length)]
});
break;
case 3:
locations.Add(new EggStore()
{
Name = eggStoreNames[RNG.Range(0, eggStoreNames.Length)]
});
break;
}
}
return locations;
}
}
}

View File

@@ -1,5 +1,3 @@
using PeopleVille.Equipment;
namespace PeopleVille.Locations
{
public class Store : Location

View File

@@ -26,10 +26,9 @@ namespace PeopleVille.Persons
return;
}
// 50/50 om vi gør noget eller ej
if (RNG.ThrowDice(Dices.D3) == 1)
return;
switch (RNG.ThrowDice(Dices.D3))
switch (RNG.ThrowDice(Dices.D4))
{
case 1:
bool hasGun = Inventory.OfType<Gun>().Any();
@@ -55,8 +54,23 @@ namespace PeopleVille.Persons
break;
case 2:
//Move location
break;
var otherLocations = World.Locations.Where(x => x != CurrentLocation).ToList();
if (otherLocations.Count > 0)
Walk(otherLocations[RNG.ThrowDice(new Die(otherLocations.Count)) - 1]);
Console.WriteLine($"{Name} Gik hen til {CurrentLocation.Name}");
break;
case 3:
try
{
var items = this.Inventory.Where(x => x is not Gun && x is not Food).ToList();
items[RNG.Range(0, items.Count)].Use(this);
} catch
{
Console.WriteLine($"{this.Name} brugte ikke nogle items");
}
break;
case 4:
//Do nothing
break;
}

View File

@@ -26,6 +26,7 @@ namespace PeopleVille.Persons
public void Walk(Location newLocation)
{
this.CurrentLocation = newLocation;
newLocation.UseLocation(this);
}
}
}

View File

@@ -2,9 +2,9 @@ namespace PeopleVille.Persons
{
public class PeopleBuilder
{
readonly string[] maleNames = ["John", "Peter", "Mikkel", "Lars", "Benjamin"];
readonly string[] femaleNames = ["Cirkeline", "Josefine", "Simone", "Gertrud", "Smilla"];
readonly string[] lastNames = ["Petersen", "Rasmussen", "Madsen"];
readonly string[] maleNames = ["John", "Peter", "Mikkel", "Lars", "Benjamin", "Anders", "Christian", "Mathias", "Magnus", "Emil"];
readonly string[] femaleNames = ["Cirkeline", "Josefine", "Simone", "Gertrud", "Smilla", "Mette", "Sofie", "Laura", "Emma", "Freja"];
readonly string[] lastNames = ["Petersen", "Rasmussen", "Madsen", "Jensen", "Nielsen", "Hansen", "Møller", "Lund", "Vestergaard"];
public List<Person> CreatePeople(int number)
{

View File

@@ -4,8 +4,7 @@ using PeopleVille.Persons;
using PeopleVille.WorldBuilder;
var peopleBuilder = new PeopleBuilder();
var location = new Bank { Name = "Banken" };
var locationBuilder = new LocationBuilder();
var gun = new Gun()
{
@@ -23,8 +22,9 @@ var world = new WorldBuilder()
.AddGameManager()
.AddEquipment()
.FromRange([gun, kage])
.FromFolder("/home/smallbenji/school/hf2/HF2-peopleville/PeopleVille.Extension.Mod1/bin/Debug/net10.0")
.AddLocations()
.FromRange([location])
.FromRange(locationBuilder.CreateLocations(15))
.AddPersons()
.FromRange(peopleBuilder.CreatePeople(15))
.WithRandomItems(20)

View File

@@ -1,7 +1,6 @@
using PeopleVille.Equipment;
using PeopleVille.Locations;
using PeopleVille.Persons;
using PeopleVille;
using System.Reflection;
namespace PeopleVille.WorldBuilder
{
@@ -110,9 +109,17 @@ namespace PeopleVille.WorldBuilder
{
var instances = new List<T>();
string[] dlls = Directory.GetFiles(pathToAssemblyFolder, "*.dll");
var baseAssemblyName = typeof(T).Assembly.GetName().Name;
foreach (var dll in dlls)
{
var assemblyName = AssemblyName.GetAssemblyName(dll).Name;
if (string.Equals(assemblyName, baseAssemblyName, StringComparison.OrdinalIgnoreCase))
{
continue;
}
instances.AddRange(LoadTypesFromAssembly<T>(dll));
}

View File

@@ -39,21 +39,4 @@ namespace PeopleVille.WorldBuilder
IPersonBuilder WithRandomItems(int number);
IWorldBuilder EndWorldBuilding();
}
// public interface ITownBuilder
// {
// ITownBuilder AddGunStore(string name);
// ITownBuilder AddEggStore(string name);
// ITownBuilder AddBank(string name);
// List<Location> BuildTown();
// }
// public interface ICitizenBuilder
// {
// ICitizenBuilder CreateAdult(string name, int health);
// ICitizenBuilder CreateChild(string name, int health);
// ICitizenBuilder WithGun(string name, int damage);
// ICitizenBuilder WithFood(string name, int healthPoints);
// List<Person> BuildCitizens();
// }
}

View File

@@ -1,3 +1,4 @@
<Solution>
<Project Path="PeopleVille.Extension.Mod1/PeopleVille.Extension.Mod1.csproj" />
<Project Path="PeopleVille/PeopleVille.csproj" />
</Solution>

View File

@@ -4,10 +4,10 @@
### Benjamin
- [x] Implementer dynamisk import af "eksterne" dll'er
- [x] Find ud af hvordan tid skal fungere
- [ ] Lav ny data så program kan køre
- [x] Lav ny data så program kan køre
### Mikkel
- [ ] Opret logik DoSomething()
- [ ] Lav worldbuilder
- [x] Opret logik DoSomething()
- [x] Personer skal kunne skifte lokation
**Husk at opdatere mermaid løbende**
@@ -131,4 +131,4 @@ classDiagram
TownBuilder --> Location
GameManager --> Store
```
```