-
Notifications
You must be signed in to change notification settings - Fork 36
/
EventManager.cs
107 lines (83 loc) · 3.41 KB
/
EventManager.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace freETarget {
public class EventManager {
private List<Event> eventList = new List<Event>();
private List<Event> activeEventList = new List<Event>();
StorageController storage;
public EventManager(StorageController storage) {
this.storage = storage;
}
/*
* no events in the DB. create the default events
*/
public void initializeEvents() {
//air pistol practice
Event evAPP = new Event(-1, "Pistol Practice", false, Event.EventType.Practice, -1, new targets.AirPistol(4.5m), -1, 4.5m, -1, -1, -1, -1, -1, Color.Gold);
storage.storeEvent(evAPP);
//air pistol match
Event evAPM = new Event(-1, "Pistol Match", false, Event.EventType.Match, 60, new targets.AirPistol(4.5m), 75, 4.5m, -1, -1, -1, -1, -1, Color.Orange);
storage.storeEvent(evAPM);
//air pistol final
Event evAPF = new Event(-1, "Pistol Final", true, Event.EventType.Final, 24, new targets.AirPistol(4.5m), 75, 4.5m, 5, 250, 10, 2, 50, Color.Red);
storage.storeEvent(evAPF);
//air rifle practice
Event evARP = new Event(-1, "Rifle Practice", true, Event.EventType.Practice, -1, new targets.AirRifle(4.5m), -1, 4.5m, -1, -1, -1, -1, -1, Color.LimeGreen);
storage.storeEvent(evARP);
//air rifle match
Event evARM = new Event(-1, "Rifle Match", true, Event.EventType.Match, 60, new targets.AirRifle(4.5m), 75, 4.5m, -1, -1, -1, -1, -1, Color.Turquoise);
storage.storeEvent(evARM);
//air rfile final
Event evARF = new Event(-1, "Rifle Final", true, Event.EventType.Final, 24, new targets.AirRifle(4.5m), 75, 4.5m, 5, 250, 10, 2, 50, Color.DodgerBlue);
storage.storeEvent(evARF);
//reload events to get autogenerated IDs
List<Event> evs = storage.loadEvents();
storage.updateActiveEvents(evs);
}
public void setEventsList(List<Event> list) {
this.eventList = list;
}
public List<Event> getEventsList() {
return this.eventList;
}
public void setActiveEventsList(List<long> idList) {
if (eventList.Count == 0) {
Console.WriteLine("Event list empty");
return;
}
this.activeEventList.Clear();
foreach (Event ev in eventList) {
if (idList.Contains(ev.ID)) {
this.activeEventList.Add(ev);
}
}
}
public List<Event> getActiveEventsList() {
return this.activeEventList;
}
public Event findEventByID(long id) {
Event ret = null;
foreach(Event e in eventList) {
if(e.ID == id) {
ret = e;
break;
}
}
return ret;
}
public Event findEventByName(string name) {
Event ret = null;
foreach (Event e in eventList) {
if (e.Name == name) {
ret = e;
break;
}
}
return ret;
}
}
}