diff --git a/CoreLogic.php b/CoreLogic.php index cf2548f91..f93878198 100644 --- a/CoreLogic.php +++ b/CoreLogic.php @@ -1,73 +1,69 @@ $combatChainState[$CCS_WeaponIndex]+7) $attack = $allies[$combatChainState[$CCS_WeaponIndex]+7]; - } - if($canGainAttack || $attack < 0) - { - array_push($attackModifiers, "+1 Attack Counters", $attack); - AddAttack($totalAttack, $attack); - } - } - $attack = MainCharacterAttackModifiers(); - if($canGainAttack || $attack < 0) - { - array_push($attackModifiers, "Character/Equipment", $attack); - AddAttack($totalAttack, $attack); - } - //$attack = AuraAttackModifiers(0);//FAB - if($canGainAttack || $attack < 0) - { - array_push($attackModifiers, "Aura Ability", $attack); - AddAttack($totalAttack, $attack); + if ($combatChainState[$CCS_WeaponIndex] != -1) { + $attack = 0; + if ($attackType == "W") + $attack = $mainCharacter[$combatChainState[$CCS_WeaponIndex] + 3]; + else if (DelimStringContains(CardSubtype($combatChain[0]), "Aura")) + $attack = $mainAuras[$combatChainState[$CCS_WeaponIndex] + 3]; + else if (IsAlly($combatChain[0])) { + $allies = &GetAllies($mainPlayer); + if (count($allies) > $combatChainState[$CCS_WeaponIndex] + 7) + $attack = $allies[$combatChainState[$CCS_WeaponIndex] + 7]; } - $attack = ArsenalAttackModifier(); - if($canGainAttack || $attack < 0) - { - array_push($attackModifiers, "Arsenal Ability", $attack); + if ($canGainAttack || $attack < 0) { + array_push($attackModifiers, "+1 Attack Counters", $attack); AddAttack($totalAttack, $attack); } + } + $attack = MainCharacterAttackModifiers(); + if ($canGainAttack || $attack < 0) { + array_push($attackModifiers, "Character/Equipment", $attack); + AddAttack($totalAttack, $attack); + } + //$attack = AuraAttackModifiers(0);//FAB + if ($canGainAttack || $attack < 0) { + array_push($attackModifiers, "Aura Ability", $attack); + AddAttack($totalAttack, $attack); + } + $attack = ArsenalAttackModifier(); + if ($canGainAttack || $attack < 0) { + array_push($attackModifiers, "Arsenal Ability", $attack); + AddAttack($totalAttack, $attack); + } } function CharacterLevel($player) @@ -79,32 +75,35 @@ function CharacterLevel($player) function AddAttack(&$totalAttack, $amount) { global $combatChain; - if($amount > 0 && $combatChain[0] == "OUT100") $amount += 1; - if($amount > 0 && ($combatChain[0] == "OUT065" || $combatChain[0] == "OUT066" || $combatChain[0] == "OUT067") && ComboActive()) $amount += 1; - if($amount > 0) $amount += PermanentAddAttackAbilities(); + if ($amount > 0 && $combatChain[0] == "OUT100") + $amount += 1; + if ($amount > 0 && ($combatChain[0] == "OUT065" || $combatChain[0] == "OUT066" || $combatChain[0] == "OUT067") && ComboActive()) + $amount += 1; + if ($amount > 0) + $amount += PermanentAddAttackAbilities(); $totalAttack += $amount; } -function BlockingCardDefense($index, $from="", $resourcesPaid=-1) +function BlockingCardDefense($index, $from = "", $resourcesPaid = -1) { global $combatChain, $defPlayer, $mainPlayer, $currentTurnEffects; - $from = $combatChain[$index+2]; - $resourcesPaid = $combatChain[$index+3]; + $from = $combatChain[$index + 2]; + $resourcesPaid = $combatChain[$index + 3]; $defense = BlockValue($combatChain[$index]) + BlockModifier($combatChain[$index], $from, $resourcesPaid) + $combatChain[$index + 6]; - if(CardType($combatChain[$index]) == "E") - { + if (CardType($combatChain[$index]) == "E") { $defCharacter = &GetPlayerCharacter($defPlayer); $charIndex = FindDefCharacter($combatChain[$index]); - $defense += $defCharacter[$charIndex+4]; + $defense += $defCharacter[$charIndex + 4]; } for ($i = 0; $i < count($currentTurnEffects); $i += CurrentTurnPieces()) { if (IsCombatEffectActive($currentTurnEffects[$i]) && !IsCombatEffectLimited($i)) { if ($currentTurnEffects[$i + 1] == $defPlayer) { - $defense += EffectBlockModifier($currentTurnEffects[$i], index:$index); + $defense += EffectBlockModifier($currentTurnEffects[$i], index: $index); } } } - if($defense < 0) $defense = 0; + if ($defense < 0) + $defense = 0; return $defense; } @@ -136,13 +135,13 @@ function CacheCombatResult() { global $combatChain, $combatChainState, $CCS_CachedTotalAttack, $CCS_CachedTotalBlock, $CCS_CachedDominateActive, $CCS_CachedNumBlockedFromHand, $CCS_CachedOverpowerActive; global $CSS_CachedNumActionBlocked, $CCS_CachedNumDefendedFromHand; - if(count($combatChain) > 0) - { + if (count($combatChain) > 0) { $combatChainState[$CCS_CachedTotalAttack] = 0; $combatChainState[$CCS_CachedTotalBlock] = 0; EvaluateCombatChain($combatChainState[$CCS_CachedTotalAttack], $combatChainState[$CCS_CachedTotalBlock]); $combatChainState[$CCS_CachedDominateActive] = (IsDominateActive() ? "1" : "0"); - if ($combatChainState[$CCS_CachedNumBlockedFromHand] == 0) $combatChainState[$CCS_CachedNumBlockedFromHand] = NumBlockedFromHand(); + if ($combatChainState[$CCS_CachedNumBlockedFromHand] == 0) + $combatChainState[$CCS_CachedNumBlockedFromHand] = NumBlockedFromHand(); $combatChainState[$CCS_CachedOverpowerActive] = (IsOverpowerActive() ? "1" : "0"); $combatChainState[$CSS_CachedNumActionBlocked] = NumActionBlocked(); $combatChainState[$CCS_CachedNumDefendedFromHand] = NumDefendedFromHand(); //Reprise @@ -202,20 +201,23 @@ function ArsenalStartTurnAbilities() { global $mainPlayer; $arsenal = &GetArsenal($mainPlayer); - for($i=0; $i 0) - { + if (count($combatChain) > 0) { $attack = 0; $defense = 0; EvaluateCombatChain($attack, $defense); - if($attack > AttackValue($combatChain[0])) return true; + if ($attack > AttackValue($combatChain[0])) + return true; } return false; } -function DamageTrigger($player, $damage, $type, $source="NA", $canPass=false) +function DamageTrigger($player, $damage, $type, $source = "NA", $canPass = false) { AddDecisionQueue("DEALDAMAGE", $player, $damage . "-" . $source . "-" . $type, ($canPass ? 1 : "0")); return $damage; @@ -396,14 +394,16 @@ function DamageTrigger($player, $damage, $type, $source="NA", $canPass=false) // return true; // } -function DealDamageAsync($player, $damage, $type="DAMAGE", $source="NA") +function DealDamageAsync($player, $damage, $type = "DAMAGE", $source = "NA") { global $CS_DamagePrevention, $combatChain; global $CS_ArcaneDamagePrevention, $dqVars, $dqState; $classState = &GetPlayerClassState($player); - if($type == "COMBAT" && $damage > 0 && EffectPreventsHit()) HitEffectsPreventedThisLink(); - if($type == "COMBAT" || $type == "ATTACKHIT") $source = $combatChain[0]; + if ($type == "COMBAT" && $damage > 0 && EffectPreventsHit()) + HitEffectsPreventedThisLink(); + if ($type == "COMBAT" || $type == "ATTACKHIT") + $source = $combatChain[0]; $damage = max($damage, 0); $damageThreatened = $damage; // $preventable = CanDamageBePrevented($player, $damage, $type, $source);//FAB @@ -444,10 +444,10 @@ function DealDamageAsync($player, $damage, $type="DAMAGE", $source="NA") //$damage = ItemTakeDamageAbilities($player, $damage, $type); //if($damage == 1 && $preventable && SearchItemsForCard("EVR069", $player) != "") $damage = 0;//Must be last//FAB $dqVars[0] = $damage; - if($type == "COMBAT") $dqState[6] = $damage; + if ($type == "COMBAT") + $dqState[6] = $damage; PrependDecisionQueue("FINALIZEDAMAGE", $player, $damageThreatened . "," . $type . "," . $source); - if($damage > 0) - { + if ($damage > 0) { //AddDamagePreventionSelection($player, $damage, $preventable);//FAB AddDamagePreventionSelection($player, $damage, false); } @@ -468,16 +468,15 @@ function FinalizeDamage($player, $damage, $damageThreatened, $type, $source) global $CCS_AttackFused; $classState = &GetPlayerClassState($player); $otherPlayer = $player == 1 ? 2 : 1; - if($damage > 0) - { - if($source != "NA") - { + if ($damage > 0) { + if ($source != "NA") { $damage += CurrentEffectDamageModifiers($player, $source, $type); } AllyDealDamageAbilities($otherPlayer, $damage); $classState[$CS_DamageTaken] += $damage; - if($player == $defPlayer && $type == "COMBAT" || $type == "ATTACKHIT") $combatChainState[$CCS_AttackTotalDamage] += $damage; + if ($player == $defPlayer && $type == "COMBAT" || $type == "ATTACKHIT") + $combatChainState[$CCS_AttackTotalDamage] += $damage; // if($type == "ARCANE") $classState[$CS_ArcaneDamageTaken] += $damage;//FAB CurrentEffectDamageEffects($player, $source, $type, $damage); } @@ -495,14 +494,14 @@ function CurrentEffectDamageModifiers($player, $source, $type) { global $currentTurnEffects; $modifier = 0; - for($i=count($currentTurnEffects)-CurrentTurnPieces(); $i >= 0; $i-=CurrentTurnPieces()) - { + for ($i = count($currentTurnEffects) - CurrentTurnPieces(); $i >= 0; $i -= CurrentTurnPieces()) { $remove = 0; - switch($currentTurnEffects[$i]) - { - default: break; + switch ($currentTurnEffects[$i]) { + default: + break; } - if($remove == 1) RemoveCurrentTurnEffect($i); + if ($remove == 1) + RemoveCurrentTurnEffect($i); } return $modifier; } @@ -510,18 +509,21 @@ function CurrentEffectDamageModifiers($player, $source, $type) function CurrentEffectDamageEffects($target, $source, $type, $damage) { global $currentTurnEffects; - if(CardType($source) == "AA" && (SearchAuras("CRU028", 1) || SearchAuras("CRU028", 2))) return; - for($i=count($currentTurnEffects)-CurrentTurnPieces(); $i >= 0; $i-=CurrentTurnPieces()) - { - if($currentTurnEffects[$i+1] == $target) continue; - if($type == "COMBAT" && HitEffectsArePrevented()) continue; + if (CardType($source) == "AA" && (SearchAuras("CRU028", 1) || SearchAuras("CRU028", 2))) + return; + for ($i = count($currentTurnEffects) - CurrentTurnPieces(); $i >= 0; $i -= CurrentTurnPieces()) { + if ($currentTurnEffects[$i + 1] == $target) + continue; + if ($type == "COMBAT" && HitEffectsArePrevented()) + continue; $remove = 0; - switch($currentTurnEffects[$i]) - { + switch ($currentTurnEffects[$i]) { - default: break; + default: + break; } - if($remove == 1) RemoveCurrentTurnEffect($i); + if ($remove == 1) + RemoveCurrentTurnEffect($i); } } @@ -542,18 +544,19 @@ function LoseHealth($amount, $player) function Restore($amount, $player) { - if(SearchCurrentTurnEffects("7533529264", $player)) { + if (SearchCurrentTurnEffects("7533529264", $player)) { WriteLog("Wolffe prevents the healing"); return false; } - if(SearchAlliesForCard(1, "6277739341") != "" || SearchAlliesForCard(2, "6277739341") != "") { + if (SearchAlliesForCard(1, "6277739341") != "" || SearchAlliesForCard(2, "6277739341") != "") { WriteLog("Confederate Tri-Fighter prevents the healing"); return false; } $health = &GetHealth($player); WriteLog("Player " . $player . " gained " . $amount . " health."); - if($amount > $health) $amount = $health; + if ($amount > $health) + $amount = $health; $health -= $amount; AddEvent("RESTORE", "P" . $player . "BASE!" . $amount); return true; @@ -564,19 +567,21 @@ function PlayerLoseHealth($player, $amount) $health = &GetHealth($player); //$amount = AuraLoseHealthAbilities($player, $amount);//FAB $char = &GetPlayerCharacter($player); - if(count($char) == 0) return; + if (count($char) == 0) + return; $health += $amount; AddEvent("DAMAGE", "P" . $player . "BASE!" . $amount); - if(PlayerRemainingHealth($player) <= 0) - { + if (PlayerRemainingHealth($player) <= 0) { PlayerWon(($player == 1 ? 2 : 1)); } } -function PlayerRemainingHealth($player) { +function PlayerRemainingHealth($player) +{ $health = &GetHealth($player); $char = &GetPlayerCharacter($player); - if($char[0] == "DUMMY") return 1000 - $health; + if ($char[0] == "DUMMY") + return 1000 - $health; return CardHP($char[0]) - $health; } @@ -590,18 +595,23 @@ function PlayerWon($playerID) { global $winner, $turn, $gameName, $p1id, $p2id, $p1uid, $p2uid, $p1IsChallengeActive, $p2IsChallengeActive, $conceded, $currentRound; global $p1DeckLink, $p2DeckLink, $inGameStatus, $GameStatus_Over, $firstPlayer, $p1deckbuilderID, $p2deckbuilderID; - if($turn[0] == "OVER") return; + if ($turn[0] == "OVER") + return; include_once "./MenuFiles/ParseGamefile.php"; $winner = $playerID; - if ($playerID == 1 && $p1uid != "") WriteLog($p1uid . " wins!", $playerID); - elseif ($playerID == 2 && $p2uid != "") WriteLog($p2uid . " wins!", $playerID); - else WriteLog("Player " . $winner . " wins!"); + if ($playerID == 1 && $p1uid != "") + WriteLog($p1uid . " wins!", $playerID); + elseif ($playerID == 2 && $p2uid != "") + WriteLog($p2uid . " wins!", $playerID); + else + WriteLog("Player " . $winner . " wins!"); $inGameStatus = $GameStatus_Over; $turn[0] = "OVER"; SetCachePiece($gameName, 14, 6);//$MGS_GameOverStatsLogged - if(GetCachePiece($gameName, 14) == 7) return;//$MGS_StatsLoggedIrreversible + if (GetCachePiece($gameName, 14) == 7) + return;//$MGS_StatsLoggedIrreversible try { logCompletedGameStats(); } catch (Exception $e) { @@ -614,18 +624,19 @@ function PlayerWon($playerID) } - if(!$conceded || $currentRound>= 3) { + if (!$conceded || $currentRound >= 3) { //If this happens, they left a game in progress -- add disconnect logging? } } -function SendSWUStatsResults() { +function SendSWUStatsResults() +{ global $gameName, $firstPlayer, $winner, $currentRound, $p1id, $p2id, $p1DeckLink, $p2DeckLink; $url = 'https://swustats.net/TCGEngine/APIs/SubmitGameResult.php'; - $loser = ($winner == 1 ? 2 : 1); + $loser = ($winner == 1 ? 2 : 1); $winHero = GetCachePiece($gameName, ($winner == 1 ? 7 : 8)); - $loseHero = GetCachePiece($gameName, ($winner == 1 ? 8 : 7)); + $loseHero = GetCachePiece($gameName, ($winner == 1 ? 8 : 7)); $winnerHealth = GetHealth($winner); $p1Char = &GetPlayerCharacter(1); $p1Hero = FindLeaderInPlay(1); @@ -635,8 +646,8 @@ function SendSWUStatsResults() { $p2Hero = FindLeaderInPlay(2); $p2Base = $p2Char[0]; $p2BaseColor = AspectToColor(CardAspects($p2Base)); - $winnerDeck = file_get_contents("./Games/" . $gameName . "/p" . $winner . "Deck.txt"); - $loserDeck = file_get_contents("./Games/" . $gameName . "/p" . $loser . "Deck.txt"); + $winnerDeck = file_get_contents("./Games/" . $gameName . "/p" . $winner . "Deck.txt"); + $loserDeck = file_get_contents("./Games/" . $gameName . "/p" . $loser . "Deck.txt"); $data_json = json_encode([ 'gameName' => $gameName, 'round' => $currentRound, @@ -669,9 +680,9 @@ function SendSWUStatsResults() { // Check for errors if ($response === false) { - $error = curl_error($ch); - curl_close($ch); - die('Curl error: ' . $error); + $error = curl_error($ch); + curl_close($ch); + die('Curl error: ' . $error); } // Close cURL session @@ -680,33 +691,39 @@ function SendSWUStatsResults() { function AspectToColor($aspect) { - switch($aspect) { - case "Command": return "Green"; - case "Vigilance": return "Blue"; - case "Aggression": return "Red"; - case "Cunning": return "Yellow"; - case "Heroism": return "White"; - case "Villainy": return "Black"; + switch ($aspect) { + case "Command": + return "Green"; + case "Vigilance": + return "Blue"; + case "Aggression": + return "Red"; + case "Cunning": + return "Yellow"; + case "Heroism": + return "White"; + case "Villainy": + return "Black"; } } -function UnsetBanishModifier($player, $modifier, $newMod="DECK") +function UnsetBanishModifier($player, $modifier, $newMod = "DECK") { $banish = &GetBanish($player); - for($i=0; $i= 6) - { - $character[FindCharacterIndex($defPlayer, "MON089")+1] = 0; + if (!DelimStringContains($chainLinkSummary[$i * ChainLinkSummaryPieces() + 3], "ILLUSIONIST") && $chainLinkSummary[$i * ChainLinkSummaryPieces() + 1] >= 6) { + $character[FindCharacterIndex($defPlayer, "MON089") + 1] = 0; } break; case "RVD003": Writelog("Processing " . Cardlink($chainLinks[$i][$j], $chainLinks[$i][$j]) . " trigger: "); $deck = &GetDeck($defPlayer); $rv = ""; - if (count($deck) == 0) $rv .= "Your deck is empty. No card is revealed."; + if (count($deck) == 0) + $rv .= "Your deck is empty. No card is revealed."; $wasRevealed = RevealCards($deck[0]); if ($wasRevealed) { if (AttackValue($deck[0]) < 6) { @@ -887,7 +899,8 @@ function CombatChainClosedCharacterEffects() } } break; - default: break; + default: + break; } } } @@ -898,12 +911,11 @@ function NumDefendedFromHand() //Reprise { global $combatChain, $defPlayer; $num = 0; - for($i=0; $i $highRoll) $highRoll = $roll; + if ($roll > $highRoll) + $highRoll = $roll; } AddEvent("ROLL", $highRoll); SetClassState($player, $CS_DieRoll, $highRoll); $GGActive = HasGamblersGloves(1) || HasGamblersGloves(2); - if($GGActive) - { - if($fromDQ && !$subsequent) PrependDecisionQueue("AFTERDIEROLL", $player, "-"); + if ($GGActive) { + if ($fromDQ && !$subsequent) + PrependDecisionQueue("AFTERDIEROLL", $player, "-"); GamblersGloves($player, $player, $fromDQ); GamblersGloves(($player == 1 ? 2 : 1), $player, $fromDQ); - if(!$fromDQ && !$subsequent) AddDecisionQueue("AFTERDIEROLL", $player, "-"); - } - else - { - if(!$subsequent) AfterDieRoll($player); + if (!$fromDQ && !$subsequent) + AddDecisionQueue("AFTERDIEROLL", $player, "-"); + } else { + if (!$subsequent) + AfterDieRoll($player); } } @@ -1051,12 +1066,18 @@ function AfterDieRoll($player) global $CS_DieRoll, $CS_HighestRoll; $roll = GetClassState($player, $CS_DieRoll); $skullCrusherIndex = FindCharacterIndex($player, "EVR001"); - if($skullCrusherIndex > -1 && IsCharacterAbilityActive($player, $skullCrusherIndex)) - { - if($roll == 1) { WriteLog("Skull Crushers was destroyed."); DestroyCharacter($player, $skullCrusherIndex); } - if($roll == 5 || $roll == 6) { WriteLog("Skull Crushers gives +1 this turn."); AddCurrentTurnEffect("EVR001", $player); } + if ($skullCrusherIndex > -1 && IsCharacterAbilityActive($player, $skullCrusherIndex)) { + if ($roll == 1) { + WriteLog("Skull Crushers was destroyed."); + DestroyCharacter($player, $skullCrusherIndex); + } + if ($roll == 5 || $roll == 6) { + WriteLog("Skull Crushers gives +1 this turn."); + AddCurrentTurnEffect("EVR001", $player); + } } - if($roll > GetClassState($player, $CS_HighestRoll)) SetClassState($player, $CS_HighestRoll, $roll); + if ($roll > GetClassState($player, $CS_HighestRoll)) + SetClassState($player, $CS_HighestRoll, $roll); } function HasGamblersGloves($player) @@ -1068,18 +1089,14 @@ function HasGamblersGloves($player) function GamblersGloves($player, $origPlayer, $fromDQ) { $gamblersGlovesIndex = FindCharacterIndex($player, "CRU179"); - if(HasGamblersGloves($player)) - { - if($fromDQ) - { + if (HasGamblersGloves($player)) { + if ($fromDQ) { PrependDecisionQueue("ROLLDIE", $origPlayer, "1", 1); PrependDecisionQueue("DESTROYCHARACTER", $player, "-", 1); PrependDecisionQueue("PASSPARAMETER", $player, $gamblersGlovesIndex, 1); PrependDecisionQueue("NOPASS", $player, "-"); PrependDecisionQueue("YESNO", $player, "if_you_want_to_destroy_Gambler's_Gloves_to_reroll_the_result"); - } - else - { + } else { AddDecisionQueue("YESNO", $player, "if_you_want_to_destroy_Gambler's_Gloves_to_reroll_the_result"); AddDecisionQueue("NOPASS", $player, "-"); AddDecisionQueue("PASSPARAMETER", $player, $gamblersGlovesIndex, 1); @@ -1089,25 +1106,28 @@ function GamblersGloves($player, $origPlayer, $fromDQ) } } -function IsCharacterAbilityActive($player, $index, $checkGem=false) +function IsCharacterAbilityActive($player, $index, $checkGem = false) { $character = &GetPlayerCharacter($player); - if($checkGem && $character[$index+9] == 0) return false; - return $character[$index+1] == 2; + if ($checkGem && $character[$index + 9] == 0) + return false; + return $character[$index + 1] == 2; } -function GetMultizoneIndicesForTitle($player, $title, $onlyReady=false) { - $indices=[]; +function GetMultizoneIndicesForTitle($player, $title, $onlyReady = false) +{ + $indices = []; $char = &GetPlayerCharacter($player); $leaderIndex = CharacterPieces(); - if(count($char) > $leaderIndex && CardTitle($char[$leaderIndex]) == $title && (!$onlyReady || $char[$leaderIndex+1] == 2)) + if (count($char) > $leaderIndex && CardTitle($char[$leaderIndex]) == $title && (!$onlyReady || $char[$leaderIndex + 1] == 2)) array_push($indices, "MYCHAR-$leaderIndex"); $allies = SearchAlliesForTitle($player, $title); - if($allies != "") { + if ($allies != "") { $allies = explode(",", $allies); - for($i=0; $iIsExhausted()) array_push($indices, "MYALLY-$allies[$i]"); + if (!$onlyReady || !$ally->IsExhausted()) + array_push($indices, "MYALLY-$allies[$i]"); } } return implode(",", $indices); @@ -1172,7 +1192,8 @@ function ClearDieRoll($player) function HasLostClass($player) { - if(SearchCurrentTurnEffects("UPR187", $player)) return true;//Erase Face + if (SearchCurrentTurnEffects("UPR187", $player)) + return true;//Erase Face return false; } @@ -1212,16 +1233,18 @@ function HasLostClass($player) // return $cardClass; // } -function NameOverride($cardID, $player="") +function NameOverride($cardID, $player = "") { $name = CardName($cardID); - if(SearchCurrentTurnEffects("OUT183", $player)) $name = ""; + if (SearchCurrentTurnEffects("OUT183", $player)) + $name = ""; return $name; } -function DefinedTypesContains($cardID, $type, $player="") +function DefinedTypesContains($cardID, $type, $player = "") { - if(!$cardID || $cardID == "" || strlen($cardID) < 3) return ""; + if (!$cardID || $cardID == "" || strlen($cardID) < 3) + return ""; $cardTypes = DefinedCardType($cardID); $cardTypes2 = DefinedCardType2Wrapper($cardID); return DelimStringContains($cardTypes, $type) || DelimStringContains($cardTypes2, $type); @@ -1240,65 +1263,87 @@ function DefinedTypesContains($cardID, $type, $player="") // return DelimStringContains($cardClass, $class); // } -function AspectContains($cardID, $aspect, $player="") +function AspectContains($cardID, $aspect, $player = "") { $cardAspect = CardAspects($cardID); return DelimStringContains($cardAspect, $aspect); } -function TraitContainsAny($cardID, $traits, $player="", $index=-1) { +function TraitContainsAny($cardID, $traits, $player = "", $index = -1) +{ $traitsArr = explode(",", $traits); for ($i = 0; $i < count($traitsArr); $i++) { - if (TraitContains($cardID, $traitsArr[$i], $player, $index)) return true; + if (TraitContains($cardID, $traitsArr[$i], $player, $index)) + return true; } return false; } -function TraitContainsAll($cardID, $traits, $player="", $index=-1) { +function TraitContainsAll($cardID, $traits, $player = "", $index = -1) +{ $traitsArr = explode(",", $traits); for ($i = 0; $i < count($traitsArr); $i++) { - if (!TraitContains($cardID, $traits[$i], $player, $index)) return false; + if (!TraitContains($cardID, $traits[$i], $player, $index)) + return false; } return true; } -function TraitContains($cardID, $trait, $player="", $index=-1) { +function TraitContains($cardID, $trait, $player = "", $index = -1) +{ $trait = str_replace("_", " ", $trait); //"MZALLCARDTRAITORPASS" and possibly other decision queue options call this function with $trait having been underscoreified, so I undo that here. - if($index != -1) { + if ($index != -1) { $ally = new Ally("MYALLY-" . $index, $player); // Check for upgrades $upgrades = $ally->GetUpgrades(); - for($i=0; $iIsCloned() && $trait == "Clone") return true; + if ($ally->IsCloned() && $trait == "Clone") + return true; } $cardTrait = CardTraits($cardID); return DelimStringContains($cardTrait, $trait); } -function HasKeyword($cardID, $keyword, $player="", $index=-1){ - switch($keyword){ - case "Smuggle": return SmuggleCost($cardID, $player, $index) > -1; - case "Raid": return RaidAmount($cardID, $player, $index, true) > 0; - case "Grit": return HasGrit($cardID, $player, $index); - case "Restore": return RestoreAmount($cardID, $player, $index) > 0; - case "Bounty": return CollectBounty($player, $cardID, $cardID, false, $player, true) > 0; // Since we don't have information about "exhausted" and "owner," this data may be imprecise in very rare cases. - case "Overwhelm": return HasOverwhelm($cardID, $player, $index); - case "Saboteur": return HasSaboteur($cardID, $player, $index); - case "Shielded": return HasShielded($cardID, $player, $index); - case "Sentinel": return HasSentinel($cardID, $player, $index); - case "Ambush": return HasAmbush($cardID, $player, $index,""); - case "Coordinate": return HasCoordinate($cardID, $player, $index); - case "Exploit": return ExploitAmount($cardID, $player, true) > 0; - case "Piloting": return PilotingCost($cardID) > -1;//TODO: test Boba Daimyo trigger when piloting as upgrade vs unit +function HasKeyword($cardID, $keyword, $player = "", $index = -1) +{ + switch ($keyword) { + case "Smuggle": + return SmuggleCost($cardID, $player, $index) > -1; + case "Raid": + return RaidAmount($cardID, $player, $index, true) > 0; + case "Grit": + return HasGrit($cardID, $player, $index); + case "Restore": + return RestoreAmount($cardID, $player, $index) > 0; + case "Bounty": + return CollectBounty($player, $cardID, $cardID, false, $player, true) > 0; // Since we don't have information about "exhausted" and "owner," this data may be imprecise in very rare cases. + case "Overwhelm": + return HasOverwhelm($cardID, $player, $index); + case "Saboteur": + return HasSaboteur($cardID, $player, $index); + case "Shielded": + return HasShielded($cardID, $player, $index); + case "Sentinel": + return HasSentinel($cardID, $player, $index); + case "Ambush": + return HasAmbush($cardID, $player, $index, ""); + case "Coordinate": + return HasCoordinate($cardID, $player, $index); + case "Exploit": + return ExploitAmount($cardID, $player, true) > 0; + case "Piloting": + return PilotingCost($cardID) > -1;//TODO: test Boba Daimyo trigger when piloting as upgrade vs unit case "Any": return SmuggleCost($cardID, $player, $index) > -1 || RaidAmount($cardID, $player, $index, true) > 0 || @@ -1312,17 +1357,18 @@ function HasKeyword($cardID, $keyword, $player="", $index=-1){ HasAmbush($cardID, $player, $index, "") || HasCoordinate($cardID, $player, $index) || ExploitAmount($cardID, $player, true) > 0; - default: return false; + default: + return false; } } -function ArenaContains($cardID, $arena, $player="") +function ArenaContains($cardID, $arena, $player = "") { $cardArena = CardArenas($cardID); return DelimStringContains($cardArena, $arena); } -function SubtypeContains($cardID, $subtype, $player="") +function SubtypeContains($cardID, $subtype, $player = "") { $cardSubtype = CardSubtype($cardID); return DelimStringContains($cardSubtype, $subtype); @@ -1335,7 +1381,7 @@ function SubtypeContains($cardID, $subtype, $player="") // return DelimStringContains($cardElement, $element); // } -function CardNameContains($cardID, $name, $player="") +function CardNameContains($cardID, $name, $player = "") { $cardName = NameOverride($cardID, $player); return DelimStringContains($cardName, $name); @@ -1374,16 +1420,18 @@ function CardNameContains($cardID, $name, $player="") // } //parameters: (comma delimited list of card ids, , ) -function RevealCards($cards, $player="", $from="HAND") +function RevealCards($cards, $player = "", $from = "HAND") { global $currentPlayer; - if($player == "") $player = $currentPlayer; - if(!CanRevealCards($player)) return false; + if ($player == "") + $player = $currentPlayer; + if (!CanRevealCards($player)) + return false; $cardArray = explode(",", $cards); $string = ""; - for($i=count($cardArray)-1; $i>=0; --$i) - { - if($string != "") $string .= ", "; + for ($i = count($cardArray) - 1; $i >= 0; --$i) { + if ($string != "") + $string .= ", "; $string .= CardLink($cardArray[$i], $cardArray[$i]); //AddEvent("REVEAL", $cardArray[$i]); OnRevealEffect($player, $cardArray[$i], $from, $i); @@ -1396,16 +1444,17 @@ function RevealCards($cards, $player="", $from="HAND") function OnRevealEffect($player, $cardID, $from, $index) { - switch($cardID) - { - default: break; + switch ($cardID) { + default: + break; } } function IsEquipUsable($player, $index) { $character = &GetPlayerCharacter($player); - if($index >= count($character) || $index < 0) return false; + if ($index >= count($character) || $index < 0) + return false; return $character[$index + 1] == 2; } @@ -1415,7 +1464,7 @@ function UndestroyCurrentWeapon() global $combatChainState, $CCS_WeaponIndex, $mainPlayer; $index = $combatChainState[$CCS_WeaponIndex]; $char = &GetPlayerCharacter($mainPlayer); - $char[$index+7] = "0"; + $char[$index + 7] = "0"; } function DestroyCurrentWeapon() @@ -1423,7 +1472,7 @@ function DestroyCurrentWeapon() global $combatChainState, $CCS_WeaponIndex, $mainPlayer; $index = $combatChainState[$CCS_WeaponIndex]; $char = &GetPlayerCharacter($mainPlayer); - $char[$index+7] = "1"; + $char[$index + 7] = "1"; } function AttackDestroyed($attackID) @@ -1431,10 +1480,10 @@ function AttackDestroyed($attackID) global $mainPlayer, $combatChainState, $CCS_GoesWhereAfterLinkResolves; $type = CardType($attackID); $character = &GetPlayerCharacter($mainPlayer); - switch($attackID) - { + switch ($attackID) { - default: break; + default: + break; } AttackDestroyedEffects($attackID); } @@ -1442,16 +1491,15 @@ function AttackDestroyed($attackID) function AttackDestroyedEffects($attackID) { global $currentTurnEffects, $mainPlayer; - for($i=0; $i=$index; --$i) - { + for ($i = $index + CharacterPieces() - 1; $i >= $index; --$i) { unset($char[$i]); } $char = array_values($char); return $cardID; } -function AddDurabilityCounters($player, $amount=1) +function AddDurabilityCounters($player, $amount = 1) { AddDecisionQueue("PASSPARAMETER", $player, $amount); AddDecisionQueue("SETDQVAR", $player, "0"); @@ -1505,37 +1553,44 @@ function AddDurabilityCounters($player, $amount=1) function RemoveCombatChain($index) { global $combatChain; - if($index < 0) return; - for($i = CombatChainPieces() - 1; $i >= 0; --$i) { + if ($index < 0) + return; + for ($i = CombatChainPieces() - 1; $i >= 0; --$i) { unset($combatChain[$index + $i]); } $combatChain = array_values($combatChain); } -function GainActionPoints($amount=1, $player=0) +function GainActionPoints($amount = 1, $player = 0) { global $actionPoints, $mainPlayer, $currentPlayer; - if($player == 0) $player = $currentPlayer; - if($player == $mainPlayer) $actionPoints += $amount; + if ($player == 0) + $player = $currentPlayer; + if ($player == $mainPlayer) + $actionPoints += $amount; } function AddCharacterUses($player, $index, $numToAdd) { $character = &GetPlayerCharacter($player); - if($character[$index+1] == 0) return; - $character[$index+1] = 2; - $character[$index+5] += $numToAdd; + if ($character[$index + 1] == 0) + return; + $character[$index + 1] = 2; + $character[$index + 5] += $numToAdd; } function HaveUnblockedEquip($player) { $char = &GetPlayerCharacter($player); - for($i=CharacterPieces(); $i 0) return $combatChain[0]; - if(count($layers) > 0) - { - for($i=count($layers)-LayerPieces(); $i>=0; $i-=LayerPieces()) - { - if($layers[$i+1] != $currentPlayer) return $layers[$i]; - } +function GetDefaultLayerTarget() +{ + global $layers, $combatChain, $currentPlayer; + if (count($combatChain) > 0) + return $combatChain[0]; + if (count($layers) > 0) { + for ($i = count($layers) - LayerPieces(); $i >= 0; $i -= LayerPieces()) { + if ($layers[$i + 1] != $currentPlayer) + return $layers[$i]; } - return "-"; } + return "-"; +} //FAB // function GetDamagePreventionIndices($player) @@ -1798,7 +1895,8 @@ function GetDamagePreventionTargetIndices() $rv = SearchMultizone($otherPlayer, "LAYER"); if (count($combatChain) > 0) { - if ($rv != "") $rv .= ","; + if ($rv != "") + $rv .= ","; $rv .= "CC-0"; } if (SearchLayer($otherPlayer, "W") == "" && (count($combatChain) == 0 || CardType($combatChain[0]) != "W")) { @@ -1819,38 +1917,42 @@ function SameWeaponEquippedTwice() global $mainPlayer; $char = &GetPlayerCharacter($mainPlayer); $weaponIndex = explode(",", SearchCharacter($mainPlayer, "W")); - if (count($weaponIndex) > 1 && $char[$weaponIndex[0]] == $char[$weaponIndex[1]]) return true; + if (count($weaponIndex) > 1 && $char[$weaponIndex[0]] == $char[$weaponIndex[1]]) + return true; return false; } -function IgnoreAspectPenalty($cardID, $player, $reportMode) { +function IgnoreAspectPenalty($cardID, $player, $reportMode) +{ global $myClassState, $CS_NumClonesPlayed, $CS_LayerTarget, $currentTurnEffects; - if(TraitContains($cardID, "Spectre")) { + if (TraitContains($cardID, "Spectre")) { return !LeaderAbilitiesIgnored() && (HeroCard($player) == "7440067052" || SearchAlliesForCard($player, "80df3928eb") != ""); //Hera Syndulla (Spectre Two) } if (TraitContains($cardID, "Clone")) { return (SearchAlliesForCard($player, "1386874723") != "" && GetClassState($player, $CS_NumClonesPlayed) < 1) //Omega (Part of the Squad) || (!LeaderAbilitiesIgnored() && (HeroCard($player) == "2742665601" || SearchAlliesForCard($player, "f05184bd91") != "")); //Nala Se (Kaminoan Prime Minister) } - if(TraitContains($cardID, "Lightsaber")) { + if (TraitContains($cardID, "Lightsaber")) { $findGrievous = SearchAlliesForCard($player, "4776553531");//General Grievous (Trophy Collector) return $findGrievous != "" && ($reportMode || $myClassState[$CS_LayerTarget] == "MYALLY-$findGrievous"); } - for($i=0;$iLostAbilities(); } else { $techOnBoard = false; } - switch($cardID) { + switch ($cardID) { case "5169472456"://Chewbacca (Pykesbane) - if(!$techOnBoard || $playerAspects["Aggression"] != 0) { + if (!$techOnBoard || $playerAspects["Aggression"] != 0) { //if tech is here and player is not aggression, tech will always be cheaper than aggression cost $cardAspects = "Heroism,Aggression"; } @@ -1883,48 +1985,52 @@ function SelfCostModifier($cardID, $from, $reportMode=false) $cardAspects = "Vigilance"; break; case "5874342508"://Hotshot DL-44 Blaster - if(!$techOnBoard || ($playerAspects["Cunning"] != 0 && $playerAspects["Aggression"] == 0)) { + if (!$techOnBoard || ($playerAspects["Cunning"] != 0 && $playerAspects["Aggression"] == 0)) { //if tech is here, cunning smuggle is better only if player is cunning and not aggression $cardAspects = "Cunning"; } break; case "4002861992"://DJ (Blatant Thief) - if(!$techOnBoard) { + if (!$techOnBoard) { //cunning will always be cheaper than cunning+cunning, do not add a cunning if tech is here $cardAspects = "Cunning,Cunning"; } break; case "3010720738"://Tobias Beckett - if(!$techOnBoard || $playerAspects["Vigilance"] != 0) { + if (!$techOnBoard || $playerAspects["Vigilance"] != 0) { //if tech is here and player is not vigilance, tech will always be cheaper than vigilance cost $cardAspects = "Vigilance"; } break; - default: break; + default: + break; } } - if($from == "HAND" && PilotingCost($cardID) > -1) { - switch($cardID) { + if ($from == "HAND" && PilotingCost($cardID) > -1) { + switch ($cardID) { case "6421006753"://The Mandalorian - if($reportMode) $cardAspects = "Cunning"; - else $cardAspects = GetClassState($currentPlayer, $CS_PlayedAsUpgrade) == "1" ? "Cunning" : "Cunning,Cunning"; + if ($reportMode) + $cardAspects = "Cunning"; + else + $cardAspects = GetClassState($currentPlayer, $CS_PlayedAsUpgrade) == "1" ? "Cunning" : "Cunning,Cunning"; break; } } - if($cardAspects != "") { + if ($cardAspects != "") { $aspectArr = explode(",", $cardAspects); - for($i=0; $i 0) $modifier -= 1; + if (SearchCount(SearchAllies($currentPlayer, trait: "Force")) > 0) + $modifier -= 1; break; case "7884488904"://For The Republic - if(SearchCount(SearchAllies($currentPlayer, trait:"Republic")) >= 3) $modifier -= 2; + if (SearchCount(SearchAllies($currentPlayer, trait: "Republic")) >= 3) + $modifier -= 2; break; case "4111616117"://Volunteer Soldier - if(SearchCount(SearchAllies($currentPlayer, trait:"Trooper")) > 0) $modifier -= 1; + if (SearchCount(SearchAllies($currentPlayer, trait: "Trooper")) > 0) + $modifier -= 1; break; case "6905327595"://Reputable Hunter $otherPlayer = $currentPlayer == 1 ? 2 : 1; $theirAllies = &GetAllies($otherPlayer); $hasBounty = false; - for($i=0; $iHasBounty()) { $hasBounty = true; $modifier -= 1; } + if ($theirAlly->HasBounty()) { + $hasBounty = true; + $modifier -= 1; + } } break; case "7212445649"://Bravado global $CS_NumAlliesDestroyed; $otherPlayer = $currentPlayer == 1 ? 2 : 1; - if(GetClassState($otherPlayer, $CS_NumAlliesDestroyed) > 0) $modifier -= 2; + if (GetClassState($otherPlayer, $CS_NumAlliesDestroyed) > 0) + $modifier -= 2; break; case "8380936981"://Jabba's Rancor - if(ControlsNamedCard($currentPlayer, "Jabba the Hutt")) $modifier -= 1; + if (ControlsNamedCard($currentPlayer, "Jabba the Hutt")) + $modifier -= 1; break; case "6238512843"://Republic Defense Carrier $otherPlayer = $currentPlayer == 1 ? 2 : 1; $modifier -= SearchCount(SearchAllies($otherPlayer)); break; case "2443835595"://Republic Attack Pod - if(SearchCount(SearchAllies($currentPlayer)) >= 3) $modifier -= 1; + if (SearchCount(SearchAllies($currentPlayer)) >= 3) + $modifier -= 1; break; case "1356826899"://Home One $otherPlayer = $currentPlayer == 1 ? 2 : 1; - if(SearchCount(SearchAllies($otherPlayer, arena:"Space")) >= 3) $modifier -= 3; + if (SearchCount(SearchAllies($otherPlayer, arena: "Space")) >= 3) + $modifier -= 3; + break; + default: break; - default: break; } //Target cost modifier - if(count($layers) > 0) { + if (count($layers) > 0) { $mzIndex = GetClassState($currentPlayer, $CS_LayerTarget); $targetID = GetMZCard($currentPlayer, $mzIndex); } else { - if(SearchAlliesForCard($currentPlayer, "4166047484") != "") $targetID = "4166047484"; - else if(SearchAlliesForCard($currentPlayer, "fb7af4616c") != "") $targetID = "fb7af4616c"; - else if(SearchAlliesForCard($currentPlayer, "4776553531") != "") $targetID = "4776553531"; - else if($cardID == "3141660491") $targetID = "4088c46c4d"; - else $targetID = ""; + if (SearchAlliesForCard($currentPlayer, "4166047484") != "") + $targetID = "4166047484"; + else if (SearchAlliesForCard($currentPlayer, "fb7af4616c") != "") + $targetID = "fb7af4616c"; + else if (SearchAlliesForCard($currentPlayer, "4776553531") != "") + $targetID = "4776553531"; + else if ($cardID == "3141660491") + $targetID = "4088c46c4d"; + else + $targetID = ""; } - if(DefinedTypesContains($cardID, "Upgrade", $currentPlayer)) { - if($targetID == "4166047484") $modifier -= 1;//Guardian of the Whills - if($cardID == "0875550518" && ($targetID == "fb7af4616c" || $targetID == "4776553531")) $modifier -= 2;//Grievous's Wheel Bike - if($cardID == "3141660491" && $targetID != "" && $penalty > 0) {//The Darksaber + if (DefinedTypesContains($cardID, "Upgrade", $currentPlayer)) { + if ($targetID == "4166047484") + $modifier -= 1;//Guardian of the Whills + if ($cardID == "0875550518" && ($targetID == "fb7af4616c" || $targetID == "4776553531")) + $modifier -= 2;//Grievous's Wheel Bike + if ($cardID == "3141660491" && $targetID != "" && $penalty > 0) {//The Darksaber $isMando = TraitContains($targetID, "Mandalorian", $currentPlayer, isset($mzIndex) && $mzIndex != "-" ? explode("-", $mzIndex)[1] : -1); - if($isMando) { + if ($isMando) { $modifier -= $penalty * 2; } } } //My ally cost modifier $allies = &GetAllies($currentPlayer); - for($i=0; $iGetUpgrades(); - for($j=0; $j= 0; $i -= CurrentTurnPieces()) { + for ($i = count($currentTurnEffects) - CurrentTurnPieces(); $i >= 0; $i -= CurrentTurnPieces()) { $remove = false; - if($currentTurnEffects[$i + 1] == $currentPlayer) { - switch($currentTurnEffects[$i]) { + if ($currentTurnEffects[$i + 1] == $currentPlayer) { + switch ($currentTurnEffects[$i]) { case "9644107128"://Bamboozle $isAlternativeCostPaid = true; $remove = true; @@ -2127,7 +2253,8 @@ function IsAlternativeCostPaid($cardID, $from) default: break; } - if($remove) RemoveCurrentTurnEffect($i); + if ($remove) + RemoveCurrentTurnEffect($i); } } return $isAlternativeCostPaid; @@ -2136,21 +2263,24 @@ function IsAlternativeCostPaid($cardID, $from) function BanishCostModifier($from, $index) { global $currentPlayer; - if($from != "BANISH") return 0; + if ($from != "BANISH") + return 0; $banish = GetBanish($currentPlayer); $mod = explode("-", $banish[$index + 1]); - switch($mod[0]) { - case "ARC119": return -1 * intval($mod[1]); - default: return 0; + switch ($mod[0]) { + case "ARC119": + return -1 * intval($mod[1]); + default: + return 0; } } function IsCurrentAttackName($name) { $names = GetCurrentAttackNames(); - for($i=0; $i 1 ? GamestateUnsanitize($effectArr[1]) : "N/A")); //You have to do this at the end, or you might have a recursive loop -- e.g. with OUT052 - if($name != "" && $currentTurnEffects[$i+1] == $player) return true; + if ($name != "" && $currentTurnEffects[$i + 1] == $player) + return true; } return false; } @@ -2173,14 +2304,15 @@ function GetCurrentAttackNames() { global $combatChain, $currentTurnEffects, $mainPlayer; $names = []; - if(count($combatChain) == 0) return $names; + if (count($combatChain) == 0) + return $names; $names[] = CardName($combatChain[0]); - for($i=0; $i 1 ? GamestateUnsanitize($effectArr[1]) : "N/A")); //You have to do this at the end, or you might have a recursive loop -- e.g. with OUT052 - if($name != "" && $currentTurnEffects[$i+1] == $mainPlayer && IsCombatEffectActive($effectArr[0]) && !IsCombatEffectLimited($i)) $names[] = $name; + if ($name != "" && $currentTurnEffects[$i + 1] == $mainPlayer && IsCombatEffectActive($effectArr[0]) && !IsCombatEffectLimited($i)) + $names[] = $name; } return $names; } @@ -2189,9 +2321,9 @@ function SerializeCurrentAttackNames() { $names = GetCurrentAttackNames(); $serializedNames = ""; - for($i=0; $i= 0; $i-=CurrentTurnPieces()) - { - if($currentTurnEffects[$i+1] != $mainPlayer) continue; + for ($i = count($currentTurnEffects) - CurrentTurnPieces(); $i >= 0; $i -= CurrentTurnPieces()) { + if ($currentTurnEffects[$i + 1] != $mainPlayer) + continue; $remove = 0; - switch($currentTurnEffects[$i]) - { - case "OUT108": if(CardType($combatChain[0]) == "AA") { $preventsHit = true; $remove = 1; } break; - default: break; + switch ($currentTurnEffects[$i]) { + case "OUT108": + if (CardType($combatChain[0]) == "AA") { + $preventsHit = true; + $remove = 1; + } + break; + default: + break; } - if($remove == 1) RemoveCurrentTurnEffect($i); + if ($remove == 1) + RemoveCurrentTurnEffect($i); } return $preventsHit; } @@ -2256,8 +2394,7 @@ function HitsInRow() { global $chainLinkSummary; $numHits = 0; - for($i=count($chainLinkSummary)-ChainLinkSummaryPieces(); $i>=0 && intval($chainLinkSummary[$i+5]) > 0; $i-=ChainLinkSummaryPieces()) - { + for ($i = count($chainLinkSummary) - ChainLinkSummaryPieces(); $i >= 0 && intval($chainLinkSummary[$i + 5]) > 0; $i -= ChainLinkSummaryPieces()) { ++$numHits; } return $numHits; @@ -2267,37 +2404,40 @@ function HitsInCombatChain() { global $chainLinkSummary, $combatChainState, $CCS_HitThisLink; $numHits = intval($combatChainState[$CCS_HitThisLink]); - for($i=count($chainLinkSummary)-ChainLinkSummaryPieces(); $i>=0; $i-=ChainLinkSummaryPieces()) - { - $numHits += intval($chainLinkSummary[$i+5]); + for ($i = count($chainLinkSummary) - ChainLinkSummaryPieces(); $i >= 0; $i -= ChainLinkSummaryPieces()) { + $numHits += intval($chainLinkSummary[$i + 5]); } return $numHits; } function NumAttacksHit() { - global $chainLinkSummary; - $numHits = 0; - for($i=count($chainLinkSummary)-ChainLinkSummaryPieces(); $i>=0; $i-=ChainLinkSummaryPieces()) - { - if($chainLinkSummary[$i] > 0) ++$numHits; - } - return $numHits; + global $chainLinkSummary; + $numHits = 0; + for ($i = count($chainLinkSummary) - ChainLinkSummaryPieces(); $i >= 0; $i -= ChainLinkSummaryPieces()) { + if ($chainLinkSummary[$i] > 0) + ++$numHits; + } + return $numHits; } function NumChainLinks() { global $chainLinkSummary, $combatChain; - $numLinks = count($chainLinkSummary)/ChainLinkSummaryPieces(); - if(count($combatChain) > 0) ++$numLinks; + $numLinks = count($chainLinkSummary) / ChainLinkSummaryPieces(); + if (count($combatChain) > 0) + ++$numLinks; return $numLinks; } function ClearGameFiles($gameName) { - if(file_exists("./Games/" . $gameName . "/gamestateBackup.txt")) unlink("./Games/" . $gameName . "/gamestateBackup.txt"); - if(file_exists("./Games/" . $gameName . "/beginTurnGamestate.txt")) unlink("./Games/" . $gameName . "/beginTurnGamestate.txt"); - if(file_exists("./Games/" . $gameName . "/lastTurnGamestate.txt")) unlink("./Games/" . $gameName . "/lastTurnGamestate.txt"); + if (file_exists("./Games/" . $gameName . "/gamestateBackup.txt")) + unlink("./Games/" . $gameName . "/gamestateBackup.txt"); + if (file_exists("./Games/" . $gameName . "/beginTurnGamestate.txt")) + unlink("./Games/" . $gameName . "/beginTurnGamestate.txt"); + if (file_exists("./Games/" . $gameName . "/lastTurnGamestate.txt")) + unlink("./Games/" . $gameName . "/lastTurnGamestate.txt"); } //FAB @@ -2314,10 +2454,10 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC global $currentPlayer, $layers, $CS_PlayIndex, $CS_OppIndex, $initiativePlayer, $CCS_CantAttackBase, $CS_NumAlliesDestroyed; $index = GetClassState($currentPlayer, $CS_PlayIndex); - if($from == "PLAY" && IsAlly($cardID, $currentPlayer)) { + if ($from == "PLAY" && IsAlly($cardID, $currentPlayer)) { $playAlly = new Ally("MYALLY-" . $index); $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Heroic Resolve") { + if ($abilityName == "Heroic Resolve") { $ally = new Ally("MYALLY-" . $index, $currentPlayer); $ownerId = $ally->DefeatUpgrade("4085341914"); AddGraveyard("4085341914", $ownerId, "PLAY"); @@ -2325,7 +2465,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("PASSPARAMETER", $currentPlayer, "MYALLY-" . $index); AddDecisionQueue("MZOP", $currentPlayer, "ATTACK"); return ""; - } else if($abilityName == "Strategic Acumen") { + } else if ($abilityName == "Strategic Acumen") { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to play"); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYHAND:definedType=Unit"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -2335,45 +2475,47 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } else if ($abilityName == "Mill") { //Satine Kryze $ally = new Ally("MYALLY-" . $index, $currentPlayer); $otherPlayer = $currentPlayer == 1 ? 2 : 1; - Mill($otherPlayer, ceil($ally->Health()/2)); + Mill($otherPlayer, ceil($ally->Health() / 2)); return ""; } } - if($target != "-") - { + if ($target != "-") { $targetArr = explode("-", $target); - if($targetArr[0] == "LAYERUID") { $targetArr[0] = "LAYER"; $targetArr[1] = SearchLayersForUniqueID($targetArr[1]); } + if ($targetArr[0] == "LAYERUID") { + $targetArr[0] = "LAYER"; + $targetArr[1] = SearchLayersForUniqueID($targetArr[1]); + } $target = count($targetArr) > 1 ? $targetArr[0] . "-" . $targetArr[1] : "-"; } - if($from != "PLAY" && IsAlly($cardID, $currentPlayer)) { + if ($from != "PLAY" && IsAlly($cardID, $currentPlayer)) { //LastAllyIndex does not work well when you play multiple unit on same times (Vader, U-Wing, Endless Legion ...) - if($uniqueId != "") { - $lastAllyUniqueId = SearchAlliesForUniqueID($uniqueId, $currentPlayer); - $lastAllyUniqueId = $lastAllyUniqueId == -1 ? LastAllyIndex($currentPlayer) : $lastAllyUniqueId; - $playAlly = new Ally("MYALLY-" . $lastAllyUniqueId); - } else { - $playAlly = new Ally("MYALLY-" . LastAllyIndex($currentPlayer)); - } + if ($uniqueId != "") { + $lastAllyUniqueId = SearchAlliesForUniqueID($uniqueId, $currentPlayer); + $lastAllyUniqueId = $lastAllyUniqueId == -1 ? LastAllyIndex($currentPlayer) : $lastAllyUniqueId; + $playAlly = new Ally("MYALLY-" . $lastAllyUniqueId); + } else { + $playAlly = new Ally("MYALLY-" . LastAllyIndex($currentPlayer)); + } } - if($from != "PLAY" && $from != "EQUIP" && $from != "CHAR") { + if ($from != "PLAY" && $from != "EQUIP" && $from != "CHAR") { AddAllyPlayAbilityLayers($cardID, $from, isset($playAlly) ? $playAlly->UniqueID() : "-", $resourcesPaid); } - if($from == "EQUIP" && DefinedTypesContains($cardID, "Leader", $currentPlayer)) { + if ($from == "EQUIP" && DefinedTypesContains($cardID, "Leader", $currentPlayer)) { $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Deploy" || $abilityName == "Pilot" || $abilityName == "") { - if(NumResources($currentPlayer) < CardCost($cardID)) { + if ($abilityName == "Deploy" || $abilityName == "Pilot" || $abilityName == "") { + if (NumResources($currentPlayer) < CardCost($cardID)) { WriteLog("You don't control enough resources to deploy that leader; reverting the game state."); RevertGamestate(); return ""; } - if($abilityName == "Deploy" || $abilityName == "") { + if ($abilityName == "Deploy" || $abilityName == "") { $playIndex = PlayAlly(LeaderUnit($cardID), $currentPlayer); - if(HasShielded(LeaderUnit($cardID), $currentPlayer, $playIndex)) { + if (HasShielded(LeaderUnit($cardID), $currentPlayer, $playIndex)) { $allies = &GetAllies($currentPlayer); AddLayer("TRIGGER", $currentPlayer, "SHIELDED", "-", "-", $allies[$playIndex + 5]); } PlayAbility(LeaderUnit($cardID), "CHAR", 0, "-", "-", false, $uniqueId); - } else if($abilityName == "Pilot") { + } else if ($abilityName == "Pilot") { AddDecisionQueue("PASSPARAMETER", $currentPlayer, $cardID); AddDecisionQueue("SETDQVAR", $currentPlayer, "0"); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:trait=Vehicle;canAddPilot=1"); @@ -2384,8 +2526,8 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("DEPLOYLEADERASUPGRADE", $currentPlayer, $cardID, 1); } //On Deploy ability / When Deployed ability - if(!LeaderAbilitiesIgnored()) { - switch($cardID) { + if (!LeaderAbilitiesIgnored()) { + switch ($cardID) { case "5784497124"://Emperor Palpatine Leader Unit AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY:damagedOnly=true"); AddDecisionQueue("MZFILTER", $currentPlayer, "definedType=Leader"); @@ -2395,19 +2537,17 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "2432897157"://Qi'Ra Leader Unit $myAllies = &GetAllies($currentPlayer); - for($i=0; $iHeal(9999); - $ally->DealDamage(floor($ally->MaxHealth()/2)); + $ally->DealDamage(floor($ally->MaxHealth() / 2)); } $otherPlayer = $currentPlayer == 1 ? 2 : 1; $theirAllies = &GetAllies($otherPlayer); - for($i=0; $iHeal(9999); - $ally->DealDamage(floor($ally->MaxHealth()/2)); + $ally->DealDamage(floor($ally->MaxHealth() / 2)); } break; case "0254929700"://Doctor Aphra Leader Unit @@ -2433,10 +2573,9 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "4628885755"://Mace Windu Leader Unit $otherPlayer = $currentPlayer == 1 ? 2 : 1; $theirAllies = &GetAllies($otherPlayer); - for($i=count($theirAllies)-AllyPieces(); $i>=0; $i-=AllyPieces()) - { + for ($i = count($theirAllies) - AllyPieces(); $i >= 0; $i -= AllyPieces()) { $ally = new Ally("MYALLY-" . $i, $otherPlayer); - if($ally->IsDamaged()) { + if ($ally->IsDamaged()) { $ally->DealDamage(2); } } @@ -2445,30 +2584,31 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC CreateCloneTrooper($currentPlayer); break; case "2847868671"://Yoda Leader Unit - $deck = &GetDeck($currentPlayer); - if(count($deck) > 0) { - AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose if you want to discard a card to Yoda"); - AddDecisionQueue("YESNO", $currentPlayer, "-"); - AddDecisionQueue("NOPASS", $currentPlayer, "-"); - AddDecisionQueue("PASSPARAMETER", $currentPlayer, "1", 1); - AddDecisionQueue("OP", $currentPlayer, "MILL", 1); - AddDecisionQueue("MZOP", $currentPlayer, "GETCARDCOST", 1); - AddDecisionQueue("SETDQVAR", $currentPlayer, "0", 1); - AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY:maxCost={0}", 1); - AddDecisionQueue("MZFILTER", $currentPlayer, "definedType=Leader"); - AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to destroy"); - AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); - AddDecisionQueue("MZOP", $currentPlayer, "DESTROY", 1); - } + $deck = &GetDeck($currentPlayer); + if (count($deck) > 0) { + AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose if you want to discard a card to Yoda"); + AddDecisionQueue("YESNO", $currentPlayer, "-"); + AddDecisionQueue("NOPASS", $currentPlayer, "-"); + AddDecisionQueue("PASSPARAMETER", $currentPlayer, "1", 1); + AddDecisionQueue("OP", $currentPlayer, "MILL", 1); + AddDecisionQueue("MZOP", $currentPlayer, "GETCARDCOST", 1); + AddDecisionQueue("SETDQVAR", $currentPlayer, "0", 1); + AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY:maxCost={0}", 1); + AddDecisionQueue("MZFILTER", $currentPlayer, "definedType=Leader"); + AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to destroy"); + AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); + AddDecisionQueue("MZOP", $currentPlayer, "DESTROY", 1); + } + break; + default: break; - default: break; } } RemoveCharacter($currentPlayer, CharacterPieces()); //Base deploy ability $char = &GetPlayerCharacter($currentPlayer); $baseID = $char[0]; - switch($baseID) { + switch ($baseID) { case "8589863038"://Droid Manufactory CreateBattleDroid($currentPlayer); CreateBattleDroid($currentPlayer); @@ -2478,15 +2618,15 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC Draw($currentPlayer); WriteLog("Shadow Collective Camp drew a card."); break; - default: break; + default: + break; } return CardLink($cardID, $cardID) . " was deployed."; } } - switch($cardID) - { + switch ($cardID) { case "8839068683"://Freelance Assassin - if(GetResources($currentPlayer) >= 2) { + if (GetResources($currentPlayer) >= 2) { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Pay 2 resources to deal 2 damage to a unit?", 1); AddDecisionQueue("YESNO", $currentPlayer, "-", 1); AddDecisionQueue("NOPASS", $currentPlayer, "-", 1); @@ -2503,7 +2643,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC foreach ($jediUniqueIDs as $jediUniqueID) { $ally = new Ally($jediUniqueID, $p); $enemyDamage = $p != $currentPlayer; - $destroyed = $ally->DealDamage(6, enemyDamage:$enemyDamage); + $destroyed = $ally->DealDamage(6, enemyDamage: $enemyDamage); if ($destroyed) { CreateCloneTrooper($p); @@ -2526,7 +2666,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "7895170711"://A Fine Addition $otherPlayer = $currentPlayer == 1 ? 2 : 1; - if(GetClassState($otherPlayer, $CS_NumAlliesDestroyed) > 0) { + if (GetClassState($otherPlayer, $CS_NumAlliesDestroyed) > 0) { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose where to play an upgrade from"); AddDecisionQueue("BUTTONINPUT", $currentPlayer, "My Hand,My Discard,Opponent Discard", 1); AddDecisionQueue("SPECIFICCARD", $currentPlayer, "AFINEADDITION", 1); @@ -2547,7 +2687,8 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZREMOVE", $currentPlayer, "-", 1); break; case "4721628683"://Patrolling V-Wing - if($from != "PLAY") Draw($currentPlayer); + if ($from != "PLAY") + Draw($currentPlayer); break; case "2050990622"://Spark of Rebellion AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRHAND"); @@ -2557,10 +2698,11 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZREMOVE", $currentPlayer, "-", 1); break; case "3377409249"://Rogue Squadron Skirmisher - if($from != "PLAY") MZMoveCard($currentPlayer, "MYDISCARD:maxCost=2;definedType=Unit", "MYHAND", may:true); + if ($from != "PLAY") + MZMoveCard($currentPlayer, "MYDISCARD:maxCost=2;definedType=Unit", "MYHAND", may: true); break; case "5335160564"://Guerilla Attack Pod - if($from != "PLAY" && (GetHealth(1) >= 15 || GetHealth(2) >= 15)) { + if ($from != "PLAY" && (GetHealth(1) >= 15 || GetHealth(2) >= 15)) { $playAlly->Ready(); } break; @@ -2571,7 +2713,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC Draw($player); break; case "6253392993"://Bright Hope - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:arena=Ground"); AddDecisionQueue("MZFILTER", $currentPlayer, "definedType=Leader"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to bounce"); @@ -2582,9 +2724,11 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "6702266551"://Smoke and Cinders $hand = &GetHand(1); - for($i=0; $i<(count($hand)/HandPieces())-2; ++$i) PummelHit(1); + for ($i = 0; $i < (count($hand) / HandPieces()) - 2; ++$i) + PummelHit(1); $hand = &GetHand(2); - for($i=0; $i<(count($hand)/HandPieces())-2; ++$i) PummelHit(2); + for ($i = 0; $i < (count($hand) / HandPieces()) - 2; ++$i) + PummelHit(2); break; case "8148673131"://Open Fire AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY"); @@ -2593,27 +2737,28 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZOP", $currentPlayer, "DEALDAMAGE,4,$currentPlayer", 1); break; case "8429598559"://Black One - if($from != "PLAY") BlackOne($currentPlayer); + if ($from != "PLAY") + BlackOne($currentPlayer); break; case "8986035098"://Viper Probe Droid - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("LOOKHAND", $currentPlayer, "-"); } break; case "9266336818"://Grand Moff Tarkin - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("SEARCHDECKTOPX", $currentPlayer, "5;2;include-trait-Imperial"); AddDecisionQueue("MULTIADDHAND", $currentPlayer, "-", 1); AddDecisionQueue("REVEALCARDS", $currentPlayer, "-", 1); } break; case "9459170449"://Cargo Juggernaut - if($from != "PLAY" && SearchCount(SearchAllies($currentPlayer, aspect:"Vigilance")) > 1) { + if ($from != "PLAY" && SearchCount(SearchAllies($currentPlayer, aspect: "Vigilance")) > 1) { Restore(4, $currentPlayer); } break; case "7257556541"://Bodhi Rook - if($from != "PLAY") { + if ($from != "PLAY") { $otherPlayer = $currentPlayer == 1 ? 2 : 1; AddDecisionQueue("FINDINDICES", $otherPlayer, "HAND"); AddDecisionQueue("REVEALHANDCARDS", $otherPlayer, "-"); @@ -2625,7 +2770,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "6028207223"://Pirated Starfighter - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY"); AddDecisionQueue("MZFILTER", $currentPlayer, "leader=1"); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -2633,15 +2778,16 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "8981523525"://Moment of Peace - if($target != "-") { + if ($target != "-") { $ally = new Ally($target); $ally->Attach("8752877738", $currentPlayer);//Shield } break; case "8679831560"://Repair $mzArr = explode("-", $target); - if($mzArr[0] == "MYCHAR") Restore(3, $currentPlayer); - else if($mzArr[0] == "MYALLY") { + if ($mzArr[0] == "MYCHAR") + Restore(3, $currentPlayer); + else if ($mzArr[0] == "MYALLY") { $ally = new Ally($target); $ally->Heal(3); } @@ -2652,18 +2798,19 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddCurrentTurnEffect($cardID, $otherPlayer); break; case "7596515127"://Academy Walker - if($from != "PLAY") { + if ($from != "PLAY") { $allies = &GetAllies($currentPlayer); - for($i=0; $iIsDamaged()) $ally->Attach("2007868442");//Experience token + if ($ally->IsDamaged()) + $ally->Attach("2007868442");//Experience token } } break; case "7235023816"://Guerilla Insurgency $otherPlayer = $currentPlayer == 1 ? 2 : 1; - MZChooseAndDestroy($currentPlayer, "MYRESOURCES", context:"Choose a resource to destroy"); - MZChooseAndDestroy($otherPlayer, "MYRESOURCES", context:"Choose a resource to destroy"); + MZChooseAndDestroy($currentPlayer, "MYRESOURCES", context: "Choose a resource to destroy"); + MZChooseAndDestroy($otherPlayer, "MYRESOURCES", context: "Choose a resource to destroy"); PummelHit($currentPlayer); PummelHit($currentPlayer); PummelHit($otherPlayer); @@ -2699,7 +2846,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC MZChooseAndDestroy($otherPlayer, "MYALLY"); break; case "0827076106"://Admiral Ackbar - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to damage"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -2709,7 +2856,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "0867878280"://It Binds All Things $ally = new Ally($target); $amountHealed = $ally->Heal(3); - if(SearchCount(SearchAllies($currentPlayer, trait:"Force")) > 0) { + if (SearchCount(SearchAllies($currentPlayer, trait: "Force")) > 0) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to deal " . $amountHealed . " damage to"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -2717,7 +2864,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "1021495802"://Cantina Bouncer - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY&MYALLY"); AddDecisionQueue("MZFILTER", $currentPlayer, "definedType=Leader"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -2729,14 +2876,16 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "1705806419"://Force Throw $otherPlayer = $currentPlayer == 1 ? 2 : 1; - if($additionalCosts == "Yourself") PummelHit($currentPlayer); - else PummelHit($otherPlayer); - if(SearchCount(SearchAllies($currentPlayer, trait:"Force")) > 0) { + if ($additionalCosts == "Yourself") + PummelHit($currentPlayer); + else + PummelHit($otherPlayer); + if (SearchCount(SearchAllies($currentPlayer, trait: "Force")) > 0) { AddDecisionQueue("SPECIFICCARD", $currentPlayer, "FORCETHROW", 1); } break; case "1746195484"://Jedha Agitator - if($from == "PLAY" && HasLeader($currentPlayer)){ + if ($from == "PLAY" && HasLeader($currentPlayer)) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRCHAR:definedType=Base&MYALLY:arena=Ground&THEIRALLY:arena=Ground"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose something to deal 2 damage", 1); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -2749,15 +2898,15 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("ADDLIMITEDCURRENTEFFECT", $ally->PlayerID(), "2587711125,HAND"); break; case "5707383130"://Bendu - if($from == "PLAY") { + if ($from == "PLAY") { AddCurrentTurnEffect($cardID, $currentPlayer); } break; case "6472095064"://Vanquish - MZChooseAndDestroy($currentPlayer, "MYALLY&THEIRALLY", filter:"definedType=Leader"); + MZChooseAndDestroy($currentPlayer, "MYALLY&THEIRALLY", filter: "definedType=Leader"); break; case "6663619377"://AT-AT Suppressor - if($from != "PLAY"){ + if ($from != "PLAY") { ExhaustAllAllies("Ground", 1); ExhaustAllAllies("Ground", 2); } @@ -2778,7 +2927,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("SPECIFICCARD", $currentPlayer, "REINFORCEMENTWALKER", 1); break; case "9002021213"://Imperial Interceptor - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a Space unit to deal 3 damage to"); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:arena=Space&THEIRALLY:arena=Space"); AddDecisionQueue("MZFILTER", $currentPlayer, "index=MYALLY-" . $playAlly->Index()); @@ -2787,18 +2936,19 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "9133080458"://Inferno Four - if($from != "PLAY") PlayerOpt($currentPlayer, 2); + if ($from != "PLAY") + PlayerOpt($currentPlayer, 2); break; case "9568000754"://R2-D2 PlayerOpt($currentPlayer, 1); break; case "9624333142"://Count Dooku (Darth Tyranus) - if($from != "PLAY") { - MZChooseAndDestroy($currentPlayer, "MYALLY:maxHealth=4&THEIRALLY:maxHealth=4", may:true, filter:"index=MYALLY-" . $playAlly->Index()); + if ($from != "PLAY") { + MZChooseAndDestroy($currentPlayer, "MYALLY:maxHealth=4&THEIRALLY:maxHealth=4", may: true, filter: "index=MYALLY-" . $playAlly->Index()); } break; case "9097316363"://Emperor Palpatine (Master of the Dark Side) - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("FINDINDICES", $currentPlayer, "ALLTHEIRUNITSMULTI"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose units to damage", 1); AddDecisionQueue("MULTICHOOSETHEIRUNIT", $currentPlayer, "<-", 1); @@ -2819,7 +2969,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZOP", $currentPlayer, "DEALDAMAGE,5,$currentPlayer", 1); break; case "1047592361"://Ruthless Raider - if($from != "PLAY") { + if ($from != "PLAY") { $otherPlayer = $currentPlayer == 1 ? 2 : 1; DealDamageAsync($otherPlayer, 2, "DAMAGE", "1047592361"); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY"); @@ -2829,7 +2979,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "1862616109"://Snowspeeder - if($from == "PLAY") { + if ($from == "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY:arena=Ground;trait=Vehicle"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to exhaust"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -2837,7 +2987,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "2554951775"://Bail Organa - if($from == "PLAY" && GetResolvedAbilityType($cardID) == "A") { + if ($from == "PLAY" && GetResolvedAbilityType($cardID) == "A") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY"); AddDecisionQueue("MZFILTER", $currentPlayer, "index=MYALLY-" . $index); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to add an experience"); @@ -2852,7 +3002,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZOP", $currentPlayer, "READY", 1); break; case "3613174521"://Outer Rim Headhunter - if($from == "PLAY" && HasLeader($currentPlayer)) { + if ($from == "PLAY" && HasLeader($currentPlayer)) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY"); AddDecisionQueue("MZFILTER", $currentPlayer, "definedType=Leader"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to exhaust"); @@ -2861,10 +3011,11 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "3684950815"://Bounty Hunter Crew - if($from != "PLAY") MZMoveCard($currentPlayer, "MYDISCARD:definedType=Event", "MYHAND", may:true, context:"Choose an event to return with " . CardLink("3684950815", "3684950815")); + if ($from != "PLAY") + MZMoveCard($currentPlayer, "MYDISCARD:definedType=Event", "MYHAND", may: true, context: "Choose an event to return with " . CardLink("3684950815", "3684950815")); break; case "4092697474"://TIE Advanced - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:trait=Imperial"); AddDecisionQueue("MZFILTER", $currentPlayer, "index=MYALLY-" . $playAlly->Index()); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to give experience"); @@ -2911,7 +3062,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("SPECIFICCARD", $currentPlayer, "BOLDRESISTANCE", 1); break; case "7929181061"://General Tagge - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:trait=Trooper"); AddDecisionQueue("OP", $currentPlayer, "MZTONORMALINDICES"); AddDecisionQueue("PREPENDLASTRESULT", $currentPlayer, "3-", 1); @@ -2921,13 +3072,13 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "8240629990"://Avenger - if(!$playAlly->LostAbilities()) { + if (!$playAlly->LostAbilities()) { $otherPlayer = $currentPlayer == 1 ? 2 : 1; MZChooseAndDestroy($otherPlayer, "MYALLY", filter: "definedType=Leader", context: "Choose a unit to destroy"); } break; case "8294130780"://Gladiator Star Destroyer - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to give Sentinel"); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -2937,7 +3088,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "4919000710"://Home One - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to play"); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYDISCARD:definedType=Unit;aspect=Heroism"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); //Technically as written the trigger is not optional, but coding to get around the case where the only options are too expensive to play(which makes Home One unplayable because trying to play off the ability reverts the gamestate) doesn't seem worth it to cover the vanishingly rare case where a player should be forced to play something despite preferring not to. @@ -2949,9 +3100,9 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC MZChooseAndDestroy($currentPlayer, "MYALLY:maxHealth=5&THEIRALLY:maxHealth=5"); break; case "4631297392"://Devastator - if($from != "PLAY") { + if ($from != "PLAY") { $resourceCards = &GetResourceCards($currentPlayer); - $numResources = count($resourceCards)/ResourcePieces(); + $numResources = count($resourceCards) / ResourcePieces(); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to deal " . $numResources . " damage"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -2959,12 +3110,12 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "4599464590"://Rugged Survivors - if($from == "PLAY" && HasLeader($currentPlayer)) { + if ($from == "PLAY" && HasLeader($currentPlayer)) { Draw($currentPlayer); } break; case "4299027717"://Mining Guild Tie Fighter - if($from == "PLAY" && NumResourcesAvailable($currentPlayer) >= 2) { + if ($from == "PLAY" && NumResourcesAvailable($currentPlayer) >= 2) { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Do you want to pay 2 to draw a card?"); AddDecisionQueue("YESNO", $currentPlayer, "-"); AddDecisionQueue("NOPASS", $currentPlayer, "", 1); @@ -2973,7 +3124,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "3802299538"://Cartel Spacer - if($from != "PLAY" && SearchCount(SearchAllies($currentPlayer, aspect:"Cunning")) > 1) { + if ($from != "PLAY" && SearchCount(SearchAllies($currentPlayer, aspect: "Cunning")) > 1) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY:maxCost=4"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to exhaust"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -2981,7 +3132,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "3443737404"://Wing Leader - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:trait=Rebel"); AddDecisionQueue("MZFILTER", $currentPlayer, "index=MYALLY-" . $playAlly->Index()); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to add experience"); @@ -2991,7 +3142,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "2756312994"://Alliance Dispatcher - if($from == "PLAY" && GetResolvedAbilityType($cardID) == "A") { + if ($from == "PLAY" && GetResolvedAbilityType($cardID) == "A") { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to play"); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYHAND:definedType=Unit"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -3027,7 +3178,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "1880931426"://Lothal Insurgent global $CS_NumCardsPlayed; - if($from != "PLAY" && GetClassState($currentPlayer, $CS_NumCardsPlayed) > 1) { + if ($from != "PLAY" && GetClassState($currentPlayer, $CS_NumCardsPlayed) > 1) { $otherPlayer = $currentPlayer == 1 ? 2 : 1; Draw($otherPlayer); DiscardRandom($otherPlayer, $cardID); @@ -3042,18 +3193,18 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "3018017739"://Vanguard Ace global $CS_NumCardsPlayed; - if($from != "PLAY") { - for($i=0; $i<(GetClassState($currentPlayer, $CS_NumCardsPlayed)-1); ++$i) { + if ($from != "PLAY") { + for ($i = 0; $i < (GetClassState($currentPlayer, $CS_NumCardsPlayed) - 1); ++$i) { $playAlly->Attach("2007868442");//Experience token } } break; case "3401690666"://Relentless - if($from != "PLAY") { + if ($from != "PLAY") { global $CS_NumEventsPlayed; $otherPlayer = ($currentPlayer == 1 ? 2 : 1); - if(GetClassState($otherPlayer, $CS_NumEventsPlayed) == 0) { - AddCurrentTurnEffect("3401690666", $otherPlayer, from:"PLAY"); + if (GetClassState($otherPlayer, $CS_NumEventsPlayed) == 0) { + AddCurrentTurnEffect("3401690666", $otherPlayer, from: "PLAY"); } } break; @@ -3063,7 +3214,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("REVEALCARDS", $currentPlayer, "-", 1); break; case "3498814896"://Mon Mothma - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("SEARCHDECKTOPX", $currentPlayer, "5;1;include-trait-Rebel"); AddDecisionQueue("ADDHAND", $currentPlayer, "-", 1); AddDecisionQueue("REVEALCARDS", $currentPlayer, "-", 1); @@ -3082,7 +3233,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "3572356139"://Chewbacca (Walking Carpet) $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Play Taunt") { + if ($abilityName == "Play Taunt") { global $CS_AfterPlayedBy; SetClassState($currentPlayer, $CS_AfterPlayedBy, $cardID); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYHAND:definedType=Unit;maxCost=3"); @@ -3093,7 +3244,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "2579145458"://Luke Skywalker $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Give Shield") { + if ($abilityName == "Give Shield") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:aspect=Heroism"); AddDecisionQueue("MZFILTER", $currentPlayer, "turns=>0"); AddDecisionQueue("MZFILTER", $currentPlayer, "leader=1"); @@ -3103,7 +3254,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "2912358777"://Grand Moff Tarkin $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Give Experience") { + if ($abilityName == "Give Experience") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:trait=Imperial"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); AddDecisionQueue("MZOP", $currentPlayer, "ADDEXPERIENCE", 1); @@ -3111,15 +3262,16 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "3187874229"://Cassian Andor $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Draw Card") { + if ($abilityName == "Draw Card") { global $CS_DamageTaken; $otherPlayer = $currentPlayer == 1 ? 2 : 1; - if(GetClassState($otherPlayer, $CS_DamageTaken) >= 3) Draw($currentPlayer); + if (GetClassState($otherPlayer, $CS_DamageTaken) >= 3) + Draw($currentPlayer); } break; case "4841169874"://Sabine Wren $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Deal Damage") { + if ($abilityName == "Deal Damage") { DealDamageAsync(1, 1, "DAMAGE", $cardID); DealDamageAsync(2, 1, "DAMAGE", $cardID); } @@ -3129,14 +3281,14 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC Draw($currentPlayer); global $CS_DamageTaken; $otherPlayer = $currentPlayer == 1 ? 2 : 1; - if(GetClassState($otherPlayer, $CS_DamageTaken) > 0) { + if (GetClassState($otherPlayer, $CS_DamageTaken) > 0) { PummelHit($otherPlayer); PummelHit($otherPlayer); } break; case "9250443409"://Lando Calrissian - if($from != "PLAY") { - for($i=0; $i<2; ++$i) { + if ($from != "PLAY") { + for ($i = 0; $i < 2; ++$i) { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose up to two resource cards to return to your hand"); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYRESOURCES"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -3145,7 +3297,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "9070397522"://SpecForce Soldier - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to lose sentinel"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -3154,7 +3306,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "6458912354"://Death Trooper - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:arena=Ground"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to deal 2 damage to"); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -3167,7 +3319,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "7109944284"://Luke Skywalker unit global $CS_NumAlliesDestroyed; - if($from != "PLAY") { + if ($from != "PLAY") { $otherPlayer = $currentPlayer == 1 ? 2 : 1; $amount = GetClassState($currentPlayer, $CS_NumAlliesDestroyed) > 0 ? 6 : 3; AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to debuff"); @@ -3198,7 +3350,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZOP", $currentPlayer, "ADDSHIELD", 1); break; case "0705773109"://Vader's Lightsaber - if(CardTitle(GetMZCard($currentPlayer, $target)) == "Darth Vader") { + if (CardTitle(GetMZCard($currentPlayer, $target)) == "Darth Vader") { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to deal 4 damage to"); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY:arena=Ground"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -3207,16 +3359,16 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "2048866729"://Iden Versio $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Heal") { + if ($abilityName == "Heal") { global $CS_NumAlliesDestroyed; $otherPlayer = $currentPlayer == 1 ? 2 : 1; - if(GetClassState($otherPlayer, $CS_NumAlliesDestroyed) > 0) { + if (GetClassState($otherPlayer, $CS_NumAlliesDestroyed) > 0) { Restore(1, $currentPlayer); } } break; case "9680213078"://Leia Organa - if($from != "PLAY") { + if ($from != "PLAY") { $options = "Ready a resource;Exhaust a unit"; AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose one"); AddDecisionQueue("CHOOSEOPTION", $currentPlayer, "$cardID&$options"); @@ -3234,7 +3386,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "6088773439"://Darth Vader global $CS_NumVillainyPlayed; $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Deal Damage" && GetClassState($currentPlayer, $CS_NumVillainyPlayed) > 0) { + if ($abilityName == "Deal Damage" && GetClassState($currentPlayer, $CS_NumVillainyPlayed) > 0) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY", 1); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to deal 1 damage to", 1); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -3244,7 +3396,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "3503494534"://Regional Governor - if($from != "PLAY") { + if ($from != "PLAY") { $otherPlayer = $currentPlayer == 1 ? 2 : 1; AddDecisionQueue("INPUTCARDNAME", $currentPlayer, "<-"); AddDecisionQueue("SETDQVAR", $currentPlayer, "0", 1); @@ -3271,9 +3423,9 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("DRAW", $currentPlayer, "-", 1); break; case "6903722220"://Luke's Lightsaber - if(CardTitle(GetMZCard($currentPlayer, $target)) == "Luke Skywalker") { + if (CardTitle(GetMZCard($currentPlayer, $target)) == "Luke Skywalker") { $ally = new Ally($target, $currentPlayer); - $ally->Heal($ally->MaxHealth()-$ally->Health()); + $ally->Heal($ally->MaxHealth() - $ally->Health()); $ally->Attach("8752877738");//Shield Token } break; @@ -3321,13 +3473,13 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("REVEALCARDS", $currentPlayer, "-", 1); break; case "3896582249"://Redemption - if($from != "PLAY") { - for($i=0; $i<8; ++$i) { + if ($from != "PLAY") { + for ($i = 0; $i < 8; ++$i) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY", $i == 0 ? 0 : 1); AddDecisionQueue("PREPENDLASTRESULT", $currentPlayer, "MYCHAR-0,THEIRCHAR-0,", $i == 0 ? 0 : 1); AddDecisionQueue("MZFILTER", $currentPlayer, "index=MYALLY-" . $playAlly->Index()); AddDecisionQueue("MZFILTER", $currentPlayer, "damaged=0"); - AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to restore 1 (Remaining: " . (8-$i) . ")", $i == 0 ? 0 : 1); + AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to restore 1 (Remaining: " . (8 - $i) . ")", $i == 0 ? 0 : 1); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); AddDecisionQueue("MZOP", $currentPlayer, "RESTORE,1", 1); AddDecisionQueue("UNIQUETOMZ", $currentPlayer, $playAlly->UniqueID(), 1); @@ -3339,10 +3491,10 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC $ally = new Ally($target, $currentPlayer); $ally->Attach("2007868442");//Experience token $ally->Attach("2007868442");//Experience token - if(SearchCount(SearchAllies($currentPlayer, trait:"Force")) > 0) { + if (SearchCount(SearchAllies($currentPlayer, trait: "Force")) > 0) { $ally->Attach("8752877738");//Shield Token } - if(!$ally->IsExhausted()) { + if (!$ally->IsExhausted()) { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Do you want to attack with the unit?"); AddDecisionQueue("YESNO", $currentPlayer, "-"); AddDecisionQueue("NOPASS", $currentPlayer, "-"); @@ -3352,16 +3504,16 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "9985638644"://Snapshot Reflexes $mzArr = explode("-", $target); - if($mzArr[0] == "MYALLY") { + if ($mzArr[0] == "MYALLY") { $ally = new Ally($target); - if(!$ally->IsExhausted()) { + if (!$ally->IsExhausted()) { AddDecisionQueue("PASSPARAMETER", $currentPlayer, $target); AddDecisionQueue("MZOP", $currentPlayer, "ATTACK"); } } break; case "7728042035"://Chimaera - if($from == "PLAY") { + if ($from == "PLAY") { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Name the card in chat"); AddDecisionQueue("OK", $currentPlayer, "-"); AddDecisionQueue("PASSPARAMETER", $currentPlayer, "1"); @@ -3387,7 +3539,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZOP", $currentPlayer, "ATTACK", 1); break; case "3038238423"://Fleet Lieutenant - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY"); AddDecisionQueue("MZFILTER", $currentPlayer, "status=1"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to attack with"); @@ -3435,7 +3587,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "2758597010"://Maximum Firepower AddDecisionQueue("PASSPARAMETER", $currentPlayer, "-", 1); AddDecisionQueue("SETDQVAR", $currentPlayer, 0, 1); - for($i=0; $i<2; ++$i) { + for ($i = 0; $i < 2; ++$i) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:trait=Imperial"); AddDecisionQueue("MZFILTER", $currentPlayer, "dqVar=0", 1); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to deal damage", 1); @@ -3449,7 +3601,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "4263394087"://Chirrut Imwe $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Buff HP") { + if ($abilityName == "Buff HP") { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to give +2 hp"); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -3459,7 +3611,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "5154172446"://ISB Agent - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to reveal"); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYHAND:definedType=Event"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -3472,15 +3624,16 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "4300219753"://Fett's Firespray - if($from != "PLAY") { + if ($from != "PLAY") { $ready = false; - if(ControlsNamedCard($currentPlayer, "Boba Fett") || ControlsNamedCard($currentPlayer, "Jango Fett")) $ready = true; - if($ready) { + if (ControlsNamedCard($currentPlayer, "Boba Fett") || ControlsNamedCard($currentPlayer, "Jango Fett")) + $ready = true; + if ($ready) { $playAlly->Ready(); } } else { $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Exhaust") { + if ($abilityName == "Exhaust") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY"); AddDecisionQueue("MZFILTER", $currentPlayer, "unique=1"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to exhaust"); @@ -3505,7 +3658,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "7911083239"://Grand Inquisitor $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Deal Damage") { + if ($abilityName == "Deal Damage") { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to deal 2 damage and ready"); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:maxAttack=3"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -3515,9 +3668,9 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "5954056864"://Han Solo $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Play Resource") { + if ($abilityName == "Play Resource") { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to resource"); - MZMoveCard($currentPlayer, "MYHAND", "MYRESOURCES", may:false, silent:true); + MZMoveCard($currentPlayer, "MYHAND", "MYRESOURCES", may: false, silent: true); AddNextTurnEffect($cardID, $currentPlayer); } break; @@ -3542,7 +3695,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "6514927936"://Leia Organa Leader $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Attack") { + if ($abilityName == "Attack") { AddCurrentTurnEffect($cardID . "-1", $currentPlayer); AddDecisionQueue("PASSPARAMETER", $currentPlayer, "{0}", 1); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:trait=Rebel"); @@ -3554,14 +3707,14 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "8055390529"://Traitorous $mzArr = explode("-", $target); - if($mzArr[0] == "THEIRALLY") { + if ($mzArr[0] == "THEIRALLY") { AddDecisionQueue("PASSPARAMETER", $currentPlayer, $target); AddDecisionQueue("MZOP", $currentPlayer, "TAKECONTROL"); } break; case "8244682354"://Jyn Erso $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Attack") { + if ($abilityName == "Attack") { $otherPlayer = $currentPlayer == 1 ? 2 : 1; AddCurrentTurnEffect($cardID, $otherPlayer); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY"); @@ -3580,8 +3733,9 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "8600121285"://IG-88 $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Attack") { - if(HasMoreUnits($currentPlayer)) AddCurrentTurnEffect($cardID, $currentPlayer); + if ($abilityName == "Attack") { + if (HasMoreUnits($currentPlayer)) + AddCurrentTurnEffect($cardID, $currentPlayer); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY"); AddDecisionQueue("MZFILTER", $currentPlayer, "status=1"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to attack with"); @@ -3633,7 +3787,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("ADDLIMITEDNEXTTURNEFFECT", $otherPlayer, "8800836530", 1); break; case "9097690846"://Snowtrooper Lieutenant - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY"); AddDecisionQueue("MZFILTER", $currentPlayer, "status=1"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to attack with"); @@ -3670,7 +3824,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "7870435409"://Bib Fortuna $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Play Event") { + if ($abilityName == "Play Event") { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose an event to play"); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYHAND:definedType=Event"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -3692,18 +3846,18 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "5767546527"://For a Cause I Believe In $deck = new Deck($currentPlayer); $deck->Reveal(4); - $cards = $deck->Top(remove:true, amount:4); + $cards = $deck->Top(remove: true, amount: 4); $cardArr = explode(",", $cards); $damage = 0; - for($i=0; $iDestroy(); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY", 1); @@ -3837,7 +3991,8 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC DefeatUpgrade($currentPlayer); break; case "2668056720"://Disabling Fang Fighter - if($from != "PLAY") DefeatUpgrade($currentPlayer, true); + if ($from != "PLAY") + DefeatUpgrade($currentPlayer, true); break; case "4323691274"://Power Failure DefeatUpgrade($currentPlayer); @@ -3850,7 +4005,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("SPECIFICCARD", $currentPlayer, "RESTOCK", 1); break; case "5035052619"://Jabba the Hutt - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("SEARCHDECKTOPX", $currentPlayer, "8;1;include-trait-Trick&include-definedType-Event"); AddDecisionQueue("ADDHAND", $currentPlayer, "-", 1); AddDecisionQueue("REVEALCARDS", $currentPlayer, "-", 1); @@ -3877,7 +4032,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "1951911851"://Grand Admiral Thrawn $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Exhaust") { + if ($abilityName == "Exhaust") { AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose player to reveal top of deck"); AddDecisionQueue("BUTTONINPUT", $currentPlayer, "Yourself,Opponent"); AddDecisionQueue("SPECIFICCARD", $currentPlayer, "GRANDADMIRALTHRAWN", 1); @@ -3889,7 +4044,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "1939951561"://Attack Pattern Delta AddDecisionQueue("PASSPARAMETER", $currentPlayer, "-", 1); AddDecisionQueue("SETDQVAR", $currentPlayer, 0, 1); - for($i=3; $i>0; --$i) { + for ($i = 3; $i > 0; --$i) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY"); AddDecisionQueue("MZFILTER", $currentPlayer, "dqVar=0"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to give +" . $i . "/+" . $i, 1); @@ -3962,18 +4117,18 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("REMOVECURRENTEFFECT", $currentPlayer, $cardID . "-1"); break; case "8142386948"://Razor Crest - MZMoveCard($currentPlayer, "MYDISCARD:definedType=Upgrade", "MYHAND", may:true); + MZMoveCard($currentPlayer, "MYDISCARD:definedType=Upgrade", "MYHAND", may: true); break; case "3228620062"://Cripple Authority Draw($currentPlayer); $otherPlayer = $currentPlayer == 1 ? 2 : 1; - if(NumResources($otherPlayer) > NumResources($currentPlayer)) { + if (NumResources($otherPlayer) > NumResources($currentPlayer)) { PummelHit($otherPlayer); } break; case "6722700037"://Doctor Pershing $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Draw") { + if ($abilityName == "Draw") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to deal 1 damage"); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -3983,16 +4138,16 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "6536128825"://Grogu $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Exhaust") { + if ($abilityName == "Exhaust") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to exhaust"); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); AddDecisionQueue("MZOP", $currentPlayer, "REST", 1); } break; - case "3258646001"://Steadfast Senator + case "3258646001"://Steadfast Senator $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Buff") { + if ($abilityName == "Buff") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY"); AddDecisionQueue("MZFILTER", $currentPlayer, "status=1"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to attack and give +2"); @@ -4006,7 +4161,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "9262288850"://Independent Senator $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Exhaust") { + if ($abilityName == "Exhaust") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:maxAttack=4&THEIRALLY:maxAttack=4"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to exhaust"); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -4014,7 +4169,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "6585115122"://The Mandalorian unit - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:maxCost=2&THEIRALLY:maxCost=2"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to heal and shield"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -4024,10 +4179,10 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "3329959260"://Fell the Dragon - MZChooseAndDestroy($currentPlayer, "MYALLY:minAttack=5&THEIRALLY:minAttack=5", filter:"leader=1"); + MZChooseAndDestroy($currentPlayer, "MYALLY:minAttack=5&THEIRALLY:minAttack=5", filter: "leader=1"); break; case "0282219568"://Clan Wren Rescuer - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to add experience"); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -4035,7 +4190,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "1081897816"://Mandalorian Warrior - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:trait=Mandalorian&THEIRALLY:trait=Mandalorian"); AddDecisionQueue("MZFILTER", $currentPlayer, "index=MYALLY-" . $playAlly->Index()); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to add experience"); @@ -4048,7 +4203,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "1090660242"://The Client $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Bounty") { + if ($abilityName == "Bounty") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to give the bounty"); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -4063,24 +4218,26 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("REVEALCARDS", $currentPlayer, "-", 1); break; case "2288926269"://Privateer Crew - if($from == "RESOURCES") { - for($i=0; $i<3; ++$i) $playAlly->Attach("2007868442");//Experience token + if ($from == "RESOURCES") { + for ($i = 0; $i < 3; ++$i) + $playAlly->Attach("2007868442");//Experience token } break; case "2470093702"://Wrecker - MZChooseAndDestroy($currentPlayer, "MYRESOURCES", may:true, context:"Choose a resource to destroy"); + MZChooseAndDestroy($currentPlayer, "MYRESOURCES", may: true, context: "Choose a resource to destroy"); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:arena=Ground&THEIRALLY:arena=Ground", 1); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a ground unit to deal 5 damage to", 1); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); AddDecisionQueue("MZOP", $currentPlayer, "DEALDAMAGE,5,$currentPlayer,1", 1); break; case "1885628519"://Crosshair - if($from != "PLAY") break; + if ($from != "PLAY") + break; $ally = new Ally("MYALLY-" . $index); $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Buff") { + if ($abilityName == "Buff") { AddCurrentTurnEffect("1885628519", $currentPlayer, $from, $ally->UniqueID()); - } else if($abilityName == "Snipe") { + } else if ($abilityName == "Snipe") { $currentPower = $ally->CurrentPower(); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY:arena=Ground", 1); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a ground unit to deal " . $currentPower . " damage to", 1); @@ -4090,7 +4247,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "3514010297"://Mandalorian Armor $ally = new Ally($target); - if(TraitContains(GetMZCard($ally->PlayerID(), $target), "Mandalorian", $ally->PlayerID(), $ally->Index())) { + if (TraitContains(GetMZCard($ally->PlayerID(), $target), "Mandalorian", $ally->PlayerID(), $ally->Index())) { $ally->Attach("8752877738");//Shield Token } break; @@ -4122,7 +4279,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "2503039837"://Moff Gideon Leader $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Attack") { + if ($abilityName == "Attack") { AddCurrentTurnEffect($cardID, $currentPlayer); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:maxCost=3"); AddDecisionQueue("MZFILTER", $currentPlayer, "status=1", 1); @@ -4132,13 +4289,13 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "9690731982"://Reckless Gunslinger - if($from != "PLAY") { + if ($from != "PLAY") { DealDamageAsync(1, 1, "DAMAGE", $cardID); DealDamageAsync(2, 1, "DAMAGE", $cardID); } break; case "8712779685"://Outland TIE Vanguard - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:maxCost=3&THEIRALLY:maxCost=3"); AddDecisionQueue("MZFILTER", $currentPlayer, "index=MYALLY-" . $playAlly->Index()); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to give experience"); @@ -4147,16 +4304,16 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "5874342508"://Hotshot DL-44 Blaster - if($from == "RESOURCES") { + if ($from == "RESOURCES") { $ally = new Ally($target); - if(!$ally->IsExhausted() && $ally->PlayerID() == $currentPlayer) { + if (!$ally->IsExhausted() && $ally->PlayerID() == $currentPlayer) { AddDecisionQueue("PASSPARAMETER", $currentPlayer, $target); AddDecisionQueue("MZOP", $currentPlayer, "ATTACK", 1); } } break; case "6884078296"://Greef Karga - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("SEARCHDECKTOPX", $currentPlayer, "5;1;include-definedType-Upgrade"); AddDecisionQueue("ADDHAND", $currentPlayer, "-", 1); AddDecisionQueue("REVEALCARDS", $currentPlayer, "-", 1); @@ -4170,7 +4327,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "2526288781"://Bossk $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Deal Damage/Buff") { + if ($abilityName == "Deal Damage/Buff") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:hasBountyOnly=true&THEIRALLY:hasBountyOnly=true"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit with bounty to deal 1 damage to"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -4186,7 +4343,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "7424360283"://Bo-Katan Kryze global $CS_NumMandalorianAttacks; $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Deal Damage" && GetClassState($currentPlayer, $CS_NumMandalorianAttacks)) { + if ($abilityName == "Deal Damage" && GetClassState($currentPlayer, $CS_NumMandalorianAttacks)) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to deal 1 damage to"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -4196,30 +4353,33 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "0505904136"://Scanning Officer $otherPlayer = $currentPlayer == 1 ? 2 : 1; $resources = &GetResourceCards($otherPlayer); - if(count($resources) == 0) break; + if (count($resources) == 0) + break; $numDestroyed = 0; $cards = ""; - $indices = explode(",", GetIndices(count($resources), pieces:ResourcePieces())); + $indices = explode(",", GetIndices(count($resources), pieces: ResourcePieces())); $randomIndices = array_rand($indices, count($indices) >= 3 ? 3 : count($indices)); rsort($randomIndices); foreach ($randomIndices as $randomIndex) { $index = $indices[$randomIndex]; - if ($cards != "") $cards .= ","; + if ($cards != "") + $cards .= ","; $cards .= $resources[$index]; if (SmuggleCost($resources[$index], $otherPlayer, $index) >= 0) { AddGraveyard($resources[$index], $otherPlayer, 'ARS'); - for ($j = $index; $j < $index + ResourcePieces(); ++$j) unset($resources[$j]); + for ($j = $index; $j < $index + ResourcePieces(); ++$j) + unset($resources[$j]); $resources = array_values($resources); ++$numDestroyed; } } - for($i=0; $i<$numDestroyed; ++$i) { + for ($i = 0; $i < $numDestroyed; ++$i) { AddTopDeckAsResource($otherPlayer); } RevealCards($cards); break; case "2560835268"://The Armorer - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:trait=Mandalorian"); AddDecisionQueue("OP", $currentPlayer, "MZTONORMALINDICES"); AddDecisionQueue("PREPENDLASTRESULT", $currentPlayer, "3-", 1); @@ -4230,8 +4390,8 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "3622749641"://Krrsantan $otherPlayer = $currentPlayer == 1 ? 2 : 1; - $numBounty = SearchCount(SearchAllies($otherPlayer, hasBountyOnly:true)); - if($numBounty > 0) { + $numBounty = SearchCount(SearchAllies($otherPlayer, hasBountyOnly: true)); + if ($numBounty > 0) { $playAlly->Ready(); } break; @@ -4252,7 +4412,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "8877249477"://Legal Authority $targetAlly = new Ally($target, $currentPlayer); - AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY:maxAttack=" . ($targetAlly->CurrentPower()-1)); + AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY:maxAttack=" . ($targetAlly->CurrentPower() - 1)); AddDecisionQueue("MZFILTER", $currentPlayer, "definedType=Leader"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to capture"); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -4262,9 +4422,9 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC MZChooseAndDestroy($currentPlayer, "MYALLY&THEIRALLY"); break; case "8818201543"://Midnight Repairs - for($i=0; $i<8; ++$i) { + for ($i = 0; $i < 8; ++$i) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY", $i == 0 ? 0 : 1); - AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to restore 1 (Remaining: " . (8-$i) . ")", $i == 0 ? 0 : 1); + AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to restore 1 (Remaining: " . (8 - $i) . ")", $i == 0 ? 0 : 1); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); AddDecisionQueue("MZOP", $currentPlayer, "RESTORE,1", 1); } @@ -4277,7 +4437,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("WRITELOG", $currentPlayer, "This is a partially manual card. Make sure you attack a unit with this unit for your next action.", 1); break; case "2090698177"://Street Gang Recruiter - MZMoveCard($currentPlayer, "MYDISCARD:trait=Underworld", "MYHAND", may:true, context:"Choose an underworld card to return with " . CardLink("2090698177", "2090698177")); + MZMoveCard($currentPlayer, "MYDISCARD:trait=Underworld", "MYHAND", may: true, context: "Choose an underworld card to return with " . CardLink("2090698177", "2090698177")); break; case "7964782056"://Qi'Ra unit $otherPlayer = $currentPlayer == 1 ? 2 : 1; @@ -4299,7 +4459,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "5157630261"://Compassionate Senator $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Heal") { + if ($abilityName == "Heal") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY"); AddDecisionQueue("PREPENDLASTRESULT", $currentPlayer, "MYCHAR-0,THEIRCHAR-0,"); AddDecisionQueue("MZFILTER", $currentPlayer, "damaged=0"); @@ -4309,7 +4469,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "6570091935"://Tranquility - MZMoveCard($currentPlayer, "MYDISCARD:trait=Republic;definedType=Unit", "MYHAND", may:true, context:"Choose a Republic unit to return to your hand"); + MZMoveCard($currentPlayer, "MYDISCARD:trait=Republic;definedType=Unit", "MYHAND", may: true, context: "Choose a Republic unit to return to your hand"); break; case "5830140660"://Bazine Netal $otherPlayer = $currentPlayer == 1 ? 2 : 1; @@ -4327,7 +4487,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZOP", $currentPlayer, "ADDEXPERIENCE", 1); break; case "4783554451"://First Light - if($from == "RESOURCES") { + if ($from == "RESOURCES") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY"); AddDecisionQueue("MZFILTER", $currentPlayer, "index=MYALLY-" . $playAlly->Index()); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to deal 4 damage to"); @@ -4336,7 +4496,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "5351496853"://Gideon's Light Cruiser - if(ControlsNamedCard($currentPlayer, "Moff Gideon")) { + if (ControlsNamedCard($currentPlayer, "Moff Gideon")) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYDISCARD:definedType=Unit;aspect=Villainy;maxCost=3&MYHAND:definedType=Unit;aspect=Villainy;maxCost=3"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to play"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -4359,10 +4519,10 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "040a3e81f3"://Lando Calrissian Leader Unit $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Smuggle") { + if ($abilityName == "Smuggle") { $mzIndex = "MYALLY-" . GetAllyIndex($cardID, $currentPlayer); $ally = new Ally($mzIndex, $currentPlayer); - if($ally->NumUses() <= 0) { + if ($ally->NumUses() <= 0) { WriteLog("Smuggle ability was already used this turn. Game state reverted"); RevertGamestate(); } else { @@ -4384,7 +4544,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "0754286363"://The Mandalorian's Rifle $ally = new Ally($target, $currentPlayer); - if(CardTitle($ally->CardID()) == "The Mandalorian") { + if (CardTitle($ally->CardID()) == "The Mandalorian") { AddLayer("TRIGGER", $currentPlayer, $cardID, uniqueID: $ally->UniqueID()); } break; @@ -4409,7 +4569,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZFILTER", $currentPlayer, "status=1"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to attack and give +2"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); - if($initiativePlayer == $currentPlayer) { + if ($initiativePlayer == $currentPlayer) { AddDecisionQueue("SETDQVAR", $currentPlayer, "0", 1); AddDecisionQueue("MZOP", $currentPlayer, "GETUNIQUEID", 1); AddDecisionQueue("ADDLIMITEDCURRENTEFFECT", $currentPlayer, "9757839764,HAND", 1); @@ -4425,7 +4585,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "2432897157"://Qi'Ra $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Shield") { + if ($abilityName == "Shield") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to deal 2 damage and give a shield"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -4435,7 +4595,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "4352150438"://Rey $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Experience") { + if ($abilityName == "Experience") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:maxAttack=2"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to give an experience"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -4444,7 +4604,8 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "5778949819"://Relentless Pursuit $ally = new Ally($target, $currentPlayer); - if(TraitContains($ally->CardID(), "Bounty Hunter", $currentPlayer)) $ally->Attach("8752877738");//Shield Token + if (TraitContains($ally->CardID(), "Bounty Hunter", $currentPlayer)) + $ally->Attach("8752877738");//Shield Token AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY:maxCost=" . (CardCost($ally->CardID()))); AddDecisionQueue("MZFILTER", $currentPlayer, "definedType=Leader"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to capture"); @@ -4474,7 +4635,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC XanaduBlood($currentPlayer, $playAlly->Index()); break; case "1312599620"://Smuggler's Starfighter - if(SearchCount(SearchAllies($currentPlayer, trait:"Underworld")) > 0) { + if (SearchCount(SearchAllies($currentPlayer, trait: "Underworld")) > 0) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to give -3 power"); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -4486,13 +4647,14 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC $otherPlayer = $currentPlayer == 1 ? 2 : 1; $theirAllies = &GetAllies($otherPlayer); $numUpgrades = 0; - for($i=0; $iNumUpgrades(); } - if($numUpgrades > 0) { + if ($numUpgrades > 0) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:maxAttack=" . $numUpgrades . "&THEIRALLY:maxAttack=" . $numUpgrades); - if($index > -1) AddDecisionQueue("MZFILTER", $currentPlayer, "index=MYALLY-" . $playAlly->Index()); + if ($index > -1) + AddDecisionQueue("MZFILTER", $currentPlayer, "index=MYALLY-" . $playAlly->Index()); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to ready"); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); AddDecisionQueue("MZOP", $currentPlayer, "READY", 1); @@ -4505,7 +4667,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("SPECIFICCARD", $currentPlayer, "THEMARAUDER", 1); break; case "7642980906"://Stolen Landspeeder - if($from == "HAND") { + if ($from == "HAND") { $otherPlayer = $currentPlayer == 1 ? 2 : 1; AddDecisionQueue("PASSPARAMETER", $otherPlayer, "THEIRALLY-" . $playAlly->Index(), 1); AddDecisionQueue("MZOP", $otherPlayer, "TAKECONTROL", 1); @@ -4528,7 +4690,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC PlayCaptive($currentPlayer, $target); break; case "1477806735"://Wookiee Warrior - if(SearchCount(SearchAllies($currentPlayer, trait:"Wookiee")) > 1) { + if (SearchCount(SearchAllies($currentPlayer, trait: "Wookiee")) > 1) { Draw($currentPlayer); } break; @@ -4544,7 +4706,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "0911874487"://Fennec Shand $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Ambush") { + if ($abilityName == "Ambush") { AddCurrentTurnEffect($cardID, $currentPlayer, "PLAY"); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYHAND:definedType=Unit;maxCost=4"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to put into play"); @@ -4554,7 +4716,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "2b13cefced"://Fennec Shand Leader Unit $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Ambush") { + if ($abilityName == "Ambush") { AddCurrentTurnEffect($cardID, $currentPlayer, "PLAY"); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYHAND:definedType=Unit;maxCost=4"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to put into play"); @@ -4563,7 +4725,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "9828896088"://Spark of Hope - MZMoveCard($currentPlayer, "MYDISCARD:definedType=Unit;defeatedThisPhase=true", "MYRESOURCES", may:true); + MZMoveCard($currentPlayer, "MYDISCARD:definedType=Unit;defeatedThisPhase=true", "MYRESOURCES", may: true); AddDecisionQueue("PAYRESOURCES", $currentPlayer, "1,1", 1); break; case "9845101935"://This is the Way @@ -4574,18 +4736,18 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "8261033110"://Evacuate $p1Allies = &GetAllies(1); $p1Captives = []; - for($i=count($p1Allies)-AllyPieces(); $i>=0; $i-=AllyPieces()) { + for ($i = count($p1Allies) - AllyPieces(); $i >= 0; $i -= AllyPieces()) { $ally = new Ally("MYALLY-" . $i, 1); - if(!$ally->IsLeader()) { + if (!$ally->IsLeader()) { $p1Captives = array_merge($p1Captives, $ally->GetCaptives()); MZBounce(1, "MYALLY-" . $i); } } $p2Allies = &GetAllies(2); - for($i=count($p2Allies)-AllyPieces(); $i>=0; $i-=AllyPieces()) { + for ($i = count($p2Allies) - AllyPieces(); $i >= 0; $i -= AllyPieces()) { $ally = new Ally("MYALLY-" . $i, 2); - if(in_array($ally->CardID(), $p1Captives)) { - $index = array_search($ally->CardID(),$p1Captives); + if (in_array($ally->CardID(), $p1Captives)) { + $index = array_search($ally->CardID(), $p1Captives); unset($p1Captives[$index]); } else if (!$ally->IsLeader()) { MZBounce(2, "MYALLY-" . $i); @@ -4595,8 +4757,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "1910812527"://Final Showdown AddCurrentTurnEffect("1910812527", $currentPlayer); $myAllies = &GetAllies($currentPlayer); - for($i=0; $iReady(); } @@ -4605,7 +4766,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "9226435975"://Han Solo Red $abilityName = GetResolvedAbilityName($cardID, $from); $choosePhase = $cardID == "9226435975" ? "MAYCHOOSEMULTIZONE" : "CHOOSEMULTIZONE"; - if($abilityName == "Play") { + if ($abilityName == "Play") { global $CS_AfterPlayedBy; AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYHAND:definedType=Unit"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to play"); @@ -4628,20 +4789,20 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "2744523125"://Salacious Crumb $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Bounce") { + if ($abilityName == "Bounce") { $salaciousCrumbIndex = SearchAlliesForCard($currentPlayer, $cardID); MZBounce($currentPlayer, "MYALLY-" . $salaciousCrumbIndex); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:arena=Ground&THEIRALLY:arena=Ground"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to deal 1 damage to"); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); AddDecisionQueue("MZOP", $currentPlayer, "DEALDAMAGE,1,$currentPlayer,1", 1); - } else if($from != "PLAY") { + } else if ($from != "PLAY") { Restore(1, $currentPlayer); } break; case "0622803599"://Jabba the Hutt Leader $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Bounty") { + if ($abilityName == "Bounty") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to give bounty"); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -4652,7 +4813,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "f928681d36"://Jabba the Hutt Leader Unit $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Bounty") { + if ($abilityName == "Bounty") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to give bounty"); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -4663,9 +4824,9 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "8090818642"://The Chaos of War $p1Hand = &GetHand(1); - DamageTrigger(1, count($p1Hand)/HandPieces(), "DAMAGE", "8090818642"); + DamageTrigger(1, count($p1Hand) / HandPieces(), "DAMAGE", "8090818642"); $p2Hand = &GetHand(2); - DamageTrigger(2, count($p2Hand)/HandPieces(), "DAMAGE", "8090818642"); + DamageTrigger(2, count($p2Hand) / HandPieces(), "DAMAGE", "8090818642"); break; case "7826408293"://Daring Raid AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY"); @@ -4689,15 +4850,16 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("DRAW", $currentPlayer, "-", 1); break; case "6234506067"://Cassian Andor - if($from == "RESOURCES") $playAlly->Ready(); + if ($from == "RESOURCES") + $playAlly->Ready(); break; case "5169472456"://Chewbacca Pykesbane - if($from != "PLAY") { - MZChooseAndDestroy($currentPlayer, "MYALLY:maxHealth=5&THEIRALLY:maxHealth=5", may:true, filter:"index=MYALLY-" . $playAlly->Index()); + if ($from != "PLAY") { + MZChooseAndDestroy($currentPlayer, "MYALLY:maxHealth=5&THEIRALLY:maxHealth=5", may: true, filter: "index=MYALLY-" . $playAlly->Index()); } break; case "6962053552"://Desperate Attack - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY"); AddDecisionQueue("MZFILTER", $currentPlayer, "status=1"); AddDecisionQueue("MZFILTER", $currentPlayer, "damaged=0"); @@ -4717,7 +4879,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZOP", $currentPlayer, "DEALDAMAGE,2,$currentPlayer,1", 1); break; case "4057912610"://Bounty Guild Initiate - if($from != "PLAY" && SearchCount(SearchAllies($currentPlayer, trait:"Bounty Hunter")) > 1) { + if ($from != "PLAY" && SearchCount(SearchAllies($currentPlayer, trait: "Bounty Hunter")) > 1) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY:arena=Ground"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to deal 2 damage to"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -4725,13 +4887,14 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "6475868209"://Criminal Muscle - if($from != "PLAY") { - DefeatUpgrade($currentPlayer, may:true, upgradeFilter: "unique=1", to:"HAND"); + if ($from != "PLAY") { + DefeatUpgrade($currentPlayer, may: true, upgradeFilter: "unique=1", to: "HAND"); } break; case "1743599390"://Trandoshan Hunters $otherPlayer = $currentPlayer == 1 ? 2 : 1; - if(SearchCount(SearchAllies($otherPlayer, hasBountyOnly:true)) > 0) $playAlly->Attach("2007868442");//Experience token + if (SearchCount(SearchAllies($otherPlayer, hasBountyOnly: true)) > 0) + $playAlly->Attach("2007868442");//Experience token break; case "1141018768"://Commission AddDecisionQueue("SEARCHDECKTOPX", $currentPlayer, "10;1;include-trait-Bounty Hunter|include-trait-Item|include-trait-Transport"); @@ -4740,8 +4903,8 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "9596662994"://Finn $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Shield") { - DefeatUpgrade($currentPlayer, search:"MYALLY"); + if ($abilityName == "Shield") { + DefeatUpgrade($currentPlayer, search: "MYALLY"); AddDecisionQueue("PASSPARAMETER", $currentPlayer, "{0}", 1); AddDecisionQueue("MZOP", $currentPlayer, "ADDSHIELD", 1); } @@ -4773,7 +4936,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZOP", $currentPlayer, "REST", 1); break; case "4002861992"://DJ (Blatant Thief) - if($from == "RESOURCES") { + if ($from == "RESOURCES") { $djAlly = new Ally("MYALLY-" . LastAllyIndex($currentPlayer), $currentPlayer); $otherPlayer = $currentPlayer == 1 ? 2 : 1; @@ -4790,7 +4953,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC // Steal the resource $resourceCard = RemoveResource($otherPlayer, $theirResourceIndex); - AddResources($resourceCard, $currentPlayer, "PLAY", "DOWN", isExhausted:$isExhausted, stealSource:$djAlly->UniqueID()); + AddResources($resourceCard, $currentPlayer, "PLAY", "DOWN", isExhausted: $isExhausted, stealSource: $djAlly->UniqueID()); // The new rules (v3) allow you to change the state of your resources immediately after smuggling the DJ, provided the total number of "ready" and "exhausted" resources remains the same. // So, we will exhaust the stolen resource and ready another. @@ -4816,14 +4979,14 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC $ally->Attach("8752877738");//Shield Token break; case "1386874723"://Omega (Part of the Squad) - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("SEARCHDECKTOPX", $currentPlayer, "5;1;include-trait-Clone"); AddDecisionQueue("ADDHAND", $currentPlayer, "-", 1); AddDecisionQueue("REVEALCARDS", $currentPlayer, "-", 1); } break; case "6151970296"://Bounty Posting - MZMoveCard($currentPlayer, "MYDECK:trait=Bounty", "MYHAND", isReveal:true, may:true, context:"Choose a bounty to add to your hand"); + MZMoveCard($currentPlayer, "MYDECK:trait=Bounty", "MYHAND", isReveal: true, may: true, context: "Choose a bounty to add to your hand"); AddDecisionQueue("SHUFFLEDECK", $currentPlayer, "-"); AddDecisionQueue("YESNO", $currentPlayer, "if you want to play the upgrade", 1); AddDecisionQueue("NOPASS", $currentPlayer, "-", 1); @@ -4844,7 +5007,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("SETDQVAR", $currentPlayer, 0, 1); AddDecisionQueue("MZOP", $currentPlayer, "GETUNIQUEID", 1); AddDecisionQueue("ADDLIMITEDCURRENTEFFECT", $otherPlayer, "9999079491,HAND", 1); - if(SearchCount(SearchAllies($currentPlayer, trait:"Force")) > 0) { + if (SearchCount(SearchAllies($currentPlayer, trait: "Force")) > 0) { AddDecisionQueue("PASSPARAMETER", $currentPlayer, "{0}", 1); AddDecisionQueue("MZOP", $currentPlayer, "REDUCEHEALTH,2", 1); } @@ -4853,7 +5016,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("SPECIFICCARD", $currentPlayer, "ENDLESSLEGIONS"); break; case "8095362491"://Frontier Trader - if($from != "PLAY") { + if ($from != "PLAY") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYRESOURCES"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a resource to return to hand", 1); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -4862,10 +5025,10 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("NOPASS", $currentPlayer, "-", 1); AddDecisionQueue("OP", $currentPlayer, "ADDTOPDECKASRESOURCE", 1); } - break; + break; case "8709191884"://Hunter (Outcast Sergeant) $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Replace Resource") { + if ($abilityName == "Replace Resource") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYRESOURCES"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a resource to reveal", 1); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -4897,7 +5060,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "9752523457"://Finalizer $allies = &GetAllies($currentPlayer); - for($i=0; $iIndex(), 1); - AddDecisionQueue("MZOP", $currentPlayer, "TAKECONTROL", 1); - AddDecisionQueue("PASSPARAMETER", $currentPlayer, -1, 1); - AddDecisionQueue("SETCLASSSTATE", $currentPlayer, $CS_OppCardActive, 1); - } + if ($abilityName == "Take Control") { + global $CS_OppCardActive; + $oppIndex = GetClassState($currentPlayer, $CS_OppIndex); + $otherPlayer = $currentPlayer == 1 ? 2 : 1; + $ally = new Ally("THEIRALLY-" . $oppIndex, $otherPlayer); + AddDecisionQueue("PASSPARAMETER", $currentPlayer, "MYALLY-" . $ally->Index(), 1); + AddDecisionQueue("MZOP", $currentPlayer, "TAKECONTROL", 1); + AddDecisionQueue("PASSPARAMETER", $currentPlayer, -1, 1); + AddDecisionQueue("SETCLASSSTATE", $currentPlayer, $CS_OppCardActive, 1); + } break; case "8552292852"://Kashyyyk Defender AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY"); @@ -5020,7 +5183,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC $ally->DealDamage(2); break; case "7252148824"://501st Liberator - if (SearchCount(SearchAllies($currentPlayer, trait:"Republic")) > 1) { + if (SearchCount(SearchAllies($currentPlayer, trait: "Republic")) > 1) { Restore(3, $currentPlayer); } break; @@ -5073,7 +5236,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZOP", $otherPlayer, "DESTROY", 1); break; case "3840495762"://Old Access Codes - if(TheyControlMoreUnits($currentPlayer)) { + if (TheyControlMoreUnits($currentPlayer)) { Draw($currentPlayer); } break; @@ -5121,7 +5284,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "0959549331"://Unmasking the Conspiracy $hand = &GetHand($currentPlayer); PummelHit($currentPlayer); - if(count($hand) > 0) { + if (count($hand) > 0) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRHAND"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose which card you want your opponent to discard", 1); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -5149,8 +5312,8 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC CreateBattleDroid($currentPlayer); CreateBattleDroid($currentPlayer); $allies = &GetAllies($currentPlayer); - for($i=0; $i<3; ++$i) { - $ally = new Ally("MYALLY-" . (count($allies) - ($i+1)*AllyPieces()), $currentPlayer); + for ($i = 0; $i < 3; ++$i) { + $ally = new Ally("MYALLY-" . (count($allies) - ($i + 1) * AllyPieces()), $currentPlayer); $ally->Ready(); } break; @@ -5158,7 +5321,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC MZChooseAndDestroy($currentPlayer, "THEIRALLY:maxHealth=2"); break; case "4824842849"://Subjugating Starfighter - if($initiativePlayer == $currentPlayer) { + if ($initiativePlayer == $currentPlayer) { CreateBattleDroid($currentPlayer); } break; @@ -5195,13 +5358,13 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZOP", $currentPlayer, "ATTACK", 1); break; case "6410481716"://Mace Windu's Lightsaber - if(CardTitle(GetMZCard($currentPlayer, $target)) == "Mace Windu") { + if (CardTitle(GetMZCard($currentPlayer, $target)) == "Mace Windu") { Draw($currentPlayer); Draw($currentPlayer); } break; case "5616678900"://R2-D2 - PummelHit($currentPlayer, may:true); + PummelHit($currentPlayer, may: true); AddDecisionQueue("SEARCHDECKTOPX", $currentPlayer, "3;1;", 1); AddDecisionQueue("ADDHAND", $currentPlayer, "-", 1); break; @@ -5231,14 +5394,14 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("SPECIFICCARD", $currentPlayer, "PRISONEROFWAR", 1); break; case "3500129784"://Petition the Senate - if(SearchCount(SearchAllies($currentPlayer, trait:"Official")) >= 3) { + if (SearchCount(SearchAllies($currentPlayer, trait: "Official")) >= 3) { Draw($currentPlayer); Draw($currentPlayer); Draw($currentPlayer); } break; case "3476041913"://Low Altitude Gunship - $damage = SearchCount(SearchAllies($currentPlayer, trait:"Republic")); + $damage = SearchCount(SearchAllies($currentPlayer, trait: "Republic")); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to deal " . $damage . " damage to"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -5252,7 +5415,8 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "8929774056"://Asajj Ventress global $CS_NumEventsPlayed; - if(GetClassState($currentPlayer, $CS_NumEventsPlayed) > 0) AddCurrentTurnEffect("8929774056", $currentPlayer, "PLAY"); + if (GetClassState($currentPlayer, $CS_NumEventsPlayed) > 0) + AddCurrentTurnEffect("8929774056", $currentPlayer, "PLAY"); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY"); AddDecisionQueue("MZFILTER", $currentPlayer, "status=1", 1); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to attack with"); @@ -5260,7 +5424,8 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZOP", $currentPlayer, "ATTACK", 1); break; case "9966134941"://Pelta Supply Frigate - if(IsCoordinateActive($currentPlayer)) CreateCloneTrooper($currentPlayer); + if (IsCoordinateActive($currentPlayer)) + CreateCloneTrooper($currentPlayer); break; case "6461101372"://Maul AddCurrentTurnEffect("6461101372", $currentPlayer, "PLAY"); @@ -5281,7 +5446,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "5081383630"://Pre Viszla global $CS_CardsDrawn; $cardsDrawn = GetClassState($currentPlayer, $CS_CardsDrawn); - if($cardsDrawn > 0) { + if ($cardsDrawn > 0) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to deal " . $cardsDrawn . " damage to"); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -5294,7 +5459,8 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC $ally->DefeatIfNoRemainingHP(); break; case "8345985976"://Trade Federation Shuttle - if(SearchCount(SearchAllies($currentPlayer, damagedOnly:true))) CreateBattleDroid($currentPlayer); + if (SearchCount(SearchAllies($currentPlayer, damagedOnly: true))) + CreateBattleDroid($currentPlayer); break; case "8060312086"://Self Destruct AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY"); @@ -5308,7 +5474,8 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "8540765053"://Savage Opress $otherPlayer = $currentPlayer == 1 ? 2 : 1; - if(HasMoreUnits($otherPlayer)) $playAlly->Ready(); + if (HasMoreUnits($otherPlayer)) + $playAlly->Ready(); break; case "9620454519"://Clear the Field AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY:maxCost=3&THEIRALLY:maxCost=3"); @@ -5358,7 +5525,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZOP", $currentPlayer, "DEALDAMAGE,1,$currentPlayer", 1); break; case "0026166404"://Chancellor Palpatine Leader - if (SearchCount(SearchAlliesDestroyed($currentPlayer, aspect:"Heroism")) > 0) { + if (SearchCount(SearchAlliesDestroyed($currentPlayer, aspect: "Heroism")) > 0) { Draw($currentPlayer); Restore(2, $currentPlayer); $char = &GetPlayerCharacter($currentPlayer); @@ -5378,12 +5545,12 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "7734824762"://Captain Rex global $CS_NumAttacks; - if(GetClassState($currentPlayer, $CS_NumAttacks) > 0) { + if (GetClassState($currentPlayer, $CS_NumAttacks) > 0) { CreateCloneTrooper($currentPlayer); } break; case "3410014206"://Vanguard Droid Bomber - if(SearchCount(SearchAllies($currentPlayer, trait:"Separatist")) > 1) { + if (SearchCount(SearchAllies($currentPlayer, trait: "Separatist")) > 1) { DealDamageAsync($currentPlayer == 1 ? 2 : 1, 2, "DAMAGE", "3410014206"); } break; @@ -5394,7 +5561,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZOP", $currentPlayer, "DEALDAMAGE,2,$currentPlayer,1", 1); break; case "4512764429"://Sanctioner's Shuttle - if(IsCoordinateActive($currentPlayer)) { + if (IsCoordinateActive($currentPlayer)) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY:maxCost=3"); AddDecisionQueue("MZFILTER", $currentPlayer, "definedType=Leader"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to capture"); @@ -5404,7 +5571,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "6849037019"://Now There Are Two of Them $allies = &GetAllies($currentPlayer); - if(count($allies) == AllyPieces()) { + if (count($allies) == AllyPieces()) { $ally = new Ally("MYALLY-0"); $traits = CardTraits($ally->CardID()); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to put into play"); @@ -5417,9 +5584,9 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "7013591351"://Admiral Trench - MZMoveCard($currentPlayer, "MYDISCARD:definedType=Unit;defeatedThisPhase=true", "MYHAND", may:true, context:"Return up to 3 units that were defeated this phase"); - MZMoveCard($currentPlayer, "MYDISCARD:definedType=Unit;defeatedThisPhase=true", "MYHAND", may:true, context:"Return up to 2 units that were defeated this phase", isSubsequent:1); - MZMoveCard($currentPlayer, "MYDISCARD:definedType=Unit;defeatedThisPhase=true", "MYHAND", may:true, context:"Return 1 unit that was defeated this phase", isSubsequent:1); + MZMoveCard($currentPlayer, "MYDISCARD:definedType=Unit;defeatedThisPhase=true", "MYHAND", may: true, context: "Return up to 3 units that were defeated this phase"); + MZMoveCard($currentPlayer, "MYDISCARD:definedType=Unit;defeatedThisPhase=true", "MYHAND", may: true, context: "Return up to 2 units that were defeated this phase", isSubsequent: 1); + MZMoveCard($currentPlayer, "MYDISCARD:definedType=Unit;defeatedThisPhase=true", "MYHAND", may: true, context: "Return 1 unit that was defeated this phase", isSubsequent: 1); break; case "6648824001": ObiWansAethersprite($currentPlayer, $playAlly->Index()); @@ -5444,7 +5611,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC $otherPlayer = $currentPlayer == 1 ? 2 : 1; $theirDiscard = &GetDiscard($otherPlayer); $deck = new Deck($otherPlayer); - for($i=count($theirDiscard) - DiscardPieces(); $i>=0; $i-=DiscardPieces()) { + for ($i = count($theirDiscard) - DiscardPieces(); $i >= 0; $i -= DiscardPieces()) { $deck->Add(RemoveDiscard($otherPlayer, $i)); } break; @@ -5456,7 +5623,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "1686059165"://Wat Tambor global $CS_NumAlliesDestroyed; - if(GetClassState($currentPlayer, $CS_NumAlliesDestroyed) > 0) { + if (GetClassState($currentPlayer, $CS_NumAlliesDestroyed) > 0) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to give +2/+2"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -5473,7 +5640,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZOP", $currentPlayer, "CAPTURE," . $playAlly->UniqueID(), 1); break; case "2298508689"://Reckless Torrent - if(IsCoordinateActive($currentPlayer)) { + if (IsCoordinateActive($currentPlayer)) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a friendly unit to deal 2 damage (or pass)"); AddDecisionQueue("MAYCHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -5497,7 +5664,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "2267524398"://The Clone Wars $otherPlayer = $currentPlayer == 1 ? 2 : 1; - for($i=0; $i<$resourcesPaid-2; ++$i) { + for ($i = 0; $i < $resourcesPaid - 2; ++$i) { CreateCloneTrooper($currentPlayer); CreateBattleDroid($otherPlayer); } @@ -5521,7 +5688,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "2847868671"://Yoda Leader global $CS_NumLeftPlay; $otherPlayer = $currentPlayer == 1 ? 2 : 1; - if(GetClassState($currentPlayer, $CS_NumLeftPlay) > 0 || GetClassState($otherPlayer, $CS_NumLeftPlay) > 0) { + if (GetClassState($currentPlayer, $CS_NumLeftPlay) > 0 || GetClassState($otherPlayer, $CS_NumLeftPlay) > 0) { Draw($currentPlayer); AddDecisionQueue("HANDTOPBOTTOM", $currentPlayer, "-"); } @@ -5537,7 +5704,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "5333016146"://Rune Haako global $CS_NumAlliesDestroyed; - if(GetClassState($currentPlayer, $CS_NumAlliesDestroyed) > 0) { + if (GetClassState($currentPlayer, $CS_NumAlliesDestroyed) > 0) { $otherPlayer = $currentPlayer == 1 ? 2 : 1; AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to give -1/-1", 1); @@ -5552,7 +5719,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "6064906790"://Nute Gunray WriteLog(DefinedCardType($cardID)); global $CS_NumAlliesDestroyed; - if(GetClassState($currentPlayer, $CS_NumAlliesDestroyed) >= 2) { + if (GetClassState($currentPlayer, $CS_NumAlliesDestroyed) >= 2) { CreateBattleDroid($currentPlayer); } break; @@ -5567,7 +5734,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "0693815329"://Cad Bane AddDecisionQueue("PASSPARAMETER", $currentPlayer, "8"); AddDecisionQueue("SETDQVAR", $currentPlayer, "0"); - for($i=0; $i<3; ++$i) { + for ($i = 0; $i < 3; ++$i) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY:maxHealth={0}"); AddDecisionQueue("MZFILTER", $currentPlayer, "definedType=Leader"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to capture (Max HP: {0})"); @@ -5594,7 +5761,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC $theirAllies = &GetTheirAllies($currentPlayer); for ($i = 0; $i < count($theirAllies); $i += AllyPieces()) { if (CardArenas($theirAllies[$i]) == "Ground") { - AddCurrentTurnEffect("0216922902", $otherPlayer, "PLAY", $theirAllies[$i+5]); + AddCurrentTurnEffect("0216922902", $otherPlayer, "PLAY", $theirAllies[$i + 5]); } } break; @@ -5603,7 +5770,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC for ($i = 0; $i < count($allies); $i += AllyPieces()) { AddDecisionQueue("PASSPARAMETER", $currentPlayer, "MYALLY-$i", 1); AddDecisionQueue("MZOP", $currentPlayer, "ADDHEALTH,1", 1); - AddDecisionQueue("PASSPARAMETER", $currentPlayer, $allies[$i+5], 1); + AddDecisionQueue("PASSPARAMETER", $currentPlayer, $allies[$i + 5], 1); AddDecisionQueue("ADDLIMITEDCURRENTEFFECT", $currentPlayer, "4916334670,PLAY", 1); } break; @@ -5617,7 +5784,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "2870878795"://Padme Amidala - if(IsCoordinateActive($currentPlayer)) { + if (IsCoordinateActive($currentPlayer)) { AddDecisionQueue("SEARCHDECKTOPX", $currentPlayer, "3;1;include-trait-Republic"); AddDecisionQueue("ADDHAND", $currentPlayer, "-", 1); AddDecisionQueue("REVEALCARDS", $currentPlayer, "-", 1); @@ -5644,13 +5811,13 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "2483520485"://Private Manufacturing Draw($currentPlayer); Draw($currentPlayer); - if(SearchCount(SearchAllies($currentPlayer, tokenOnly:true)) == 0) { - MZMoveCard($currentPlayer, "MYHAND", "MYBOTDECK", context:"Choose a card to put on the bottom of your deck"); - MZMoveCard($currentPlayer, "MYHAND", "MYBOTDECK", context:"Choose a card to put on the bottom of your deck"); + if (SearchCount(SearchAllies($currentPlayer, tokenOnly: true)) == 0) { + MZMoveCard($currentPlayer, "MYHAND", "MYBOTDECK", context: "Choose a card to put on the bottom of your deck"); + MZMoveCard($currentPlayer, "MYHAND", "MYBOTDECK", context: "Choose a card to put on the bottom of your deck"); } break; case "0633620454"://Synchronized Strike - $damage = SearchCount(SearchAllies($currentPlayer, arena:$additionalCosts)); + $damage = SearchCount(SearchAllies($currentPlayer, arena: $additionalCosts)); AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "THEIRALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to deal " . $damage . " damage to", 1); AddDecisionQueue("CHOOSEMULTIZONE", $currentPlayer, "<-", 1); @@ -5662,7 +5829,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "0056489820"://Unlimited Power AddDecisionQueue("PASSPARAMETER", $currentPlayer, "-"); AddDecisionQueue("SETDQVAR", $currentPlayer, 0); - for($i=4; $i>=1; --$i) { + for ($i = 4; $i >= 1; --$i) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY"); AddDecisionQueue("MZFILTER", $currentPlayer, "dqVar=0"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to deal " . $i . " damage to", 1); @@ -5675,7 +5842,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "0741296536"://Ahsoka's Padawan Lightsaber - if(CardTitle(GetMZCard($currentPlayer, $target)) == "Ahsoka Tano") { + if (CardTitle(GetMZCard($currentPlayer, $target)) == "Ahsoka Tano") { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY"); AddDecisionQueue("MZFILTER", $currentPlayer, "status=1"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a card to attack"); @@ -5701,7 +5868,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("PREPENDLASTRESULT", $currentPlayer, "4-"); AddDecisionQueue("MULTICHOOSEDISCARD", $currentPlayer, "<-"); AddDecisionQueue("SPECIFICCARD", $currentPlayer, "RESTOCK", 1); - for($i=0; $i<4; ++$i) { + for ($i = 0; $i < 4; ++$i) { CreateBattleDroid($currentPlayer); } break; @@ -5788,7 +5955,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; //Jump to Lightspeed case "0425156332"://Planetary Bombardment - $hasCapitalShip = SearchCount(SearchAllies($currentPlayer, trait:"Capital Ship")) > 0; + $hasCapitalShip = SearchCount(SearchAllies($currentPlayer, trait: "Capital Ship")) > 0; $indirectAmount = $hasCapitalShip ? 12 : 8; $otherPlayer = $currentPlayer == 1 ? 2 : 1; IndirectDamage($otherPlayer, $indirectAmount); @@ -5819,7 +5986,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC break; case "4179470615"://Asajj Ventress $abilityName = GetResolvedAbilityName($cardID, $from); - if($abilityName == "Damage") { + if ($abilityName == "Damage") { AsajjVentressIWorkAlone($currentPlayer); } break; @@ -5829,17 +5996,19 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC case "8833191722"://Never Tell Me the Odds $damageAmount = 0; $cards = Mill(1, 3); - if($cards != "") { + if ($cards != "") { $cards = explode(",", $cards); - for($i=0; $iReveal()) { + if ($deck->Reveal()) { $cardCost = CardCost($deck->Top()); } AddDecisionQueue("PASSPARAMETER", $currentPlayer, $cardCost); @@ -5890,19 +6059,19 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC } break; case "3658069276"://Lando Calrissian Leader - if(GetResolvedAbilityName($cardID) == "Play") { + if (GetResolvedAbilityName($cardID) == "Play") { WriteLog(CardLink($cardID, $cardID) . " ability is not implemented yet. Reverting gamestate"); RevertGamestate(); } break; case "7514405173"://Admiral Ackbar Leader - if(GetResolvedAbilityName($cardID) == "Exhaust") { + if (GetResolvedAbilityName($cardID) == "Exhaust") { WriteLog(CardLink($cardID, $cardID) . " ability is not implemented yet. Reverting gamestate"); RevertGamestate(); } break; case "1519837763"://Shuttle ST-149 - if($from != "PLAY") { + if ($from != "PLAY") { ShuttleST149($currentPlayer); } break; @@ -5919,7 +6088,7 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZOP", $currentPlayer, "REST", 1); break; case "3722493191"://IG-2000 - if($from != "PLAY") { + if ($from != "PLAY") { for ($j = 0; $j < 3; $j++) { AddDecisionQueue("MULTIZONEINDICES", $currentPlayer, "MYALLY&THEIRALLY"); AddDecisionQueue("SETDQCONTEXT", $currentPlayer, "Choose a unit to deal 1 damage to"); @@ -5927,53 +6096,57 @@ function PlayAbility($cardID, $from, $resourcesPaid, $target = "-", $additionalC AddDecisionQueue("MZOP", $currentPlayer, "DEALDAMAGE,1,$currentPlayer,1", 1); } } - break; + break; //PlayAbility End - default: break; + default: + break; } } -function ReadyResource($player, $amount=1) { +function ReadyResource($player, $amount = 1) +{ $resourceCards = &GetResourceCards($player); $numReadied = 0; - for($i=0; $iCurrentArena() == $arena) { + if ($ally->CurrentArena() == $arena) { $ally->Exhaust(); } } } -function DestroyAllAllies($player="") +function DestroyAllAllies($player = "") { //To avoid problems to do with allies entering play in the middle of things(i.e. captives), we first note the uniqueID of every ally in play and then destroy only those noted. global $currentPlayer; //Get all uniqueIDs of allies that are on board right now. $currentPlayerAllies = &GetAllies($currentPlayer); $currentPlayerAlliesUniqueIDs = []; - if($player == "" || $player == $currentPlayer) { - for($i = 0; $i < count($currentPlayerAllies); $i += AllyPieces()) { - $currentPlayerAlliesUniqueIDs[] = $currentPlayerAllies[$i+5]; + if ($player == "" || $player == $currentPlayer) { + for ($i = 0; $i < count($currentPlayerAllies); $i += AllyPieces()) { + $currentPlayerAlliesUniqueIDs[] = $currentPlayerAllies[$i + 5]; } } $otherPlayer = $currentPlayer == 1 ? 2 : 1; $otherPlayerAllies = &GetAllies($otherPlayer); $otherPlayerAlliesUniqueIDs = []; - if($player == "" || $player != $currentPlayer) { - for($i = 0; $i < count($otherPlayerAllies); $i += AllyPieces()) { - $otherPlayerAlliesUniqueIDs[] = $otherPlayerAllies[$i+5]; + if ($player == "" || $player != $currentPlayer) { + for ($i = 0; $i < count($otherPlayerAllies); $i += AllyPieces()) { + $otherPlayerAlliesUniqueIDs[] = $otherPlayerAllies[$i + 5]; } } @@ -6068,49 +6242,55 @@ function DestroyAllAllies($player="") } } -function DamagePlayerAllies($player, $damage, $source, $type, $arena="") +function DamagePlayerAllies($player, $damage, $source, $type, $arena = "") { $enemyDamage = false; $fromUnitEffect = false; - switch($source) { + switch ($source) { case "0160548661"://Fallen Lightsaber case "0683052393"://Hevy case "0354710662"://Saw Gerrera (Resistance Is Not Terrorism) $enemyDamage = true; $fromUnitEffect = true; break; - default: break; + default: + break; } $allies = &GetAllies($player); - for($i=count($allies)-AllyPieces(); $i>=0; $i-=AllyPieces()) - { - if($arena != "" && !ArenaContains($allies[$i], $arena, $player)) continue; + for ($i = count($allies) - AllyPieces(); $i >= 0; $i -= AllyPieces()) { + if ($arena != "" && !ArenaContains($allies[$i], $arena, $player)) + continue; $ally = new Ally("MYALLY-" . $i, $player); $ally->DealDamage($damage, enemyDamage: $enemyDamage, fromUnitEffect: $fromUnitEffect); } } -function DamageAllAllies($amount, $source, $alsoRest=false, $alsoFreeze=false, $arena="", $except="") +function DamageAllAllies($amount, $source, $alsoRest = false, $alsoFreeze = false, $arena = "", $except = "") { global $currentPlayer; $otherPlayer = $currentPlayer == 1 ? 2 : 1; $theirAllies = &GetAllies($otherPlayer); - for($i=count($theirAllies) - AllyPieces(); $i>=0; $i-=AllyPieces()) - { - if(!ArenaContains($theirAllies[$i], $arena, $otherPlayer)) continue; - if($alsoRest) $theirAllies[$i+1] = 1; - if($alsoFreeze) $theirAllies[$i+3] = 1; + for ($i = count($theirAllies) - AllyPieces(); $i >= 0; $i -= AllyPieces()) { + if (!ArenaContains($theirAllies[$i], $arena, $otherPlayer)) + continue; + if ($alsoRest) + $theirAllies[$i + 1] = 1; + if ($alsoFreeze) + $theirAllies[$i + 3] = 1; $ally = new Ally("THEIRALLY-$i"); $ally->DealDamage($amount); } $allies = &GetAllies($currentPlayer); - for($i=count($allies) - AllyPieces(); $i>=0; $i-=AllyPieces()) - { - if(!ArenaContains($allies[$i], $arena, $currentPlayer)) continue; - if($except != "" && $except == ("MYALLY-" . $i)) continue; - if($alsoRest) $allies[$i+1] = 1; - if($alsoFreeze) $allies[$i+3] = 1; + for ($i = count($allies) - AllyPieces(); $i >= 0; $i -= AllyPieces()) { + if (!ArenaContains($allies[$i], $arena, $currentPlayer)) + continue; + if ($except != "" && $except == ("MYALLY-" . $i)) + continue; + if ($alsoRest) + $allies[$i + 1] = 1; + if ($alsoFreeze) + $allies[$i + 3] = 1; $ally = new Ally("MYALLY-$i"); $ally->DealDamage($amount); } @@ -6124,13 +6304,14 @@ function IsHarmonizeActive($player) return GetClassState($player, $CS_NumMelodyPlayed) > 0; } -function IsMultiTargetAttackActive() { +function IsMultiTargetAttackActive() +{ global $combatChainState, $CCS_MultiAttackTargets; //TODO: look into why SubmitSideboard.php is not initializing this - return isset($combatChainState[$CCS_MultiAttackTargets]) && $combatChainState[$CCS_MultiAttackTargets]!=="-"; + return isset($combatChainState[$CCS_MultiAttackTargets]) && $combatChainState[$CCS_MultiAttackTargets] !== "-"; } -function AddPreparationCounters($player, $amount=1) +function AddPreparationCounters($player, $amount = 1) { global $CS_PreparationCounters; IncrementClassState($player, $CS_PreparationCounters, $amount); @@ -6139,30 +6320,32 @@ function AddPreparationCounters($player, $amount=1) function DrawIntoMemory($player) { $deck = &GetDeck($player); - if(count($deck) > 0) AddMemory(array_shift($deck), $player, "DECK", "DOWN"); + if (count($deck) > 0) + AddMemory(array_shift($deck), $player, "DECK", "DOWN"); } function Mill($player, $amount) { $cards = ""; $deck = &GetDeck($player); - if($amount > count($deck)) $amount = count($deck); - for($i=0; $i<$amount; ++$i) - { + if ($amount > count($deck)) + $amount = count($deck); + for ($i = 0; $i < $amount; ++$i) { $card = array_shift($deck); - if($cards != "") $cards .= ","; + if ($cards != "") + $cards .= ","; $cards .= $card; AddGraveyard($card, $player, "DECK"); } return $cards; } -function AddTopDeckAsResource($player, $isExhausted=true) +function AddTopDeckAsResource($player, $isExhausted = true) { $deck = &GetDeck($player); - if(count($deck) > 0) { + if (count($deck) > 0) { $card = array_shift($deck); - AddResources($card, $player, "DECK", "DOWN", isExhausted:($isExhausted ? 1 : 0)); + AddResources($card, $player, "DECK", "DOWN", isExhausted: ($isExhausted ? 1 : 0)); } } @@ -6179,121 +6362,138 @@ function AddTopDeckAsResource($player, $isExhausted=true) function PlayRequiresTarget($cardID) { global $currentPlayer; - switch($cardID) - { - case "8679831560": return 2;//Repair - case "8981523525": return 6;//Moment of Peace - case "0867878280": return 6;//It Binds All Things - case "2587711125": return 6;//Disarm - case "6515891401": return 7;//Karabast - case "2651321164": return 6;//Tactical Advantage - case "1900571801": return 7;//Overwhelming Barrage - case "5013139687": return 3;//Caught In The Crossfire - case "7861932582": return 6;//The Force is With Me - case "2758597010": return 6;//Maximum Firepower - case "2202839291": return 6;//Don't Get Cocky - case "1701265931": return 6;//Moment of Glory - case "3765912000": return 7;//Take Captive - case "5778949819": return 7;//Relentless Pursuit - case "1973545191": return 6;//Unexpected Escape - case "0598830553": return 6;//Dryden Vos - case "8576088385": return 6;//Detention Block Rescue - default: return -1; + switch ($cardID) { + case "8679831560": + return 2;//Repair + case "8981523525": + return 6;//Moment of Peace + case "0867878280": + return 6;//It Binds All Things + case "2587711125": + return 6;//Disarm + case "6515891401": + return 7;//Karabast + case "2651321164": + return 6;//Tactical Advantage + case "1900571801": + return 7;//Overwhelming Barrage + case "5013139687": + return 3;//Caught In The Crossfire + case "7861932582": + return 6;//The Force is With Me + case "2758597010": + return 6;//Maximum Firepower + case "2202839291": + return 6;//Don't Get Cocky + case "1701265931": + return 6;//Moment of Glory + case "3765912000": + return 7;//Take Captive + case "5778949819": + return 7;//Relentless Pursuit + case "1973545191": + return 6;//Unexpected Escape + case "0598830553": + return 6;//Dryden Vos + case "8576088385": + return 6;//Detention Block Rescue + default: + return -1; } } - //target type return values - //-1: no target - // 0: My Hero + Their Hero - // 1: Their Hero only - // 2: Any Target - // 3: Their Units - // 4: My Hero only (For afflictions) - // 6: Any unit - // 7: Friendly unit - // 8: Any Non-Leader + Non-Vehicle unit - function GetArcaneTargetIndices($player, $target) - { - global $CS_ArcaneTargetsSelected; - $otherPlayer = ($player == 1 ? 2 : 1); - - if ($target == 8) { - $rvArr = []; - $theirAllies = &GetAllies($otherPlayer); - for($i=0; $i=0; --$i) - { - if(DelimStringContains($targetsSelected, $targets[$i])) unset($targets[$i]); + } else if ($target == 7) { + $myAllies = &GetAllies($player); + for ($i = 0; $i < count($myAllies); $i += AllyPieces()) { + if ($rv != "") + $rv .= ","; + $rv .= "MYALLY-" . $i; } - return implode(",", $targets); } + $targets = explode(",", $rv); + $targetsSelected = GetClassState($player, $CS_ArcaneTargetsSelected); + for ($i = count($targets) - 1; $i >= 0; --$i) { + if (DelimStringContains($targetsSelected, $targets[$i])) + unset($targets[$i]); + } + return implode(",", $targets); +} function CountPitch(&$pitch, $min = 0, $max = 9999) { $pitchCount = 0; - for($i = 0; $i < count($pitch); ++$i) { + for ($i = 0; $i < count($pitch); ++$i) { $cost = CardCost($pitch[$i]); - if($cost >= $min && $cost <= $max) ++$pitchCount; + if ($cost >= $min && $cost <= $max) + ++$pitchCount; } return $pitchCount; } @@ -6313,17 +6513,20 @@ function Draw($player, $mainPhase = true, $fromCardEffect = true) $otherPlayer = ($player == 1 ? 2 : 1); $deck = &GetDeck($player); $hand = &GetHand($player); - if(count($deck) == 0) { + if (count($deck) == 0) { $char = &GetPlayerCharacter($player); - if(count($char) > CharacterPieces() && $char[CharacterPieces()] != "DUMMY") WriteLog("Player " . $player . " took 3 damage for having no cards left in their deck."); + if (count($char) > CharacterPieces() && $char[CharacterPieces()] != "DUMMY") + WriteLog("Player " . $player . " took 3 damage for having no cards left in their deck."); DealDamageAsync($player, 3, "DAMAGE", "DRAW"); return -1; } - if(CurrentEffectPreventsDraw($player, $mainPhase)) return -1; + if (CurrentEffectPreventsDraw($player, $mainPhase)) + return -1; $hand[] = array_shift($deck); PermanentDrawCardAbilities($player); $hand = array_values($hand); - if($mainPhase) IncrementClassState($player, $CS_CardsDrawn); + if ($mainPhase) + IncrementClassState($player, $CS_CardsDrawn); return $hand[count($hand) - 1]; } diff --git a/Database/database.sql b/Database/database.sql index aa2f79684..bf13d0020 100644 --- a/Database/database.sql +++ b/Database/database.sql @@ -9,6 +9,20 @@ SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; START TRANSACTION; SET time_zone = "+00:00"; +CREATE TABLE `game` ( + `id` int(22) NOT NULL, + `name` varchar(255) NOT NULL, + `format` int(11) DEFAULT NULL, + `p1UserID` int(11) NOT NULL, + `p2UserID` int(11) DEFAULT NULL, + `p1Leader` char(15) NOT NULL, + `p2Leader` char(15) DEFAULT NULL, + `visibility` varchar(1000) DEFAULT NULL, + `lastAuthKey` varchar(128) DEFAULT NULL + `createdAt` timestamp NOT NULL DEFAULT current_timestamp(), +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; + + CREATE TABLE `completedgame` ( `CompletionTime` timestamp NOT NULL DEFAULT current_timestamp(), `WinningHero` char(15) NOT NULL, diff --git a/FindGame.php b/FindGame.php new file mode 100644 index 000000000..6d5f7800f --- /dev/null +++ b/FindGame.php @@ -0,0 +1,125 @@ +", $favoriteDeckLink); + if(count($favDeckArr) == 1) $favoriteDeckLink = $favDeckArr[0]; + else { + $favoriteDeckIndex = $favDeckArr[0]; + $favoriteDeckLink = $favDeckArr[1]; + } +} + +session_start(); + +if (!isset($_SESSION["userid"])) { + if (isset($_COOKIE["rememberMeToken"])) { + include_once './Assets/patreon-php-master/src/PatreonLibraries.php'; + include_once './Assets/patreon-php-master/src/API.php'; + include_once './Assets/patreon-php-master/src/PatreonDictionary.php'; + loginFromCookie(); + } +} + +$isShadowBanned = false; +if(isset($_SESSION["isBanned"])) $isShadowBanned = intval($_SESSION["isBanned"]) == 1; +else if(isset($_SESSION["userid"])) $isShadowBanned = IsBanned($_SESSION["userid"]); + +if($visibility == "public" && $deckTestMode != "" && !isset($_SESSION["userid"])) { + //Must be logged in to use matchmaking + header("Location: MainMenu.php"); + exit; +} + +if(isset($_SESSION["userid"])) +{ + //Save game creation settings + if(isset($favoriteDeckIndex)) + { + ChangeSetting("", $SET_FavoriteDeckIndex, $favoriteDeckIndex, $_SESSION["userid"]); + } + ChangeSetting("", $SET_Format, FormatCode($format), $_SESSION["userid"]); + ChangeSetting("", $SET_GameVisibility, ($visibility == "public" ? 1 : 0), $_SESSION["userid"]); + if($deckbuilderID != "") + { + if(str_contains($decklink, "fabrary")) storeFabraryId($_SESSION["userid"], $deckbuilderID); + else if(str_contains($decklink, "fabdb")) storeFabDBId($_SESSION["userid"], $deckbuilderID); + } +} + +session_write_close(); +if($isShadowBanned) { + if($format == "cc" || $format == "livinglegendscc") $format = "shadowcc"; + else if($format == "compcc") $format = "shadowcompcc"; + else if($format == "blitz" || $format == "compblitz" || $format == "commoner") $format = "shadowblitz"; +} + +$gameName = GetGameCounter(); + +if (file_exists("Games/$gameName") || !mkdir("Games/$gameName", 0700, true)) { + print_r("Encountered a problem creating a game. Please return to the main menu and try again"); +} + +$p1Data = [1]; +$p2Data = [2]; +$p1SideboardSubmitted = "0"; +$p2SideboardSubmitted = "0"; +if ($deckTestMode != "") { + $gameStatus = 4; //ReadyToStart + $p2SideboardSubmitted = "1"; + $opponentDeck = "./Assets/Dummy.txt"; + $fileName = "./Roguelike/Encounters/".$deckTestMode.".txt"; + if(file_exists($fileName)) $opponentDeck = $fileName; + copy($opponentDeck, "./Games/" . $gameName . "/p2Deck.txt"); +} else { + $gameStatus = 0; //Initial +} +$firstPlayerChooser = ""; +$firstPlayer = 1; +$p1Key = hash("sha256", rand() . rand()); +$p2Key = hash("sha256", rand() . rand() . rand()); +$p1uid = "-"; +$p2uid = "-"; +$p1id = "-"; +$p2id = "-"; +$hostIP = $_SERVER['REMOTE_ADDR']; +$p1StartingHealth = $startingHealth; + +$filename = "./Games/" . $gameName . "/GameFile.txt"; +$gameFileHandler = fopen($filename, "w"); +include "MenuFiles/WriteGamefile.php"; +WriteGameFile(); + +CreateLog($gameName); + +$currentTime = round(microtime(true) * 1000); +$cacheVisibility = ($visibility == "public" ? "1" : "0"); +WriteCache($gameName, 1 . "!" . $currentTime . "!" . $currentTime . "!0!-1!" . $currentTime . "!!!" . $cacheVisibility . "!0!0!0!" . $format . "!" . $gameStatus . "!0!0!$currentTime!0!0"); //Initialize SHMOP cache for this game +header("Location:" . $redirectPath . "/JoinGameInput.php?gameName=$gameName&playerID=1&deck=$deck&fabdb=$decklink&format=$format&set=$set&decksToTry=$decksToTry&favoriteDeck=$favoriteDeck&favoriteDecks=$favoriteDeckLink"); diff --git a/JoinGameInput.php b/JoinGameInput.php index 3fbb50b92..5d91367c4 100644 --- a/JoinGameInput.php +++ b/JoinGameInput.php @@ -53,11 +53,11 @@ include "CardDictionary.php"; include "MenuFiles/ParseGamefile.php"; include "MenuFiles/WriteGamefile.php"; -if($playerID == 2 && isset($_SESSION["userid"])) { +if ($playerID == 2 && isset($_SESSION["userid"])) { $isBlocked = false; $blockedPlayers = LoadBlockedPlayers($_SESSION["userid"]); - for($i=0; $i' . "⚠️ Deck URL is not valid: " . $decklink . ''; @@ -105,13 +106,15 @@ $usesUuid = false; if ($decklink != "") { - if ($playerID == 1) $p1DeckLink = $decklink; - else if ($playerID == 2) $p2DeckLink = $decklink; + if ($playerID == 1) + $p1DeckLink = $decklink; + else if ($playerID == 2) + $p2DeckLink = $decklink; $originalLink = $decklink; - if(str_contains($decklink, "swustats.net")) { + if (str_contains($decklink, "swustats.net")) { $decklinkArr = explode("gameName=", $decklink); - if(count($decklinkArr) > 1) { + if (count($decklinkArr) > 1) { $deckLinkArr = explode("&", $decklinkArr[1]); $deckID = $deckLinkArr[0]; $decklink = "https://swustats.net/TCGEngine/APIs/LoadDeck.php?deckID=" . $deckID . "&format=json"; @@ -123,11 +126,10 @@ $errorMessage = curl_error($curl); curl_close($curl); $json = $apiDeck; - echo($json); + echo ($json); $usesUuid = true; } - } - else if(str_contains($decklink, "swudb.com/deck")) { + } else if (str_contains($decklink, "swudb.com/deck")) { $decklinkArr = explode("/", $decklink); $decklink = "https://swudb.com/deck/view/" . trim($decklinkArr[count($decklinkArr) - 1]) . "?handler=JsonFile"; $curl = curl_init(); @@ -138,11 +140,10 @@ $errorMessage = curl_error($curl); curl_close($curl); $json = $apiDeck; - echo($json); - } - else if(str_contains($decklink, "sw-unlimited-db.com/decks")) { + echo ($json); + } else if (str_contains($decklink, "sw-unlimited-db.com/decks")) { $decklinkArr = explode("/", $decklink); - $deckId = trim($decklinkArr[count($decklinkArr) - 1]); + $deckId = trim($decklinkArr[count($decklinkArr) - 1]); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "https://sw-unlimited-db.com/umbraco/api/deckapi/get?id=" . $deckId); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); @@ -151,11 +152,11 @@ $errorMessage = curl_error($curl); curl_close($curl); $json = $apiDeck; - echo($json); - } - else $json = $decklink; + echo ($json); + } else + $json = $decklink; - if($json == "") { + if ($json == "") { echo "Failed to retrieve deck from API. Check to make sure you have a valid deckbuilder link. If it's a SWUDB link, make sure it's not a private deck.
"; echo "Your link: " . $originalLink . "
"; echo "API link: " . $decklink . "
"; @@ -173,30 +174,34 @@ $cards = ""; $bannedSet = "JTL"; $hasBannedCard = false; - for($i=0; $iid = CardIDLookup($deck[$i]->id); + for ($i = 0; $i < count($deck); ++$i) { + if ($usesUuid) + $deck[$i]->id = CardIDLookup($deck[$i]->id); $deck[$i]->id = CardIDOverride($deck[$i]->id); $cardID = UUIDLookup($deck[$i]->id); $cardID = CardUUIDOverride($cardID); - if(CardSet($cardID) == $bannedSet) { + if (CardSet($cardID) == $bannedSet) { $hasBannedCard = true; } - for($j=0; $j<$deck[$i]->count; ++$j) { - if($cards != "") $cards .= " "; + for ($j = 0; $j < $deck[$i]->count; ++$j) { + if ($cards != "") + $cards .= " "; $cards .= $cardID; } } $sideboard = $deckObj->sideboard ?? []; $sideboardCards = ""; - for($i=0; $iid = CardIDLookup($sideboard[$i]->id); + for ($i = 0; $i < count($sideboard); ++$i) { + if ($usesUuid) + $sideboard[$i]->id = CardIDLookup($sideboard[$i]->id); $sideboard[$i]->id = CardIDOverride($sideboard[$i]->id); $cardID = CardUUIDOverride(UUIDLookup($sideboard[$i]->id)); - if(CardSet($cardID) == $bannedSet) { + if (CardSet($cardID) == $bannedSet) { $hasBannedCard = true; } - for($j=0; $j<$sideboard[$i]->count; ++$j) { - if($sideboardCards != "") $sideboardCards .= " "; + for ($j = 0; $j < $sideboard[$i]->count; ++$j) { + if ($sideboardCards != "") + $sideboardCards .= " "; $sideboardCards .= $cardID; } } @@ -248,7 +253,8 @@ if ($playerID == 2) { $gameStatus = $MGS_Player2Joined; - if (file_exists("./Games/" . $gameName . "/gamestate.txt")) unlink("./Games/" . $gameName . "/gamestate.txt"); + if (file_exists("./Games/" . $gameName . "/gamestate.txt")) + unlink("./Games/" . $gameName . "/gamestate.txt"); $firstPlayerChooser = 1; $p1roll = 0; @@ -267,7 +273,8 @@ $joinerIP = $_SERVER['REMOTE_ADDR']; } - if ($playerID == 2) $p2Key = hash("sha256", rand() . rand() . rand()); + if ($playerID == 2) + $p2Key = hash("sha256", rand() . rand() . rand()); WriteGameFile(); SetCachePiece($gameName, $playerID + 1, strval(round(microtime(true) * 1000))); @@ -291,62 +298,97 @@ session_write_close(); header("Location: " . $redirectPath . "/GameLobby.php?gameName=$gameName&playerID=$playerID"); -function CardIDOverride($cardID) { - switch($cardID) { - case "SHD_030": return "SOR_033"; //Death Trooper - case "SHD_063": return "SOR_066"; //System Patrol Craft - case "SHD_066": return "SOR_068"; //Cargo Juggernaut - case "SHD_070": return "SOR_069"; //Resilient - case "SHD_081": return "SOR_080"; //General Tagge - case "SHD_085": return "SOR_083"; //Superlaser Technician - case "SHD_083": return "SOR_081"; //Seasoned Shoretrooper - case "SHD_166": return "SOR_162"; //Disabling Fang Fighter - case "SHD_223": return "SOR_215"; //Snapshot Reflexes - case "SHD_231": return "SOR_220"; //Surprise Strike - case "SHD_236": return "SOR_227"; //Snowtrooper Lieutenant - case "SHD_238": return "SOR_229"; //Cell Block Guard - case "SHD_257": return "SOR_247"; //Underworld Thug - case "SHD_262": return "SOR_251"; //Confiscate - case "SHD_121": return "SOR_117"; //Mercenary Company - case "TWI_077": return "SOR_078"; //Vanquish - case "TWI_107": return "SOR_111"; //Patrolling V-Wing - case "TWI_123": return "SHD_128"; //Outflank - case "TWI_124": return "SOR_124"; //Tactical Advantage - case "TWI_127": return "SOR_126"; //Resupply - case "TWI_128": return "SHD_131"; //Take Captive - case "TWI_170": return "SHD_178"; //Daring Raid - case "TWI_174": return "SOR_172"; //Open Fire - case "TWI_226": return "SOR_222"; //Waylay - case "TWI_254": return "SOR_248"; //Volunteer Soldier - case "C24_001": return "SOR_038"; //Count Dooku (Darth Tyranus) - case "C24_002": return "SOR_087"; //Darth Vader (Commanding the First Legion) - case "C24_003": return "SOR_135"; //Emperor Palpatine (Master of the Dark Side) - case "C24_004": return "SHD_141"; //Kylo Ren (Killing the Past) - case "C24_005": return "TWI_134"; //Asajj Ventress (Count Dooku's Assassin) - case "C24_006": return "TWI_135"; //Darth Maul (Revenge at Last) - - default: return $cardID; +function CardIDOverride($cardID) +{ + switch ($cardID) { + case "SHD_030": + return "SOR_033"; //Death Trooper + case "SHD_063": + return "SOR_066"; //System Patrol Craft + case "SHD_066": + return "SOR_068"; //Cargo Juggernaut + case "SHD_070": + return "SOR_069"; //Resilient + case "SHD_081": + return "SOR_080"; //General Tagge + case "SHD_085": + return "SOR_083"; //Superlaser Technician + case "SHD_083": + return "SOR_081"; //Seasoned Shoretrooper + case "SHD_166": + return "SOR_162"; //Disabling Fang Fighter + case "SHD_223": + return "SOR_215"; //Snapshot Reflexes + case "SHD_231": + return "SOR_220"; //Surprise Strike + case "SHD_236": + return "SOR_227"; //Snowtrooper Lieutenant + case "SHD_238": + return "SOR_229"; //Cell Block Guard + case "SHD_257": + return "SOR_247"; //Underworld Thug + case "SHD_262": + return "SOR_251"; //Confiscate + case "SHD_121": + return "SOR_117"; //Mercenary Company + case "TWI_077": + return "SOR_078"; //Vanquish + case "TWI_107": + return "SOR_111"; //Patrolling V-Wing + case "TWI_123": + return "SHD_128"; //Outflank + case "TWI_124": + return "SOR_124"; //Tactical Advantage + case "TWI_127": + return "SOR_126"; //Resupply + case "TWI_128": + return "SHD_131"; //Take Captive + case "TWI_170": + return "SHD_178"; //Daring Raid + case "TWI_174": + return "SOR_172"; //Open Fire + case "TWI_226": + return "SOR_222"; //Waylay + case "TWI_254": + return "SOR_248"; //Volunteer Soldier + case "C24_001": + return "SOR_038"; //Count Dooku (Darth Tyranus) + case "C24_002": + return "SOR_087"; //Darth Vader (Commanding the First Legion) + case "C24_003": + return "SOR_135"; //Emperor Palpatine (Master of the Dark Side) + case "C24_004": + return "SHD_141"; //Kylo Ren (Killing the Past) + case "C24_005": + return "TWI_134"; //Asajj Ventress (Count Dooku's Assassin) + case "C24_006": + return "TWI_135"; //Darth Maul (Revenge at Last) + + default: + return $cardID; } } function CardUUIDOverride($cardID) { switch ($cardID) { - case "1706333706": return "8380936981";//Jabba's Rancor + case "1706333706": + return "8380936981";//Jabba's Rancor //TODO: left here just in case we need these IDs //case "1401885853"://con exclusive 2024 Count Dooku (Darth Tyranus) - //return "9624333142"; + //return "9624333142"; //case "8292269690"://con exclusive 2024 Darth Vader (Commanding the First Legion) - //return "8506660490"; + //return "8506660490"; //case "9954244145"://con exclusive 2024 Emperor Palpatine (Master of the Dark Side) - //return "9097316363"; + //return "9097316363"; //case "3038397952"://con exclusive 2024 Kylo Ren (Killing the Past) - //return "6263178121"; + //return "6263178121"; //case "7315203824"://con exclusive 2024 Asajj Ventress (Count Dooku's Assassin) - //return "3556557330"; + //return "3556557330"; //case "5866567543"://con exclusive 2024 Darth Maul (Revenge at Last) - //return "8613680163"; - default: return $cardID; + //return "8613680163"; + default: + return $cardID; } } @@ -357,18 +399,31 @@ function IsBanned($cardID, $format) case "compblitz": switch ($cardID) { case "WTR152": - case "ARC076": case "ARC077": //Viserai - case "ARC129": case "ARC130": case "ARC131": + case "ARC076": + case "ARC077": //Viserai + case "ARC129": + case "ARC130": + case "ARC131": case "ELE006": - case "ELE186": case "ELE187": case "ELE188": + case "ELE186": + case "ELE187": + case "ELE188": case "ELE223": case "CRU141": - case "CRU174": case "CRU175": case "CRU176": + case "CRU174": + case "CRU175": + case "CRU176": case "MON239": - case "MON183": case "MON184": case "MON185": + case "MON183": + case "MON184": + case "MON185": case "EVR037": case "EVR123": // Aether Wildfire - case "UPR103": case "EVR120": case "ELE002": case "ELE003": case "EVR121": + case "UPR103": + case "EVR120": + case "ELE002": + case "ELE003": + case "EVR121": return true; default: return false; @@ -377,20 +432,28 @@ function IsBanned($cardID, $format) case "cc": case "compcc": switch ($cardID) { - case "WTR164": case "WTR165": case "WTR166": //Drone of Brutality - case "ARC170": case "ARC171": case "ARC172": //Plunder Run + case "WTR164": + case "WTR165": + case "WTR166": //Drone of Brutality + case "ARC170": + case "ARC171": + case "ARC172": //Plunder Run case "CRU141": case "MON001": //Prism case "MON003": //Luminaris case "MON153": case "MON155": case "MON239": - case "MON266": case "MON267": case "MON268": //Belittle + case "MON266": + case "MON267": + case "MON268": //Belittle case "ELE003": case "ELE006": case "ELE114": case "ELE172": - case "ELE186": case "ELE187": case "ELE188": + case "ELE186": + case "ELE187": + case "ELE188": case "ELE223": case "EVR017": case "UPR139": diff --git a/MainMenu.php b/MainMenu.php index babc24617..ee74a1c17 100644 --- a/MainMenu.php +++ b/MainMenu.php @@ -23,9 +23,12 @@ } if (isset($_GET['language'])) { ChangeSetting("", $SET_Language, $language, $_SESSION["userid"]); - } else if (isset($settingArray[$SET_Language])) $language = $settingArray[$SET_Language]; - if (isset($settingArray[$SET_Format])) $defaultFormat = $settingArray[$SET_Format]; - if (isset($settingArray[$SET_GameVisibility])) $defaultVisibility = $settingArray[$SET_GameVisibility]; + } else if (isset($settingArray[$SET_Language])) + $language = $settingArray[$SET_Language]; + if (isset($settingArray[$SET_Format])) + $defaultFormat = $settingArray[$SET_Format]; + if (isset($settingArray[$SET_GameVisibility])) + $defaultVisibility = $settingArray[$SET_GameVisibility]; } $_SESSION['language'] = $language; $isPatron = $_SESSION["isPatron"] ?? false; @@ -58,98 +61,178 @@
- "); + else + echo ("
"); + ?> - if (IsMobile()) echo ("
"); - else echo ("
"); + +
+ Find Game + Create Game +
- ?> + +
+ + +
+ 0) { + $selIndex = -1; + if (isset($settingArray[$SET_FavoriteDeckIndex])) + $selIndex = $settingArray[$SET_FavoriteDeckIndex]; + echo ("
Favorite Decks"); + echo ("
"); + } + } + ?> + + + "); + echo (""); + echo ("Save to Favorite Decks"); + echo (""); + } + ?> + + +
+ +
+ +
-

