forked from Talishar/Talishar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChooseFirstPlayer.php
38 lines (31 loc) · 927 Bytes
/
ChooseFirstPlayer.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
<?php
include "WriteLog.php";
include "Libraries/HTTPLibraries.php";
include "Libraries/SHMOPLibraries.php";
$gameName = $_GET["gameName"];
if (!IsGameNameValid($gameName)) {
echo ("Invalid game name.");
exit;
}
$playerID = $_GET["playerID"];
$action = $_GET["action"];
$authKey = $_GET["authKey"];
include "HostFiles/Redirector.php";
include "MenuFiles/ParseGamefile.php";
include "MenuFiles/WriteGamefile.php";
$targetAuth = ($playerID == 1 ? $p1Key : $p2Key);
if ($authKey != $targetAuth) {
echo ("Invalid Auth Key");
exit;
}
if ($action == "Go First") {
$firstPlayer = $playerID;
} else {
$firstPlayer = ($playerID == 1 ? 2 : 1);
}
WriteLog("Player " . $firstPlayer . " will go first.");
$gameStatus = $MGS_P2Sideboard;
SetCachePiece($gameName, 14, $gameStatus);
GamestateUpdated($gameName);
WriteGameFile();
header("Location: " . $redirectPath . "/GameLobby.php?gameName=$gameName&playerID=$playerID");