Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
danbastin committed Feb 19, 2025
2 parents d82f674 + bca3d28 commit 39ea21a
Show file tree
Hide file tree
Showing 83 changed files with 519 additions and 167 deletions.
2 changes: 1 addition & 1 deletion AI/CombatDummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function CombatDummyAI()
for($i=0; $i<count($character) && $index == -1; $i += CharacterPieces()) if(CardType($character[$i]) != "C") $index = $i;
$cardID = $character[$index];
$from = "EQUIP";
$baseCost = AbilityCost($cardID, $index);
$baseCost = AbilityCost($cardID);
//$cost = $baseCost + CurrentEffectCostModifiers($cardID, $from) + CharacterCostModifier($cardID, $from);//FAB
$cost = $baseCost + CurrentEffectCostModifiers($cardID, $from);

Expand Down
16 changes: 16 additions & 0 deletions APIs/GetCosmetics.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@
$cardBack->id = 23;
$response->cardBacks[] = $cardBack;
$cardBack = new stdClass();
$cardBack->name = "Galactic Gonks";
$cardBack->id = 24;
$response->cardBacks[] = $cardBack;
$cardBack = new stdClass();
$cardBack->name = "Fallen Order";
$cardBack->id = 25;
$response->cardBacks[] = $cardBack;
$cardBack = new stdClass();
$cardBack->name = "Mythic Force";
$cardBack->id = 26;
$response->cardBacks[] = $cardBack;
$cardBack = new stdClass();
$cardBack->name = "MoG TCG";
$cardBack->id = 27;
$response->cardBacks[] = $cardBack;
$cardBack = new stdClass();