+ +
+ +
+ 0) { + $selIndex = -1; + if (isset($settingArray[$SET_FavoriteDeckIndex])) + $selIndex = $settingArray[$SET_FavoriteDeckIndex]; + echo ("
Favorite Decks"); + echo ("
"); + } + } + ?> + + + "); + echo (""); + echo ("Save to Favorite Decks"); + echo (""); + } + ?> + + - "); + + - $favoriteDecks = []; - if (isset($_SESSION["userid"])) { - $favoriteDecks = LoadFavoriteDecks($_SESSION["userid"]); - if (count($favoriteDecks) > 0) { - $selIndex = -1; - if (isset($settingArray[$SET_FavoriteDeckIndex])) $selIndex = $settingArray[$SET_FavoriteDeckIndex]; - echo ("
Favorite Decks"); - echo ("
"); - } - } - /* - if (count($favoriteDecks) == 0) { - echo ("
"); - echo (" + Public"); + } + echo (""); + ?> + - echo ("
"); - } - */ - - ?> - - - "); - echo (""); - echo ("Save to Favorite Decks"); - echo (""); - } - ?> - - - - Format"); - echo (""); - ?> - - '; - echo ('Public'); - } else { - echo ''; - } - ?> - - -
- +
+ +
+ +
- -
+ -
-
+
+

