Skip to content

Commit

Permalink
Merge pull request #6441 from NoahTheDuke/nb/strength-bonus-fix
Browse files Browse the repository at this point in the history
Fix strength bonuses not applying correctly to programs
  • Loading branch information
NoahTheDuke authored Jul 23, 2022
2 parents 60df0b4 + 5396cd5 commit 1f054e8
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 48 deletions.
52 changes: 26 additions & 26 deletions src/clj/game/cards/ice.clj
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
[game.core.gaining :refer [gain-credits lose-clicks lose-credits]]
[game.core.hand-size :refer [hand-size]]
[game.core.hosting :refer [host]]
[game.core.ice :refer [add-sub add-sub! break-sub remove-sub! remove-subs!
resolve-subroutine set-current-ice strength-bonus
unbroken-subroutines-choice update-all-ice update-all-icebreakers
[game.core.ice :refer [add-sub add-sub! break-sub ice-strength-bonus
remove-sub! remove-subs! resolve-subroutine
set-current-ice unbroken-subroutines-choice update-all-ice update-all-icebreakers
update-ice-strength]]
[game.core.initializing :refer [card-init]]
[game.core.installing :refer [corp-install corp-install-list
Expand Down Expand Up @@ -359,7 +359,7 @@
[subroutines]
{:advanceable :always
:subroutines subroutines
:constant-effects [(strength-bonus (req (get-counters card :advancement)))]})
:constant-effects [(ice-strength-bonus (req (get-counters card :advancement)))]})

(defn space-ice
"Creates data for Space ice with specified abilities."
Expand Down Expand Up @@ -592,7 +592,7 @@
:effect (effect (add-prop target :advance-counter 1 {:placed true})
(gain-credits eid 1))}
(assoc end-the-run :breakable breakable-fn)]
:constant-effects [(strength-bonus
:constant-effects [(ice-strength-bonus
(req (<= 3 (get-counters card :advancement)))
3)]}))

Expand Down Expand Up @@ -758,7 +758,7 @@

(defcard "Bathynomus"
{:subroutines [(do-net-damage 3)]
:constant-effects [(strength-bonus (req (protecting-archives? card)) 3)]})
:constant-effects [(ice-strength-bonus (req (protecting-archives? card)) 3)]})

(defcard "Battlement"
{:subroutines [end-the-run
Expand Down Expand Up @@ -1083,7 +1083,7 @@
:label "The Runner trashes 1 program")
runner-loses-click
end-the-run]
:constant-effects [(strength-bonus
:constant-effects [(ice-strength-bonus
(req (some #(has-subtype? % "AI") (all-active-installed state :runner)))
3)]})

Expand All @@ -1102,13 +1102,13 @@
(corp? %))}
:msg (msg (corp-install-msg target))
:effect (effect (corp-install eid target nil nil))}]
:constant-effects [(strength-bonus (req (protecting-archives? card)) 3)]})
:constant-effects [(ice-strength-bonus (req (protecting-archives? card)) 3)]})

(defcard "Curtain Wall"
{:subroutines [end-the-run
end-the-run
end-the-run]
:constant-effects [(strength-bonus
:constant-effects [(ice-strength-bonus
(req (let [ices (:ices (card->server state card))]
(same-card? card (last ices))))
4)]
Expand Down Expand Up @@ -1257,7 +1257,7 @@
:msg (msg "place " (quantify target "power counter"))
:effect (effect (add-counter card :power target)
(update-ice-strength card))}
:constant-effects [(strength-bonus (req (get-counters card :power)))]
:constant-effects [(ice-strength-bonus (req (get-counters card :power)))]
:subroutines [(trace-ability 2 {:label "Give the Runner 1 tag and end the run"
:msg "give the Runner 1 tag and end the run"
:async true
Expand Down Expand Up @@ -1655,7 +1655,7 @@
:label "Draw cards, reveal and shuffle agendas"
:effect (req (wait-for (resolve-ability state side draw-ab card nil)
(continue-ability state side reveal-and-shuffle card nil)))}]
{:constant-effects [(strength-bonus (req (= :this-turn (:rezzed card))) 6)]
{:constant-effects [(ice-strength-bonus (req (= :this-turn (:rezzed card))) 6)]
:subroutines [draw-reveal-shuffle
end-the-run]}))

Expand Down Expand Up @@ -1691,7 +1691,7 @@

(defcard "Gutenberg"
{:subroutines [(tag-trace 7)]
:constant-effects [(strength-bonus (req (protecting-rd? card)) 3)]})
:constant-effects [(ice-strength-bonus (req (protecting-rd? card)) 3)]})

(defcard "Gyri Labyrinth"
{:subroutines [{:req (req run)
Expand Down Expand Up @@ -1742,8 +1742,8 @@
:effect (effect (clear-wait-prompt :runner)
(trash eid target {:cause :subroutine}))}
end-the-run]
:constant-effects [(strength-bonus (req (- (count (filter #(has-subtype? % "Icebreaker")
(all-active-installed state :runner))))))]})
:constant-effects [(ice-strength-bonus (req (- (count (filter #(has-subtype? % "Icebreaker")
(all-active-installed state :runner))))))]})

