-
Notifications
You must be signed in to change notification settings - Fork 0
/
CombatTable.cs
80 lines (77 loc) · 2.08 KB
/
CombatTable.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
namespace WpfApplication1
{
public class CombatTable : ObservableCollection<Combatant>
{
Combatant currentCombatant;
bool encounter;
int turn;
public void startEncounter()
{
if (!encounter)
{
turn = 0;
encounter = true;
setCurrent(0);
}
}
public void finishEncounter()
{
if (encounter)
{
turn = 0;
encounter = false;
currentCombatant.Turn = false;
currentCombatant = null;
}
}
public void setCurrent( int index )
{
if (index < this.Count)
{
if (currentCombatant != null)
currentCombatant.Turn = false;
currentCombatant = this.ElementAt(index);
currentCombatant.Turn = true;
}
}
public void setCurrent(Combatant combatant)
{
if (this.Contains(combatant))
{
if (currentCombatant != null)
currentCombatant.Turn = false;
this.currentCombatant = combatant;
currentCombatant.Turn = true;
}
}
public Combatant getCurrent()
{
return currentCombatant;
}
public void nextCombatant()
{
int currentIndex = this.IndexOf(currentCombatant);
if (currentIndex < this.Count-1)
setCurrent(currentIndex + 1);
else
setCurrent(0);
}
public void previousCombatant()
{
int currentIndex = this.IndexOf(currentCombatant);
if (currentIndex > 0)
setCurrent(currentIndex - 1);
else
setCurrent(this.Count - 1);
}
public CombatTable()
: base()
{
}
}
}