Skip to content

Commit

Permalink
Merge pull request #6975 from NBKelly/automata-release
Browse files Browse the repository at this point in the history
Fixes for phoneutria, solidarity badge, seymour/audrey, federal fundraising
  • Loading branch information
NoahTheDuke authored Aug 4, 2023
2 parents e2ed145 + 7a83912 commit a9e38e7
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 37 deletions.
10 changes: 6 additions & 4 deletions src/clj/game/cards/assets.clj
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@
"returns a set of cards to the top of the deck"
([set-aside-cards] (return-to-top set-aside-cards false))
([set-aside-cards reveal]
{:prompt "choose a card to put ontop of R&D"
{:prompt "choose a card to put on top of R&D"
:req (req (not (zero? (count set-aside-cards))))
:choices {:min 1
:max 1
:req (req (some #(same-card? % target) set-aside-cards))}
:async true
:waiting-prompt "corp to return cards to R&D"
:msg (msg "place " (if reveal (:title target) "a card") " ontop of R&D")
:msg (msg "place " (if reveal (:title target) "a card") " on top of R&D")
:effect (req (move state :corp target :deck {:front true})
(let [rem (seq (filter #(not (same-card? target %)) set-aside-cards))]
(if (not (empty? rem))
Expand Down Expand Up @@ -991,20 +991,22 @@

(defcard "Federal Fundraising"
(let [draw-ab {:optional {:req (req unprotected)
:prompt "draw a cards?"
:prompt "draw a card?"
:yes-ability {:msg "draw a card"
:async true
:effect (effect (draw eid 1))}
:no-ability {:msg "decline to draw cards"}}}
:no-ability {:msg "decline to draw"}}}
ability
{:once :per-turn
:req (req (:corp-phase-12 @state))
:interactive (req true)
:label "look at the top 3 cards"
:async true
:optional
{:prompt "look at the top 3 cards?"
:no-ability
{:msg (msg "declines to look at the top 3 cards")
:async true
:effect (req (continue-ability state side draw-ab card nil))}
:yes-ability
{:msg (msg "rearrange the top 3 cards of R&D")
Expand Down
19 changes: 11 additions & 8 deletions src/clj/game/cards/events.clj
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@
:ability (sabotage-ability 4)})]})

(defcard "Chrysopoeian Skimming"
{:on-play {:prompt "reveal an agenda from HQ?"
{:on-play {:prompt "Reveal an agenda from HQ?"
:player :corp
:choices (req (conj (filter agenda? (:hand corp)) "No thanks"))
:async true
Expand All @@ -556,13 +556,16 @@
:prompt (msg "the top 3 cards of R&D are " (str/join ", " (map :title (take 3 (:deck corp)))))
:choices ["Noted"]}
card nil))
(continue-ability
state :runner
{:msg "gain [Click] and draw a card"
:async true
:effect (req (gain-clicks state :runner 1)
(draw state :runner eid 1))}
card nil)))}})
(do
(wait-for (reveal state side target)
(system-msg state :corp (str "reveals " (:title target) " from HQ"))
(continue-ability
state :runner
{:msg "gain [Click] and draw a card"
:async true
:effect (req (gain-clicks state :runner 1)
(draw state :runner eid 1))}
card nil)))))}})

(defcard "Code Siphon"
(letfn [(rd-ice [state]
Expand Down
9 changes: 6 additions & 3 deletions src/clj/game/cards/hardware.clj
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@
:req (req true)}]}
:events [(trash-on-empty :power)
{:event :encounter-ice
:req (req (and (not-used-once? state {:once :per-turn} card)
(contains? (card-def current-ice) :on-encounter)))
:req (req (contains? (card-def current-ice) :on-encounter))
:async true
:effect
(effect (continue-ability
Expand All @@ -134,6 +133,7 @@
:yes-ability ability}}
card nil))}]
:abilities [{:cost [:power 1]
:req (req run)
:msg "prevent 1 net damage"
:effect (effect (damage-prevent :net 1))}
(assoc ability
Expand Down Expand Up @@ -2073,7 +2073,10 @@
{:event :runner-trash
:async true
:interactive (req true)
:req (req (some #(corp? (:card %)) targets))
:req (req (and (some #(corp? (:card %)) targets)
(first-event? state side :runner-trash
(fn [targets]
(some #(corp? (:card %)) targets)))))
:once :per-turn
:msg "place 1 power counter on itself"
:effect (effect (add-counter :runner card :power 1)
Expand Down
38 changes: 24 additions & 14 deletions src/clj/game/cards/ice.clj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
[game.core.effects :refer [get-effects register-floating-effect unregister-constant-effects]]
[game.core.eid :refer [complete-with-result effect-completed make-eid]]
[game.core.engine :refer [gather-events pay register-events resolve-ability
trigger-event unregister-events]]
trigger-event trigger-event-simult unregister-events]]
[game.core.events :refer [run-events]]
[game.core.finding :refer [find-cid]]
[game.core.flags :refer [can-rez? card-flag? prevent-draw prevent-jack-out
Expand All @@ -38,7 +38,8 @@
[game.core.installing :refer [corp-install corp-install-list
corp-install-msg]]
[game.core.memory :refer [available-mu]]
[game.core.moving :refer [as-agenda mill move swap-cards swap-ice swap-installed trash
[game.core.moving :refer [as-agenda mill move swap-cards swap-cards-async
swap-ice swap-installed trash
trash-cards]]
[game.core.optional :refer [get-autoresolve set-autoresolve]]
[game.core.payment :refer [can-pay? cost->string build-cost-label]]
Expand Down Expand Up @@ -3155,8 +3156,8 @@
{:subroutines [(do-net-damage 1)
(do-net-damage 1)]
:events [{:event :pass-ice
:req (req (same-card? (:ice context) card)
(<= 4 (count (:hand runner))))
:req (req (and (same-card? (:ice context) card)
(<= 4 (count (:hand runner)))))
:msg "give the runner a tag"
:effect (effect (gain-tags eid 1))}]})

Expand Down Expand Up @@ -3673,16 +3674,25 @@
(defcard "Tatu-Bola"
{:events [{:event :pass-ice
:interactive (req run)
:optional
{:req (req (same-card? (:ice context) card))
:prompt (msg "Gain 4 [Credit] and swap " (:title card) " with an Ice in HQ?")
:yes-ability {:prompt "Choose a piece of ice to swap Tatu-Bola with"
:choices (req (filter ice? (:hand corp)))
:async true
:effect (effect (swap-cards current-ice target)
(gain-credits eid 4))
:msg (msg "swap " (card-str state card)
" with a card from HQ and gain 4 [Credits]")}}}]
:req (req (same-card? (:ice context) card))
:async true
:effect (req (continue-ability
state side
(if (< 0 (count (filter ice? (:hand corp))))
{:optional
{:prompt (msg "Gain 4 [Credit] and swap " (:title card) " with an Ice in HQ?")
:no-ability {:msg "decline to use it's ability"}
:yes-ability {:prompt "Choose a piece of ice to swap Tatu-Bola with"
:choices (req (filter ice? (:hand corp)))
:async true
:effect (req (wait-for (swap-cards-async state side (make-eid state eid) target current-ice)
(gain-credits state :corp eid 4)))
:msg (msg "swap " (card-str state card)
" with a card from HQ and gain 4 [Credits]")}}}
{:prompt "You have no ice"
:choices ["OK"]
:msg "decline to use it's ability"})
card nil))}]
:subroutines [end-the-run]})

(defcard "Taurus"
Expand Down
3 changes: 2 additions & 1 deletion src/clj/game/cards/identities.clj
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@
(continue-ability
state :corp
{:prompt (msg (str "The top cards are " (str (str/join ", " (map :title top))) ". Install a card?"))
:not-distinct true
:choices (req (conj
(filter #(not (operation? %)) top)
"No Thanks"))
Expand All @@ -595,7 +596,7 @@
;; don't look at this spaghetti please
(if (= target (first top)) "first"
(if (= target (second top)) "second" "third"))
"card from R&D")))
" card from R&D")))
:async true
:effect (req (if-not (= target "No Thanks")
(corp-install state side eid target nil)
Expand Down
7 changes: 4 additions & 3 deletions src/clj/game/cards/programs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
[game.core.sabotage :refer [sabotage-ability]]
[game.core.say :refer [system-msg]]
[game.core.sabotage :refer [sabotage-ability]]
[game.core.servers :refer [is-central? is-remote? target-server zone->name]]
[game.core.servers :refer [is-central? is-remote? protecting-same-server?
target-server zone->name]]
[game.core.shuffling :refer [shuffle!]]
[game.core.tags :refer [gain-tags lose-tags]]
[game.core.to-string :refer [card-str]]
Expand Down Expand Up @@ -519,7 +520,7 @@
:once-per-instance true
:req (req (:accessed target))
:effect (effect (add-counter :runner card :virus 1))
:msg "place 1 virus counter on Seymour"}]})
:msg "place 1 virus counter on itself"}]})

(defcard "Aumakua"
(auto-icebreaker {:implementation "Erratum: Whenever you finish breaching a server, if you did not steal or trash any accessed cards, place 1 virus counter on this program."
Expand Down Expand Up @@ -1871,7 +1872,7 @@
:effect (effect (pump card 3 :end-of-turn))}
:hosting {:card #(and (ice? %)
(can-host? %))}
:abilities [(break-sub 1 1 "Sentry" {:req (req (same-card? current-ice (:host card)))})
:abilities [(break-sub 1 1 "Sentry" {:req (req (protecting-same-server? current-ice (:host card)))})
(strength-pump 1 2)]}))

(defcard "LLDS Energy Regulator"
Expand Down
5 changes: 3 additions & 2 deletions src/clj/game/cards/resources.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,8 @@
(let [constant-ability
;; event breach req target run hq
{:event :breach-server
:req (req (and (= :rd target)
:req (req (and (threat-level 3 state)
(= :rd target)
(= :archives (first (:server run)))))
:msg (msg "access an additional card")
:effect (effect (access-bonus :rd 1))}]
Expand All @@ -1285,7 +1286,7 @@
{:target-server :archives
:this-card-run true
:mandatory true
:ability {:msg "breach R&D, accessing one additional card"
:ability {:msg "breach R&D"
:async true
:effect (req (breach-server state :runner eid [:rd] nil))}})]
:abilities [{:cost [:click 1]
Expand Down
1 change: 1 addition & 0 deletions src/clj/game/cards/upgrades.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,7 @@
:effect (effect (register-events
card
[(assoc ability
:event :agenda-stolen
:req (req (= (second (:previous-zone card)) (first (:server context))))
:duration :end-of-run)]))}}))

Expand Down
1 change: 1 addition & 0 deletions src/clj/game/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@
remove-from-currently-drawing
swap-agendas
swap-cards
swap-cards-async
swap-ice
swap-installed
trash
Expand Down
26 changes: 24 additions & 2 deletions src/clj/game/core/moving.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[game.core.card-defs :refer [card-def]]
[game.core.effects :refer [register-constant-effects unregister-constant-effects]]
[game.core.eid :refer [complete-with-result effect-completed make-eid make-result]]
[game.core.engine :as engine :refer [checkpoint dissoc-req register-pending-event queue-event register-default-events register-events should-trigger? trigger-event unregister-events]]
[game.core.engine :as engine :refer [checkpoint dissoc-req register-pending-event queue-event register-default-events register-events should-trigger? trigger-event trigger-event-sync unregister-events]]
[game.core.finding :refer [get-scoring-owner]]
[game.core.flags :refer [can-trash? card-flag? cards-can-prevent? get-prevent-list untrashable-while-resources? untrashable-while-rezzed? zone-locked?]]
[game.core.hosting :refer [remove-from-host]]
Expand Down Expand Up @@ -497,7 +497,11 @@
{:keep-server-alive true
:index (card-index state a)
:suppress-event true
:swap true})]
:swap true})
;; under the new nsg rules, swapping a card into play triggers an install event
;; TODO - quote exactly where
install-event (or (and (installed? a) (not (installed? b)))
(and (installed? b) (not (installed? a))))]
(trigger-event state side :swap moved-a moved-b)
(when (and (:run @state)
(or (ice? a)
Expand All @@ -510,6 +514,24 @@
(when (in-hand? moved-b) (add-to-currently-drawing state b-side moved-b)))
[(get-card state moved-a) (get-card state moved-b)])))