(defcard "Hailstorm"
{:subroutines [{:label "Remove a card in the Heap from the game"
Expand Down Expand Up @@ -2039,7 +2039,7 @@

(defcard "IQ"
{:subroutines [end-the-run]
:constant-effects [(strength-bonus (req (count (:hand corp))))]
:constant-effects [(ice-strength-bonus (req (count (:hand corp))))]
:rez-cost-bonus (req (count (:hand corp)))
:leave-play (req (remove-watch state (keyword (str "iq" (:cid card)))))})

Expand Down Expand Up @@ -2453,7 +2453,7 @@

(defcard "Meru Mati"
{:subroutines [end-the-run]
:constant-effects [(strength-bonus (req (protecting-hq? card)) 3)]})
:constant-effects [(ice-strength-bonus (req (protecting-hq? card)) 3)]})

(defcard "Metamorph"
{:subroutines [{:label "Swap two pieces of ice or swap two installed non-ice"
Expand Down Expand Up @@ -2688,7 +2688,7 @@

(defcard "NEXT Bronze"
{:subroutines [end-the-run]
:constant-effects [(strength-bonus (req (next-ice-count corp)))]})
:constant-effects [(ice-strength-bonus (req (next-ice-count corp)))]})

(defcard "NEXT Diamond"
{:rez-cost-bonus (req (- (next-ice-count corp)))
Expand Down Expand Up @@ -2865,7 +2865,7 @@
end-the-run-if-tagged]})

(defcard "Palisade"
{:constant-effects [(strength-bonus (req (not (protecting-a-central? card))) 2)]
{:constant-effects [(ice-strength-bonus (req (not (protecting-a-central? card))) 2)]
:subroutines [end-the-run]})

(defcard "Paper Wall"
Expand Down Expand Up @@ -2901,7 +2901,7 @@
:subroutines [(give-tags 1)
end-the-run
end-the-run]
:constant-effects [(strength-bonus (req (wonder-sub card 3)) 5)]})
:constant-effects [(ice-strength-bonus (req (wonder-sub card 3)) 5)]})

(defcard "Ping"
{:on-rez {:req (req (and run this-server))
Expand Down Expand Up @@ -2937,7 +2937,7 @@
:effect (effect (add-counter card :power 1)
(update-all-ice))}
:subroutines [end-the-run]
:constant-effects [(strength-bonus (req (get-counters card :power)))]})
:constant-effects [(ice-strength-bonus (req (get-counters card :power)))]})

(defcard "Rainbow"
{:subroutines [end-the-run]})
Expand All @@ -2961,7 +2961,7 @@
(update-all-ice))}]})

(defcard "Resistor"
{:constant-effects [(strength-bonus (req (count-tags state)))]
{:constant-effects [(ice-strength-bonus (req (count-tags state)))]
:subroutines [(trace-ability 4 end-the-run)]})

(defcard "Rime"
Expand Down Expand Up @@ -3080,7 +3080,7 @@

(defcard "Sandstone"
{:subroutines [end-the-run]
:constant-effects [(strength-bonus (req (- (get-counters card :virus))))]
:constant-effects [(ice-strength-bonus (req (- (get-counters card :virus))))]
:on-encounter {:msg "place 1 virus counter on Sandstone"
:effect (effect (add-counter card :virus 1)
(update-ice-strength (get-card state card)))}})
Expand All @@ -3103,7 +3103,7 @@
sub]}))

