-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
409 lines (360 loc) · 16 KB
/
example.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
<?php
require __DIR__ . '/vendor/autoload.php';
use SDM\Enetpulse\Configuration;
use SDM\Enetpulse\Generator;
use SDM\Enetpulse\Model\Event\Participant;
use SDM\Enetpulse\Model\Odds\Offer;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Helper\TableSeparator;
use Symfony\Component\Console\Output\BufferedOutput;
$dsn = include __DIR__ . '/dsn.php';
$config = new Configuration($dsn);
$generator = new Generator($config);
//
///**
// * Table standings
// */
//echo "\n\nTable standings\n-------------------\n\n";
//
//$output = new BufferedOutput();
//// Total for all matches
//$output->writeln('// Total for all matches');
//$table = new Table($output);
//$table->setHeaders(['Team', 'Rank', 'Matches', 'Won', 'Draws', 'Lost', 'Goals', 'Points']);
//$standing = $generator->getStandingProvider()->getStandingFromTournamentStageId(849851);
//foreach ($standing->getTotalStandings() as $stand) {
// $table->addRow([
// $stand->getParticipant()->getName(),
// $stand->getData()->getRank(),
// $stand->getData()->getPlayed(),
// $stand->getData()->getWins(),
// $stand->getData()->getDraws(),
// $stand->getData()->getDefeits(),
// $stand->getData()->getGoalsFor() . '-' . $stand->getData()->getGoalsAgainst(),
// $stand->getData()->getPoints(),
// ]);
//}
//$table->render();
//
//// Total for home matches
//$output->writeln('// Total for home matches');
//$table = new Table($output);
//$table->setHeaders(['Team', 'Rank', 'Matches', 'Won', 'Draws', 'Lost', 'Goals', 'Points']);
//$standing = $generator->getStandingProvider()->getStandingFromTournamentStageId(849851);
//foreach ($standing->getHomeStandings() as $stand) {
// $table->addRow([
// $stand->getParticipant()->getName(),
// $stand->getData()->getRank(),
// $stand->getData()->getPlayed(),
// $stand->getData()->getWins(),
// $stand->getData()->getDraws(),
// $stand->getData()->getDefeits(),
// $stand->getData()->getGoalsFor() . '-' . $stand->getData()->getGoalsAgainst(),
// $stand->getData()->getPoints(),
// ]);
//}
//$table->render();
//
//// Total for away matches
//$output->writeln('// Total for away matches');
//$table = new Table($output);
//$table->setHeaders(['Team', 'Rank', 'Matches', 'Won', 'Draws', 'Lost', 'Goals', 'Points']);
//$standing = $generator->getStandingProvider()->getStandingFromTournamentStageId(849851);
//foreach ($standing->getAwayStandings() as $stand) {
// $table->addRow([
// $stand->getParticipant()->getName(),
// $stand->getData()->getRank(),
// $stand->getData()->getPlayed(),
// $stand->getData()->getWins(),
// $stand->getData()->getDraws(),
// $stand->getData()->getDefeits(),
// $stand->getData()->getGoalsFor() . '-' . $stand->getData()->getGoalsAgainst(),
// $stand->getData()->getPoints(),
// ]);
//}
//$table->render();
//
//echo $output->fetch();
$event = $generator->getEventProvider()->getEvent(2059521);
echo "----- EVENT -----\n";
echo implode(' - ', array_map(function(Participant $part) { return $part->getName(); }, $event->getParticipants()));
echo "\n";
echo $event->getStartDate()->format('Y-m-d H:i');
echo "\n=================================";
// ordinare time - meaning in regular time
// CS: Hvis en kamp ender med 15-15 (så stoppes ordinær tid her, selvom kampen fortsætter i overtid)
/**
* 1x2 - Ordinare time
*/
echo "\n\n1x2 - Ordinare time\n-------------------\n\n";
// 1x2 - 3Way (ordinare time) - Home (1)
// CS: Hvis Astralis mod Faze og Astralis vinder - så er 1 tallet opfyldt (ordinær tid kun!) (BEMÆRK at det er fordi Astralis står først)
echo "// 1x2 - Ordinare time - Home\n\n";
$multipleOdds = $event->getOrd1x2HomeTeamOdds();
foreach ($multipleOdds as $singleOdds) {
foreach ($singleOdds->getOffers() as $offer) {
echo $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
// 1x2 - 3Way (ordinare time) - Draw (x)
// CS: Hvis Astralis mod Faze spiller uafgjort (15-15) - så er X'et opfyldt (ordinær tid kun!)
echo "// 1x2 - Ordinare time - Draw\n\n";
$multipleOdds = $event->getOrd1x2DrawOdds();
foreach ($multipleOdds as $singleOdds) {
foreach ($singleOdds->getOffers() as $offer) {
echo $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
// 1x2 - 3Way (ordinare time) - Away (2)
// CS: Hvis Astralis mod Faze og Faze vinder - så er 2 tallet opfyldt (ordinær tid kun!) (BEMÆRK at det er fordi Faze står til sidst)
echo "// 1x2 - Ordinare time - Away\n\n";
$multipleOdds = $event->getOrd1x2AwayTeamOdds();
foreach ($multipleOdds as $singleOdds) {
foreach ($singleOdds->getOffers() as $offer) {
echo $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
/**
* 1x2 - 1. half
*/
echo "\n\n1x2 - 1. half\n-------------------\n\n";
// 1x2 - 3Way (1. half) - Home (1)
// CS: Hvis Astralis mod Faze og Astralis vinder 1. halvleg (fx 9-6) - så er 1 tallet opfyldt (BEMÆRK at det er fordi Astralis står først)
echo "// 1x2 - 1. half - Home\n\n";
$multipleOdds = $event->get1H1x2HomeTeamOdds();
foreach ($multipleOdds as $singleOdds) {
foreach ($singleOdds->getOffers() as $offer) {
echo $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
// 1x2 - 3Way (1. half) - Draw (x)
// CS: Hvis Astralis mod Faze og Astralis spiller uafgjort i 1. halvleg (kan så ikke lade sig gøre i CS - men forstil dig 7-7)
echo "// 1x2 - 1. half - Draw\n\n";
$multipleOdds = $event->get1H1x2DrawOdds();
foreach ($multipleOdds as $singleOdds) {
foreach ($singleOdds->getOffers() as $offer) {
echo $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
// 1x2 - 3Way (1. half) - Away (2)
// CS: Hvis Astralis mod Faze og Faze vinder - 1. halvleg (fx 6-9) så er 2 tallet opfyldt (BEMÆRK at det er fordi Faze står til sidst)
echo "// 1x2 - 1. half - Away\n\n";
$multipleOdds = $event->get1H1x2DrawOdds();
foreach ($multipleOdds as $singleOdds) {
foreach ($singleOdds->getOffers() as $offer) {
echo $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
/**
* O/E (Ord / Even goals)
*/
echo "\n\nO/E (odd/even goals)\n-------------------\n\n";
// Get the odds if the match ends with even goals (ordinare time)
// CS: Ender kampen Astralis - Faze med en lige score altså fx 12-16 (28 mål)
echo "// Even goals\n\n";
$multipleOdds = $event->getOrdEvenGoals();
foreach ($multipleOdds as $singleOdds) {
foreach ($singleOdds->getOffers() as $offer) {
echo $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
// Get the odds if the match ends with odd goals (ordinare time)
// CS: Ender kampen Astralis - Faze med en lige score altså fx 13-16 (29 mål)
echo "// Odd goals\n\n";
$multipleOdds = $event->getOrdOddGoals();
foreach ($multipleOdds as $singleOdds) {
foreach ($singleOdds->getOffers() as $offer) {
echo $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
/**
* O/U (Over / Under goals) - Ordinare time
*/
echo "\n\nO/U (Over / Under goals) (ordinar time)\n-------------------\n\n";
// Get the odds if goals scored in (ordinare time) is over a number
// CS: Ender kampen Astralis - Faze med en lige score over 18.5 mål (Dparam1 = antal mål) altså fx 3-16 (19 mål)
echo "// Over goals\n\n";
$multipleOdds = $event->getOrdOverGoals();
foreach ($multipleOdds as $singleOdds) {
foreach ($singleOdds->getOffers() as $offer) {
echo 'Over: ' . $singleOdds->getDparam1() . ' ' . $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
// Get the odds if goals scored in (ordinare time) is under a number
// CS: Ender kampen Astralis - Faze med en lige score UNDER 18.5 mål (Dparam1 = antal mål) altså fx 1-16 (17 mål)
echo "// Under goals\n\n";
$multipleOdds = $event->getOrdUnderGoals();
foreach ($multipleOdds as $singleOdds) {
foreach ($singleOdds->getOffers() as $offer) {
echo 'Under: ' . $singleOdds->getDparam1() . ' ' . $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
/**
* O/U (Over / Under goals) - 1. half
*/
echo "\n\nO/U (Over / Under goals) (1. half)\n-------------------\n\n";
// Get the odds if goals scored in (1. half) is over a number
// CS: Ender kampen Astralis - Faze med en lige score over 10.5 mål (Dparam1 = antal mål) altså fx 2-9 (11 mål)
echo "// Over goals\n";
$multipleOdds = $event->get1HOverGoals();
foreach ($multipleOdds as $singleOdds) {
foreach ($singleOdds->getOffers() as $offer) {
echo 'Over: ' . $singleOdds->getDparam1() . ' ' . $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
// Get the odds if goals scored in (1. half) is under a number
// CS: Ender kampen Astralis - Faze med en lige score UNDER 12.5 mål (Dparam1 = antal mål) altså fx 11-4 (15 mål)
echo "\n// Under goals\n";
$multipleOdds = $event->get1HUnderGoals();
foreach ($multipleOdds as $singleOdds) {
foreach ($singleOdds->getOffers() as $offer) {
echo 'Under: ' . $singleOdds->getDparam1() . ' ' . $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
/**
* 1x2 with handicap
*/
echo "\n\n1x2 with handicap (ordinar time)\n-------------------\n\n";
// Same as the other 1x2 - but this is when a team starts with a either minus or plus goals
// This is a special one, because we need some handicap
// 1x2 Handicap - Ordinare time - Home
echo "\n\n// 1x2 Handicap - Ordinare time - Home\n\n";
$multipleHandicaps = $event->getOrd1x2HomeTeamOddsHandicap();
foreach ($multipleHandicaps as $handicap) {
echo "\nHandicap: " . $handicap->getHandicap() . ' Team - ' . $handicap->getParticipant()->getName() . "\n----------\n";
foreach ($handicap->getOffers() as $offer) {
echo $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
// 1x2 Handicap - Ordinare time - Draw
echo "\n\n// 1x2 Handicap - Ordinare time - Draw\n\n";
$multipleHandicaps = $event->getOrd1x2HomeTeamOddsHandicap();
foreach ($multipleHandicaps as $handicap) {
echo "\nHandicap: " . $handicap->getHandicap() . ' Team - ' . $handicap->getParticipant()->getName() . "\n----------\n";
foreach ($handicap->getOffers() as $offer) {
echo $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
// 1x2 Handicap - Ordinare time - Away
echo "\n\n// 1x2 Handicap - Ordinare time - Away\n\n";
$multipleHandicaps = $event->getOrd1x2AwayTeamOddsHandicap();
foreach ($multipleHandicaps as $handicap) {
echo "\nHandicap: " . $handicap->getHandicap() . ' Team - ' . $handicap->getParticipant()->getName() . "\n----------\n";
foreach ($handicap->getOffers() as $offer) {
echo $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
/**
* DC (Double Chance)
*/
// CS: Her kan man spille på om et hold enten vinder eller spiller uafgjort (dobbelt chance)
echo "\n\nDC (Double chance) (ordinar time)\n-------------------\n\n";
// Win/Draw - Ordinare time - Home
echo "\n// Home team\n";
$multipleOdds = $event->get1HOverGoals();
foreach ($multipleOdds as $singleOdds) {
foreach ($singleOdds->getOffers() as $offer) {
echo $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
// Win/Draw - Ordinare time - Away
echo "\n// Away team\n";
$multipleOdds = $event->get1HOverGoals();
foreach ($multipleOdds as $singleOdds) {
foreach ($singleOdds->getOffers() as $offer) {
echo $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
/**
* hf_tf (Halftime / Fulltime)
*/
echo "\n\nhf_tf (Halftime / Fulltime)\n-------------------\n\n";
// CS: Her kan man spille på hvem der vinder 1. halvleg og hvem der vinder ved fuldtid
// Fx Astralis - Faze 9-6 (Astralis vandt første halvleg) - Kampen ender 12-16 (Faze vandt fuldtid)
// BEMÆRK - at hvis et af holdene er NULL så er det uafjort
// Fx
// Astralis - Faze 9-6 - men kampen ender 15-15 - så vil Astralis holdet være halvlegs holdet - men der vil være NULL i fuldtids holdet
$multipleHFTF = $event->getOrdHalftimeFulltime();
foreach ($multipleHFTF as $singleHFTF) {
$halfTime = 'X';
$fullTime = 'X';
if (null !== $singleHFTF->getHalftimeParticipant()) {
$halfTime = $singleHFTF->getHalftimeParticipant()->getId() === $event->getParticipants()[0]->getId() ? 1 : 2;
}
if (null !== $singleHFTF->getFullTimeParticipant()) {
$fullTime = $singleHFTF->getFullTimeParticipant()->getId() === $event->getParticipants()[0]->getId() ? 1 : 2;
}
echo $halfTime . ' / ' . $fullTime . "\n";
foreach ($singleHFTF->getOffers() as $offer) {
echo $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
/**
* bts (Both team scores)
*/
echo "\n\nbts (Both team scores)\n-------------------\n\n";
echo "\n// Yes\n";
$multipleOdds = $event->getOrdBothTeamScoresYes();
foreach ($multipleOdds as $singleOdds) {
foreach ($singleOdds->getOffers() as $offer) {
echo $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
echo "\n// No\n";
$multipleOdds = $event->getOrdBothTeamScoresNo();
foreach ($multipleOdds as $singleOdds) {
foreach ($singleOdds->getOffers() as $offer) {
echo $offer->getProvider()->getName() . ' - ' . $offer->getOdds() . "\n";
}
}
/**
* Upcoming matches for a participant (not started matches)
*/
echo "\n\nUpcoming matches for a participant (not started matches)\n-------------------\n\n";
// Can be either a integer or a participant object
$events = $generator->getEventProvider()->getUpcomingMatchesParticipant($event->getParticipants()[0], 5);
foreach ($events as $upcomingEvent) {
echo $upcomingEvent->getStartDate()->format('Y-m-d H:i') . ' - ' . implode(' - ', array_map(function(Participant $participant) { return $participant->getName(); }, $upcomingEvent->getParticipants())) . "\n";
}
/**
* Latest matches for a participant (finished matches)
*/
echo "\n\nLatest matches for a participant (finished matches)\n-------------------\n\n";
// Can be either a integer or a participant object
$events = $generator->getEventProvider()->getLatestMatchesParticipant($event->getParticipants()[0], 5);
foreach ($events as $latestEvent) {
echo $latestEvent->getStartDate()->format('Y-m-d H:i') . ' - ' . implode(' - ', array_map(function(Participant $participant) { return $participant->getName(); }, $latestEvent->getParticipants())) . "\n";
}
/**
* Latest matches between multiple participants (finished matches)
*/
echo "\n\nLatest matches between multiple participants (finished matches)\n-------------------\n\n";
// Can be either a array of integers or an array of participant objects
$events = $generator->getEventProvider()->getLatestMatchesBetween($event->getParticipants(), 5);
foreach ($events as $latestBetween) {
echo $latestBetween->getStartDate()->format('Y-m-d H:i') . ' - ' . implode(' - ', array_map(function(Participant $participant) { return $participant->getName(); }, $latestBetween->getParticipants())) . "\n";
}
/**
* AH (Asian Handicap)
*/
// This will decrease or increase the "start" goals for both teams
// This is a special one, because we need the score - so it will
// Ja, jeg jeg kan ikke give nogle eksempler på hvad der menes med den, da jeg ikke har nogle anelse om hvad der er med den
$output = new BufferedOutput();
$table = new Table($output);
$multipleHandicaps = $event->getOrdAH();
$table->setHeaders(['Hometeam', 'Awayteam', 'Starting home score', 'Starting away score', 'odds']);
foreach ($multipleHandicaps as $handicap) {
$table->addRow([
$event->getParticipants()[0]->getName(),
$event->getParticipants()[1]->getName(),
$event->getParticipants()[0]->getId() === $handicap->getParticipant()->getId() ? $handicap->getHandicap() : 0,
$event->getParticipants()[1]->getId() === $handicap->getParticipant()->getId() ? $handicap->getHandicap() : 0,
implode("\n", array_map(function(Offer $offer) {
return $offer->getProvider()->getName() . ' - ' . $offer->getOdds();
}, $handicap->getOffers()))
]);
$table->addRow(new TableSeparator());
}
$table->render();
echo $output->fetch();