-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpresent_setup.php
147 lines (142 loc) · 6.02 KB
/
present_setup.php
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
require_once 'rebus.php';
require_once 'rebus_util.php';
require_once 'slide.php';
$actions = array();
foreach ($parts as $part => $data) {
if (is_string($data) and array_key_exists($data, $events)) {
array_push($actions, new EventSlide($events[$data], $data));
}
elseif (is_string($data) and preg_match('/^\*sorted\*(.+)/', $data, $matches)) {
$e = $matches[1];
array_push($actions, new EventSlide($events[$e], $e, null, 0, 1));
}
elseif (is_string($data) and preg_match('/^\*picture\*(.+):(.+)/', $data, $matches)) {
$pic = $matches[2];
if (checkPic($pic)) {
array_push($actions, new PictureSlide($matches[1], $pic));
}
else {
echo "ERROR: Could not find picture '$pic'<br>";
}
}
elseif ($data[0] == '*sum*') {
array_push($actions, new SumSlide($part, $data));
}
elseif ($data[0] == '*sumcomp*') {
array_push($actions, new SumCompSlide($part, $data));
}
else {
if (preg_match('/Etapp ([0-9]+)/', $part, $matches)) {
$n = $matches[1];
$pic = "etapp$n";
if (checkPic($pic)) {
array_push($actions, new PictureSlide($part, $pic));
}
}
foreach ($data as $e) {
if (!is_string($e)) {
if (is_array($e) and $e[0] == '*esum*') {
array_push($actions, new SumSlide($e[1], array_slice($e, 2)));
}
elseif (is_subclass_of($e, 'Slide')) {
array_push($actions, $e);
}
}
else {
if (preg_match('/^R ([0-9]+)/', $e, $matches)) {
// Rebus
$n = $matches[1];
$eventName = $events[$e];
array_push($actions, new SolutionSlide('R', $n));
if (in_array($n, $GLOBALS['bluerebus'])) {
array_push($actions, new SolutionSlide('B', $n));
}
array_push($actions, new SolutionSlide('H', $n));
if (in_array($n, $GLOBALS['bluehelprebus'])) {
array_push($actions, new SolutionSlide('J', $n));
}
array_push($actions, new EventSlide($eventName, $e));
}
elseif (preg_match('/^S ([0-9]+)/', $e, $matches)) {
// Stjälprebus
$n = $matches[1];
$eventName = $events[$e];
array_push($actions, new SolutionSlide('S', $n));
array_push($actions, new EventSlide($eventName, $e));
}
elseif (preg_match('/^X ([0-9]+)/', $e, $matches)) {
// Bonusrebus
$n = $matches[1];
$eventName = $events[$e];
array_push($actions, new SolutionSlide('X', $n));
array_push($actions, new EventSlide($eventName, $e));
}
elseif (preg_match('/^Y ([0-9]+)/', $e, $matches)) {
// Rebusredovisning utom tävlan - har ingen poängpresentation
$n = $matches[1];
$eventName = $events[$e];
array_push($actions, new SolutionSlide('Y', $n, $eventName));
}
elseif (preg_match('/^P (.*)/', $e, $matches)) {
// Pyssel
$n = $matches[1];
$eventName = $events[$e];
$pic = "gren$n";
if (checkPic($pic)) {
array_push($actions, new PictureSlide($eventName, $pic));
}
$pic = "$n";
if (checkPic($pic)) {
array_push($actions, new PictureSlide($eventName, $pic));
}
if (array_key_exists($e, $maxPoints)) {
array_push($actions, new EventSlide($eventName, $e, null, $maxPoints[$e]));
}
else {
array_push($actions, new EventSlide($eventName, $e));
}
}
elseif (preg_match('/^[FT]P ([0-9]+)/', $e, $matches)) {
// Foto- och tallricksplock.
$eventName = $events[$e];
$pic = "gren$e";
if (checkPic($pic)) {
array_push($actions, new PictureSlide($eventName, $pic));
}
if (array_key_exists($e . 'V', $events)) {
$eventName = $events[$e . 'V'];
array_push($actions, new EventSlide($eventName,
$e . 'V', $e . 'H'));
}
else {
array_push($actions, new EventSlide($eventName, $e));
}
}
elseif (preg_match('/^\*picture\*(.+):(.+)/', $e, $matches)) {
$pic = $matches[2];
if (checkPic($pic)) {
array_push($actions, new PictureSlide($matches[1], $pic));
}
else {
echo "ERROR: Could not find picture '$pic'<br>";
}
}
elseif (preg_match('/^\*solution\*(.)(.+)/', $e, $matches)) {
array_push($actions, new SolutionSlide($matches[1], $matches[2]));
}
else {
// Övrigt, tex öppnade stjälp.
$eventName = $events[$e];
$pic = "gren$e";
if (checkPic($pic)) {
array_push($actions, new PictureSlide($eventName, $pic));
}
array_push($actions, new EventSlide($eventName, $e));
}
}
}
array_push($actions, new SumSlide('Summering ' . $part, $part));
}
}
?>