forked from Talishar/Talishar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAllyAbilities.php
345 lines (331 loc) · 11.9 KB
/
AllyAbilities.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
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
<?php
function PlayAlly($cardID, $player, $subCards="-", $number=1, $isToken=false, $firstTransform=true)
{
global $EffectContext;
$otherPlayer = ($player == 1 ? 2 : 1);
if(TypeContains($cardID, "T", $player)) $isToken = true;
$numMinusTokens = 0;
$numMinusTokens = CountCurrentTurnEffects("HVY209", $player) + CountCurrentTurnEffects("HVY209", $otherPlayer);
if($numMinusTokens > 0 && $isToken && (TypeContains($EffectContext, "AA", $player) || TypeContains($EffectContext, "A", $player)) && $firstTransform) $number -= $numMinusTokens;
$allies = &GetAllies($player);
for($i = 0; $i < $number; ++$i) {
array_push($allies, $cardID);
array_push($allies, 2);
array_push($allies, AllyHealth($cardID));
array_push($allies, 0); //Frozen
array_push($allies, $subCards); //Subcards
array_push($allies, GetUniqueId($cardID, $player)); //Unique ID
array_push($allies, AllyEnduranceCounters($cardID)); //Endurance Counters
array_push($allies, 0); //Life Counters
array_push($allies, 1); //Ability/effect uses
array_push($allies, 0); //Attack Counters
if($cardID == "UPR414") {
WriteLog(CardLink($cardID, $cardID) . " lets you transform up to 1 ash into an Ashwing.");
Transform($player, "Ash", "UPR042", true);
}
}
return count($allies) - AllyPieces();
}
function DestroyAlly($player, $index, $skipDestroy = false, $fromCombat = false)
{
global $mainPlayer;
$allies = &GetAllies($player);
if(!$skipDestroy) AllyDestroyedAbility($player, $index);
if(IsSpecificAllyAttacking($player, $index) || (IsSpecificAllyAttackTarget($player, $index) && !$fromCombat)) {
CloseCombatChain();
}
$cardID = $allies[$index];
AllyAddGraveyard($player, $cardID);
AllyAddGraveyard($player, $allies[$index+4]);
for($j = $index + AllyPieces() - 1; $j >= $index; --$j) unset($allies[$j]);
$allies = array_values($allies);
return $cardID;
}
function AllyAddGraveyard($player, $cardID)
{
if(CardType($cardID) != "T") {
if(SubtypeContains($cardID, "Ash", $player)) AddGraveyard($cardID, $player, "PLAY", $player);
$set = substr($cardID, 0, 3);
$number = intval(substr($cardID, 3, 3));
$number -= 400;
if($number < 0) return;
$id = $number;
if($number < 100) $id = "0" . $id;
if($number < 10) $id = "0" . $id;
$id = $set . $id;
if(!SubtypeContains($id, "Invocation", $player) && !SubtypeContains($id, "Figment", $player)) return;
AddGraveyard($id, $player, "PLAY", $player);
}
}
function AllyHealth($cardID)
{
switch($cardID) {
case "MON219": return 6;
case "MON220": return 6;
case "UPR406": return 6;
case "UPR407": return 5;
case "UPR408": return 4;
case "UPR409": return 3;
case "UPR410": return 2;
case "UPR411": return 2;
case "UPR412": return 4;
case "UPR413": return 7;
case "UPR414": return 6;
case "UPR415": return 4;
case "UPR416": return 1;
case "UPR417": return 3;
case "DYN612": return 4;
case "DTD193": return 6;
case "DTD405": return 4;
case "DTD406": return 4;
case "DTD407": return 4;
case "DTD408": return 4;
case "DTD409": return 4;
case "DTD410": return 4;
case "DTD411": return 4;
case "DTD412": return 4;
case "HVY134": return 2;
default: return 1;
}
}
function AllyDestroyedAbility($player, $index)
{
global $mainPlayer;
$allies = &GetAllies($player);
$cardID = $allies[$index];
switch($cardID) {
case "UPR410":
if($player == $mainPlayer && $allies[$index+8] > 0) {
GainActionPoints(1, $player);
--$allies[$index+8];
}
break;
case "UPR551":
$charIndex = FindCharacterIndex($player, "UPR151");
if($charIndex > -1) DestroyCharacter($player, $charIndex);
break;
default: break;
}
if (HasWard($cardID, $player)) WardPoppedAbility($player, $cardID);
}
function AllyStartTurnAbilities($player)
{
$allies = &GetAllies($player);
for($i = 0; $i < count($allies); $i += AllyPieces()) {
switch($allies[$i]) {
case "UPR414":
WriteLog(CardLink($allies[$i], $allies[$i]) . " lets you transform up to 1 ash into an Ashwing.");
Transform($player, "Ash", "UPR042", true);
break;
default: break;
}
}
}
function AllyEnduranceCounters($cardID)
{
switch($cardID) {
case "UPR417": return 1;
default: return 0;
}
}
function AllyDamagePrevention($player, $index, $damage, $type="")
{
$allies = &GetAllies($player);
$cardID = $allies[$index];
$canBePrevented = CanDamageBePrevented($player, $damage, $type);
switch($cardID) {
case "UPR417":
if($allies[$index + 6] > 0) {
if($damage > 0) --$allies[$index + 6];
if($canBePrevented) $damage -= 3;
if($damage < 0) $damage = 0;
}
return $damage;
default: return $damage;
}
}
//NOTE: This is for ally abilities that trigger when any ally attacks (for example miragai GRANTS an ability)
function AllyAttackAbilities($attackID)
{
global $mainPlayer, $CS_NumDragonAttacks;
$allies = &GetAllies($mainPlayer);
for($i = 0; $i < count($allies); $i += AllyPieces()) {
switch($allies[$i]) {
case "UPR412":
if($allies[$i + 8] > 0 && DelimStringContains(CardSubType($attackID), "Dragon") && GetClassState($mainPlayer, $CS_NumDragonAttacks) <= 1) {
AddCurrentTurnEffect("UPR412", $mainPlayer);
--$allies[$i + 8];
}
break;
default: break;
}
}
}
//NOTE: This is for the actual attack abilities that allies have
function SpecificAllyAttackAbilities($attackID)
{
global $mainPlayer, $combatChainState, $CCS_WeaponIndex, $defPlayer;
$allies = &GetAllies($mainPlayer);
$i = $combatChainState[$CCS_WeaponIndex];
switch($allies[$i]) {
case "UPR406":
if(IsHeroAttackTarget()) {
AddLayer("TRIGGER", $mainPlayer, $allies[$i], "-", "-", $allies[$i + 5]);
}
return "";
case "UPR407":
if(IsHeroAttackTarget()) {
AddLayer("TRIGGER", $mainPlayer, $allies[$i], "-", "-", $allies[$i + 5]);
}
return "";
case "UPR408":
if(IsHeroAttackTarget()) {
AddLayer("TRIGGER", $mainPlayer, $allies[$i], "-", "-", $allies[$i + 5]);
}
return "";
case "UPR409":
AddLayer("TRIGGER", $mainPlayer, $allies[$i], "-", "-", $allies[$i + 5]);
return "";
case "UPR410":
if($attackID == $allies[$i] && $allies[$i + 8] > 0) {
GainActionPoints(1);
--$allies[$i + 8];
WriteLog("Gained 1 action point from " . CardLink($allies[$i], $allies[$i]));
}
break;
case "DTD405":
$soul = &GetSoul($mainPlayer);
if(count($soul) == 0) break;
AddDecisionQueue("YESNO", $mainPlayer, "if you want to banish a card from soul");
AddDecisionQueue("NOPASS", $mainPlayer, "-");
MZMoveCard($mainPlayer, "MYSOUL", "MYBANISH,SOUL,-", isSubsequent:true);
AddDecisionQueue("DRAW", $mainPlayer, "-", 1);
AddDecisionQueue("DRAW", $mainPlayer, "-", 1);
break;
case "DTD406":
$soul = &GetSoul($mainPlayer);
if(count($soul) == 0) break;
AddDecisionQueue("YESNO", $mainPlayer, "if you want to banish a card from soul");
AddDecisionQueue("NOPASS", $mainPlayer, "-");
MZMoveCard($mainPlayer, "MYSOUL", "MYBANISH,SOUL,-", isSubsequent:true);
AddDecisionQueue("MULTIZONEINDICES", $mainPlayer, "THEIRBANISH", 1);
AddDecisionQueue("MAYCHOOSEMULTIZONE", $mainPlayer, "<-", 1);
AddDecisionQueue("MZOP", $mainPlayer, "TURNBANISHFACEDOWN", 1);
break;
case "DTD407":
$soul = &GetSoul($mainPlayer);
if(count($soul) == 0) break;
AddDecisionQueue("YESNO", $mainPlayer, "if you want to banish a card from soul");
AddDecisionQueue("NOPASS", $mainPlayer, "-");
MZMoveCard($mainPlayer, "MYSOUL", "MYBANISH,SOUL,-", isSubsequent:true);
AddDecisionQueue("PLAYAURA", $mainPlayer, "MON104", 1);
AddDecisionQueue("PLAYAURA", $mainPlayer, "MON104", 1);
break;
case "DTD408":
$soul = &GetSoul($mainPlayer);
if(count($soul) == 0) break;
AddDecisionQueue("YESNO", $mainPlayer, "if you want to banish a card from soul");
AddDecisionQueue("NOPASS", $mainPlayer, "-");
MZMoveCard($mainPlayer, "MYSOUL", "MYBANISH,SOUL,-", isSubsequent:true);
DealArcane(2, 2, "PLAYCARD", $allies[$i], false, $mainPlayer, isPassable:1);
break;
case "DTD409":
$soul = &GetSoul($mainPlayer);
if(count($soul) == 0) break;
AddDecisionQueue("YESNO", $mainPlayer, "if you want to banish a card from soul");
AddDecisionQueue("NOPASS", $mainPlayer, "-");
MZMoveCard($mainPlayer, "MYSOUL", "MYBANISH,SOUL,-", isSubsequent:true);
MZMoveCard($mainPlayer, "MYDISCARD:pitch=2", "MYTOPDECK", isSubsequent:true);
break;
case "DTD410":
$soul = &GetSoul($mainPlayer);
if(count($soul) == 0) break;
AddDecisionQueue("YESNO", $mainPlayer, "if you want to banish a card from soul");
AddDecisionQueue("NOPASS", $mainPlayer, "-");
MZMoveCard($mainPlayer, "MYSOUL", "MYBANISH,SOUL,-", isSubsequent:true);
AddDecisionQueue("ADDCURRENTEFFECT", $mainPlayer, "DTD410", 1);
break;
case "DTD411":
$soul = &GetSoul($mainPlayer);
if(count($soul) == 0) break;
AddDecisionQueue("YESNO", $mainPlayer, "if you want to banish a card from soul");
AddDecisionQueue("NOPASS", $mainPlayer, "-");
MZMoveCard($mainPlayer, "MYSOUL", "MYBANISH,SOUL,-", isSubsequent:true);
AddDecisionQueue("ADDCURRENTANDNEXTTURNEFFECT", $defPlayer, "DTD411", 1);
break;
case "DTD412":
$soul = &GetSoul($mainPlayer);
if(count($soul) == 0) break;
AddDecisionQueue("YESNO", $mainPlayer, "if you want to banish a card from soul");
AddDecisionQueue("NOPASS", $mainPlayer, "-");
MZMoveCard($mainPlayer, "MYSOUL", "MYBANISH,SOUL,-", isSubsequent:true);
AddDecisionQueue("MULTIZONEINDICES", $mainPlayer, "MYALLY:subtype=Angel", 1);
AddDecisionQueue("ADDALLATTACKCOUNTERS", $mainPlayer, "1", 1);
break;
default: break;
}
}
function AllyDamageTakenAbilities($player, $i)
{
$allies = &GetAllies($player);
switch($allies[$i]) {
case "UPR413":
$allies[$i+2] -= 1;
$allies[$i+7] -= 1;
PutPermanentIntoPlay($player, "UPR043");
WriteLog(CardLink($allies[$i], $allies[$i]) . " got a -1 health counter and created an ash token");
break;
default: break;
}
}
function AllyTakeDamageAbilities($player, $index, $damage, $preventable)
{
$allies = &GetAllies($player);
//CR 2.1 6.4.10f If an effect states that a prevention effect can not prevent the damage of an event, the prevention effect still applies to the event but its prevention amount is not reduced. Any additional modifications to the event by the prevention effect still occur.
$remove = false;
if($damage > 0 && HasWard($allies[$index], $player)) {
if($preventable) $damage -= WardAmount($allies[$index], $player);
$remove = true;
WardPoppedAbility($player, $allies[$index]);
}
switch($allies[$index]) {
default: break;
}
if($remove) DestroyAlly($player, $index);
if($damage <= 0) $damage = 0;
return $damage;
}
function AllyBeginEndTurnEffects()
{
global $mainPlayer, $defPlayer;
//CR 2.0 4.4.3a Reset health for all allies
$mainAllies = &GetAllies($mainPlayer);
for($i = 0; $i < count($mainAllies); $i += AllyPieces()) {
if($mainAllies[$i+1] != 0) {
$mainAllies[$i+1] = 2;
$mainAllies[$i+2] = AllyHealth($mainAllies[$i]) + $mainAllies[$i+7];
$mainAllies[$i+8] = 1;
}
}
$defAllies = &GetAllies($defPlayer);
for($i = 0; $i < count($defAllies); $i += AllyPieces()) {
if($defAllies[$i+1] != 0) {
$defAllies[$i+1] = 2;
$defAllies[$i+2] = AllyHealth($defAllies[$i]) + $defAllies[$i + 7];
$defAllies[$i+8] = 1;
}
}
}
function AllyEndTurnAbilities()
{
global $mainPlayer;
$allies = &GetAllies($mainPlayer);
for($i = count($allies) - AllyPieces(); $i >= 0; $i -= AllyPieces()) {
switch($allies[$i]) {
case "UPR551":
DestroyAlly($mainPlayer, $i, true);
break;
default: break;
}
}
}