WIP: Add basic effects and condition interface #8
@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using pflib_net.characters.internals.proficiencies;
|
using pflib_net.characters.internals.proficiencies;
|
||||||
using pflib_net.characters.internals.stats;
|
using pflib_net.characters.internals.stats;
|
||||||
|
using pflib_net.conditions;
|
||||||
using pflib_net.damage;
|
using pflib_net.damage;
|
||||||
|
|
||||||
namespace pflib_net.characters;
|
namespace pflib_net.characters;
|
||||||
@ -14,6 +15,7 @@ public class PlayerCharacter : ICharacter
|
|||||||
private ISet<string> Immunities { get; }
|
private ISet<string> Immunities { get; }
|
||||||
private Dictionary<string, int> Resistances { get; }
|
private Dictionary<string, int> Resistances { get; }
|
||||||
private Dictionary<string, int> Weaknesses { get; }
|
private Dictionary<string, int> Weaknesses { get; }
|
||||||
|
private IEnumerable<ICondition>? Conditions { get; set; } = null;
|
||||||
|
|
||||||
public PlayerCharacter(
|
public PlayerCharacter(
|
||||||
int hp,
|
int hp,
|
||||||
|
|||||||
9
pflib-net/conditions/ICondition.cs
Normal file
9
pflib-net/conditions/ICondition.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
using pflib_net.characters;
|
||||||
|
using pflib_net.effects;
|
||||||
|
|
||||||
|
namespace pflib_net.conditions;
|
||||||
|
|
||||||
|
public interface ICondition
|
||||||
|
{
|
||||||
|
public ISet<IEffect> GetEffects(ICharacter character);
|
||||||
|
}
|
||||||
@ -1,21 +1,43 @@
|
|||||||
namespace pflib_net.dice;
|
namespace pflib_net.dice;
|
||||||
|
|
||||||
public struct Dice
|
public class Dice
|
||||||
{
|
{
|
||||||
|
private int _keepHighest;
|
||||||
|
private int _keepLowest;
|
||||||
private int Count { get; set; }
|
private int Count { get; set; }
|
||||||
private int Size { get; set; }
|
private int Size { get; set; }
|
||||||
private int KeepHighest { get; set; }
|
|
||||||
private int KeepLowest { get; set; }
|
private int KeepHighest
|
||||||
|
{
|
||||||
|
get => _keepHighest;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value > 0 && KeepLowest > 0)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Cannot set keepHighest and keepLowest at the same time");
|
||||||
|
}
|
||||||
|
_keepHighest = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int KeepLowest
|
||||||
|
{
|
||||||
|
get => _keepLowest;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value > 0 && KeepHighest > 0)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Cannot set keepHighest and keepLowest at the same time");
|
||||||
|
}
|
||||||
|
|
||||||
|
_keepLowest = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
private int Add { get; set; }
|
private int Add { get; set; }
|
||||||
private static readonly Random Random = new();
|
private static readonly Random Random = new();
|
||||||
|
|
||||||
public Dice(int size, int count = 1, int keepHighest = 0, int keepLowest = 0, int add = 0)
|
public Dice(int size, int count = 1, int keepHighest = 0, int keepLowest = 0, int add = 0)
|
||||||
{
|
{
|
||||||
if (keepHighest > 0 && keepLowest > 0)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Cannot set keepHighest and keepLowest at the same time");
|
|
||||||
}
|
|
||||||
|
|
||||||
Count = count;
|
Count = count;
|
||||||
Size = size;
|
Size = size;
|
||||||
KeepHighest = keepHighest;
|
KeepHighest = keepHighest;
|
||||||
@ -25,22 +47,12 @@ public struct Dice
|
|||||||
|
|
||||||
public Dice Kh(int keepHighest)
|
public Dice Kh(int keepHighest)
|
||||||
{
|
{
|
||||||
if (KeepLowest > 0)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Cannot set keepHighest and keepLowest in the same roll");
|
|
||||||
}
|
|
||||||
|
|
||||||
KeepHighest = keepHighest;
|
KeepHighest = keepHighest;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dice Kl(int keepLowest)
|
public Dice Kl(int keepLowest)
|
||||||
{
|
{
|
||||||
if (KeepHighest > 0)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Cannot set keepHighest and keepLowest in the same roll");
|
|
||||||
}
|
|
||||||
|
|
||||||
KeepLowest = keepLowest;
|
KeepLowest = keepLowest;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
6
pflib-net/effects/IEffect.cs
Normal file
6
pflib-net/effects/IEffect.cs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
namespace pflib_net.effects;
|
||||||
|
|
||||||
|
public interface IEffect
|
||||||
|
{
|
||||||
|
public string Reason { get; }
|
||||||
|
}
|
||||||
24
pflib-net/effects/implementation/ConditionEffect.cs
Normal file
24
pflib-net/effects/implementation/ConditionEffect.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using pflib_net.conditions;
|
||||||
|
|
||||||
|
namespace pflib_net.effects.implementation;
|
||||||
|
|
||||||
|
public readonly struct ConditionEffect: IEffect
|
||||||
|
{
|
||||||
|
private readonly ICondition _condition;
|
||||||
|
private readonly string _reason;
|
||||||
|
public ICondition Condition
|
||||||
|
{
|
||||||
|
get => _condition;
|
||||||
|
}
|
||||||
|
public string Reason
|
||||||
|
{
|
||||||
|
get => _reason;
|
||||||
|
init => _reason = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConditionEffect(ICondition condition, string reason)
|
||||||
|
{
|
||||||
|
_condition = condition;
|
||||||
|
_reason = reason;
|
||||||
|
}
|
||||||
|
}
|
||||||
14
pflib-net/effects/implementation/ImmunityEffect.cs
Normal file
14
pflib-net/effects/implementation/ImmunityEffect.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
namespace pflib_net.effects.implementation;
|
||||||
|
|
||||||
|
public readonly struct ImmunityEffect: IEffect
|
||||||
|
{
|
||||||
|
public ImmunityEffect(string tag, string reason)
|
||||||
|
{
|
||||||
|
Tag = tag;
|
||||||
|
Reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Tag { get; }
|
||||||
|
|
||||||
|
public string Reason { get; }
|
||||||
|
}
|
||||||
19
pflib-net/effects/implementation/ModifierEffect.cs
Normal file
19
pflib-net/effects/implementation/ModifierEffect.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
namespace pflib_net.effects.implementation;
|
||||||
|
|
||||||
|
public readonly struct ModifierEffect: IEffect
|
||||||
|
{
|
||||||
|
public ModifierEffect(string tag, string reason, int value, string? type)
|
||||||
|
{
|
||||||
|
Tag = tag;
|
||||||
|
Reason = reason;
|
||||||
|
Value = value;
|
||||||
|
Type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Tag { get; }
|
||||||
|
|
||||||
|
public string Reason { get; }
|
||||||
|
|
||||||
|
public string? Type { get; }
|
||||||
|
public int Value { get; }
|
||||||
|
}
|
||||||
17
pflib-net/effects/implementation/ResistanceEffect.cs
Normal file
17
pflib-net/effects/implementation/ResistanceEffect.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
namespace pflib_net.effects.implementation;
|
||||||
|
|
||||||
|
public readonly struct ResistanceEffect: IEffect
|
||||||
|
{
|
||||||
|
public ResistanceEffect(string tag, string reason, int amount)
|
||||||
|
{
|
||||||
|
Tag = tag;
|
||||||
|
Reason = reason;
|
||||||
|
Amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Tag { get; }
|
||||||
|
|
||||||
|
public string Reason { get; }
|
||||||
|
|
||||||
|
public int Amount { get; }
|
||||||
|
}
|
||||||
13
pflib-net/effects/implementation/TeamEffect.cs
Normal file
13
pflib-net/effects/implementation/TeamEffect.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
namespace pflib_net.effects.implementation;
|
||||||
|
|
||||||
|
public readonly struct TeamEffect: IEffect
|
||||||
|
{
|
||||||
|
public TeamEffect(int side, string reason)
|
||||||
|
{
|
||||||
|
Side = side;
|
||||||
|
Reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Side { get; }
|
||||||
|
public string Reason { get; }
|
||||||
|
}
|
||||||
16
pflib-net/effects/implementation/WeaknessEffect.cs
Normal file
16
pflib-net/effects/implementation/WeaknessEffect.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
namespace pflib_net.effects.implementation;
|
||||||
|
|
||||||
|
public readonly struct WeaknessEffect: IEffect
|
||||||
|
{
|
||||||
|
public WeaknessEffect(string tag, string reason, int amount)
|
||||||
|
{
|
||||||
|
Tag = tag;
|
||||||
|
Reason = reason;
|
||||||
|
Amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Tag { get; }
|
||||||
|
public string Reason { get; }
|
||||||
|
public int Amount { get; }
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user