CitizenBuilder
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
using PeopleVille;
|
using PeopleVille;
|
||||||
|
using PeopleVille.Equipment;
|
||||||
|
using PeopleVille.Persons;
|
||||||
|
using PeopleVille.WorldBuilder;
|
||||||
|
|
||||||
var gameManager = new GameManager();
|
var gameManager = new GameManager();
|
||||||
|
|
||||||
@@ -6,3 +9,18 @@ await gameManager.StartClock();
|
|||||||
|
|
||||||
// See https://aka.ms/new-console-template for more information
|
// See https://aka.ms/new-console-template for more information
|
||||||
Console.WriteLine("Hello, World!");
|
Console.WriteLine("Hello, World!");
|
||||||
|
|
||||||
|
|
||||||
|
/* burde i teorien virke?
|
||||||
|
var testCitizen = new AdultCitizen { Name = "", Health = 100 };
|
||||||
|
testCitizen.Inventory.Add(new Gun { Name = "Glock", Damage = 50 }); */
|
||||||
|
|
||||||
|
/* builder?
|
||||||
|
var builder = new CitizenBuilder();
|
||||||
|
|
||||||
|
builder
|
||||||
|
.CreateAdult("Lars", 100).WithGun("Glock", 20)
|
||||||
|
.CreateAdult("Thomas", 100).WithGun("AK", 40).WithFood("Hvid Monster", 0)
|
||||||
|
.CreateChild("Troels", 60).WithFood("Apple", 10);
|
||||||
|
|
||||||
|
var borgere = builder.Build(); */
|
||||||
@@ -1,10 +1,46 @@
|
|||||||
using System;
|
using PeopleVille.Equipment;
|
||||||
|
using PeopleVille.Persons;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using static PeopleVille.WorldBuilder.WorldInterfaces;
|
||||||
|
|
||||||
namespace PeopleVille.WorldBuilder
|
namespace PeopleVille.WorldBuilder
|
||||||
{
|
{
|
||||||
internal class WorldBuilder
|
public class CitizenBuilder : ICitizenBuilder
|
||||||
{
|
{
|
||||||
|
Person person;
|
||||||
|
List<Person> Citizens = new List<Person>();
|
||||||
|
|
||||||
|
public ICitizenBuilder CreateAdult(string name, int health)
|
||||||
|
{
|
||||||
|
person = new AdultCitizen { Name = name, Health = health, Inventory = new List<Equipment.IEquipment>() };
|
||||||
|
Citizens.Add(person);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICitizenBuilder CreateChild(string name, int health)
|
||||||
|
{
|
||||||
|
person = new ChildCitizen { Name = name, Health = health, Inventory = new List<Equipment.IEquipment>() };
|
||||||
|
Citizens.Add(person);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICitizenBuilder WithGun(string name, int damage)
|
||||||
|
{
|
||||||
|
person.Inventory.Add(new Gun { Name = name, Damage = damage });
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICitizenBuilder WithFood(string name, int healthPoints)
|
||||||
|
{
|
||||||
|
person.Inventory.Add(new Food { Name = name, HealthPoints = healthPoints });
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Person Build()
|
||||||
|
{
|
||||||
|
return person;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,26 @@
|
|||||||
using System;
|
using PeopleVille.Persons;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace PeopleVille.WorldBuilder
|
namespace PeopleVille.WorldBuilder
|
||||||
{
|
{
|
||||||
internal class WorldInterfaces
|
public class WorldInterfaces
|
||||||
{
|
{
|
||||||
|
public interface IWorldBuilder
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ITownBuilder
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
Person Build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user