Karabast is an open-source, fan-made platform.

-

It is an educational tool only, meant to facilitate researching decks and strategies that is supportive of in-person play. As such, direct competition through the form of automated tournaments or rankings will not be added.

-

This tool is free to use and is published non-commercially. Payment is not required to access any functionality.

+

It is an educational tool only, meant to facilitate researching decks and strategies that is supportive of + in-person play. As such, direct competition through the form of automated tournaments or rankings will not be + added.

+

This tool is free to use and is published non-commercially. Payment is not required to access any functionality. +

-
+

News

@@ -157,13 +240,17 @@ SHD
-

SWU Stats

-

The amazing deck stat tracking you may know from other game sites like Fabrary has finally come to SWU!

-

Announcing SWU Stats! This is a deckbuilder particularly focused on tracking your game stats over time to help you train for upcoming organized play tournaments or even game night at your local LGS. If you'd prefer to deckbuild on another site, you can use the Import function. Just use the deck link from swustats to make sure you can view the stats for your deck. Join our Discord for the latest progress updates.

+

SWU Stats

+

The amazing deck stat tracking you may know from other game sites like Fabrary has finally come to SWU!

+

Announcing SWU Stats! This is a deckbuilder particularly focused on tracking your game stats over time to + help you train for upcoming organized play tournaments or even game night at your local LGS. If you'd prefer + to deckbuild on another site, you can use the Import function. Just use the deck link from swustats to make + sure you can view the stats for your deck. Join our + Discord for the latest progress updates.

