51 lines
947 B
C#
51 lines
947 B
C#
using MiniJeuxFinal.Games.PierrePapierCiseaux.Actions;
|
|
using MiniJeuxFinal.Games.PierrePapierCiseaux.Factories;
|
|
|
|
namespace MiniJeuxFinal.Games.PierrePapierCiseaux.Players
|
|
{
|
|
public class PlayerPpc : IPlayer
|
|
{
|
|
private readonly List<IActionPpc> _actions = [];
|
|
private readonly IActionPpcFactory _actionPpcFactory;
|
|
|
|
|
|
|
|
public PlayerPpc(string name, IActionPpcFactory actionPpcFactory)
|
|
{
|
|
Name = name;
|
|
_actionPpcFactory = actionPpcFactory;
|
|
}
|
|
|
|
|
|
|
|
public string Name { get; }
|
|
|
|
public int Score { get; private set; }
|
|
|
|
|
|
public void AddAction(params IAction[] action)
|
|
{
|
|
_actions.AddRange(action.Cast<IActionPpc>());
|
|
}
|
|
|
|
public void IncrementScore()
|
|
{
|
|
Score++;
|
|
}
|
|
|
|
public IAction Play()
|
|
{
|
|
if (!_actions.Any())
|
|
throw new InvalidOperationException("You don't have a action");
|
|
|
|
return _actionPpcFactory.GetAction(_actions);
|
|
}
|
|
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"{Name}: {Score}";
|
|
}
|
|
}
|
|
}
|