(defn swap-cards-async
"Swaps two cards when one or both aren't installed"
[state side eid a b]
(let [async-result (swap-cards state side a b)
moved-a (first async-result)
moved-b (second async-result)
install-event (= 1 (count (filter installed? [moved-a moved-b])))]
;; todo - we might need behaviour for runner swap installs down the line, depending on future cards
;; that's a problem for another day
(if (and install-event (= :corp side))
(do (queue-event
state :corp-install
{:card (get-card state (if (installed? moved-a) moved-a moved-b))
:install-state (:install-state (card-def (if (installed? moved-a) moved-a moved-b)))})
(wait-for (checkpoint state nil (make-eid state eid))
(complete-with-result state side eid async-result)))
(complete-with-result state side eid async-result))))

(defn swap-agendas
"Swaps the two specified agendas, first one scored (on corp side), second one stolen (on runner side).
Returns the first agenda now in runner score area and second agenda now in corp score area."
Expand Down
14 changes: 14 additions & 0 deletions test/clj/game/cards/hardware_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4493,6 +4493,20 @@
(click-prompt state :runner "Remove 1 tag")
(is (zero? (count-tags state)))))

(deftest solidarity-badge-first-trash-only
(do-game
(new-game {:corp {:hand ["Rashida Jaheem" "Rashida Jaheem"]}
:runner {:hand ["Solidarity Badge"]}})
(take-credits state :corp)
(run-empty-server state "HQ")
(click-prompt state :runner "Pay 1 [Credits] to trash")
(play-from-hand state :runner "Solidarity Badge")
(run-empty-server state "HQ")
(changes-val-macro
0 (get-counters (get-hardware state 0) :power)
"added a counter to solidarity badge"
(click-prompt state :runner "Pay 1 [Credits] to trash"))))