+
-
- +?> \ No newline at end of file diff --git a/css/karabast011625.css b/css/karabast011625.css index 8d613b063..877469db9 100644 --- a/css/karabast011625.css +++ b/css/karabast011625.css @@ -375,6 +375,7 @@ select { } .save-deck { + margin-top: 3px; margin-bottom: 20px; display: block; } @@ -719,4 +720,57 @@ select { font-size: 12px; font-weight: 300; text-align: center; +} + + + +/* CREATE GAME TABS ---------------------------------------------------------------------------------------------- */ +/* Tabs specific to the create-game-wrapper */ +.create-game-tabs { + display: flex; + width: 100%; /* Ensure tabs take up full width */ + border-bottom: 2px solid #394452; /* Bottom border for the tabs container */ + margin-bottom: 20px; +} + +.create-game-tab { + flex: 1; /* Each tab takes up equal space */ + text-align: center; /* Center the text */ + padding: 10px 0; /* Padding for better spacing */ + cursor: pointer; + font-size: 18px; + font-weight: 600; + color: #aaaaaa; /* Inactive tab color */ + transition: color 0.3s, border-bottom 0.3s; + border-bottom: 2px solid transparent; /* Transparent border by default */ +} + +.create-game-tab.active { + color: white; /* Active tab color */ + border-bottom: 2px solid #bddbff; /* Bottom border for the active tab */ +} + +.create-game-tab:hover { + color: white; /* Hover color */ +} + +.create-game-tab-content { + display: none; /* Hide all tab content by default */ +} + +.create-game-tab-content.active { + display: block; /* Show active tab content */ +} + +/* Dropdown styling */ +.create-game-wrapper select { + width: 100%; + margin: 10px 0 20px 0; + background: #394452 url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23eceff4'%3E%3Cpath d='M5 6l5 5 5-5 2 1-7 7-7-7 2-1z'/%3E%3C/svg%3E") no-repeat right 5px center; + border-radius: 5px; + appearance: none; + border: none; + padding: 10px 15px; + font-size: 16px; + color: white; } \ No newline at end of file