Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/MTGPocket/Game/Game.php
Original file line number Diff line number Diff line change
Expand Up @@ -6858,7 +6858,8 @@ private function objectFits(GameObject $object, string $kind): bool
'multicolored' => count($card->colors) > 1,
// `a spell that has an X in its mana cost`
'x spell' => $card->cost->xCount > 0,
default => in_array($kind, $card->subtypes, true),
// `an Aura, Equipment, or Vehicle spell`
default => str_starts_with($kind, 'any:') ? array_intersect(explode('|', substr($kind, 4)), $card->subtypes) !== [] : in_array($kind, $card->subtypes, true),
};
}

Expand Down
7 changes: 7 additions & 0 deletions src/MTGPocket/Game/TextParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3073,6 +3073,13 @@ private static function triggered(string $line, array &$result): bool
$event = $match[1] === 'you' ? 'you_cast_kind' : 'opponent_cast_kind';
$extra = ['objectKind' => $match[3] !== '' ? ($match[2] !== '' ? "{$match[2]}with {$match[3]}" : $match[3]) : $match[4]];
$text = $match[5];
} elseif (preg_match('/^Whenever (you|an opponent) casts? an? ((?:[A-Z][a-z]+, )*[A-Z][a-z]+,? or [A-Z][a-z]+) spell, (.+)$/', $line, $match)
&& ($match[1] === 'you') === str_starts_with($match[0], 'Whenever you cast ')
&& ($types = array_map(fn (string $word) => self::subtypeOf($word), preg_split('/,? or |, /', $match[2]))) !== [] && ! in_array(null, $types, true)) {
// `Whenever you cast an Aura, Equipment, or Vehicle spell, …`: any of those subtypes; see Game::objectFits().
$event = $match[1] === 'you' ? 'you_cast_kind' : 'opponent_cast_kind';
$extra = ['objectKind' => 'any:'.implode('|', $types)];
$text = $match[3];
} elseif (preg_match('/^Whenever you cast ('.implode('|', array_keys($casts)).'), (.+)$/', $line, $match)) {
$event = $casts[$match[1]];
$text = $match[2];
Expand Down
Loading
Loading