forked from jhauberg/ComponentKit-Example-RockPaperScissors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
History.cs
45 lines (38 loc) · 1.02 KB
/
History.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Collections.Generic;
using ComponentKit.Model;
namespace ComponentKit.Examples.RockPaperScissors {
/// <summary>
/// Keeps track of previous decisions.
/// </summary>
internal class History : Component {
IList<Decision> _decisions =
new List<Decision>();
public void Push(Decision decision) {
_decisions.Add(decision);
}
public int Count {
get {
return _decisions.Count;
}
}
public Decision MostRecentDecision {
get {
return this[Count - 1];
}
}
public Decision PreviousDecision {
get {
return this[Count - 2];
}
}
public Decision this[int index] {
get {
if (index >= 0 && _decisions.Count > index) {
return _decisions[index];
}
return Decision.Undecided;
}
}
}
}