LocationBuilder

This commit is contained in:
aqys
2026-03-26 12:55:30 +01:00
parent 3808fb0f1a
commit 6a7399977d
3 changed files with 44 additions and 1 deletions

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

@@ -58,6 +58,7 @@ namespace PeopleVille.Persons
var otherLocations = World.Locations.Where(x => x != CurrentLocation).ToList(); var otherLocations = World.Locations.Where(x => x != CurrentLocation).ToList();
if (otherLocations.Count > 0) if (otherLocations.Count > 0)
Walk(otherLocations[RNG.ThrowDice(new Die(otherLocations.Count)) - 1]); Walk(otherLocations[RNG.ThrowDice(new Die(otherLocations.Count)) - 1]);
Console.WriteLine($"{Name} Walked to {CurrentLocation.Name}");
break; break;
case 3: case 3:
//Do nothing //Do nothing

View File

@@ -4,6 +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 location = new Bank { Name = "Banken" };
@@ -24,7 +25,7 @@ var world = new WorldBuilder()
.AddEquipment() .AddEquipment()
.FromRange([gun, kage]) .FromRange([gun, kage])
.AddLocations() .AddLocations()
.FromRange([location]) .FromRange(locationBuilder.CreateLocations(15))
.AddPersons() .AddPersons()
.FromRange(peopleBuilder.CreatePeople(15)) .FromRange(peopleBuilder.CreatePeople(15))
.WithRandomItems(20) .WithRandomItems(20)