Compare commits
10 Commits
ea1d6b0634
...
eb1b7ee688
| Author | SHA1 | Date | |
|---|---|---|---|
| eb1b7ee688 | |||
| 25b09b7c0d | |||
|
|
4315b709cb | ||
|
|
93945f4b77 | ||
| 61222df6d1 | |||
|
|
22701bc529 | ||
|
|
6a7399977d | ||
| 4def2b7d13 | |||
|
|
3808fb0f1a | ||
|
|
fa5d754ad6 |
23
PeopleVille.Extension.Mod1/Class1.cs
Normal file
23
PeopleVille.Extension.Mod1/Class1.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
13
PeopleVille.Extension.Mod1/PeopleVille.Extension.Mod1.csproj
Normal file
13
PeopleVille.Extension.Mod1/PeopleVille.Extension.Mod1.csproj
Normal 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>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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) {}
|
||||
}
|
||||
}
|
||||
41
PeopleVille/Location/LocationBuilder.cs
Normal file
41
PeopleVille/Location/LocationBuilder.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ namespace PeopleVille.Persons
|
||||
// 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 +55,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;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace PeopleVille.Persons
|
||||
public void Walk(Location newLocation)
|
||||
{
|
||||
this.CurrentLocation = newLocation;
|
||||
newLocation.UseLocation(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<Solution>
|
||||
<Project Path="PeopleVille.Extension.Mod1/PeopleVille.Extension.Mod1.csproj" />
|
||||
<Project Path="PeopleVille/PeopleVille.csproj" />
|
||||
</Solution>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
- [x] Find ud af hvordan tid skal fungere
|
||||
- [ ] 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
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user