Compare commits

..

10 Commits

Author SHA1 Message Date
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
15 changed files with 172 additions and 31 deletions

View File

@@ -0,0 +1,23 @@
using PeopleVille.Equipment;
using PeopleVille.Persons;
namespace PeopleVille.Extension.Mod1;
public class Snake : IEquipment
{
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");
}
}

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) public void Use(Person person)
{ {
person.Health += HealthPoints; person.Health += HealthPoints;
Console.WriteLine($"{person.Name} ate food and healed {HealthPoints}"); Console.WriteLine($"{person.Name} spiste og healede {HealthPoints}");
person.Inventory.Remove(this); person.Inventory.Remove(this);
} }
} }

View File

@@ -1,7 +1,14 @@
using PeopleVille.Persons;
namespace PeopleVille.Locations namespace PeopleVille.Locations
{ {
public class Bank : Location 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 namespace PeopleVille.Locations
{ {
public class EggStore : Store 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 namespace PeopleVille.Locations
{ {
public class GunStore : Store 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 namespace PeopleVille.Locations
{ {
public abstract class Location public abstract class Location
{ {
public string Name { get; set; } 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

@@ -29,7 +29,7 @@ namespace PeopleVille.Persons
// 50/50 om vi gør noget eller ej // 50/50 om vi gør noget eller ej
if (RNG.ThrowDice(Dices.D3) == 1) if (RNG.ThrowDice(Dices.D3) == 1)
return; return;
switch (RNG.ThrowDice(Dices.D3)) switch (RNG.ThrowDice(Dices.D4))
{ {
case 1: case 1:
bool hasGun = Inventory.OfType<Gun>().Any(); bool hasGun = Inventory.OfType<Gun>().Any();
@@ -55,8 +55,23 @@ namespace PeopleVille.Persons
break; break;
case 2: case 2:
//Move location //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: 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 //Do nothing
break; break;
} }

View File

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

View File

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

View File

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

View File

@@ -39,21 +39,4 @@ namespace PeopleVille.WorldBuilder
IPersonBuilder WithRandomItems(int number); IPersonBuilder WithRandomItems(int number);
IWorldBuilder EndWorldBuilding(); 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> <Solution>
<Project Path="PeopleVille.Extension.Mod1/PeopleVille.Extension.Mod1.csproj" />
<Project Path="PeopleVille/PeopleVille.csproj" /> <Project Path="PeopleVille/PeopleVille.csproj" />
</Solution> </Solution>

View File

@@ -6,8 +6,8 @@
- [x] Find ud af hvordan tid skal fungere - [x] Find ud af hvordan tid skal fungere
- [ ] Lav ny data så program kan køre - [ ] Lav ny data så program kan køre
### Mikkel ### Mikkel
- [ ] Opret logik DoSomething() - [x] Opret logik DoSomething()
- [ ] Lav worldbuilder - [x] Personer skal kunne skifte lokation
**Husk at opdatere mermaid løbende** **Husk at opdatere mermaid løbende**