$response->playmats = [];
if(IsUserLoggedIn()) {
Expand Down
120 changes: 74 additions & 46 deletions AllyAbilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@ function AllyTakeControl($player, $uniqueID) {
$otherPlayer = $player == 1 ? 2 : 1;
$ally = new Ally($uniqueID, $otherPlayer);
if (!$ally->Exists()) return -1;
if($ally->IsLeader()) {
$ally->Destroy();
return $uniqueID;
}

$allyIndex = $ally->Index();
$allyController = $ally->Controller();

Expand Down Expand Up @@ -591,8 +596,8 @@ function AllyEntersPlayState($cardID, $player, $from="-")
}

function AllyPlayableExhausted(Ally $ally) {
global $CS_LeaderUpgradeAbilityID1, $CS_NumUsesLeaderUpgrade1;
//global $CS_LeaderUpgradeAbilityID2, $CS_NumUsesLeaderUpgrade2;//Twin Suns prep
$playable = false;

$cardID = $ally->CardID();
switch($cardID) {
case "5630404651"://MagnaGuard Wing Leader
Expand All @@ -606,62 +611,83 @@ function AllyPlayableExhausted(Ally $ally) {
return true;
default: break;
}

$leaderUpgradeAbilityID = GetClassState($ally->Controller(), $CS_LeaderUpgradeAbilityID1);
$numUsesLeaderUpgradeUses = GetClassState($ally->Controller(), $CS_NumUsesLeaderUpgrade1);
switch($leaderUpgradeAbilityID) {
case "3eb545eb4b"://Poe Dameron JTL leader upgrade
return $ally->HasUpgrade("3eb545eb4b") && $numUsesLeaderUpgradeUses > 0;
default: break;
if($ally->IsUpgraded()) {
$playable = $playable || CheckForUpgradesPlayableExhausted($ally);
}

return false;
return $playable;
}

function TheirAllyPlayableExhausted($ally) {
function TheirAllyPlayableExhausted(Ally $ally) {
$playable = false;

$cardID = $ally->CardID();
switch($cardID) {
case "3577961001"://Mercenary Gunship
return true;
default: return false;
default: break;
}
if($ally->IsUpgraded()) {
$playable = $playable || CheckForUpgradesPlayableExhausted($ally);
}

return $playable;
}

function CheckForUpgradesPlayableExhausted(Ally $ally, $theirCard=false) {
global $currentPlayer, $CS_NumUsesLeaderUpgrade1, $CS_NumUsesLeaderUpgrade2;
$otherPlayer = $currentPlayer == 1 ? 2 : 1;
$playableBy = $theirCard ? $otherPlayer : $currentPlayer;
if($ally->IsUpgraded()) {
$upgrades = $ally->GetUpgrades(withMetadata:true);
for($i=0; $i<count($upgrades); $i+=SubcardPieces()) {
switch($upgrades[$i]) {
case "3eb545eb4b"://Poe Dameron JTL leader
return $upgrades[$i+1] == $playableBy && GetClassState($playableBy, $CS_NumUsesLeaderUpgrade1) > 0;
break;
default: break;
}
}
}

return false;
}

function AllyDoesAbilityExhaust($cardID, $abilityIndex) {
global $currentPlayer, $CS_LeaderUpgradeAbilityID1, $CS_LeaderUpgradeAbilityID2;
function AllyDoesAbilityExhaust($cardID) {
global $currentPlayer;
$abilityName = GetResolvedAbilityName($cardID);
if($abilityName == "Poe Pilot") return false;
switch($cardID) {
case "5630404651"://MagnaGuard Wing Leader
return $abilityIndex == 1;
return $abilityName != "Droid Attack";
case "4300219753"://Fett's Firespray
return $abilityIndex == 1;
return $abilityName != "Exhaust";
case "2471223947"://Frontline Shuttle
return $abilityIndex == 1;
return $abilityName != "Shuttle";
case "1885628519"://Crosshair
return $abilityIndex == 1 || $abilityIndex == 2;
return $abilityName != "Buff";
case "040a3e81f3"://Lando Leader Unit
return $abilityIndex == 1;
return $abilityName != "Smuggle";
case "2b13cefced"://Fennec Shand Leader Unit
return $abilityIndex == 1;
return $abilityName != "Ambush";
case "a742dea1f1"://Han Solo Red Leader Unit
return $abilityIndex == 1;
default: break;
}
$leaderUpgradeAbilityID = GetClassState($currentPlayer, $CS_LeaderUpgradeAbilityID1);
switch($leaderUpgradeAbilityID) {
case "3eb545eb4b"://Poe Dameron JTL leader upgrade
return $abilityIndex == 0;
return $abilityName != "Play";
default: break;
}

return true;
}

function TheirAllyDoesAbilityExhaust($cardID, $abilityIndex) {
function TheirAllyDoesAbilityExhaust($cardID) {
$abilityName = GetResolvedAbilityName($cardID);
if($abilityName == "Poe Pilot") return false;
switch($cardID) {
case "3577961001"://Mercenary Gunship
return false;
return $abilityName != "Take Control";
default: return true;
}


}

function AllyHealth($cardID, $playerID="")
Expand All @@ -679,26 +705,28 @@ function AllyHealth($cardID, $playerID="")

function AllyLeavesPlayAbility($player, $index)
{
$allies = &GetAllies($player);
$cardID = $allies[$index];
$uniqueID = $allies[$index + 5];
$fromEpicAction = $allies[$index + 16];
$leaderUndeployed = LeaderUndeployed($cardID);
global $CS_CachedLeader1EpicAction, $CS_CachedLeader2EpicAction;
$cachedEpicAction1 = GetClassState($player, $CS_CachedLeader1EpicAction) == 1;
$ally = new Ally("MYALLY-" . $index, $player);
$leaderUndeployed = LeaderUndeployed($ally->CardID());
if($leaderUndeployed != "") {
AddCharacter($leaderUndeployed, $player, counters:$fromEpicAction ? 1 : 0, status:1);
$usedEpicAction = $ally->FromEpicAction() || $cachedEpicAction1;
AddCharacter($leaderUndeployed, $ally->Owner(), counters:$usedEpicAction ? 1 : 0, status:1);
}
//Pilot leader upgrades
$subcardsArr = explode(",", $allies[$index + 4]);
$subcardsArr = $ally->GetSubcards();
for($i=0;$i<count($subcardsArr);$i+=SubcardPieces()) {
if(CardIDIsLeader($subcardsArr[$i])) {
$leaderUndeployed = LeaderUndeployed($subcardsArr[$i]);
$subcard = new SubCard($ally, $i);
if(CardIDIsLeader($subcard->CardID())) {
$leaderUndeployed = LeaderUndeployed($subcard->CardID());
if($leaderUndeployed != "") {
AddCharacter($leaderUndeployed, $player, counters:$subcardsArr[$i+4] == 1 ? 1 : 0, status:1);
$usedEpicAction = $subcard->FromEpicAction() || $cachedEpicAction1;
AddCharacter($leaderUndeployed, $subcard->Owner(), counters:$usedEpicAction ? 1 : 0, status:1);
}
}
}

switch($cardID)
switch($ally->CardID())
{
case "3401690666"://Relentless
$otherPlayer = ($player == 1 ? 2 : 1);
Expand All @@ -709,11 +737,11 @@ function AllyLeavesPlayAbility($player, $index)
break;
case "7964782056"://Qi'Ra unit
$otherPlayer = $player == 1 ? 2 : 1;
SearchLimitedCurrentTurnEffects("7964782056", $otherPlayer, uniqueID:$uniqueID, remove:true);
SearchLimitedCurrentTurnEffects("7964782056", $otherPlayer, uniqueID:$ally->UniqueID(), remove:true);
break;
case "3503494534"://Regional Governor
$otherPlayer = $player == 1 ? 2 : 1;
SearchLimitedCurrentTurnEffects("3503494534", $otherPlayer, uniqueID:$uniqueID, remove:true);
SearchLimitedCurrentTurnEffects("3503494534", $otherPlayer, uniqueID:$ally->UniqueID(), remove:true);
break;
case "4002861992"://DJ (Blatant Thief)
$djAlly = new Ally("MYALLY-" . $index, $player);
Expand Down Expand Up @@ -2590,6 +2618,7 @@ function SpecificAllyAttackAbilities($attackID)
$card = Mill($mainPlayer, 1);
if(CardCostIsOdd($card)) {
AddDecisionQueue("MULTIZONEINDICES", $mainPlayer, "MYALLY");
AddDecisionQueue("MZFILTER", $mainPlayer, "index=" . $attackerAlly->MZIndex());
AddDecisionQueue("SETDQCONTEXT", $mainPlayer, "Choose a unit to give an experience");
AddDecisionQueue("CHOOSEMULTIZONE", $mainPlayer, "<-", 1);
AddDecisionQueue("MZOP", $mainPlayer, "ADDEXPERIENCE", 1);
Expand Down Expand Up @@ -2645,9 +2674,7 @@ function SpecificAllyAttackAbilities($attackID)
AddDecisionQueue("SETDQCONTEXT", $mainPlayer, "Choose a unit to deal 1 damage to");
AddDecisionQueue("MAYCHOOSEMULTIZONE", $mainPlayer, "<-", 1);
AddDecisionQueue("MZOP", $mainPlayer, "DEALDAMAGE,1,$mainPlayer,1", 1);
AddDecisionQueue("MULTIZONEINDICES", $mainPlayer, "MYCHAR:definedType=Base&THEIRCHAR:definedType=Base");
AddDecisionQueue("SETDQCONTEXT", $mainPlayer, "Choose a base to deal 1 damage to", 1);
AddDecisionQueue("CHOOSEMULTIZONE", $mainPlayer, "<-", 1);
AddDecisionQueue("PASSPARAMETER", $mainPlayer, "THEIRCHAR-0", 1);
AddDecisionQueue("MZOP", $mainPlayer, "DEALDAMAGE,1,$mainPlayer,1", 1);
}
break;
Expand All @@ -2665,7 +2692,8 @@ function SpecificAllyAttackAbilities($attackID)
AddDecisionQueue("MZOP", $mainPlayer, "ADDEXPERIENCE", 1);
}
if(SearchCount(SearchAllies($mainPlayer, aspect:"Aggression")) > 0) {
AddDecisionQueue("MULTIZONEINDICES", $mainPlayer, "MYALLY&THEIRALLY&MYCHAR:definedType=Base&THEIRCHAR:definedType=Base");
AddDecisionQueue("MULTIZONEINDICES", $mainPlayer, "MYALLY&THEIRALLY");
AddDecisionQueue("PREPENDLASTRESULT", $mainPlayer, "THEIRCHAR-0,", 1);
AddDecisionQueue("SETDQCONTEXT", $mainPlayer, "Choose a card to deal 1 damage to");
AddDecisionQueue("CHOOSEMULTIZONE", $mainPlayer, "<-", 1);
AddDecisionQueue("MZOP", $mainPlayer, DamageStringBuilder(1, $mainPlayer, 1), 1);
Expand Down
42 changes: 35 additions & 7 deletions CardDictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -883,10 +883,10 @@ function HasSaboteur($cardID, $player, $index)
// return $cost;
// }

function AbilityCost($cardID, $index=-1, $theirCard = false)
function AbilityCost($cardID)
{
global $currentPlayer;
$abilityName = $theirCard ? GetOpponentControlledAbilityNames($cardID) : GetResolvedAbilityName($cardID);
$abilityName = GetResolvedAbilityName($cardID);
if($abilityName == "Heroic Resolve") return 2;
if($abilityName == "Poe Pilot") return 1;
switch($cardID) {
Expand Down Expand Up @@ -1401,7 +1401,9 @@ function CheckSORAbilityNames($cardID, $index, $validate) {
case "8117080217"://Admiral Ozzel
return "Play Imperial Unit,Attack";
case "2471223947"://Frontline Shuttle
return "Shuttle,Attack";
$ally = new Ally("MYALLY-" . $index, $currentPlayer);
if($validate) return $ally->IsExhausted() ? "Shuttle" : "Shuttle,Attack";
else return "Shuttle,Attack";
case "1951911851"://Grand Admiral Thrawn
return LeaderAbilitiesIgnored() ? "" : "Exhaust";

Expand All @@ -1422,7 +1424,9 @@ function CheckSHDAbilityNames($cardID, $index, $validate) {
case "1090660242"://The Client
return "Bounty,Attack";
case "1885628519"://Crosshair
return "Buff,Snipe,Attack";
$ally = new Ally("MYALLY-" . $index, $currentPlayer);
if($validate) return $ally->IsExhausted() ? "Buff" : "Buff,Snipe,Attack";
else return "Buff,Snipe,Attack";
case "2503039837"://Moff Gideon
return LeaderAbilitiesIgnored() ? "" : "Attack";
case "2526288781"://Bossk
Expand Down Expand Up @@ -1578,6 +1582,8 @@ function CheckJTLAbilityNames($cardID) {
}

function GetOpponentControlledAbilityNames($cardID) {
global $currentPlayer, $CS_NumUsesLeaderUpgrade1;
$otherPlayer = ($currentPlayer == 1 ? 2 : 1);
$abilityNames = "";

switch($cardID) {
Expand All @@ -1587,13 +1593,34 @@ function GetOpponentControlledAbilityNames($cardID) {
default: break;
}

$theirAlliesWithCardID = explode(",", SearchAlliesForCard($otherPlayer, $cardID));
for($i=0; $i<count($theirAlliesWithCardID); ++$i) {
$ally = new Ally("MYALLY-" . $theirAlliesWithCardID[$i], $otherPlayer);
if($ally->IsUpgraded()) {
$upgrades = $ally->GetUpgrades(withMetadata:true);
for($j=0; $j<count($upgrades); ++$j) {
switch($upgrades[$j]) {
case "3eb545eb4b"://Poe Dameron JTL leader
if($upgrades[$j+1] == $currentPlayer && GetClassState($currentPlayer, $CS_NumUsesLeaderUpgrade1) > 0) {
if($abilityNames != "") $abilityNames .= ",";
$abilityNames .= "Poe Pilot";
}
break;
default: break;
}
}
}
}

return $abilityNames;
}

function GetAbilityIndex($cardID, $index, $abilityName, $theirCard = false)
{
$abilityName = str_replace("_", " ", $abilityName);
$names = explode(",", GetAbilityNames($cardID, $index));
$names = $theirCard
? explode(",", GetOpponentControlledAbilityNames($cardID))
: explode(",", GetAbilityNames($cardID, $index));
for($i = 0; $i < count($names); ++$i) {
if($abilityName == $names[$i]) return $i;
}
Expand All @@ -1615,10 +1642,11 @@ function GetResolvedAbilityType($cardID, $from="-", $theirCard = false)

function GetResolvedAbilityName($cardID, $from="-")
{
global $currentPlayer, $CS_AbilityIndex, $CS_PlayIndex;
global $currentPlayer, $CS_AbilityIndex, $CS_PlayIndex, $CS_OppCardActive;
$theirCard = GetClassState($currentPlayer, $CS_OppCardActive) == 1;
if($from != "PLAY" && $from != "EQUIP" && $from != "-") return "";
$abilityIndex = GetClassState($currentPlayer, $CS_AbilityIndex);
$abilityNames = GetAbilityNames($cardID, GetClassState($currentPlayer, $CS_PlayIndex));
$abilityNames = $theirCard ? GetOpponentControlledAbilityNames($cardID) : GetAbilityNames($cardID, GetClassState($currentPlayer, $CS_PlayIndex));
if($abilityNames == "" || $abilityIndex == "-") return "";
$abilityNames = explode(",", $abilityNames);
return $abilityNames[$abilityIndex];
Expand Down
Loading

0 comments on commit 39ea21a

Please sign in to comment.