forked from Talishar/Talishar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimulateGame.php
102 lines (79 loc) · 2.62 KB
/
SimulateGame.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
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
ob_start();
include "WriteLog.php";
include "GameLogic.php";
include "GameTerms.php";
include "HostFiles/Redirector.php";
include "Libraries/SHMOPLibraries.php";
include "Libraries/StatFunctions.php";
include "Libraries/UILibraries.php";
include "Libraries/PlayerSettings.php";
include "Libraries/NetworkingLibraries.php";
include "AI/CombatDummy.php";
include "AI/PlayerMacros.php";
include "Libraries/HTTPLibraries.php";
require_once("Libraries/CoreLibraries.php");
include_once "./includes/dbh.inc.php";
include_once "./includes/functions.inc.php";
include_once "APIKeys/APIKeys.php";
ob_end_clean();
$gameName = $_GET["gameName"];
if (!IsGameNameValid($gameName)) {
echo ("Invalid game name.");
exit;
}
$gameName = "r" . $gameName;
$filename = "./Games/" . $gameName . "/commandfile.txt";
$handler = fopen($filename, "r");
$filesize = filesize($filename);
$commands = explode("\r\n", fread($handler, $filesize));
fclose($handler);
$playerID = $commands[0][0];
copy("./Games/" . $gameName . "/startGamestate.txt", "./Games/" . $gameName . "/gamestate.txt");
include "ParseGamestate.php";
$otherPlayer = $currentPlayer == 1 ? 2 : 1;
$skipWriteGamestate = false;
$mainPlayerGamestateStillBuilt = 0;
$makeCheckpoint = 0;
$makeBlockBackup = 0;
$MakeStartTurnBackup = false;
$targetAuth = ($playerID == 1 ? $p1Key : $p2Key);
$conceded = false;
$randomSeeded = false;
$afterResolveEffects = [];
$animations = [];
echo(count($commands) . "<BR>");
for($k=0; $k<count($commands); ++$k)
{
$skipWriteGamestate = false;
$makeCheckpoint = 0;
$makeBlockBackup = 0;
$MakeStartTurnBackup = false;
$command = explode(" ", $commands[$k]);
if(count($command) < 5) break;
if($command[5] == "") $command[5] = [];
else $command[5] = explode("|", $command[5]);
$playerID = $command[0];
BuildMyGamestate($playerID);
echo($command[0] . " " . $command[1] . " " . $command[2] . " " . $command[3] . " " . $command[4] . "<BR>");
$mode = $command[1];
ProcessInput($command[0], $command[1], $command[2], $command[3], $command[4], $command[5], true);
ProcessMacros();
CacheCombatResult();
$defPlayer = $mainPlayer == 1 ? 2 : 1;
DoGamestateUpdate();
if (!$skipWriteGamestate) {
UpdateGameState($playerID);
WriteGamestate();
}
if ($makeCheckpoint) MakeGamestateBackup();
if ($makeBlockBackup) MakeGamestateBackup("preBlockBackup.txt");
if ($MakeStartTurnBackup) MakeStartTurnBackup();
if($mode == 10000) ParseGamestate();
}
//include "WriteGamestate.php";
?>
Something is wrong with the XAMPP installation :-(