(deftest spinal-modem-pay-credits-prompt
;; Pay-credits prompt
(do-game
Expand Down
38 changes: 38 additions & 0 deletions test/clj/game/cards/ice_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5356,6 +5356,44 @@
(is (= 3 (get-counters (refresh pha) :advancement)) "Pharos has 3 adv tokens")
(is (= 10 (get-strength (refresh pha))) "Pharos is now at 10 strength"))))

(deftest phonuetria-tag-only-when-passing-itself
(do-game
(new-game {:corp {:hand ["Hedge Fund" "Phoneutria" "Vanilla"]}
:runner {:hand [(qty "Sure Gamble" 5)]}})
(play-from-hand state :corp "Hedge Fund")
(play-from-hand state :corp "Phoneutria" "HQ")
(play-from-hand state :corp "Vanilla" "HQ")
(take-credits state :corp)
(run-on state :hq)
(rez state :corp (get-ice state :hq 1))
(rez state :corp (get-ice state :hq 0))
(changes-val-macro
0 (count-tags state)
"gained no tag for passing vanilla"
(run-continue state :encounter-ice)
(run-continue state :pass-ice)
(run-continue state :approach-ice))
(run-continue state :encounter-ice)
(changes-val-macro
1 (count-tags state)
"gained 1 tag for phoneutria"
(run-continue state :pass-ice))))

