{:effect(effect(run:hq{:req(req(=target:hq)):replace-access{:msg(msg"force the Corp to lose "(min5(:creditcorp))" [Credits], gain "(*2(min5(:creditcorp)))" [Credits] and take 2 tags"):delayed-completiontrue:effect(req(when-completed(tag-runnerstate:runner2)(do(gainstate:runner:credit(*2(min5(:creditcorp))))(losestate:corp:credit(min5(:creditcorp)))(effect-completedstatesideeid))))}}card))}
{:req(req(and(some#{:hq}(:successful-runrunner-reg))(some#{:rd}(:successful-runrunner-reg))(some#{:archives}(:successful-runrunner-reg))));; trash cards from right to left
;; otherwise, auto-killing servers would move the cards to the next server
;; so they could no longer be trashed in the same loop
:msg"trash all installed Corp cards and turn all installed Runner cards facedown":effect(req(let[allcorp(->>(all-installedstate:corp)(sort-by#(vec(:zone%)))(reverse))](doseq[callcorp](trashstatesidec)));; do hosted cards first so they don't get trashed twice
(doseq[c(all-installedstate:runner)](when(or(=["onhost"](getc:zone))(='(:onhost)(getc:zone)))(movestatesidec[:rig:facedown])(if(:memoryunitsc)(gainstate:runner:memory(:memoryunitsc)))))(doseq[c(all-installedstate:runner)](when(not(or(=["onhost"](getc:zone))(='(:onhost)(getc:zone))))(movestatesidec[:rig:facedown])(if(:memoryunitsc)(gainstate:runner:memory(:memoryunitsc))))))}
{:req(reqhas-bad-pub):prompt"Choose a server":choices(reqrunnable-servers):msg"prevent ICE from being rezzed during this run":effect(effect(register-run-flag!card:can-rez(fn[statesidecard](if(ice?card)((constantlyfalse)(system-msgstateside(str"is prevented from rezzing ICE on this run by Blackmail")))true)))(runtargetnilcard))}
{:prompt"How many [Credits]?":choices:credit:msg(msg"increase the rez cost of the 1st unrezzed ICE approached by "target" [Credits]"):effect(effect(resolve-ability{:prompt"Choose a server":choices(reqrunnable-servers):effect(effect(runtargetnilcard))}cardnil))}
{:prompt"Choose a resource to install from your Grip":choices{:req#(and(is-type?%"Resource")(in-hand?%))}:effect(effect(install-cost-bonus[:credit-3])(runner-installtarget))}
(letfn[(cbi-final[chosenoriginal]{:prompt(str"The top cards of R&D will be "(clojure.string/join", "(map:titlechosen))"."):choices["Done""Start over"]:delayed-completiontrue:effect(req(if(=target"Done")(do(doseq[c(reversechosen)](movestate:corpc:deck{:fronttrue}))(clear-wait-promptstate:runner)(effect-completedstatesideeidcard))(continue-abilitystateside(cbi-choiceoriginal'()(countoriginal)original)cardnil)))})(cbi-choice[remainingchosennoriginal]{:prompt"Choose a card to move next onto R&D":choicesremaining:delayed-completiontrue:effect(req(let[chosen(constargetchosen)](if(<(countchosen)n)(continue-abilitystateside(cbi-choice(remove-once#(not=target%)remaining)chosennoriginal)cardnil)(continue-abilitystateside(cbi-finalchosenoriginal)cardnil))))})]{:delayed-completiontrue:effect(effect(run:hq{:replace-access{:msg"force the Corp to add all cards in HQ to the top of R&D":delayed-completiontrue:effect(req(show-wait-promptstate:runner"Corp to add all cards in HQ to the top of R&D")(let[from(:handcorp)](if(pos?(countfrom))(continue-abilitystate:corp(cbi-choicefrom'()(countfrom)from)cardnil)(do(clear-wait-promptstate:runner)(effect-completedstatesideeidcard)))))}}card))})
{:effect(effect(run:rd{:replace-access{:delayed-completiontrue:prompt"Choose a program to install":msg(msg"install "(:titletarget)" and take 1 tag"):choices(req(filter#(is-type?%"Program")(:deckrunner))):effect(effect(trigger-event:searched-stacknil)(shuffle!:deck)(install-cost-bonus[:credit(*-3(count(get-incorp[:servers:rd:ices])))])(runner-installtarget)(tag-runnereid1))}}card))}
(let[end-effect{:prompt"Choose a program that was used during the run to trash ":choices{:req#(card-is?%:type"Program")}:msg(msg"trash"(:titletarget)):effect(effect(trashtarget{:unpreventabletrue}))}]{:delayed-completiontrue:prompt"Choose a server":recurring4:choices(reqrunnable-servers):effect(req(let[c(movestateside(assoccard:zone'(:discard)):play-area{:forcetrue})](card-initstatesidecfalse)(game.core/runstateside(make-eidstate)target{:end-run{:delayed-completiontrue:effect(effect(trashc)(continue-abilityend-effectcardnil))}}c)))})
{:msg"give the Corp 1 additional bad publicity":effect(req(swap!stateupdate-in[:corp:has-bad-pub]inc)):leave-play(req(swap!stateupdate-in[:corp:has-bad-pub]dec))}
{:prompt"Choose a server":choices(reqrunnable-servers):effect(effect(runtargetnilcard)(register-events(:events(card-defcard))(assoccard:zone'(:discard)))):events{:pre-access-card{:once:per-run:delayed-completiontrue:req(req(not=(:typetarget)"Agenda")):effect(req(let[ctargetcost(:costc)title(:titlec)](if(can-pay?state:corpnil:creditcost)(do(show-wait-promptstate:runner"Corp to decide whether or not to prevent the trash")(continue-abilitystate:corp{:optional{:delayed-completiontrue:prompt(msg"Spend "cost" [Credits] to prevent the trash of "title"?"):player:corp:yes-ability{:effect(req(losestate:corp:creditcost)(system-msgstate:corp(str"spends "cost" [Credits] to prevent "title" from being trashed at no cost"))(clear-wait-promptstate:runner))}:no-ability{:msg(msg"trash "title" at no cost"):effect(effect(clear-wait-prompt:runner)(resolve-trash-no-costc))}}}cardnil))(do(resolve-trash-no-coststatesidec)(system-msgstateside(str"uses Credit Crash to trash "title" at no cost"))(effect-completedstatesideeid)))))}:run-ends{:effect(effect(unregister-eventscard))}}}
{:prompt"Choose a server":choices(reqrunnable-servers):delayed-completiontrue:effect(req(let[servtarget](continue-abilitystate:corp{:optional{:prompt(msg"Rez a piece of ICE protecting "serv"?"):yes-ability{:prompt(msg"Choose a piece of "serv" ICE to rez"):player:corp:choices{:req#(and(not(:rezzed%))(=(last(:zone%)):ices))}:effect(req(rezstate:corptargetnil))}:no-ability{:effect(effect(game.core/runeidservnilcard)):msg(msg"make a run on "serv" during which no ICE can be rezzed")}}}cardnil)))}
{:delayed-completiontrue:effect(req(register-eventsstateside(:events(card-defcard))(assoccard:zone'(:discard)))(when-completed(game.core/runstateside:rdnilcard)(let[card(get-cardstate(assoccard:zone'(:discard)))](unregister-eventsstatesidecard)(if(:run-againcard)(game.core/runstatesideeid:rdnilcard)(effect-completedstatesideeid))(update!stateside(dissoccard:run-again))))):events{:successful-run-ends{:optional{:req(req(=[:rd](:servertarget))):prompt"Make another run on R&D?":yes-ability{:effect(effect(update!(assoccard:run-againtrue)))}}}}}
{:prompt"Choose a card to add to Grip":choices(req(cancellable(:discardrunner):sorted)):msg(msg"add "(:titletarget)" to their Grip"):effect(req(movestatesidetarget:hand)(when(has-subtype?target"Virus")(resolve-abilitystateside{:prompt"Choose a virus to add to Grip":msg(msg"add "(:titletarget)" to their Grip"):choices(req(cancellable(filter#(has-subtype?%"Virus")(:discardrunner)):sorted)):effect(effect(movetarget:hand))}cardnil)))}
{:prompt"Choose a server":choices["HQ""R&D"]:abilities[{:msg(msg"trash "(:title(:card(first(get-in@state[side:prompt]))))" at no cost"):effect(effect(trash-no-cost))}]:effect(effect(runtargetnilcard)(prompt!card(str"Click Demolition Run in the Temporary Zone to trash a card being accessed at no cost")["OK"]{})(resolve-ability{:effect(req(let[c(movestateside(last(:discardrunner)):play-area)](card-initstatesidecfalse)(register-eventsstateside{:run-ends{:effect(effect(trashc))}}c)))}cardnil)):events{:run-endsnil}}
(let[all[{:effect(effect(gain:credit3)):msg"gain 3 [Credits]"}{:effect(effect(draw2)):msg"draw 2 cards"}{:effect(effect(lose:tag1)):msg"remove 1 tag"}{:prompt"Select 1 piece of ice to expose":msg"expose 1 ice and make a run":choices{:req#(and(installed?%)(ice?%))}:delayed-completiontrue:effect(req(when-completed(exposestatesidetarget)(continue-abilitystateside{:prompt"Choose a server":choices(reqrunnable-servers):delayed-completiontrue:effect(effect(game.core/runeidtarget))}cardnil)))}]choice(fnchoice[abis]{:prompt"Choose an ability to resolve":choices(map#(capitalize(:msg%))abis):delayed-completiontrue:effect(req(let[chosen(some#(when(=target(capitalize(:msg%)))%)abis)](when-completed(resolve-abilitystatesidechosencardnil)(if(=(countabis)4)(continue-abilitystateside(choice(remove-once#(not=%chosen)abis))cardnil)(effect-completedstatesideeid)))))})]{:delayed-completiontrue:effect(effect(continue-ability(choiceall)cardnil))})
{:prompt"Choose a server":choices(reqrunnable-servers):effect(effect(runtarget{:end-run{:req(req(:successfulrun)):msg" gain 5 [Credits]":effect(effect(gain:runner:credit5))}}card))}
{:choices{:req#(let[topmost(get-nested-host%)](and(is-remote?(second(:zonetopmost)))(=(last(:zonetopmost)):content)(not(:rezzed%))))}:delayed-completiontrue:effect(req(when-completed(exposestatesidetarget);; would be nice if this could return a value on completion
(ifasync-result;; expose was successful
(if(#{"Asset""Upgrade"}(:typetarget))(do(system-msgstate:runner(str"uses Drive By to trash "(:titletarget)))(trashstateside(assoctarget:seentrue))(effect-completedstatesideeid))(effect-completedstatesideeid))(effect-completedstatesideeid))))}
{:prompt"Choose a server":choices(reqrunnable-servers):msg(msg"make a run on "target" and gain [Click]"):effect(effect(gain:click1)(runtargetnilcard))}
{:req(req(and(some#{:hq}(:successful-runrunner-reg))(some#{:rd}(:successful-runrunner-reg))(some#{:archives}(:successful-runrunner-reg)))):effect(req(swap!stateassoc-in[:runner:extra-turn]true)(movestateside(first(:play-arearunner)):rfg)):msg"take an additional turn after this one"}
{:req(req(:successful-runrunner-reg)):effect(req(let[runtgt(first(flatten(turn-eventsstateside:run)))serv(zone->nameruntgt)](resolve-abilitystateside{:prompt(msg"Choose an unrezzed piece of ICE protecting "serv" that you passed on your last run"):choices{:req#(and(ice?%)(not(rezzed?%))(=runtgt(second(:zone%))))}:msg(msg"trash "(card-strstatetarget)):effect(effect(trashtarget))}cardnil)))}
(letfn[(es[]{:prompt"Select two pieces of ICE to swap positions":choices{:req#(and(installed?%)(ice?%)):max2}:effect(req(if(=(counttargets)2)(do(swap-icestateside(firsttargets)(secondtargets))(resolve-abilitystateside(es)cardnil))(system-msgstateside"has finished rearranging ICE")))})]{:effect(effect(run:hq{:replace-access{:msg"rearrange installed ICE":effect(effect(resolve-ability(es)cardnil))}}card))})
{:effect(req(let[topcard(first(:deckrunner))caninst(or(is-type?topcard"Hardware")(is-type?topcard"Program")(is-type?topcard"Resource"))](ifcaninst(resolve-abilitystateside{:optional{:prompt(msg"Install "(:titletopcard)"?"):yes-ability{:effect(effect(install-cost-bonus[:credit-10])(runner-installtopcard))}:no-ability{:effect(effect(trashtopcard{:unpreventabletrue})(system-msg(str"reveals and trashes "(:titletopcard))))}}}cardnil)(do(trashstatesidetopcard{:unpreventabletrue})(system-msgstateside(str"reveals and trashes "(:titletopcard)))))))}
{:msg(msg"draw 1 card and gain "(count(filter#(=(:title%)"Exclusive Party")(:discardrunner)))" [Credits]"):effect(effect(draw)(gain:credit(count(filter#(=(:title%)"Exclusive Party")(:discardrunner)))))}
{:prompt"Choose a server":choices(reqrunnable-servers):effect(effect(runtarget{:replace-access{:prompt"Advancements to remove from a card in or protecting this server?":choices["0","1","2","3"]:effect(req(let[c(Integer/parseInttarget)](resolve-abilitystateside{:choices{:req#(and(contains?%:advance-counter)(=(:serverrun)(vec(rest(butlast(:zone%))))))}:msg(msg"remove "c" advancements from "(card-strstatetarget)):effect(req(add-propstate:corptarget:advance-counter(-c))(swap!stateupdate-in[:runner:prompt]rest)(handle-end-runstateside))}cardnil)))}}card))}
{:prompt"Choose a card to add to your Grip":choices(req(take4(:deckrunner))):msg"look at the top 4 cards of their Stack and add 1 of them to their Grip":effect(effect(movetarget:hand)(shuffle!:deck))}
{:effect(effect(run:hq{:req(req(=target:hq)):replace-access{:delayed-completiontrue:mandatorytrue:msg"force the Corp to trash the top card of R&D":effect(req(millstate:corp)(let[n(count(filter#(=(:titlecard)(:title%))(:handrunner)))](if(>n0)(continue-abilitystateside{:prompt"Reveal how many copies of Fear the Masses?":choices{:number(reqn)}:effect(req(when(>target0)(millstate:corptarget)(system-msgstateside(str"reveals "target" copies of Fear the Masses,"" forcing the Corp to trash "target" cards"" from the top of R&D"))))}cardnil)(effect-completedstatesideeidcard))))}}card))}
{:implementation"Bypass is manual":effect(effect(run:hqnilcard)(register-events(:events(card-defcard))(assoccard:zone'(:discard)))):events{:successful-run{:msg"access 0 cards":effect(effect(max-access0))}:run-ends{:effect(effect(unregister-eventscard))}}}
{:choices{:req#(and(ice?%)(not(rezzed?%)))}:effect(req(let[icetargetserv(zone->name(second(:zoneice)))icepos(ice-indexstateice)](resolve-abilitystate:corp{:prompt(msg"Rez "(:titleice)" at position "icepos" of "serv" or trash it?"):choices["Rez""Trash"]:effect(effect(resolve-ability(if(and(=target"Rez")(<=(rez-coststate:corpice)(:creditcorp))){:msg(msg"force the rez of "(:titleice)):effect(effect(rez:corpice))}{:msg(msg"trash the ICE at position "icepos" of "serv):effect(effect(trash:corpice))})cardnil))}cardnil)))}
{:prompt"Choose an agenda to forfeit":choices(req(:scoredrunner)):effect(effect(forfeittarget)(gain:corp:bad-publicity1)):msg(msg"forfeit "(:titletarget)" and give the Corp 1 bad publicity")}
{:delayed-completiontrue:events{:runner-shuffle-decknil}:effect(req(let[topten(take10(:deckrunner))](prompt!state:runnercard(str"The top 10 cards of the Stack are "(join", "(map:titletopten)))["OK"]{})(continue-abilitystateside{:prompt"Install a program?":choices(conj(vec(sort-by:title(filter#(and(is-type?%"Program")(can-pay?statesidenil(modified-install-coststateside%[:credit-5])))topten)))"No install"):delayed-completiontrue:effect(req(if(not=target"No install")(do(register-eventsstateside{:runner-shuffle-deck{:effect(effect(update!(assoccard:shuffle-occurredtrue)))}}(assoccard:zone'(:discard)))(install-cost-bonusstateside[:credit-5])(let[to-trash(remove#(=(:cid%)(:cidtarget))topten)](when-completed(runner-installstatesidetargetnil)(let[card(get-cardstate(assoccard:zone'(:discard)))](if(not(:shuffle-occurredcard))(do(system-msgstateside(str"trashes "(join", "(map:titleto-trash))))(doseq[cto-trash](trashstatesidec{:unpreventabletrue}))(effect-completedstatesideeid))(do(system-msgstateside"does not have to trash cards because the stack was shuffled")(effect-completedstatesideeid)))))))(do(doseq[ctopten](trashstatesidec{:unpreventabletrue}))(system-msgstateside(str"trashes "(join", "(map:titletopten)))))))}cardnil)))}
{:choices{:max5:req#(and(is-type?%"Program")(in-hand?%))}:msg(msg"trash "(join", "(map:titletargets))" and gain "(*2(counttargets))" [Credits]"):effect(req(doseq[ctargets](trashstatesidec{:unpreventabletrue}))(gainstateside:credit(*2(counttargets))))}
{:implementation"Does not prevent rez if HQ is empty":events{:rez{:req(req(and(not(ice?target))(<0(count(:handcorp)))));; FIXME the above condition is just a bandaid, proper fix would be preventing the rez altogether
:msg"force the Corp to trash 1 card from HQ at random":effect(effect(trash(first(shuffle(:handcorp)))))}}}
{:prompt"Choose a server":choices(req(let[unrezzed-ice#(seq(filter(complementrezzed?)(:ices(second%))))bad-zones(keys(filter(complementunrezzed-ice)(get-in@state[:corp:servers])))](zones->sorted-names(remove(setbad-zones)(get-runnable-zones@state))))):effect(effect(runtarget{:end-run{:req(req(:successfulrun)):msg" gain 12 [Credits]":effect(effect(gain:runner:credit12))}}card))}
{:prompt"Choose a Connection":choices(req(cancellable(filter#(has-subtype?%"Connection")(:deckrunner)):sorted)):msg(msg"add "(:titletarget)" to their Grip and shuffle their Stack"):effect(req(let[connectiontarget](trigger-eventstateside:searched-stacknil)(resolve-abilitystateside{:prompt(str"Install "(:titleconnection)"?"):choices["Yes""No"]:effect(req(let[dtarget](resolve-abilitystateside{:effect(req(shuffle!stateside:deck)(if(="Yes"d)(runner-installstatesideconnection)(movestatesideconnection:hand)))}cardnil)))}cardnil)))}
{:effect(effect(run:archivesnilcard)(register-events(:events(card-defcard))(assoccard:zone'(:discard)))):events{:pre-access{:delayed-completiontrue:req(req(and(=target:archives);; don't prompt unless there's at least 1 rezzed ICE matching one in Archives
(not-empty(clojure.set/intersection(into#{}(map:title(filter#(ice?%)(:discardcorp))))(into#{}(map:title(filter#(rezzed?%)(all-installedstate:corp)))))))):effect(req(continue-abilitystateside{:delayed-completiontrue:prompt"Choose a piece of ICE in Archives":choices(req(filterice?(:discardcorp))):effect(req(let[icename(:titletarget)](continue-abilitystateside{:delayed-completiontrue:prompt(msg"Choose a rezzed copy of "icename" to trash"):choices{:req#(and(ice?%)(rezzed?%)(=(:title%)icename))}:msg(msg"trash "(card-strstatetarget)):effect(req(trashstate:corptarget)(unregister-eventsstatesidecard)(effect-completedstatesideeid))}cardnil)))}cardnil))}}}
{:delayed-completiontrue:effect(effect(run:rd{:replace-access{:msg"rearrange the top 5 cards of R&D":delayed-completiontrue:effect(req(show-wait-promptstate:corp"Runner to rearrange the top cards of R&D")(let[from(take5(:deckcorp))](if(pos?(countfrom))(continue-abilitystateside(reorder-choice:corp:corpfrom'()(countfrom)from)cardnil)(do(clear-wait-promptstate:corp)(effect-completedstatesideeidcard)))))}}card))}
{:prompt"Gain 2 [Credits] or expose a card?":choices["Gain 2 [Credits]""Expose a card"]:effect(effect(continue-ability(if(=target"Expose a card"){:choices{:reqinstalled?}:delayed-completiontrue:effect(effect(exposeeidtarget))}{:msg"gain 2 [Credits]":effect(effect(gain:credit2))})cardnil))}
(letfn[(access-pile[cardspile]{:prompt"Select a card to access. You must access all cards.":choices[(str"Card from pile "pile)]:effect(req(system-msgstateside(str"accesses "(:title(firstcards))))(when-completed(handle-accessstateside[(firstcards)])(do(if(<1(countcards))(continue-abilitystateside(access-pile(nextcards)pile)cardnil)(effect-completedstatesideeidcard)))))})(which-pile[p1p2]{:prompt"Choose a pile to access":choices[(str"Pile 1 ("(countp1)" cards)")(str"Pile 2 ("(countp2)" cards)")]:effect(req(let[choice(if(.startsWithtarget"Pile 1")12)](clear-wait-promptstate:corp)(continue-abilitystateside(access-pile(if(=1choice)p1p2)choice)cardnil)))})](let[access-effect{:delayed-completiontrue:mandatorytrue:effect(req(if(<1(count(:handcorp)))(do(show-wait-promptstate:runner"Corp to create two piles")(continue-abilitystate:corp{:prompt(msg"Select up to "(dec(count(:handcorp)))" cards for the first pile"):choices{:req#(and(in-hand?%)(card-is?%:side:corp)):max(req(dec(count(:handcorp))))}:effect(effect(clear-wait-prompt:runner)(show-wait-prompt:corp"Runner to choose a pile")(continue-ability:runner(which-pile(shuffletargets)(shuffle(vec(clojure.set/difference(set(:handcorp))(settargets)))))cardnil))}cardnil))(effect-completedstatesideeidcard)))}]{:effect(effect(run:hq{:req(req(=target:hq)):replace-accessaccess-effect}card))}))
{:effect(req(doseq[c(take4(get-in@state[:runner:deck]))](if(is-type?c"Program")(do(trashstatesidec)(gainstateside:credit1)(system-msgstateside(str"trashes "(:titlec)" and gains 1 [Credits]")))(do(movestatesidec:hand)(system-msgstateside(str"adds "(:titlec)" to Grip"))))))}
{:prompt"Choose a server":choices(reqrunnable-servers):delayed-completiontrue:effect(effect(runtargetnilcard)(continue-ability{:prompt"Choose an icebreaker":choices{:req#(and(installed?%)(has-subtype?%"Icebreaker"))}:effect(effect(pumptarget2:all-run))}cardnil))}
(let[ab(effect(register-turn-flag!card:can-rez(fn[statesidecard](if(and(=(:active-player@state):runner)(not(ice?card)))((constantlyfalse)(toaststate:corp"Cannot rez non-ICE on the Runner's turn due to Interdiction"))true))))]{:msg"prevent the Corp from rezzing non-ICE cards on the Runner's turn":effectab:events{:runner-turn-begins{:effectab}}:leave-play(req(clear-all-flags-for-card!statesidecard))})
{:msg"reduce the Corp's maximum hand size by 1 for each bad publicity":effect(req(losestate:corp:hand-size-modification(:bad-publicitycorp))(add-watchstate:itin(fn[krefoldnew](let[bpnew(get-innew[:corp:bad-publicity])bpold(get-inold[:corp:bad-publicity])](when(>bpnewbpold)(losestate:corp:hand-size-modification(-bpnewbpold)))(when(<bpnewbpold)(gainstate:corp:hand-size-modification(-bpoldbpnew))))))):leave-play(req(remove-watchstate:itin)(gainstate:corp:hand-size-modification(:bad-publicitycorp)))}
{:req(req(:stole-agendarunner-reg)):prompt"Choose a server":choices(reqservers):msg(msg"force the Corp to trash an ICE protecting "target):effect(req(let[serv(next(server->zonestatetarget))servnametarget](resolve-abilitystate:corp{:prompt(msg"Choose a piece of ICE in "target" to trash"):choices{:req#(and(=(last(:zone%)):ices)(=serv(rest(butlast(:zone%)))))}:effect(req(trashstate:corptarget)(system-msgstateside(str"trashes "(card-strstatetarget))))}cardnil)))}
{:req(req(some#{:hq}(:successful-runrunner-reg))):player:corp:prompt"Take 2 bad publicity?":choices["Yes""No"]:effect(req(if(=target"Yes")(do(gainstate:corp:bad-publicity2)(system-msgstate:corp"takes 2 bad publicity"))(do(register-eventsstateside{:pre-damage{:effect(effect(damage-prevent:netInteger/MAX_VALUE)(damage-prevent:meatInteger/MAX_VALUE)(damage-prevent:brainInteger/MAX_VALUE))}:runner-turn-begins{:effect(effect(unregister-eventscard))}}(assoccard:zone'(:discard)))(system-msgstate:runner"is immune to damage until the beginning of the Runner's next turn")))); This :events is a hack so that the unregister-events above will fire.
:events{:runner-turn-beginsnil:pre-damagenil}}
{:msg"shuffle their Grip and Heap into their Stack and draw 5 cards":effect(effect(shuffle-into-deck:hand:discard)(draw5)(move(first(:play-arearunner)):rfg))}
(letfn[(entrance-trash[cards]{:prompt"Choose a card to trash":choices(cons"None"cards):delayed-completiontrue:msg(req(when(not=target"None")(str"trash "(:titletarget)))):effect(req(if(=target"None")(if(not-emptycards)(continue-abilitystateside(reorder-choice:runner:corpcards'()(countcards)cards)cardnil)(do(clear-wait-promptstate:corp)(effect-completedstatesideeidcard)))(do(trashstatesidetarget{:unpreventabletrue})(continue-abilitystateside(entrance-trash(remove-once#(not=%target)cards))cardnil))))})]{:msg"look at and trash or rearrange the top 6 cards of their Stack":delayed-completiontrue:effect(req(show-wait-promptstate:corp"Runner to rearrange the top cards of their stack")(let[from(take6(:deckrunner))](continue-abilitystateside(entrance-trashfrom)cardnil)))})
(let[mhelper(fnmi[n]{:prompt"Select a program to install":choices{:req#(and(is-type?%"Program")(in-hand?%))}:effect(req(runner-installstatesidetarget)(when(<n3)(resolve-abilitystateside(mi(incn))cardnil)))})]{:effect(effect(resolve-ability(mhelper1)cardnil))})
{:prompt"Choose a program or piece of hardware to install from your Grip":choices{:req#(and(or(is-type?%"Hardware")(is-type?%"Program"))(in-hand?%))}:effect(effect(install-cost-bonus[:credit-3])(runner-installtarget))}
{:msg"remove 1 tag":effect(effect(lose:tag1)):optional{:prompt"Pay 1 [Credits] to add Networking to Grip?":yes-ability{:cost[:credit1]:msg"add it to their Grip":effect(effect(move(last(:discardrunner)):hand))}}}
{:req(req(and(some#{:hq}(:successful-runrunner-reg))(some#{:rd}(:successful-runrunner-reg))(some#{:archives}(:successful-runrunner-reg)))):effect(effect(as-agenda:runner(first(:play-arearunner))1)):msg"add it to their score area as an agenda worth 1 agenda point"}
{:req(req(some#(is-type?%"Resource")(all-installedstate:runner))):prompt"Choose a resource to host On the Lam":choices{:req#(and(is-type?%"Resource")(installed?%))}:effect(effect(hosttarget(assoccard:zone[:discard]))(system-msg(str"hosts On the Lam on "(:titletarget)))):prevent{:tag[:all]:damage[:meat:net:brain]}:abilities[{:label"[Trash]: Avoid 3 tags":msg"avoid up to 3 tags":effect(effect(tag-prevent3)(trashcard{:cause:ability-cost}))}{:label"[Trash]: Prevent up to 3 damage":msg"prevent up to 3 damage":effect(effect(damage-prevent:net3)(damage-prevent:meat3)(damage-prevent:brain3)(trashcard{:cause:ability-cost}))}]}
(letfn[(ashes-flag[]{:runner-phase-12{:priority-1:once:per-turn:once-key:out-of-ashes:effect(effect(continue-ability(ashes-recur(count(filter#(="Out of the Ashes"(:title%))(:discardrunner))))cardnil))}})(ashes-run[]{:prompt"Choose a server":choices(reqrunnable-servers):delayed-completiontrue:effect(effect(runeidtargetnilcard))})(ashes-recur[n]{:prompt"Remove Out of the Ashes from the game to make a run?":choices["Yes""No"]:effect(req(if(=target"Yes")(let[card(some#(when(="Out of the Ashes"(:title%))%)(:discardrunner))](system-msgstateside"removes Out of the Ashes from the game to make a run")(movestatesidecard:rfg)(unregister-eventsstatesidecard)(when-completed(resolve-abilitystateside(ashes-run)cardnil)(if(<1n)(continue-abilitystateside(ashes-recur(decn))cardnil)(effect-completedstatesideeidcard))))))})]{:prompt"Choose a server":choices(reqrunnable-servers):effect(effect(runeidtargetnilcard)):move-zone(req(if(=[:discard](:zonecard))(register-eventsstateside(ashes-flag)(assoccard:zone[:discard]))(unregister-eventsstatesidecard))):events{:runner-phase-12nil}})
{:msg(msg"play "(:titletarget)):choices(req(cancellable(filter#(and(has-subtype?%"Run")(<=(:cost%)(:creditrunner)))(:deckrunner)):sorted)):prompt"Choose a Run event":effect(effect(trigger-event:searched-stacknil)(shuffle!:deck)(play-instanttarget{:no-additional-costtrue}))}
(let[update-agendapoints(fn[statesidetargetamount](set-propstateside(get-cardstatetarget):agendapoints(+amount(:agendapoints(get-cardstatetarget))))(gain-agenda-pointstatesideamount))]{:events{:purge{:effect(effect(trashcard))}}:trash-effect{:effect(req(let[current-side(get-scoring-ownerstate{:cid(:agenda-cidcard)})](update-agendapointsstatecurrent-side(find-cid(:agenda-cidcard)(get-in@state[current-side:scored]))1)))}:effect(effect(run:archives{:req(req(=target:archives)):replace-access{:prompt"Choose an agenda to host Political Graffiti":choices{:req#(in-corp-scored?stateside%)}:msg(msg"host Political Graffiti on "(:titletarget)" as a hosted condition counter"):effect(req(hoststate:runner(get-cardstatetarget); keep host cid in :agenda-cid because `trash` will clear :host
(assoccard:zone[:discard]:installedtrue:agenda-cid(:cid(get-cardstatetarget))))(update-agendapointsstate:corptarget-1))}}card))})
{:req(req(seq(filter#(has-subtype?%"Seedy")(all-installedstate:runner)))):msg"give the Corp 1 fewer [Click] to spend on their next turn":effect(effect(lose:corp:click-per-turn1)(register-events(:events(card-defcard))(assoccard:zone'(:discard)))):events{:corp-turn-ends{:effect(effect(gain:corp:click-per-turn1)(unregister-eventscard))}}}
{:effect(effect(show-wait-prompt:runner"Corp to guess Odd or Even")(resolve-ability{:player:corp:prompt"Guess whether the Runner will spend an Odd or Even number of credits with Push Your Luck":choices["Even""Odd"]:msg"make the Corp choose a guess":effect(req(let[guesstarget](clear-wait-promptstate:runner)(resolve-abilitystate:runner{:choices:credit:prompt"How many credits?":msg(msg"spend "target" [Credits]. The Corp guessed "guess):effect(req(when(or(and(=guess"Even")(odd?target))(and(=guess"Odd")(even?target)))(system-msgstate:runner(str"gains "(*2target)" [Credits]"))(gainstate:runner:credit(*2target))))}cardnil)))}cardnil))}
{:choices["0","1","2","3"]:prompt"How many advancement tokens?":effect(req(let[c(Integer/parseInttarget)](resolve-abilitystateside{:choices{:req#(and(is-remote?(second(:zone%)))(=(last(:zone%)):content)(not(:rezzed%)))}:msg(msg"add "c" advancement tokens on a card and gain "(*2c)" [Credits]"):effect(effect(gain:credit(*2c))(add-prop:corptarget:advance-counterc{:placedtrue})(register-turn-flag!card:can-access;; prevent access of advanced card
(fn[__card](not(same-card?targetcard)))))}cardnil)))}
{:msg"change identities":prompt"Choose an identity to become":choices(req(let[is-swappable(fn[c](and(="Identity"(:typec))(=(->@state:runner:identity:faction)(:factionc))(not(.startsWith(:codec)"00")); only draft identities have this
(not(=(:titlec)(->@state:runner:identity:title)))))swappable-ids(filteris-swappable(vals@all-cards))](cancellableswappable-ids:sorted))):effect(req(movestateside(last(:discardrunner)):rfg)(disable-identitystateside);; Manually reduce the runner's link by old link
(losestate:runner:link(get-in@state[:runner:identity:baselink]));; Move the selected ID to [:runner :identity] and set the zone
(swap!stateupdate-in[side:identity](fn[x](assoc(server-card(:titletarget)(get-in@state[:runner:user])):zone[:identity])));; enable-identity does not do everything that init-identity does
(init-identitystateside(get-in@state[:runner:identity]))(system-msgstateside"NOTE: passive abilities (Kate, Gabe, etc) will incorrectly fire
if their once per turn condition was met this turn before Rebirth was played.
Please adjust your game state manually for the rest of this turn if necessary"))}
{:effect(effect(run:archives{:req(req(=target:archives)):replace-access{:prompt"Choose a program to install":msg(msg"install "(:titletarget)):choices(req(filter#(is-type?%"Program")(:discardrunner))):effect(effect(runner-installtarget{:no-costtrue}))}}card))}
(letfn[(choose-ice[]{:prompt"Choose a piece of ICE to bypass":choices{:req#(ice?%)}:effect(final-effect(system-msg:runner(str"chooses to bypass "(card-strstatetarget)))(run(second(:zonetarget))))})(corp-choice[spent]{:prompt"Guess how many credits were spent":choices["0""1""2"]:delayed-completiontrue:effect(req(system-msgstate:runner(str"spends "spent"[Credit]. "(->corp:user:username)" guesses "target"[Credit]"))(clear-wait-promptstate:runner)(if(not=(strspent)target)(continue-abilitystate:runner(choose-ice)cardnil)(effect-completedstatesideeid)))})(runner-choice[cr]{:prompt"Spend how many credits?":choices(takecr["0""1""2"]):delayed-completiontrue:effect(effect(show-wait-prompt:runner"Corp to guess")(clear-wait-prompt:corp)(continue-ability:corp(corp-choice(Integer/parseInttarget))cardnil))})]{:effect(effect(show-wait-prompt:corp"Runner to spend credits")(continue-ability(runner-choice(inc(min2(:creditrunner))))cardnil))})
{:implementation"Ice trash is manual":prompt"Choose a server":choices(reqrunnable-servers):effect(effect(runtarget{:end-run{:msg" trash 1 piece of ICE that was rezzed during the run"}}card))}
{:prompt"Choose a server":choices(reqrunnable-servers):effect(effect(runtargetnilcard)(register-events{:pre-rez{:req(req(ice?target)):effect(effect(rez-cost-bonus(:costtarget)))}:run-ends{:effect(effect(unregister-eventscard))}}(assoccard:zone'(:discard)))):events{:pre-reznil:run-endsnil}}
{:req(req(and(some#(is-type?%"Program")(all-installedstate:runner))(some#(is-type?%"Program")(concat(:handrunner)(:discardrunner))))):prompt"Choose an installed program to trash":choices{:req#(and(is-type?%"Program")(installed?%))}:effect(req(let[trashedtargettcost(-(:costtrashed))ststatesiside](trashstatesidetrashed)(resolve-abilitystateside{:prompt"Choose a program to install from your Grip or Heap":show-discardtrue:choices{:req#(and(is-type?%"Program")(#{[:hand][:discard]}(:zone%))(can-pay?stsinil(modified-install-coststsi%[:credittcost])))}:effect(effect(install-cost-bonus[:credit(-(:costtrashed))])(runner-installtarget)):msg(msg"trash "(:titletrashed)" and install "(:titletarget))}cardnil)))}
{:effect(effect(run:rd{:replace-access{:msg"access cards from the bottom of R&D":delayed-completiontrue:effect(req(when-completed(resolve-abilitystateside{:effect(effect(register-events(:events(card-defcard))(assoccard:zone'(:discard))))}cardnil)(do-accessstatesideeid(:serverrun))))}}card)):events{:pre-access{:silent(reqtrue):effect(req(swap!stateassoc-in[:corp:deck](rseq(into[](get-in@state[:corp:deck])))))}:run-ends{:effect(req(swap!stateassoc-in[:corp:deck](rseq(into[](get-in@state[:corp:deck]))))(unregister-eventsstatesidecard))}}}
{:prompt"Choose a server":choices(req(filter#(can-run-server?state%)remotes)):effect(effect(runtarget{:req(req(is-remote?target)):replace-access{:msg"trash all cards in the server at no cost":mandatorytrue:effect(req(let[allcorp(get-in(:serverscorp)(conj(:serverrun):content))](doseq[callcorp](trashstatesidec))))}}card))}
{:prompt"Choose an unrezzed piece of ICE":choices{:req#(and(=(last(:zone%)):ices)(not(rezzed?%))(ice?%))}:effect(req(let[icetargetserv(zone->name(second(:zoneice)))](resolve-abilitystate:runner{:msg(msg"choose the ICE at position "(ice-indexstateice)" of "serv):effect(effect(register-events{:pre-rez-cost{:req(req(=targetice)):effect(req(let[cost(rez-coststateside(get-cardstatetarget))](gainstate:runner:creditcost))):msg(msg"gain "(rez-coststateside(get-cardstatetarget))" [Credits]")}}(assoccard:zone'(:discard))))}cardnil))):events{:pre-rez-costnil}:end-turn{:effect(effect(unregister-eventscard))}}
{:prompt"Choose an Icebreaker":effect(effect(trigger-event:searched-stacknil)(shuffle!:deck)(system-msg(str"adds "(:titletarget)" to their Grip and shuffles their Stack"))(movetarget:hand)):choices(req(cancellable(filter#(has-subtype?%"Icebreaker")(:deckrunner)):sorted))}
{:prompt"Choose a server":choices(reqrunnable-servers):effect(effect(gain-run-credits9)(runtarget{:end-run{:msg" take 1 brain damage":effect(effect(damageeid:brain1{:unpreventabletrue:cardcard}))}}card))}
{:prompt"Install a program from your Stack or Heap?":choices(cancellable["Stack""Heap"]):msg(msg"install a program from their "target):effect(effect(resolve-ability{:prompt"Choose a program to install":choices(req(cancellable(filter#(is-type?%"Program")((if(=target"Heap"):discard:deck)runner)))):effect(effect(trigger-event:searched-stacknil)(shuffle!:deck)(runner-install(assoc-intarget[:special:test-run]true){:no-costtrue})):end-turn{:req(req(get-in(find-cid(:cidtarget)(all-installedstate:runner))[:special:test-run])):msg(msg"move "(:titletarget)" to the top of their Stack"):effect(req(movestateside(find-cid(:cidtarget)(all-installedstate:runner)):deck{:fronttrue}))}}cardtargets))}
{:effect(req(doseq[c(:handrunner)](trashstatesidec))(register-eventsstateside{:pre-damage{:effect(effect(damage-prevent:netInteger/MAX_VALUE)(damage-prevent:meatInteger/MAX_VALUE)(damage-prevent:brainInteger/MAX_VALUE))}:run-ends{:effect(effect(unregister-eventscard))}}(assoccard:zone'(:discard)))(resolve-abilitystateside{:prompt"Choose a server":choices(reqrunnable-servers):msg(msg"trash their Grip and make a run on "target", preventing all damage"):effect(req(let[runtgt[(last(server->zonestatetarget))]ices(get-in@state(concat[:corp:servers]runtgt[:ices]))](swap!stateassoc:per-runnil:run{:serverruntgt:position(countices):access-bonus0:run-effectnil})(gain-run-creditsstate:runner(:bad-publicitycorp))(swap!stateupdate-in[:runner:register:made-run]#(conj%(firstruntgt)))(trigger-eventstate:runner:runruntgt)))}cardnil)):events{:pre-damagenil:run-endsnil}}
{:req(req(some#(has-subtype?%"Connection")(all-installedstate:runner))):prompt"Choose an installed connection to trash":choices{:req#(and(has-subtype?%"Connection")(installed?%))}:msg(msg"trash "(:titletarget)" to prevent the corp from advancing cards during their next turn"):effect(effect(move(find-cid(:cidcard)(:discardrunner)):rfg)(trashtarget)(register-events(:events(card-defcard))(assoccard:zone'(:rfg)))(register-persistent-flag!card:can-advance(fn[statesidecard]((constantlyfalse)(toaststate:corp"Cannot advance cards this turn due to The Price of Freedom.""warning"))))):events{:corp-turn-ends{:effect(effect(clear-persistent-flag!card:can-advance)(unregister-eventscard))}}}
{:prompt"Choose a piece of ICE":choices{:req#(and(=(last(:zone%)):ices)(ice?%))}:effect(req(let[icetargetserv(zone->name(second(:zoneice)))stypes(:subtypeice)](resolve-abilitystate:runner{:msg(msg"make "(card-strstateice)" gain sentry, code gate, and barrier until the end of the turn"):effect(effect(update!(associce:subtype(combine-subtypestrue(:subtypeice)"Sentry""Code Gate""Barrier")))(update-ice-strength(get-cardstateice))(register-events{:runner-turn-ends{:effect(effect(update!(assoc(get-cardstateice):subtypestypes)))}}(assoccard:zone'(:discard))))}cardnil))):events{:runner-turn-endsnil}}
{:prompt"Choose a hardware to trash":choices{:req#(and(installed?%)(is-type?%"Hardware"))}:msg(msg"trash "(:titletarget)" and gain "(quot(:costtarget)2)" [Credits]"):effect(effect(trashtarget)(gain[:credit(quot(:costtarget)2)])(resolve-ability{:prompt"Choose a Hardware to add to your Grip from your Stack":choices(req(filter#(is-type?%"Hardware")(:deckrunner))):msg(msg"add "(:titletarget)" to their Grip"):effect(effect(trigger-event:searched-stacknil)(shuffle!:deck)(movetarget:hand))}cardnil))}
{:choices{:req#(and(installed?%)(not(facedown?%))(#{"Program""Hardware"}(:type%)))}:msg(msg"move "(:titletarget)" to their Grip"):effect(effect(movetarget:hand))}
{:effect(effect(run:hq{:req(req(=target:hq)):replace-access{:delayed-completiontrue:prompt"How many [Credits]?":choices:credit:msg(msg"take 1 tag and make the Corp lose "target" [Credits]"):effect(effect(lose:corp:credittarget)(tag-runnereid1))}}card))}
{:effect(effect(run:hq{:req(req(=target:hq)):replace-access{:msg(msg"force the Corp to discard "target" cards from HQ at random"):prompt"How many [Click] do you want to spend?":choices(req(mapstr(range1(inc(:clickrunner))))):effect(req(let[n(Integer/parseInttarget)](when(paystate:runnercard:clickn)(trash-cardsstate:corp(taken(shuffle(:handcorp)))))))}}card))}
{:effect(effect(shuffle!:deck)(resolve-ability{:effect(req(let[topcard(first(:deckrunner))cost(:costtopcard)](trashstatesidetopcard)(when-not(is-type?topcard"Event")(gainstateside:creditcost))(system-msgstateside(str"shuffles their Stack and trashes "(:titletopcard)(when-not(is-type?topcard"Event")(str" to gain "cost" [Credits]"))))))}cardnil))}