(defcard "Seidr Adaptive Barrier"
{:constant-effects [(strength-bonus (req (count (:ices (card->server state card)))))]
{:constant-effects [(ice-strength-bonus (req (count (:ices (card->server state card)))))]
:subroutines [end-the-run]})

(defcard "Self-Adapting Code Wall"
Expand Down Expand Up @@ -3299,7 +3299,7 @@

(defcard "Surveyor"
(let [x (req (* 2 (count (:ices (card->server state card)))))]
{:constant-effects [(strength-bonus x)]
{:constant-effects [(ice-strength-bonus x)]
:subroutines [{:label "Trace X - Give the Runner 2 tags"
:trace {:base x
:label "Give the Runner 2 tags"
Expand Down Expand Up @@ -3553,7 +3553,7 @@
:req (req (and (same-card? card (:ice context))
(has-subtype? (:icebreaker context) "AI")))
:value true}
(strength-bonus (req (not (protecting-a-central? card))) 3)]
(ice-strength-bonus (req (not (protecting-a-central? card))) 3)]
:subroutines [(end-the-run-unless-runner
"spends [Click][Click][Click]"
"spend [Click][Click][Click]"
Expand Down Expand Up @@ -3775,7 +3775,7 @@

(defcard "Wraparound"
{:subroutines [end-the-run]
:constant-effects [(strength-bonus
:constant-effects [(ice-strength-bonus
(req (not-any? #(has-subtype? % "Fracter") (all-active-installed state :runner)))
7)]})

Expand Down
42 changes: 21 additions & 21 deletions src/clj/game/cards/programs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
[game.core.hosting :refer [host]]
[game.core.ice :refer [all-subs-broken-by-card? all-subs-broken?
any-subs-broken-by-card? auto-icebreaker break-sub
break-subroutine! break-subroutines-msg dont-resolve-subroutine! get-strength ice-strength
pump pump-ice set-current-ice strength-bonus strength-pump
break-subroutine! break-subroutines-msg breaker-strength-bonus dont-resolve-subroutine!
get-strength ice-strength pump pump-ice set-current-ice strength-pump
unbroken-subroutines-choice update-breaker-strength]]
[game.core.initializing :refer [ability-init card-init]]
[game.core.installing :refer [install-locked? runner-can-install?
Expand Down Expand Up @@ -214,7 +214,7 @@
(Greek/Philosopher suite: Adept, Sage, Savant)"
[abilities]
(auto-icebreaker {:abilities abilities
:constant-effects [(strength-bonus (req (available-mu state)))]}))
:constant-effects [(breaker-strength-bonus (req (available-mu state)))]}))

(defn- break-multiple-types
"Single ability to break multiple types of ice
Expand Down Expand Up @@ -337,8 +337,8 @@
(auto-icebreaker
(cloud-icebreaker
{:abilities [(break-sub [:trash-can] 3 ice-type)]
:constant-effects [(strength-bonus (req (count (filter #(has-subtype? % "Icebreaker")
(all-active-installed state :runner)))))]})))
:constant-effects [(breaker-strength-bonus (req (count (filter #(has-subtype? % "Icebreaker")
(all-active-installed state :runner)))))]})))

(defn- global-sec-breaker
"No MU with 2+ link, break any number of subs for 2, pump 2 for 3
Expand Down Expand Up @@ -461,7 +461,7 @@
:msg (msg "add " (cost-value eid :x-credits) " power counters")
:effect (effect (add-counter card :power (cost-value eid :x-credits)))}
:abilities [(break-sub 1 1 "All" {:req (req (= (get-strength current-ice) (get-strength card)))})]
:constant-effects [(strength-bonus (req (get-counters card :power)))]})
:constant-effects [(breaker-strength-bonus (req (get-counters card :power)))]})

(defcard "Au Revoir"
{:events [{:event :jack-out
Expand All @@ -475,7 +475,7 @@
{:label "Place a virus counter"
:msg "manually place a virus counter on itself"
:effect (effect (add-counter card :virus 1))}]
:constant-effects [(strength-bonus (req (get-virus-counters state card)))]
:constant-effects [(breaker-strength-bonus (req (get-virus-counters state card)))]
:events [{:event :end-breach-server
:req (req (not (or (:did-steal target)
(:did-trash target))))
Expand Down Expand Up @@ -530,7 +530,7 @@
(auto-icebreaker {:on-install {:async true
:effect (effect (damage eid :brain 1 {:card card}))}
:abilities [(break-sub 1 0 "Barrier")]
:constant-effects [(strength-bonus (req (:brain-damage runner)))]}))
:constant-effects [(breaker-strength-bonus (req (:brain-damage runner)))]}))

(defcard "Berserker"
(auto-icebreaker {:events [{:event :encounter-ice
Expand Down Expand Up @@ -880,7 +880,7 @@

(defcard "Cradle"
(auto-icebreaker {:abilities [(break-sub 2 0 "Code Gate")]
:constant-effects [(strength-bonus (req (- (count (:hand runner)))))]}))
:constant-effects [(breaker-strength-bonus (req (- (count (:hand runner)))))]}))

(defcard "Creeper"
(cloud-icebreaker
Expand Down Expand Up @@ -988,7 +988,7 @@
:msg "place 1 virus counter"
:req (req (:runner-phase-12 @state))
:effect (effect (add-counter card :virus 1))}]
:constant-effects [(strength-bonus (req (get-virus-counters state card)))]}))
:constant-effects [(breaker-strength-bonus (req (get-virus-counters state card)))]}))

(defcard "Datasucker"
{:events [{:event :successful-run
Expand Down Expand Up @@ -1171,9 +1171,9 @@
(strength-pump 1 1)]}))

