forked from Talishar/Talishar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJoinGameInput.php
More file actions
651 lines (618 loc) · 24.1 KB
/
JoinGameInput.php
File metadata and controls
651 lines (618 loc) · 24.1 KB
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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
<?php
include "WriteLog.php";
include "Libraries/HTTPLibraries.php";
include "Libraries/SHMOPLibraries.php";
include "APIKeys/APIKeys.php";
include_once 'includes/functions.inc.php';
include_once 'includes/dbh.inc.php';
if (!function_exists("DelimStringContains")) {
function DelimStringContains($str, $find, $partial=false)
{
$arr = explode(",", $str);
for($i=0; $i<count($arr); ++$i)
{
if($partial && str_contains($arr[$i], $find)) return true;
else if($arr[$i] == $find) return true;
}
return false;
}
}
if (!function_exists("SubtypeContains")) {
function SubtypeContains($cardID, $subtype, $player="")
{
$cardSubtype = CardSubtype($cardID);
return DelimStringContains($cardSubtype, $subtype);
}
}
session_start();
$gameName = $_GET["gameName"];
if (!IsGameNameValid($gameName)) {
echo ("Invalid game name.");
exit;
}
$playerID = intval($_GET["playerID"]);
$deck = TryGet("deck");
$decklink = $_GET["fabdb"];
$decksToTry = TryGet("decksToTry");
$favoriteDeck = TryGet("favoriteDeck", "0");
$favoriteDeckLink = TryGet("favoriteDecks", "0");
$set = TryGet("set");
$matchup = TryGet("matchup", "");
$starterDeck = false;
if ($matchup == "" && GetCachePiece($gameName, $playerID + 6) != "") {
$_SESSION['error'] = '⚠️ Another player has already joined the game.';
header("Location: MainMenu.php");
die();
}
if ($decklink == "" && $deck == "" && $favoriteDeckLink == "0") {
$starterDeck = true;
switch ($decksToTry) {
case '1':
$decklink = "https://fabrary.net/decks/01GJG7Z4WGWSZ95FY74KX4M557";
break;
default:
$decklink = "https://fabrary.net/decks/01GJG7Z4WGWSZ95FY74KX4M557";
break;
}
}
if ($favoriteDeckLink != "0" && $decklink == "") $decklink = $favoriteDeckLink;
if ($deck == "" && !IsDeckLinkValid($decklink)) {
echo '<b>' . "⚠️ Deck URL is not valid: " . $decklink . '</b>';
exit;
}
include "HostFiles/Redirector.php";
include "CardDictionary.php";
include "MenuFiles/ParseGamefile.php";
include "MenuFiles/WriteGamefile.php";
if ($matchup == "" && $playerID == 2 && $gameStatus >= $MGS_Player2Joined) {
if ($gameStatus >= $MGS_GameStarted) {
header("Location: " . $redirectPath . "/NextTurn4.php?gameName=$gameName&playerID=3");
} else {
header("Location: " . $redirectPath . "/MainMenu.php");
}
WriteGameFile();
exit;
}
if ($decklink != "") {
if ($playerID == 1) $p1DeckLink = $decklink;
else if ($playerID == 2) $p2DeckLink = $decklink;
$curl = curl_init();
$isFaBDB = str_contains($decklink, "fabdb");
$isFaBMeta = str_contains($decklink, "fabmeta");
if ($isFaBDB) {
$decklinkArr = explode("/", $decklink);
$slug = $decklinkArr[count($decklinkArr) - 1];
$apiLink = "https://api.fabdb.net/decks/" . $slug;
} else if (str_contains($decklink, "fabrary")) {
$headers = array(
"x-api-key: " . $FaBraryKey,
"Content-Type: application/json",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$decklinkArr = explode("/", $decklink);
$decklinkArr = explode("?", $decklinkArr[count($decklinkArr) - 1]);
$slug = $decklinkArr[0];
$apiLink = "https://5zvy977nw7.execute-api.us-east-2.amazonaws.com/prod/decks/" . $slug;
if ($matchup != "") $apiLink .= "?matchupId=" . $matchup;
} else {
$decklinkArr = explode("/", $decklink);
$slug = $decklinkArr[count($decklinkArr) - 1];
$apiLink = "https://api.fabmeta.net/deck/" . $slug;
}
curl_setopt($curl, CURLOPT_URL, $apiLink);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$apiDeck = curl_exec($curl);
$apiInfo = curl_getinfo($curl);
curl_close($curl);
if ($apiDeck === FALSE) {
if(is_array($decklink)) echo '<b>' . "⚠️ Deckbuilder API for this deck returns no data: " . implode("/", $decklink) . '</b>';
else echo '<b>' . "⚠️ Deckbuilder API for this deck returns no data: " . $decklink . '</b>';
WriteGameFile();
exit;
}
$deckObj = json_decode($apiDeck);
// if has message forbidden error out.
if ($apiInfo['http_code'] == 403) {
$_SESSION['error'] =
"API FORBIDDEN! Invalid or missing token to access API: " . $apiLink . " The response from the deck hosting service was: " . $apiDeck;
header("Location: MainMenu.php");
die();
}
if($deckObj == null)
{
echo 'Deck object is null. Failed to retrieve deck from API.';
exit;
}
$deckName = $deckObj->{'name'};
if (isset($deckObj->{'matchups'})) {
if ($playerID == 1) $p1Matchups = $deckObj->{'matchups'};
else if ($playerID == 2) $p2Matchups = $deckObj->{'matchups'};
}
$deckFormat = (isset($deckObj->{'format'}) ? $deckObj->{'format'} : "");
$cards = $deckObj->{'cards'};
$deckCards = "";
$sideboardCards = "";
$headSideboard = "";
$chestSideboard = "";
$armsSideboard = "";
$legsSideboard = "";
$offhandSideboard = "";
$quiverSideboard = "";
$unsupportedCards = "";
$bannedCard = "";
$character = "";
$head = "";
$chest = "";
$arms = "";
$legs = "";
$offhand = "";
$quiver = "";
$weapon1 = "";
$weapon2 = "";
$weaponSideboard = "";
$totalCards = 0;
if (is_countable($cards)) {
for ($i = 0; $i < count($cards); ++$i) {
$count = $cards[$i]->{'total'};
$numSideboard = (isset($cards[$i]->{'sideboardTotal'}) ? $cards[$i]->{'sideboardTotal'} : 0);
$id = "";
if ($isFaBDB) {
$printings = $cards[$i]->{'printings'};
$printing = $printings[0];
$sku = $printing->{'sku'};
$id = $sku->{'sku'};
$id = explode("-", $id)[0];
} else if ($isFaBMeta) {
$id = $cards[$i]->{'identifier'};
} else if(isset($cards[$i]->{'cardIdentifier'})) {
$id = $cards[$i]->{'cardIdentifier'};
}
if($id == "") continue;
$id = GetAltCardID($id);
$cardType = CardType($id);
$cardSet = substr($id, 0, 3);
if (IsBanned($id, $format)) {
if ($bannedCard != "") $bannedCard .= ", ";
$bannedCard .= CardName($id);
}
if ($cardType == "") //Card not supported, error
{
if ($unsupportedCards != "") $unsupportedCards .= " ";
$unsupportedCards .= $id;
} else if (TypeContains($cardID, "C")) {
$character = $id;
} else if (TypeContains($cardID, "W")) {
$numMainBoard = ($isFaBDB ? $count - $numSideboard : $count);
for ($j = 0; $j < $numMainBoard; ++$j) {
if ($weapon1 == "") $weapon1 = $id;
else if ($weapon2 == "") $weapon2 = $id;
else {
if ($weaponSideboard != "") $weaponSideboard .= " ";
$weaponSideboard .= $id;
}
}
for ($j = 0; $j < $numSideboard; ++$j) {
if ($weaponSideboard != "") $weaponSideboard .= " ";
$weaponSideboard .= $id;
}
} else if (TypeContains($cardID, "E")) {
if ($numSideboard == 0) {
if (SubtypeContains($id, "Head")) {
if ($head == "") $head = $id;
else {
if ($headSideboard != "") $headSideboard .= " ";
$headSideboard .= $id;
}
} else if (SubtypeContains($id, "Chest")) {
if ($chest == "") $chest = $id;
else {
if ($chestSideboard != "") $chestSideboard .= " ";
$chestSideboard .= $id;
}
} else if (SubtypeContains($id, "Arms")) {
if ($arms == "") $arms = $id;
else {
$armsSideboard .= " ";
$armsSideboard .= $id;
}
} else if (SubtypeContains($id, "Legs")) {
if ($legs == "") $legs = $id;
else {
if ($legsSideboard != "") $legsSideboard .= " ";
$legsSideboard .= $id;
}
} else if (SubtypeContains($id, "Off-Hand")) {
if ($offhand == "") $offhand = $id;
else {
if ($offhandSideboard != "") $offhandSideboard .= " ";
$offhandSideboard .= $id;
}
} else if (SubtypeContains($id, "Quiver")) {
if ($quiver == "") $quiver = $id;
else {
if ($quiverSideboard != "") $quiverSideboard .= " ";
$quiverSideboard .= $id;
}
}
} else {
if (SubtypeContains($id, "Head")) {
if ($headSideboard != "") $headSideboard .= " ";
$headSideboard .= $id;
} else if (SubtypeContains($id, "Chest")) {
if ($chestSideboard != "") $chestSideboard .= " ";
$chestSideboard .= $id;
} else if (SubtypeContains($id, "Arms")) {
if ($armsSideboard != "") $armsSideboard .= " ";
$armsSideboard .= $id;
} else if (SubtypeContains($id, "Legs")) {
if ($legsSideboard != "") $legsSideboard .= " ";
$legsSideboard .= $id;
} else if (SubtypeContains($id, "Off-Hand")) {
if ($offhandSideboard != "") $offhandSideboard .= " ";
$offhandSideboard .= $id;
} else if (SubtypeContains($id, "Quiver")) {
if ($quiverSideboard != "") $quiverSideboard .= " ";
$quiverSideboard .= $id;
}
}
} else {
$numMainBoard = ($isFaBDB ? $count - $numSideboard : $count);
for ($j = 0; $j < $numMainBoard; ++$j) {
if ($deckCards != "") $deckCards .= " ";
$deckCards .= $id;
}
for ($j = 0; $j < $numSideboard; ++$j) {
if ($sideboardCards != "") $sideboardCards .= " ";
$sideboardCards .= $id;
}
$totalCards += $numMainBoard + $numSideboard;
}
}
}
//We have the decklist, now write to file
$filename = "./Games/" . $gameName . "/p" . $playerID . "Deck.txt";
$deckFile = fopen($filename, "w");
$charString = $character;
if ($weapon1 != "") $charString .= " " . $weapon1;
if ($weapon2 != "") $charString .= " " . $weapon2;
if ($offhand != "") $charString .= " " . $offhand;
if ($quiver != "") $charString .= " " . $quiver;
if ($head != "") $charString .= " " . $head;
if ($chest != "") $charString .= " " . $chest;
if ($arms != "") $charString .= " " . $arms;
if ($legs != "") $charString .= " " . $legs;
fwrite($deckFile, $charString . "\r\n");
fwrite($deckFile, $deckCards . "\r\n");
fwrite($deckFile, $headSideboard . "\r\n");
fwrite($deckFile, $chestSideboard . "\r\n");
fwrite($deckFile, $armsSideboard . "\r\n");
fwrite($deckFile, $legsSideboard . "\r\n");
fwrite($deckFile, $offhandSideboard . "\r\n");
fwrite($deckFile, $weaponSideboard . "\r\n");
fwrite($deckFile, $sideboardCards . "\r\n");
fwrite($deckFile, $quiverSideboard);
fclose($deckFile);
copy($filename, "./Games/" . $gameName . "/p" . $playerID . "DeckOrig.txt");
if (isset($_SESSION["userid"])) {
include_once './includes/functions.inc.php';
include_once "./includes/dbh.inc.php";
$deckbuilderID = GetDeckBuilderId($_SESSION["userid"], $decklink);
if ($deckbuilderID != "") {
if ($playerID == 1) $p1deckbuilderID = $deckbuilderID;
else $p2deckbuilderID = $deckbuilderID;
}
}
if ($favoriteDeck == "on" && isset($_SESSION["userid"])) {
//Save deck
include_once './includes/functions.inc.php';
include_once "./includes/dbh.inc.php";
addFavoriteDeck($_SESSION["userid"], $decklink, $deckName, $character, $deckFormat);
}
} else {
$character = "";
$deckOptions = explode("-", $deck);
if ($deckOptions[0] == "DRAFT") {
if ($set == "WTR") $deckFile = "./WTRDraftFiles/Games/" . $deckOptions[1] . "/LimitedDeck.txt";
else $deckFile = "./DraftFiles/Games/" . $deckOptions[1] . "/LimitedDeck.txt";
} else if ($deckOptions[0] == "SEALED") {
$deckFile = "./SealedFiles/Games/" . $deckOptions[1] . "/LimitedDeck.txt";
} else if ($deckOptions[0] == "ROGUELIKE") {
$deckFile = "./Roguelike/Games/" . $deckOptions[1] . "/LimitedDeck.txt";
} else {
//Draftfab
$deckFile = "./Games/" . $gameName . "/p" . $playerID . "DraftDeck.txt";
ParseDraftFab($deck, $deckFile);
}
copy($deckFile, "./Games/" . $gameName . "/p" . $playerID . "Deck.txt");
copy($deckFile, "./Games/" . $gameName . "/p" . $playerID . "DeckOrig.txt");
}
if ($matchup == "") {
if ($playerID == 2) {
$gameStatus = $MGS_Player2Joined;
if (file_exists("./Games/" . $gameName . "/gamestate.txt")) unlink("./Games/" . $gameName . "/gamestate.txt");
$firstPlayerChooser = 1;
$p1roll = 0;
$p2roll = 0;
$tries = 10;
while ($p1roll == $p2roll && $tries > 0) {
$p1roll = rand(1, 6) + rand(1, 6);
$p2roll = rand(1, 6) + rand(1, 6);
WriteLog("🎲 Player 1 rolled $p1roll and Player 2 rolled $p2roll.");
--$tries;
}
$firstPlayerChooser = ($p1roll > $p2roll ? 1 : 2);
WriteLog("Player $firstPlayerChooser chooses who goes first.");
$gameStatus = $MGS_ChooseFirstPlayer;
$joinerIP = $_SERVER['REMOTE_ADDR'];
}
if ($playerID == 1) {
$p1uid = (isset($_SESSION["useruid"]) ? $_SESSION["useruid"] : "Player 1");
$p1id = (isset($_SESSION["userid"]) ? $_SESSION["userid"] : "");
$p1IsPatron = (isset($_SESSION["isPatron"]) ? "1" : "");
$p1ContentCreatorID = (isset($_SESSION["patreonEnum"]) ? $_SESSION["patreonEnum"] : "");
} else if ($playerID == 2) {
$p2uid = (isset($_SESSION["useruid"]) ? $_SESSION["useruid"] : "Player 2");
$p2id = (isset($_SESSION["userid"]) ? $_SESSION["userid"] : "");
$p2IsPatron = (isset($_SESSION["isPatron"]) ? "1" : "");
$p2ContentCreatorID = (isset($_SESSION["patreonEnum"]) ? $_SESSION["patreonEnum"] : "");
}
if ($playerID == 2) $p2Key = hash("sha256", rand() . rand() . rand());
WriteGameFile();
SetCachePiece($gameName, $playerID + 1, strval(round(microtime(true) * 1000)));
SetCachePiece($gameName, $playerID + 3, "0");
SetCachePiece($gameName, $playerID + 6, $character);
SetCachePiece($gameName, 14, $gameStatus);
GamestateUpdated($gameName);
//$authKey = ($playerID == 1 ? $p1Key : $p2Key);
//$_SESSION["authKey"] = $authKey;
$domain = (!empty(getenv("DOMAIN")) ? getenv("DOMAIN") : "talishar.net");
if ($playerID == 1) {
$_SESSION["p1AuthKey"] = $p1Key;
setcookie("lastAuthKey", $p1Key, time() + 86400, "/", $domain);
} else if ($playerID == 2) {
$_SESSION["p2AuthKey"] = $p2Key;
setcookie("lastAuthKey", $p2Key, time() + 86400, "/", $domain);
}
}
session_write_close();
$authKey = ($playerID == 1 ? $p1Key : $p2Key);
if($isDraftFab) header("Location: https://talishar.net/game/lobby/$gameName/?playerID=$playerID&authKey=$authKey");
else header("Location: " . $redirectPath . "/GameLobby.php?gameName=$gameName&playerID=$playerID");
function ParseDraftFab($deck, $filename)
{
$character = "DYN001";
$deckCards = "";
$headSideboard = "";
$chestSideboard = "";
$armsSideboard = "";
$legsSideboard = "";
$offhandSideboard = "";
$quiverSideboard = "";
$weaponSideboard = "";
$sideboardCards = "";
$cards = explode(",", $deck);
for ($i = 0; $i < count($cards); ++$i) {
$card = explode(":", $cards[$i]);
$cardID = GetAltCardID($card[0]);
$quantity = $card[2];
$type = CardType($cardID);
switch ($type) {
case TypeContains($cardID, "T"):
break;
case TypeContains($cardID, "C"):
$character = $cardID;
break;
case TypeContains($cardID, "W"):
if ($weaponSideboard != "") $weaponSideboard .= " ";
$weaponSideboard .= $cardID;
break;
case "E":
if (SubtypeContains($cardID, "Head")) {
if ($headSideboard != "") $headSideboard .= " ";
$headSideboard .= $cardID;
} else if (SubtypeContains($cardID, "Chest")) {
if ($chestSideboard != "") $chestSideboard .= " ";
$chestSideboard .= $cardID;
} else if (SubtypeContains($cardID, "Arms")) {
if ($armsSideboard != "") $armsSideboard .= " ";
$armsSideboard .= $cardID;
} else if (SubtypeContains($cardID, "Legs")) {
if ($legsSideboard != "") $legsSideboard .= " ";
$legsSideboard .= $cardID;
} else if (SubtypeContains($cardID, "Off-Hand")) {
if ($offhandSideboard != "") $offhandSideboard .= " ";
$offhandSideboard .= $cardID;
} else if (SubtypeContains($cardID, "Quiver")) {
if ($quiverSideboard != "") $quiverSideboard .= " ";
$quiverSideboard .= $cardID;
}
break;
default:
for ($j = 0; $j < $quantity; ++$j) {
if ($card[1] == "S") {
if ($sideboardCards != "") $sideboardCards .= " ";
$sideboardCards .= GetAltCardID($cardID);
} else {
if ($deckCards != "") $deckCards .= " ";
$deckCards .= GetAltCardID($cardID);
}
}
break;
}
}
$deckFile = fopen($filename, "w");
$charString = $character;
fwrite($deckFile, $charString . "\r\n");
fwrite($deckFile, $deckCards . "\r\n");
fwrite($deckFile, $headSideboard . "\r\n");
fwrite($deckFile, $chestSideboard . "\r\n");
fwrite($deckFile, $armsSideboard . "\r\n");
fwrite($deckFile, $legsSideboard . "\r\n");
fwrite($deckFile, $offhandSideboard . "\r\n");
fwrite($deckFile, $weaponSideboard . "\r\n");
fwrite($deckFile, $sideboardCards . "\r\n");
fwrite($deckFile, $quiverSideboard);
fclose($deckFile);
}
function GetAltCardID($cardID)
{
switch ($cardID) {
case "OXO001": return "WTR155";
case "OXO002": return "WTR156";
case "OXO003": return "WTR157";
case "OXO004": return "WTR158";
case "BOL002": return "MON405";
case "BOL006": return "MON400";
case "CHN002": return "MON407";
case "CHN006": return "MON401";
case "LEV002": return "MON406";
case "LEV005": return "MON400";
case "PSM002": return "MON404";
case "PSM007": return "MON402";
case "FAB015": return "WTR191";
case "FAB016": return "WTR162";
case "FAB023": return "MON135";
case "FAB024": return "ARC200";
case "FAB030": return "DYN030";
case "FAB057": return "EVR063";
case "EVR120": return "UPR103";
case "DVR026": return "WTR182";
case "RVD008": return "WTR006";
case "UPR209": return "WTR191";
case "UPR210": return "WTR192";
case "UPR211": return "WTR193";
case "HER075": return "DYN025";
case "LGS112": return "DYN070";
case "LGS116": return "DYN200";
case "LGS117": return "DYN201";
case "LGS118": return "DYN202";
case "ARC218":
case "UPR224":
case "MON306":
case "ELE237": //Cracked Baubles
return "WTR224";
case "DYN238": return "MON401";
case "RVD004": return "DVR004";
case "OUT077": return "WTR098";
case "OUT078": return "WTR099";
case "OUT079": return "WTR100";
case "OUT083": return "WTR107";
case "OUT084": return "WTR108";
case "OUT085": return "WTR109";
case "OUT086": return "EVR047";
case "OUT087": return "EVR048";
case "OUT088": return "EVR049";
case "OUT213": return "ARC191";
case "OUT214": return "ARC192";
case "OUT215": return "ARC193";
case "OUT216": return "MON251";
case "OUT217": return "MON252";
case "OUT218": return "MON253";
case "OUT222": return "ARC203";
case "OUT223": return "ARC204";
case "OUT224": return "ARC205";
case "WIN022": return "OUT091";
case "HER085": return "DTD134";
case "FAB161": return "DTD048";
case "FAB162": return "DTD049";
case "FAB163": return "DTD050";
case "LGS179": return "DTD054";
case "LGS180": return "DTD055";
case "LGS181": return "DTD056";
case "AUR002": return "ROS009";
}
return $cardID;
}
function IsBanned($cardID, $format)
{
$set = substr($cardID, 0, 3);
if ($format == "commoner" && (Rarity($cardID) != "C" && Rarity($cardID) != "T" && Rarity($cardID) != "R")) return true;
//Ban spoilers in formats besides Open Format
if(($format != "openformatcc" && $format != "openformatblitz" && $format != "openformatllcc" && $format != "openformatllblitz") && $set == "ROS") return true; // Launch 20th September
switch ($format) {
case "blitz":
case "compblitz":
switch ($cardID) {
case "WTR164": case "WTR165": case "WTR166": // Drone of Brutality
case "WTR152": // Heartened Cross Strap
case "ARC076": case "ARC077": // Viserai | Nebula Blade
case "ELE006": // Awakening
case "ELE186": case "ELE187": case "ELE188": // Ball Lightning
case "ELE223": // Duskblade
case "CRU141": // Bloodsheath Skeleta
case "CRU174": case "CRU175": case "CRU176": // Snapback
case "MON154": case "MON155": // Chane | Galaxxi Black
case "MON239": // Stubby Hammers
case "EVR037": // Mask of Pouncing Lynx
case "UPR103": case "EVR120": case "EVR121": // Iyslander | Kraken's Aethervein
case "ELE002": case "ELE003": // Oldhim | Winter's Wail
case "ARC114": case "ARC115": case "CRU159": // Kano | Crucible of Aetherweave
case "CRU077": // Kassai, Cintari Sellsword
case "CRU046": case "CRU050": // Ira, Crimson Haze | Edge of Autumn
case "DYN009": //Berserk
case "ELE115": // Crown of Seeds
case "EVR123": // Aether Wildfire
case "ARC132": case "ARC133": case "ARC134": // Aether Flare
case "ARC002": case "ARC003": // Dash | Teklo Plasma Pistol
case "ELE063": case "ELE222": // Briar | Rosetta Thorn
case "MST047": case "MST159": // Zen | Tiger Taming Khakkara
case "ARC160": // Art of War
case "OUT056": case "OUT057": case "OUT058": // Bonds of Ancestry
case "CRU188": // Cash In
case "MST080": // Orihon of Mystic Tenets
case "ARC122": // Tome of Aetherwind
case "MON022": // Tome of Divinity
case "WTR160": // Tome of Fyendal
case "UPR089": // Tome of Firebrand
return true;
default:
return false;
}
case "cc":
case "compcc":
switch ($cardID) {
case "WTR164": case "WTR165": case "WTR166": // Drone of Brutality
case "ARC170": case "ARC171": case "ARC172": // Plunder Run
case "CRU141": // Bloodsheath Skeleta
case "MON001": case "MON003": // Prism Sculptor of Arc Light | Luminaris
case "MON153": case "MON155": // Chane, Bound by Shadow | Galaxxi Black
case "MON239": // Stubby Hammers
case "MON266": case "MON267": case "MON268": // Belittle
case "ELE001": case "ELE003": // Oldhim, Grandfather of Eternity | Winter's Wail
case "ELE006": // Awakening
case "ELE031": case "ELE034":// Lexi, Livewire | Voltaire, Strike Twice
case "ELE062": case "ELE222": // Briar, Warden of Thorns | Rosetta Thorn
case "ELE186": case "ELE187": case "ELE188": // Ball Lightning
case "ELE223": // Duskblade
case "EVR017": // Bravo, Star of the Show
case "UPR001": case "UPR003": // Dromai, Ash Artist | Storm of Sandikai
case "UPR102": case "EVR121": // Iyslander, Stormbind | Kraken's Aethervein
case "DYN009": //Berserk
case "ELE115": // Crown of Seeds
case "OUT057": case "OUT058": // Bonds of Ancestry (B) (Y)
case "ARC160": // Art of War
case "OUT056": // Bonds of Ancestry (R)
case "CRU188": // Cash In
case "MST080": // Orihon of Mystic Tenets
case "ARC122": // Tome of Aetherwind
case "MON022": // Tome of Divinity
case "WTR160": // Tome of Fyendal
case "UPR089": // Tome of Firebrand
return true;
default:
return false;
}
case "commoner":
switch ($cardID) {
case "ELE186": case "ELE187": case "ELE188": // Ball Lightning
case "MON266": case "MON267": case "MON268": // Belittle
case "ELE172": // Amulet of Ice
case "MON239": // Stubby Hammers
return true;
default:
return false;
}
default:
return false;
}
}