forked from Talishar/Talishar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartEffects.php
More file actions
244 lines (209 loc) · 8.14 KB
/
StartEffects.php
File metadata and controls
244 lines (209 loc) · 8.14 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
<?php
include "HostFiles/Redirector.php";
include_once "AccountFiles/AccountSessionAPI.php";
// Initialize game state
$layerPriority = [];
array_push($layerPriority, ShouldHoldPriority(1));
array_push($layerPriority, ShouldHoldPriority(2));
// Get player characters and health
$p1Char = &GetPlayerCharacter(1);
$p2Char = &GetPlayerCharacter(2);
$p1H = &GetHealth(1);
$p2H = &GetHealth(2);
$p1H = CharacterHealth($p1Char[0]);
$p2H = CharacterHealth($p2Char[0]);
$format = is_numeric($format) ? FormatName($format) : $format;
if ($p1StartingHealth != "") $p1H = $p1StartingHealth;
// Initialize game log
$fullLog = "../Games/" . $gameName . "/fullGamelog.txt";
if (!file_exists($fullLog)) $fullLog = "../Games/" . $gameName . "/fullGamelog.txt";
if (file_exists($fullLog)) {
$handler = fopen($fullLog, "w+");
fwrite($handler, "Player $firstPlayer is the first player and will begin play\r\n");
fclose($handler);
}
// Set up initial game state
$mainPlayer = $firstPlayer;
$currentPlayer = $firstPlayer;
$otherPlayer = ($currentPlayer == 1 ? 2 : 1);
StatsStartTurn();
$MakeStartTurnBackup = false;
$MakeStartGameBackup = false;
if (IsPlayerAI($currentPlayer)) {
SetCachePiece($gameName, 3, "99999999999999");
}
//Dummy - Single Player
if ($p2Char[0] == "DUMMY") {
$cards = ["combustible_courier_red", "zipper_hit_red", "zipper_hit_blue", "zipper_hit_yellow", "over_loop_blue", "micro_processor_blue", "induction_chamber_red", "zero_to_sixty_red"];
for ($i = 0; $i < 5; ++$i) {
AddGraveyard($cards[array_rand($cards)], 2, "DECK");
}
}
// Handle character-specific start game abilities
handleCharacterStartAbilities();
$zones = ['head' => 'Head', 'chest' => 'Chest', 'arms' => 'Arms', 'legs' => 'Legs'];
function equipModularForPlayer($playerID, $equipmentObj, $zones) {
foreach ($zones as $zoneKey => $zoneName) {
if (!isset($equipmentObj->$zoneKey)) continue;
$card = $equipmentObj->$zoneKey;
if (IsModular($card)) {
EquipEquipment($playerID, $card, $zoneName);
unset($equipmentObj->$zoneKey);
}
}
}
equipModularForPlayer(1, $p1StartingEquipment, $zones);
equipModularForPlayer(2, $p2StartingEquipment, $zones);
// Handle inventory start game abilities
InventoryStartGameAbilities(1);
InventoryStartGameAbilities(2);
// Handle Cogwerx equipment
handleCogwerxEquipment($p1Char, $p2Char);
//Macro for Limited
if($format == "draft"){
AddDecisionQueue("PASSPARAMETER", "-", "omens_of_arcana");
AddDecisionQueue("PUTPLAY", "-", "-", 1);
}
// Add final game setup decisions
GameSetup();
ProcessDecisionQueue();
CombatDummyAI(); //Only does anything if applicable
DoGamestateUpdate();
include "WriteGamestate.php";
if ($MakeStartTurnBackup) MakeStartTurnBackup();
if ($MakeStartGameBackup) MakeGamestateBackup("origGamestate.txt");
function handleCharacterStartAbilities()
{
global $p1Char, $p2Char, $format;
// Dash abilities
$p1IsDash = in_array($p1Char[0], ["dash_inventor_extraordinaire", "dash"]);
$p2IsDash = in_array($p2Char[0], ["dash_inventor_extraordinaire", "dash"]);
if ($p1IsDash) {
$items = SearchDeck(1, "", "Item", 2, -1, "MECHANOLOGIST");
AddDecisionQueue("CHOOSEDECK", 1, $items);
AddDecisionQueue("SETDQVAR", 1, "0");
}
if ($p2IsDash) {
$items = SearchDeck(2, "", "Item", 2, -1, "MECHANOLOGIST");
AddDecisionQueue("CHOOSEDECK", 2, $items);
AddDecisionQueue("SETDQVAR", 2, "1");
}
if ($p1IsDash) {
AddDecisionQueue("PASSPARAMETER", 1, "{0}");
AddDecisionQueue("PUTPLAY", 1, "-");
}
if ($p2IsDash) {
AddDecisionQueue("PASSPARAMETER", 2, "{1}");
AddDecisionQueue("PUTPLAY", 2, "-");
}
// Fai abilities
if (in_array($p1Char[0], ["fai_rising_rebellion", "fai"])) {
$cards = SearchDeckForCard(1, "phoenix_flame_red");
if ($cards != "") {
AddDecisionQueue("MAYCHOOSEDECK", 1, $cards);
AddDecisionQueue("ADDDISCARD", 1, "DECK", 1);
}
}
if (in_array($p2Char[0], ["fai_rising_rebellion", "fai"])) {
$cards = SearchDeckForCard(2, "phoenix_flame_red");
if ($cards != "") {
AddDecisionQueue("MAYCHOOSEDECK", 2, $cards);
AddDecisionQueue("ADDDISCARD", 2, "DECK", 1);
}
}
// Crown of Dominion
if (SearchCharacterForCard(1, "crown_of_dominion")) {
AddDecisionQueue("PASSPARAMETER", 1, "gold");
AddDecisionQueue("PUTPLAY", 1, "False");
}
if (SearchCharacterForCard(2, "crown_of_dominion")) {
AddDecisionQueue("PASSPARAMETER", 2, "gold");
AddDecisionQueue("PUTPLAY", 2, "False");
}
// Seasoned Saviour
if (($index = FindCharacterIndex(1, "seasoned_saviour")) > 0) {
$p1Char[$index + 4] = -2;
}
if (($index = FindCharacterIndex(2, "seasoned_saviour")) > 0) {
$p2Char[$index + 4] = -2;
}
// graven equipment
$graven_equipment = ["graven_cowl", "graven_gloves", "graven_vestment", "graven_walkers"];
$Char1 = new PlayerCharacter(1);
$Char2 = new PlayerCharacter(2);
foreach ($graven_equipment as $cardID) {
$GravenCard = $Char1->FindCardID($cardID);
if ($GravenCard != "") $GravenCard->AddDefenseCounters(-1);
$GravenCard = $Char2->FindCardID($cardID);
if ($GravenCard != "") $GravenCard->AddDefenseCounters(-1);
}
// Barbed Castaway
if (($index = FindCharacterIndex(1, "barbed_castaway")) > 0) {
AddCurrentTurnEffect("barbed_castaway-Load", 1);
AddCurrentTurnEffect("barbed_castaway-Aim", 1);
}
if (($index = FindCharacterIndex(2, "barbed_castaway")) > 0) {
AddCurrentTurnEffect("barbed_castaway-Load", 2);
AddCurrentTurnEffect("barbed_castaway-Aim", 2);
}
// Victor
if (SearchCharacterForCard(1, "victor_goldmane_high_and_mighty") || SearchCharacterForCard(1, "victor_goldmane")) {
AddDecisionQueue("ADDCURRENTTURNEFFECT", 1, $p1Char[0] . "-1", 1);
}
if (SearchCharacterForCard(2, "victor_goldmane_high_and_mighty") || SearchCharacterForCard(2, "victor_goldmane")) {
AddDecisionQueue("ADDCURRENTTURNEFFECT", 2, $p2Char[0] . "-1", 1);
}
}
function handleCogwerxEquipment(&$p1Char, &$p2Char)
{
$equipment = ["cogwerx_base_head", "cogwerx_base_chest", "cogwerx_base_arms", "cogwerx_base_legs"];
foreach ($equipment as $cardID) {
EquipWithSteamCounter($cardID, $p1Char, $p2Char);
}
}
function GameSetup()
{
global $mainPlayer;
AddDecisionQueue("SHUFFLEDECK", 1, "SKIPSEED");
AddDecisionQueue("SHUFFLEDECK", 2, "SKIPSEED");
AddDecisionQueue("DRAWTOINTELLECT", 1, "-");
AddDecisionQueue("DRAWTOINTELLECT", 2, "-");
AddDecisionQueue("STARTGAME", $mainPlayer, "-");
AddDecisionQueue("STARTTURNABILITIES", $mainPlayer, "-");
}
function EquipWithSteamCounter($cardID, &$p1Char, &$p2Char)
{
if (($index = FindCharacterIndex(1, $cardID)) >= 0) $p1Char[$index + 2] += 1;
if (($index = FindCharacterIndex(2, $cardID)) >= 0) $p2Char[$index + 2] += 1;
}
function InventoryStartGameAbilities($player)
{
global $p1Inventory, $p2Inventory;
$inventory = $player == 1 ? $p1Inventory : $p2Inventory;
for ($i = 0; $i < count($inventory); $i += InventoryPieces()) {
switch ($inventory[$i]) {
case "levia_redeemed":
PutPermanentIntoPlay($player, "levia_redeemed");
array_push($inventory, "blasmophet_levia_consumed");
break;
case "adaptive_plating":
addAdaptiveEquipmentDecision($player, $inventory[$i], "ADAPTIVEPLATING");
break;
case "adaptive_dissolver":
addAdaptiveEquipmentDecision($player, $inventory[$i], "ADAPTIVEDISSOLVER");
break;
case "adaptive_alpha_mold":
addAdaptiveEquipmentDecision($player, $inventory[$i], "ADAPTIVEALPHAMOLD");
break;
}
}
}
function addAdaptiveEquipmentDecision($player, $cardID, $modalType)
{
AddDecisionQueue("LISTEMPTYEQUIPSLOTS", $player, "-");
AddDecisionQueue("SETDQVAR", $player, "0", 1);
AddDecisionQueue("SETDQCONTEXT", $player, "Choose where to equip your " . CardLink($cardID, $cardID), 1);
AddDecisionQueue("BUTTONINPUT", $player, "{0},None", 1);
AddDecisionQueue("MODAL", $player, $modalType, 1);
AddDecisionQueue("SHOWMODES", $player, strtolower($modalType), 1);
}