(defcard "Echelon"
(auto-icebreaker {:constant-effects [(strength-bonus (req (count (filter #(and (program? %)
(has-subtype? % "Icebreaker"))
(all-active-installed state :runner)))))]
(auto-icebreaker {:constant-effects [(breaker-strength-bonus (req (count (filter #(and (program? %)
(has-subtype? % "Icebreaker"))
(all-active-installed state :runner)))))]
:abilities [(break-sub 1 1 "Sentry")
(strength-pump 3 2)]}))

Expand Down Expand Up @@ -1360,7 +1360,7 @@
(strength-pump 1 1)]}))

(defcard "Gauss"
(auto-icebreaker {:constant-effects [(strength-bonus (req (= :this-turn (installed? card))) 3)]
(auto-icebreaker {:constant-effects [(breaker-strength-bonus (req (= :this-turn (installed? card))) 3)]
:abilities [(break-sub 1 1 "Barrier")
(strength-pump 2 2)]}))

Expand Down Expand Up @@ -1503,7 +1503,7 @@
:msg "place 1 power counter"
:async true
:effect (effect (add-counter eid card :power 1 nil))}]
:constant-effects [(strength-bonus (req (get-counters card :power)))]}))
:constant-effects [(breaker-strength-bonus (req (get-counters card :power)))]}))

(defcard "Hyperdriver"
{:flags {:runner-phase-12 (req true)}
Expand Down Expand Up @@ -1780,7 +1780,7 @@

(defcard "Maven"
(auto-icebreaker {:abilities [(break-sub 2 1)]
:constant-effects [(strength-bonus (req (count (filter program? (all-active-installed state :runner)))))]}))
:constant-effects [(breaker-strength-bonus (req (count (filter program? (all-active-installed state :runner)))))]}))

(defcard "Mayfly"
(auto-icebreaker
Expand Down Expand Up @@ -1852,7 +1852,7 @@
(virus-breaker "Sentry"))

(defcard "Na'Not'K"
(auto-icebreaker {:constant-effects [(strength-bonus (req (count run-ices)))]
(auto-icebreaker {:constant-effects [(breaker-strength-bonus (req (count run-ices)))]
:abilities [(break-sub 1 1 "Sentry")
(strength-pump 3 2)]}))

Expand Down Expand Up @@ -1882,7 +1882,7 @@

(defcard "Nfr"
(auto-icebreaker {:abilities [(break-sub 1 1 "Barrier")]
:constant-effects [(strength-bonus (req (get-counters card :power)))]
:constant-effects [(breaker-strength-bonus (req (get-counters card :power)))]
:events [{:event :end-of-encounter
:req (req (all-subs-broken-by-card? (:ice context) card))
:msg "place 1 power counter on itself"
Expand Down Expand Up @@ -2207,7 +2207,7 @@
:msg "remove one power counter"
:label "Remove 1 power counter"
:effect (effect (add-counter card :power -1))}]
:constant-effects [(strength-bonus (req (get-counters card :power)))
:constant-effects [(breaker-strength-bonus (req (get-counters card :power)))
{:type :used-mu
:duration :constant
:value (req (get-counters card :power))}]}))
Expand Down Expand Up @@ -2494,11 +2494,11 @@
{:cost [:credit 2]
:msg "place 1 power counter"
:effect (effect (add-counter card :power 1))}]
:constant-effects [(strength-bonus (req (get-counters card :power)))]}))
:constant-effects [(breaker-strength-bonus (req (get-counters card :power)))]}))

(defcard "Sūnya"
(auto-icebreaker {:abilities [(break-sub 2 1 "Sentry")]
:constant-effects [(strength-bonus (req (get-counters card :power)))]
:constant-effects [(breaker-strength-bonus (req (get-counters card :power)))]
:events [{:event :end-of-encounter
:req (req (all-subs-broken-by-card? (:ice context) card))
:msg "place 1 power counter on itself"
Expand Down
14 changes: 13 additions & 1 deletion src/clj/game/core/ice.clj
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@
(when-let [pump-fn (:pump-bonus ability)]
(pump-fn state side (make-eid state) card targets)))))

(defn strength-bonus
(defn ice-strength-bonus
"Use in :constant-effect vectors to give the current ice or program a conditional strength bonus"
([bonus]
{:type :ice-strength
Expand Down Expand Up @@ -404,6 +404,18 @@
(sum-effects state side card :breaker-strength)]
(reduce (fnil + 0 0)))))

(defn breaker-strength-bonus
"Use in :constant-effect vectors to give the current ice or program a conditional strength bonus"
([bonus]
{:type :breaker-strength
:req (req (same-card? card target))
:value bonus})
([req-fn bonus]
{:type :breaker-strength
:req (req (and (same-card? card target)
(req-fn state side eid card targets)))
:value bonus}))

(defn update-breaker-strength
"Updates a breaker's current strength by triggering updates and applying their effects."
[state side breaker]
Expand Down

0 comments on commit 1f054e8

Please sign in to comment.