Skip to content

Commit

Permalink
Merge pull request mtgred#3824 from Saintis/tag-rewrite
Browse files Browse the repository at this point in the history
Tag rewrite
  • Loading branch information
nealterrell authored Aug 18, 2018
2 parents 2286b7d + 7c53f47 commit 50a0d6a
Show file tree
Hide file tree
Showing 31 changed files with 431 additions and 407 deletions.
6 changes: 3 additions & 3 deletions src/clj/game/cards/agendas.clj
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,8 @@
{:abilities [{:label "Gain 1 [Credit] for each Runner tag"
:cost [:click 1]
:once :per-turn
:msg (msg "gain " (:tag runner) " [Credits]")
:effect (effect (gain-credits (:tag runner)))}]}
:msg (msg "gain " (count-tags state) " [Credits]")
:effect (effect (gain-credits (count-tags state)))}]}

"Executive Retreat"
{:effect (effect (add-counter card :agenda 1)
Expand Down Expand Up @@ -787,7 +787,7 @@
{:interactive (req true)
:async true
:prompt "Use Meteor Mining?"
:choices (req (if (< (:tag runner) 2)
:choices (req (if (< (count-tags state) 2)
["Gain 7 [Credits]" "No action"]
["Gain 7 [Credits]" "Do 7 meat damage" "No action"]))
:effect (req (case target
Expand Down
4 changes: 2 additions & 2 deletions src/clj/game/cards/assets.clj
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@
:prompt "Choose an operation to put on top of R&D"
:cost [:click 1]
:choices (req (cancellable (filter #(is-type? % "Operation") (:deck corp)) :sorted))
:req (req (pos? (get-in @state [:runner :tag])))
:req (req (pos? (get-in @state [:runner :tag :base])))
:effect (req (lose-tags state :corp 1)
(let [c (move state :corp target :play-area)]
(shuffle! state :corp :deck)
Expand Down Expand Up @@ -1941,7 +1941,7 @@

"Watchdog"
{:events {:pre-rez {:req (req (and (ice? target) (not (get-in @state [:per-turn (:cid card)]))))
:effect (effect (rez-cost-bonus (- (:tag runner))))}
:effect (effect (rez-cost-bonus (- (count-tags state))))}
:rez {:req (req (and (ice? target) (not (get-in @state [:per-turn (:cid card)]))))
:effect (req (swap! state assoc-in [:per-turn (:cid card)] true))}}}

Expand Down
17 changes: 8 additions & 9 deletions src/clj/game/cards/events.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1125,17 +1125,16 @@

"Itinerant Protesters"
{:msg "reduce the Corp's maximum hand size by 1 for each bad publicity"
:effect (req (lose state :corp :hand-size {:mod (:bad-publicity corp)})
:effect (req (change-hand-size state :corp (- (:bad-publicity corp)))
(add-watch state :itin
(fn [k ref old new]
(let [bpnew (get-in new [:corp :bad-publicity])
bpold (get-in old [:corp :bad-publicity])]
(when (> bpnew bpold)
(lose state :corp :hand-size {:mod (- bpnew bpold)}))
(when (< bpnew bpold)
(gain state :corp :hand-size {:mod (- bpold bpnew)}))))))
bpold (get-in old [:corp :bad-publicity])
bpchange (- bpnew bpold)]
(when-not (zero? bpchange)
(change-hand-size state :corp (- bpchange)))))))
:leave-play (req (remove-watch state :itin)
(gain state :corp :hand-size {:mod (:bad-publicity corp)}))}
(change-hand-size state :corp (:bad-publicity corp)))}

"Knifed"
(cutlery "Barrier")
Expand Down Expand Up @@ -1280,10 +1279,10 @@
"Mars for Martians"
{:msg (msg "draw " (count (filter #(and (has-subtype? % "Clan") (is-type? % "Resource"))
(all-active-installed state :runner)))
" cards and gain " (:tag runner) " [Credits]")
" cards and gain " (count-tags state) " [Credits]")
:effect (effect (draw (count (filter #(and (has-subtype? % "Clan") (is-type? % "Resource"))
(all-active-installed state :runner))))
(gain-credits (:tag runner)))}
(gain-credits (count-tags state)))}

"Mass Install"
(let [mhelper (fn mi [n] {:prompt "Select a program to install"
Expand Down
19 changes: 7 additions & 12 deletions src/clj/game/cards/hardware.clj
Original file line number Diff line number Diff line change
Expand Up @@ -792,23 +792,18 @@

"Obelus"
{:in-play [:memory 1]
:effect (req (gain state :runner :hand-size {:mod (:tag runner)})
(add-watch state :obelus
(fn [k ref old new]
(let [tagnew (get-in new [:runner :tag] 0)
tagold (get-in old [:runner :tag] 0)]
(when (> tagnew tagold)
(gain state :runner :hand-size {:mod (- tagnew tagold)}))
(when (< tagnew tagold)
(lose state :runner :hand-size {:mod (- tagold tagnew)}))))))
:leave-play (req (remove-watch state :obelus)
(lose state :runner :hand-size {:mod (:tag runner)}))
:effect (req (change-hand-size state :runner (count-tags state)))
:leave-play (req (change-hand-size state :runner (- (count-tags state))))
:events {:successful-run-ends {:once :per-turn
:req (req (and (#{:rd :hq} (first (:server target)))
(first-event? state side :successful-run-ends
#(#{:rd :hq} (first (:server (first %)))))))
:msg (msg "draw " (total-cards-accessed target) " cards")
:effect (effect (draw (total-cards-accessed target)))}}}
:effect (effect (draw (total-cards-accessed target)))}
;; Events for tracking hand size
:runner-gain-tag {:effect (req (change-hand-size state :runner target))}
:runner-lose-tag {:effect (req (change-hand-size state :runner (- target)))}
:runner-additional-tag-change {:effect (req (change-hand-size state :runner target))}}}

"Omni-drive"
{:recurring 1
Expand Down
30 changes: 14 additions & 16 deletions src/clj/game/cards/ice.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1122,10 +1122,10 @@

"Hydra"
(letfn [(otherwise-tag [message ability]
{:msg (msg (if (is-tagged? @state) message "give the Runner 1 tag"))
{:msg (msg (if tagged message "give the Runner 1 tag"))
:label (str (capitalize message) " if the Runner is tagged; otherwise, give the Runner 1 tag")
:async true
:effect (req (if (is-tagged? @state)
:effect (req (if tagged
(ability state :runner eid card nil)
(gain-tags state :runner eid 1)))})]
{:subroutines [(otherwise-tag "do 3 net damage"
Expand Down Expand Up @@ -1170,7 +1170,7 @@
"Information Overload"
{:implementation "Encounter effect is manual"
:abilities [{:label "Gain subroutines"
:msg (msg "gain " (:tag runner 0) " subroutines")}
:msg (msg "gain " (count-tags state) " subroutines")}
(tag-trace 1)]
:subroutines [trash-installed]}

Expand Down Expand Up @@ -1892,15 +1892,13 @@
:events {:pre-ice-strength nil :run-ends nil}}

"Resistor"
{:effect (req (add-watch state (keyword (str "resistor" (:cid card)))
(fn [k ref old new]
(let [tags (get-in new [:runner :tag])]
(when (not= (get-in old [:runner :tag]) tags)
(update! ref side (assoc (get-card ref card) :strength-bonus tags))
(update-ice-strength ref side (get-card ref card)))))))
:strength-bonus (req (:tag runner))
:leave-play (req (remove-watch state (keyword (str "resistor" (:cid card)))))
:subroutines [(trace-ability 4 end-the-run)]}
(let [resistor-effect {:effect (effect (update! (assoc (get-card state card) :strength-bonus (count-tags state)))
(update-ice-strength (get-card state card)))}]
{:events {:runner-gain-tag resistor-effect
:runner-lose-tag resistor-effect
:runner-additional-tag-change resistor-effect}
:strength-bonus (req (count-tags state))
:subroutines [(trace-ability 4 end-the-run)]})

"Rototurret"
{:subroutines [trash-program end-the-run]}
Expand Down Expand Up @@ -2203,12 +2201,12 @@
(gain-tags state :corp eid 1))}]
:subroutines [(trace-ability 4 {:label "Do 1 net damage for each Runner tag"
:async true
:msg (msg "do " (:tag runner) " net damage")
:effect (effect (damage eid :net (:tag runner) {:card card}))})
:msg (msg "do " (count-tags state) " net damage")
:effect (effect (damage eid :net (count-tags state) {:card card}))})
(trace-ability 4 {:label "Runner loses 1 [Credits] for each tag"
:async true
:msg (msg "force the Runner to lose " (:tag runner) " [Credits]")
:effect (effect (lose-credits :runner (:tag runner)))})]}
:msg (msg "force the Runner to lose " (count-tags state) " [Credits]")
:effect (effect (lose-credits :runner (count-tags state)))})]}

"Thimblerig"
{:flags {:corp-phase-12 (req (>= (count (filter ice? (all-installed state :corp))) 2))}
Expand Down
37 changes: 21 additions & 16 deletions src/clj/game/cards/identities.clj
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@
"Acme Consulting: The Truth You Need"
(letfn [(activate [state card active]
(update! state :corp (assoc-in card [:special :acme-active] active))
(swap! state update-in [:runner :additional-tag] (if active inc dec)))
(swap! state update-in [:runner :tag :additional] (if active inc dec))
(trigger-event state :corp :runner-additional-tag-change (if active 1 -1)))
(outermost? [run-position run-ices]
(and run-position
(pos? run-position)
(= run-position (count run-ices))))]
{:implementation "Tag is gained on approach, not on encounter"
{:implementation "Additional tag is gained on approach, not on encounter"
;; Should be comprehensive list of all cases when tag should be gained or lost
:events {:run {:effect (req (when (and (outermost? run-position run-ices)
(rezzed? current-ice))
(activate state card true)))}
Expand Down Expand Up @@ -274,7 +276,7 @@
"Boris \"Syfr\" Kovac: Crafty Veteran"
{:events {:pre-start-game {:effect draft-points-target}
:runner-turn-begins {:req (req (and (has-most-faction? state :runner "Criminal")
(pos? (:tag runner))))
(pos? (get-in runner [:tag :base]))))
:msg "remove 1 tag"
:effect (effect (lose-tags 1))}}}

Expand Down Expand Up @@ -478,19 +480,22 @@
:effect (effect (update-all-ice))}

"Harishchandra Ent.: Where Youre the Star"
{:effect (req (when tagged
(reveal-hand state :runner))
(add-watch state :harishchandra
(fn [k ref old new]
(when (and (is-tagged? new) (not (is-tagged? old)))
(system-msg ref side (str "uses Harishchandra Ent.: Where You're the Star to"
" make the Runner play with their Grip revealed"))
(reveal-hand state :runner))
(when (and (is-tagged? old) (not (is-tagged? new)))
(conceal-hand state :runner)))))
:leave-play (req (when tagged
(conceal-hand state :runner))
(remove-watch state :harishchandra))}
{:events {:runner-gain-tag {:effect (req (when (is-tagged? state)
(reveal-hand state :runner)))}
:runner-lose-tag {:effect (req (when-not (is-tagged? state)
(conceal-hand state :runner)))}
;; Triggered when Paparazzi enters / leaves
:runner-is-tagged {:effect (req (if (is-tagged? state)
(reveal-hand state :runner)
(conceal-hand state :runner)))}
;; Triggered when gaining or losing additional tag
:runner-additional-tag-change {:effect (req (if (is-tagged? state)
(reveal-hand state :runner)
(conceal-hand state :runner)))}}
:effect (req (when (is-tagged? state)
(reveal-hand state :runner)))
:leave-play (req (when (is-tagged? state)
(conceal-hand state :runner)))}

"Harmony Medtech: Biomedical Pioneer"
{:effect (effect (lose :agenda-point-req 1) (lose :runner :agenda-point-req 1))
Expand Down
57 changes: 28 additions & 29 deletions src/clj/game/cards/operations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
"Best Defense"
{:async true
:req (req (not-empty (all-installed state :runner)))
:effect (req (let [t (:tag runner)]
:effect (req (let [t (count-tags state)]
(continue-ability state side
{:prompt (msg "Choose a Runner card with an install cost of " t " or less to trash")
:choices {:req #(and (installed? %)
Expand Down Expand Up @@ -271,7 +271,7 @@
(draw eid 2 nil))}

"BOOM!"
{:req (req (> (:tag runner) 1))
{:req (req (> (count-tags state) 1))
:async true
:msg "do 7 meat damage"
:effect (effect (damage eid :meat 7 {:card card}))}
Expand Down Expand Up @@ -799,12 +799,11 @@
card nil)))}

"High-Profile Target"
(letfn [(dmg-count [runner]
(* 2 (:tag runner)))]
(letfn [(dmg-count [state] (* 2 (count-tags state)))]
{:req (req tagged)
:async true
:msg (msg "do " (dmg-count runner) " meat damage")
:effect (effect (damage eid :meat (dmg-count runner) {:card card}))})
:msg (msg "do " (dmg-count state) " meat damage")
:effect (effect (damage eid :meat (dmg-count state) {:card card}))})

"Housekeeping"
{:events {:runner-install {:player :runner
Expand Down Expand Up @@ -942,13 +941,13 @@
:effect (effect (gain-tags eid 1))}}}}}

"Market Forces"
(letfn [(credit-diff [runner]
(min (* 3 (:tag runner))
(:credit runner)))]
(letfn [(credit-diff [state]
(min (* 3 (count-tags state))
(get-in @state [:runner :credit])))]
{:req (req tagged)
:msg (msg (let [c (credit-diff runner)]
:msg (msg (let [c (credit-diff state)]
(str "make the runner lose " c " [Credits], and gain " c " [Credits]")))
:effect (req (let [c (credit-diff runner)]
:effect (req (let [c (credit-diff state)]
(lose-credits state :runner c)
(gain-credits state :corp c)))})

Expand All @@ -960,13 +959,18 @@

"MCA Informant"
{:implementation "Runner must deduct 1 click and 2 credits, then trash host manually"
:req (req (not-empty (filter #(has-subtype? % "Connection") (all-active-installed state :runner))))
:req (req (not-empty (filter #(has-subtype? % "Connection")
(all-active-installed state :runner))))
:prompt "Choose a connection to host MCA Informant on it"
:choices {:req #(and (= (:side %) "Runner") (has-subtype? % "Connection") (installed? %))}
:choices {:req #(and (= (:side %) "Runner")
(has-subtype? % "Connection")
(installed? %))}
:msg (msg "host it on " (card-str state target) ". The Runner has an additional tag")
:effect (req (host state side (get-card state target) (assoc card :zone [:discard] :seen true))
(swap! state update-in [:runner :tag] inc))
:leave-play (req (swap! state update-in [:runner :tag] dec)
(swap! state update-in [:runner :tag :additional] inc)
(trigger-event state :corp :runner-additional-tag-change 1))
:leave-play (req (swap! state update-in [:runner :tag :additional] dec)
(trigger-event state :corp :runner-additional-tag-change 1)
(system-msg state :corp "trashes MCA Informant"))}

"Medical Research Fundraiser"
Expand Down Expand Up @@ -1063,7 +1067,7 @@

"Observe and Destroy"
{:additional-cost [:tag 1]
:req (req (and (pos? (:tag runner))
:req (req (and (pos? (count-tags state))
(< (:credit runner) 6)))
:async true
:effect (effect (continue-ability
Expand Down Expand Up @@ -1183,7 +1187,7 @@
:choices :credit
:prompt "How many credits?"
:async true
:effect (req (let [c (min target (:tag runner))]
:effect (req (let [c (min target (count-tags state))]
(continue-ability state side
{:msg (msg "place " c " advancement tokens on "
(card-str state target))
Expand Down Expand Up @@ -1538,7 +1542,7 @@

"Shoot the Moon"
{:choices {:req #(and (ice? %) (not (rezzed? %)))
:max (req (min (:tag runner)
:max (req (min (count-tags state)
(reduce (fn [c server]
(+ c (count (filter #(not (:rezzed %)) (:ices server)))))
0 (flatten (seq (:servers corp))))))}
Expand Down Expand Up @@ -1756,16 +1760,11 @@
:successful
{:label "Give the Runner X tags"
:async true
:effect (req (let [tags (-> @state :runner :tag)]
(if (pos? tags)
(do (gain-tags state :corp eid tags)
(system-msg
state side
(str "uses Threat Level Alpha to give the Runner " tags " tags")))
(do (gain-tags state :corp eid 1)
(system-msg
state side
"uses Threat Level Alpha to give the Runner a tag")))))}}}
:effect (req (let [tags (max 1 (count-tags state))]
(do (gain-tags state :corp eid tags)
(system-msg
state side
(str "uses Threat Level Alpha to give the Runner " (quantify tags "tag"))))))}}}

"Too Big to Fail"
{:req (req (< (:credit corp) 10))
Expand All @@ -1774,7 +1773,7 @@
(gain-bad-publicity :corp 1))}

"Traffic Accident"
{:req (req (>= (:tag runner) 2))
{:req (req (>= (count-tags state) 2))
:msg "do 2 meat damage"
:async true
:effect (effect (damage eid :meat 2 {:card card}))}
Expand Down
2 changes: 1 addition & 1 deletion src/clj/game/cards/programs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@
"Misdirection"
{:abilities [{:cost [:click 2]
:prompt "How many [Credits] to spend to remove that number of tags?"
:choices {:number (req (min (:credit runner) (:tag runner)))}
:choices {:number (req (min (:credit runner) (get-in runner [:tag :base])))}
:msg (msg "spend " target " [Credits] and remove " target " tags")
:effect (effect (lose-credits target)
(lose-tags target))}]}
Expand Down
Loading

0 comments on commit 50a0d6a

Please sign in to comment.