{:events{:pre-start-game{:req(req(=side:runner)):delayed-completiontrue:effect(req(show-wait-promptstate:corp"Runner to choose starting directives")(let[is-directive?#(has-subtype?%"Directive")directives(filteris-directive?(vals@all-cards))directives(mapmake-carddirectives)directives(zone:play-areadirectives)];; Add directives to :play-area - assumed to be empty
(swap!stateassoc-in[:runner:play-area]directives)(continue-abilitystateside{:prompt(str"Choose 3 starting directives"):choices{:max3:req#(and(=(:side%)"Runner")(=(:zone%)[:play-area]))}:effect(req(doseq[ctargets](runner-installstatesidec{:no-costtrue:custom-message(str"starts with "(:titlec)" in play")}))(swap!stateassoc-in[:runner:play-area][])(clear-wait-promptstate:corp))}cardnil)))}}}
(let[ability{:prompt"Select a card to install facedown":label"Install a card facedown (start of turn)":once:per-turn:choices{:max1:req#(and(=(:side%)"Runner")(in-hand?%))}:req(req(>(count(:handrunner))0)):effect(effect(runner-installtarget{:facedowntrue}))}]{:events{:runner-turn-beginsability}:abilities[ability]})
{:events{:agenda-stolen{:prompt"Take 1 tag or suffer 2 meat damage?":delayed-completiontrue:choices["1 tag""2 meat damage"]:player:runner:msg"make the Runner take 1 tag or suffer 2 meat damage":effect(req(if(=target"1 tag")(do(system-msgstateside"chooses to take 1 tag")(tag-runnerstate:runnereid1))(do(system-msgstateside"chooses to suffer 2 meat damage")(damagestate:runnereid:meat2{:unboostabletrue:cardcard}))))}}}
{:flags{:corp-phase-12(req(and(not(:disabledcard))(some#(rezzed?%)(all-installedstate:corp))))}:abilities[{:choices{:req#(:rezzed%)}:effect(req(trigger-eventstateside:pre-rez-costtarget)(let[cost(rez-coststatesidetarget)](gainstateside:creditcost)(movestatesidetarget:hand)(system-msgstateside(str"adds "(:titletarget)" to HQ and gains "cost" [Credits]"))(swap!stateupdate-in[:bonus]dissoc:cost)))}]}
{:events{:corp-phase-12{:effect(effect(enable-corp-damage-choice))}:runner-phase-12{:effect(effect(enable-corp-damage-choice))}:pre-resolve-damage{:delayed-completiontrue:req(req(and(=target:net)(corp-can-choose-damage?state)(>(lasttargets)0)(empty?(filter#(=:net(first%))(turn-eventsstate:runner:damage))))):effect(req(damage-deferstateside:net(lasttargets))(if(=0(count(:handrunner)))(do(swap!stateupdate-in[:damage]dissoc:damage-choose-corp)(damagestatesideeid:net(get-defer-damagestateside:netnil){:unpreventabletrue:cardcard}))(do(show-wait-promptstate:runner"Corp to use Chronos Protocol: Selective Mind-mapping")(continue-abilitystateside{:optional{:prompt(str"Use Chronos Protocol: Selective Mind-mapping to reveal the Runner's ""Grip to select the first card trashed?"):priority10:player:corp:yes-ability{:prompt(msg"Choose a card to trash"):choices(req(:handrunner)):not-distincttrue:priority10:msg(msg"trash "(:titletarget)(when(pos?(dec(or(get-defer-damagestateside:netnil)0)))(str" and deal "(-(get-defer-damagestateside:netnil)1)" more net damage"))):effect(req(clear-wait-promptstate:runner)(swap!stateupdate-in[:damage]dissoc:damage-choose-corp)(trashstatesidetarget{:cause:net:unpreventabletrue})(let[more(dec(or(get-defer-damagestateside:netnil)0))](damage-deferstateside:netmore)))}:no-ability{:effect(req(clear-wait-promptstate:runner)(swap!stateupdate-in[:damage]dissoc:damage-choose-corp))}}}cardnil))))}}:req(req(empty?(filter#(=:net(first%))(turn-eventsstate:runner:damage)))):effect(effect(enable-corp-damage-choice)):leave-play(req(swap!stateupdate-in[:damage]dissoc:damage-choose-corp))}
{:events{:pre-start-game{:effectdraft-points-target}:runner-turn-begins{:req(req(and(not(:disabledcard))(has-most-faction?state:corp"Weyland Consortium")(someice?(all-installedstateside)))):msg(msg"place 1 advancement token on "(card-strstatetarget)):prompt"Choose a piece of ICE to place 1 advancement token on":player:corp:choices{:req#(and(installed?%)(ice?%))}:effect(req(add-propstate:corptarget:advance-counter1{:placedtrue}))}}}
{:flags{:slow-remote-access(req(not(:disabledcard)))}:events{:pre-access-card{:req(req(is-remote?(second(:zonetarget)))):effect(effect(access-cost-bonus[:credit1])):msg"make the Runner spend 1 [Credits] to access"}}}
(let[haarp(fn[statesidecard](if(is-type?card"Agenda")((constantlyfalse)(toaststate:runner"Cannot steal due to Haarpsichord Studios.""warning"))true))]{:events{:agenda-stolen{:effect(effect(register-turn-flag!card:can-stealhaarp))}}:effect(req(when-not(first-event?stateside:agenda-stolen)(register-turn-flag!statesidecard:can-stealhaarp))):leave-play(effect(clear-turn-flag!card:can-steal))})
{:events{:pass-ice{:delayed-completiontrue:req(req(and(rezzed?target)(has-subtype?target"Bioroid")(first-event?state:corp:pass-ice))):effect(effect(show-wait-prompt:runner"Corp to use Haas-Bioroid: Architects of Tomorrow")(continue-ability{:prompt"Choose a bioroid to rez":player:corp:choices{:req#(and(has-subtype?%"Bioroid")(not(rezzed?%)))}:msg(msg"rez "(:titletarget)):cancel-effect(final-effect(clear-wait-prompt:runner)):effect(effect(rez-cost-bonus-4)(reztarget)(clear-wait-prompt:runner))}cardnil))}}}
{:effect(req(whentagged(reveal-handstate:runner))(add-watchstate:harishchandra(fn[krefoldnew](when(and(is-tagged?new)(not(is-tagged?old)))(system-msgrefside(str"uses Harishchandra Ent.: Where You're the Star to"" make the Runner play with their Grip revealed"))(reveal-handstate:runner))(when(and(is-tagged?old)(not(is-tagged?new)))(conceal-handstate:runner))))):leave-play(req(whentagged(conceal-handstate:runner))(remove-watchstate:harishchandra))}
{:events{:runner-install{:silent(req(not(and(first-event?stateside:runner-install)(some#(is-type?%(:typetarget))(:handrunner))))):req(req(and(first-event?stateside:runner-install)(some#(is-type?%(:typetarget))(:handrunner)))):once:per-turn:delayed-completiontrue:effect(req(let[itargettargettype(:typeitarget)](continue-abilitystateside{:optional{:prompt(msg"Install another "type" from your Grip?"):yes-ability{:prompt(msg"Choose another "type" to install from your grip"):choices{:req#(and(is-type?%type)(in-hand?%))}:msg(msg"install "(:titletarget)):effect(effect(runner-installeidtargetnil))}}}cardnil)))}}}
{:events(let[inf{:req(req(and(not(:disabledcard))(has-most-faction?state:corp"NBN"))):msg"give the Runner 1 tag":delayed-completiontrue:effect(effect(tag-runner:runnereid1))}]{:pre-start-game{:effectdraft-points-target}:agenda-scoredinf:agenda-stoleninf})}
{:events{:agenda-scored{:interactive(reqtrue):delayed-completiontrue:msg"do 1 net damage":effect(effect(damageeid:net1{:cardcard}))}:agenda-stolen{:msg"do 1 net damage":effect(effect(damageeid:net1{:cardcard}))}}}
{:events{:pre-resolve-damage{:req(req(and(=target:net)(pos?(lasttargets)))):effect(req(let[c(first(get-in@state[:runner:deck]))](system-msgstate:corp(str"uses Jinteki: Potential Unleashed to trash "(:titlec)" from the top of the Runner's Stack"))(millstate:runner)))}}}
{:events{:pre-first-turn{:req(req(=side:corp)):prompt"Choose a copy of Jinteki Biotech to use this game":choices["[The Brewery~brewery]""[The Tank~tank]""[The Greenhouse~greenhouse]"]:effect(effect(update!(assoccard:biotech-targettarget))(system-msg(str"has chosen a copy of Jinteki Biotech for this game ")))}}:abilities[{:label"Check chosen flip identity":effect(req(case(:biotech-targetcard)"[The Brewery~brewery]"(toaststate:corp"Flip to: The Brewery (Do 2 net damage)""info")"[The Tank~tank]"(toaststate:corp"Flip to: The Tank (Shuffle Archives into R&D)""info")"[The Greenhouse~greenhouse]"(toaststate:corp"Flip to: The Greenhouse (Place 4 advancement tokens on a card)""info")))}{:cost[:click3]:req(req(not(:biotech-usedcard))):label"Flip this identity":effect(req(let[flip(:biotech-targetcard)](caseflip"[The Brewery~brewery]"(do(system-msgstateside"uses [The Brewery~brewery] to do 2 net damage")(damagestatesideeid:net2{:cardcard})(update!stateside(assoccard:code"brewery")))"[The Tank~tank]"(do(system-msgstateside"uses [The Tank~tank] to shuffle Archives into R&D")(shuffle-into-deckstateside:discard)(update!stateside(assoccard:code"tank")))"[The Greenhouse~greenhouse]"(do(system-msgstateside(str"uses [The Greenhouse~greenhouse] to place 4 advancement tokens ""on a card that can be advanced"))(update!stateside(assoccard:code"greenhouse"))(resolve-abilitystateside{:prompt"Choose a card that can be advanced":choices{:reqcan-be-advanced?}:effect(effect(add-proptarget:advance-counter4{:placedtrue}))}cardnil)))(update!stateside(assoc(get-cardstatecard):biotech-usedtrue))))}]}
{:events{:pre-install{:req(req(and(#{"Hardware""Program"}(:typetarget))(not(get-in@state[:per-turn(:cidcard)])))):effect(effect(install-cost-bonus[:credit-1]))}:runner-install{:req(req(and(#{"Hardware""Program"}(:typetarget))(not(get-in@state[:per-turn(:cidcard)])))):silent(reqtrue):msg(msg"reduce the install cost of "(:titletarget)" by 1 [Credits]"):effect(req(swap!stateassoc-in[:per-turn(:cidcard)]true))}}}
{:events{:play-event{:req(req(and(has-subtype?target"Run")(empty?(filter#(has-subtype?%"Run");; have to flatten because each element is a list containing
;; the Event card that was played
(flatten(turn-eventsstate:runner:play-event)))))):msg"gain 1 [Credits]":effect(effect(gain:credit1))}}}
{:events{:pass-ice{:req(req(first-event?state:corp:pass-ice)):delayed-completiontrue:effect(req(if(some#(has-subtype?%"Icebreaker")(:handrunner))(continue-abilitystateside{:prompt"Choose an icebreaker to install from your Grip":delayed-completiontrue:choices{:req#(and(in-hand?%)(has-subtype?%"Icebreaker"))}:msg(msg"install "(:titletarget)):effect(effect(install-cost-bonus[:credit-1])(runner-installeidtargetnil))}cardnil)(effect-completedstatesideeid)))}}}
{:events{:successful-run{:delayed-completiontrue:interactive(reqtrue):req(req(and(is-central?(:serverrun))(empty?(let[successes(turn-eventsstateside:successful-run)](filter#(is-central?%)successes))))):effect(effect(continue-ability{:optional{:prompt"Force the Corp to draw a card?":yes-ability{:msg"force the Corp to draw 1 card":effect(effect(draw:corp))}:no-ability{:effect(effect(system-msg"declines to use Laramy Fisk: Savvy Investor"))}}}cardnil))}}}
(let[leela{:interactive(reqtrue):prompt"Select an unrezzed card to return to HQ":choices{:req#(and(not(rezzed?%))(installed?%)(card-is?%:side:corp))}:msg(msg"add "(card-strstatetarget)" to HQ"):effect(final-effect(move:corptarget:hand))}]{:flags{:slow-hq-access(reqtrue)}:events{:agenda-scoredleela:agenda-stolenleela}})
(let[ability{:msg(msg(let[deck(:deckrunner)](if(pos?(countdeck))(str"trash "(join", "(map:title(take2deck)))" from their Stack and draw 1 card")"trash the top 2 cards from their Stack and draw 1 card - but their Stack is empty"))):once:per-turn:effect(effect(mill2)(draw))}]{:flags{:runner-turn-drawtrue:runner-phase-12(req(and(not(:disabledcard))(some#(card-flag?%:runner-turn-drawtrue)(all-installedstate:runner))))}:events{:runner-turn-beginsability}:abilities[ability]})
{:events{:rez{:req(req(and(:run@state);; check that the rezzed item is the encountered ice
(=(:cidtarget)(:cid(get-cardstatecurrent-ice))))):effect(req(toaststate:runner"Click Nasir Meidan: Cyber Explorer to lose all credits and gain credits equal to the rez cost of the newly rezzed ice.""info"))}}:abilities[{:req(req(and(:run@state)(:rezzed(get-cardstatecurrent-ice)))):effect(req(let[current-ice(get-cardstatecurrent-ice)](trigger-eventstateside:pre-rez-costcurrent-ice)(let[cost(rez-coststatesidecurrent-ice)](losestateside:credit(:creditrunner))(gainstateside:creditcost)(system-msgstateside(str"loses all credits and gains "cost" [Credits] from the rez of "(:titlecurrent-ice)))(swap!stateupdate-in[:bonus]dissoc:cost))))}]}
{:events{:runner-trash{:delayed-completiontrue:req(req(and(let[trashes(flatten(turn-eventsstateside:runner-trash))](empty?(filter#(card-is?%:side:corp)trashes)))(card-is?target:side:corp)(installed?target))):effect(req(show-wait-promptstate:runner"Corp to use NBN: Controlling the Message")(continue-abilitystate:corp{:optional{:prompt"Trace the Runner with NBN: Controlling the Message?":yes-ability{:trace{:base4:msg"give the Runner 1 tag":delayed-completiontrue:effect(effect(tag-runner:runnereid1{:unpreventabletrue})(clear-wait-prompt:runner)):unsuccessful{:effect(effect(clear-wait-prompt:runner))}}}:no-ability{:effect(effect(clear-wait-prompt:runner))}}}cardnil))}}}
(let[nasol{:optional{:prompt"Play a Current?":player:corp:req(req(not(empty?(filter#(has-subtype?%"Current")(concat(:handcorp)(:discardcorp)))))):yes-ability{:prompt"Choose a Current to play from HQ or Archives":show-discardtrue:delayed-completiontrue:choices{:req#(and(has-subtype?%"Current")(=(:side%)"Corp")(#{[:hand][:discard]}(:zone%)))}:msg(msg"play a current from "(name-zone"Corp"(:zonetarget))):effect(effect(play-instanteidtarget))}}}]{:events{:agenda-scorednasol:agenda-stolennasol}})
(let[ndhelper(fnnd[n]{:prompt(msg"When finished, click NEXT Design: Guarding the Net to draw back up to 5 cards in HQ. ""Choose a piece of ICE in HQ to install:"):choices{:req#(and(=(:side%)"Corp")(ice?%)(in-hand?%))}:effect(req(corp-installstatesidetargetnil)(when(<n3)(resolve-abilitystateside(nd(incn))cardnil)))})]{:events{:pre-first-turn{:req(req(=side:corp)):msg"install up to 3 pieces of ICE and draw back up to 5 cards":effect(effect(resolve-ability(ndhelper1)cardnil)(update!(assoccard:fill-hqtrue)))}}:abilities[{:req(req(:fill-hqcard)):msg(msg"draw "(-5(count(:handcorp)))" cards"):effect(effect(draw(-5(count(:handcorp))))(update!(dissoccard:fill-hq)))}]})
{:abilities[{:once:per-turn:req(req(and(:run@state)(rezzed?current-ice))):prompt"Choose a card in your Grip to trash":choices{:reqin-hand?}:msg(msg"trash "(:titletarget)" and reduce the strength of "(:titlecurrent-ice)" by 2 for the remainder of the run"):effect(effect(update!(assoccard:null-targetcurrent-ice))(update-ice-strengthcurrent-ice)(trashtarget{:unpreventabletrue}))}]:events{:pre-ice-strength{:req(req(=(:cidtarget)(get-incard[:null-target:cid]))):effect(effect(ice-strength-bonus-2target))}:run-ends{:effect(req(swap!statedissoc-in[:runner:identity:null-target]))}}}
{:abilities[{:cost[:click1]:msg"make a run on Archives":once:per-turn:makes-runtrue:effect(effect(update!(assoccard:omar-run-activatedtrue))(run:archivesnil(get-cardstatecard)))}]:events{:pre-successful-run{:interactive(reqtrue):req(req(:omar-run-activatedcard)):prompt"Treat as a successful run on which server?":choices["HQ""R&D"]:effect(req(let[target-server(if(=target"HQ"):hq:rd)](swap!stateupdate-in[:runner:register:successful-run]#(rest%))(swap!stateassoc-in[:run:server][target-server]); remove the :req from the run-effect, so that other cards that replace
; access don't use Omar's req.
(swap!statedissoc-in[:run:run-effect:req])(trigger-eventstate:corp:no-action)(swap!stateupdate-in[:runner:register:successful-run]#(conj%target-server))(system-msgstateside(str"uses Omar Keung: Conspiracy Theorist to make a successful run on "target))))}:run-ends{:effect(req(swap!statedissoc-in[:runner:identity:omar-run-activated]))}}}
{:abilities[{:req(req(and(:run@state)(:rezzed(get-cardstatecurrent-ice)))):once:per-turn:msg(msg"make "(:titlecurrent-ice)" gain code gate until the end of the run"):effect(req(let[icecurrent-icestypes(:subtypeice)](update!stateside(associce:subtype(combine-subtypestruestypes"Code Gate")))(register-eventsstateside{:run-ends{:effect(effect(update!(associce:subtypestypes))(unregister-eventscard))}}card)(update-ice-strengthstatesideice)(trigger-eventstateside:ice-subtype-changed)))}]:events{:run-endsnil}}
{:events{:rez{:req(req(and(has-subtype?target"Advertisement")(empty?(filter#(has-subtype?%"Advertisement")(flatten(turn-eventsstate:corp:rez)))))):effect(effect(lose:runner:credit1)):msg(msg"make the Runner lose 1 [Credits] by rezzing an advertisement")}}}
{:events{:pre-start-game{:effectdraft-points-target}:runner-turn-ends{:req(req(and(not(:disabledcard))(has-most-faction?state:corp"Haas-Bioroid")(pos?(count(:discardcorp))))):prompt"Choose a card in Archives to shuffle into R&D":choices{:req#(and(card-is?%:side:corp)(=(:zone%)[:discard]))}:player:corp:show-discardtrue:prioritytrue:msg(msg"to shuffle "(if(:seentarget)(:titletarget)"a card")" into R&D"):effect(effect(move:corptarget:deck)(shuffle!:corp:deck))}}}
{:effect(req(when(>(:turn@state)1)(if(:sync-frontcard)(tag-remove-bonusstateside-1)(trash-resource-bonusstateside2)))):events{:pre-first-turn{:req(req(=side:corp)):effect(effect(update!(assoccard:sync-fronttrue))(tag-remove-bonus-1))}}:abilities[{:cost[:click1]:effect(req(if(:sync-frontcard)(do(tag-remove-bonusstateside1)(trash-resource-bonusstateside2)(update!stateside(->card(assoc:sync-frontfalse)(assoc:code"sync"))))(do(tag-remove-bonusstateside-1)(trash-resource-bonusstateside-2)(update!stateside(->card(assoc:sync-fronttrue)(assoc:code"09001")))))):msg(msg"flip their ID")}]:leave-play(req(if(:sync-frontcard)(tag-remove-bonusstateside1)(trash-resource-bonusstateside-2)))}
{:events{:pre-start-game{:effectdraft-points-target}}:flags{:corp-phase-12(req(and(not(:disabled(get-cardstatecard)))(has-most-faction?state:corp"Jinteki")(>(count(filterice?(all-installedstate:corp)))1)))}:abilities[{:prompt"Select two pieces of ICE to swap positions":choices{:req#(and(installed?%)(ice?%)):max2}:once:per-turn:effect(req(when(=(counttargets)2)(swap-icestateside(firsttargets)(secondtargets)))):msg(msg"swap the positions of "(card-strstate(firsttargets))" and "(card-strstate(secondtargets)))}]}
{:events{:rez{:req(req(and(ice?target);; Did you rez and ice just now
;; Are there more copies in the deck or play area (ABT interaction)?
;; (some #(= (:title %) (:title target)) (concat (:deck corp) (:play-area corp)))
;; Based on ruling re: searching and failing to find, we no longer enforce the requirement
;; of there being a target ice to bring into HQ.
(empty?(let[rezzed-this-turn(mapfirst(turn-eventsstateside:rez))](filterice?rezzed-this-turn)))));; Is this the first ice you've rezzed this turn
:optional{:prompt"Add another copy to HQ?":yes-ability{:effect(req(if-let[found-card(some#(when(=(:title%)(:titletarget))%)(concat(:deckcorp)(:play-areacorp)))](do(movestatesidefound-card:hand)(system-msgstateside(str"uses The Foundry to add a copy of "(:titlefound-card)" to HQ, and shuffles their deck"))(shuffle!stateside:deck))(do(system-msgstateside(str"fails to find a target for The Foundry, and shuffles their deck"))(shuffle!stateside:deck))))}}}}}
{:implementation"Damage triggered manually":abilities[{:label"Do 1 meat damage":once:per-turn:prompt"Do a meat damage from identity ability?":choices(cancellable["Yes"]):delayed-completiontrue:effect(req(when(=target"Yes")(damagestate:runnereid:meat1{:cardcard})(system-msgstateside"uses Weyland Consortium: Builder of Nations to do 1 meat damage")))}]}
{:events{:pre-start-game{:effectdraft-points-target}:runner-trash{:req(req(and(has-most-faction?state:runner"Anarch")(card-is?target:side:corp)(pos?(count(:discardrunner))))):msg(msg"shuffle "(:title(last(:discardrunner)))" into their Stack"):effect(effect(move:runner(last(:discardrunner)):deck)(shuffle!:runner:deck))}}}