(deftest phonuetria-no-tag
(do-game
(new-game {:corp {:hand ["Hedge Fund" "Phoneutria"]}
:runner {:hand [(qty "Sure Gamble" 3)]}})
(play-from-hand state :corp "Hedge Fund")
(play-from-hand state :corp "Phoneutria" "HQ")
(take-credits state :corp)
(run-on state :hq)
(rez state :corp (get-ice state :hq 0))
(changes-val-macro
0 (count-tags state)
"gained no tag for passing phoneutria"
(run-continue state :encounter-ice)
(run-continue state :pass-ice))))

(deftest ping
;; Ping
(do-game
Expand Down
16 changes: 16 additions & 0 deletions test/clj/game/cards/identities_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,22 @@
(is (= 2 (count (prompt-buttons :corp))) "Corp should have prompt back with 2 options")
(is (prompt-is-type? state :runner :waiting) "Runner should wait again")))

(deftest a-teia-tatu-bola
(do-game
(new-game {:corp {:id "A Teia: IP Recovery"
:hand ["Tatu-Bola" "Vanilla"]}})
(play-from-hand state :corp "Tatu-Bola" "New remote")
(click-prompt state :corp "Done")
(take-credits state :corp)
(run-on state :remote1)
(rez state :corp (get-ice state :remote1 0))
(run-continue state :encounter-ice)
(run-continue state :pass-ice)
(click-prompt state :corp "Yes")
(click-prompt state :corp "Vanilla")
(click-card state :corp "Tatu-Bola")
(click-prompt state :corp "New remote")))

(deftest acme-consulting-the-truth-you-need-tag-gain-when-rezzing-outermost-ice
;; Tag gain when rezzing outermost ice
(do-game
Expand Down

0 comments on commit a9e38e7

Please sign in to comment.