Problem:
I want to build a class for a custom dice
. But it should also provide the following:
- Every
side
can contain an otherdice
- The number of
sides
should be dynamically expandable, but must at least contain one- Logically the
dice
need to have acurrentSide
- Logically the
- Every
side
has aproperty
, which provides the content of this side (on a D6, it would be"4"
)
So far so good, I went and made two classes dice
and side
and gave them the properties I think they needed.
public class Side
{
//public bool HasDice { get { return Dice != null; } } - Removed not needed
public Dice Dice { get; set; }
public string Value { get; set; }
}
public class Dice
{
public ObservableCollection<Side> Sides { get; set; }
public string Name { get; set; }
public Side CurrentSide { get; set; }
}
Is this right, I never made any recursive classes so I'm not sure ?
Also how am I able to detect if the same dice and side are "endlessly" referring to them self.
Like:
D1.CurrentSide = Side1; Side1.Dice = D1;
Should I check this when building objects ?
Edit:
If D1 rolls S2 then D2 shouldn't be rolled. Also
D2.Dice = Null
.If D1 rolls S1 then D2 should be rolled.
If D2 rolls S1 then D3 should be rolled.
- If D2 rolls S2 then D4 should be rolled.
D3 and D4 shouldn't trigger any roll.