Skip to content

Instantly share code, notes, and snippets.

@calebhearth
Created December 18, 2020 18:40
Show Gist options
  • Save calebhearth/b84bc16c60665eced9339bfe2e881f4b to your computer and use it in GitHub Desktop.
Save calebhearth/b84bc16c60665eced9339bfe2e881f4b to your computer and use it in GitHub Desktop.
ability :: Attrs -> Ability
ability attrs =
mkAbility (toSource attrs) 1 (ReactionAbility (AssetDefeated iid))
instance ActionRunner env => HasActions env BrotherXavier where
getActions iid (AssetDefeated iid) (BrotherXavier a) | ownedBy a iid = do
let ability' = (iid, ability a)
unused <- notElem ability' . map unUsedAbility <$> getList ()
pure
[ uncurry ActivateCardAbilityAction ability' | unused ]
getActions _ _ _ = pure []
instance AssetRunner env => RunMessage env BrotherXavier where
runMessage msg a@(BrotherXavier attrs) = case msg of
AssetDefeated iid | getInvestigator attrs == iid ->
a <$ unshiftMessage
(chooseOne
iid
[ UseCardAbility iid (toSource attrs) Nothing 1
, Continue "Do not use Brother Xavier's ability"
]
)
UseCardAbility iid source _ 1 | isSource attrs source ->
locationId <- getId @LocationId (getInvestigator attrs)
locationEnemyIds <- getSetList locationId
unshiftMessages
[chooseOne
iid
[ EnemyDamage eid iid (toSource attrs) 2 | eid <- locationEnemyIds ]
]
_ -> BrotherXavier <$> runMessage msg attrs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment