forked from Talishar/Talishar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChooseFirstPlayer.php
More file actions
39 lines (31 loc) · 910 Bytes
/
ChooseFirstPlayer.php
File metadata and controls
39 lines (31 loc) · 910 Bytes
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
<?php
include "WriteLog.php";
include "Libraries/HTTPLibraries.php";
include_once "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");