Skip to content

Commit

Permalink
Merge pull request mtgred#3836 from Saintis/more-fixes
Browse files Browse the repository at this point in the history
More fixes
  • Loading branch information
nealterrell authored Aug 18, 2018
2 parents 5717965 + 2e9eada commit 2286b7d
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 92 deletions.
15 changes: 9 additions & 6 deletions src/clj/game/cards/assets.clj
Original file line number Diff line number Diff line change
Expand Up @@ -991,15 +991,18 @@

"Malia Z0L0K4"
(let [re-enable-target (req (when-let [malia-target (:malia-target card)]
(system-msg state side (str "uses " (:title card) " to unblank "
(card-str state malia-target)))
(enable-card state :runner (get-card state malia-target))
(when-let [reactivate-effect (:reactivate (card-def malia-target))]
(resolve-ability state :runner reactivate-effect (get-card state malia-target) nil))))]
(when (:disabled (get-card state malia-target))
(system-msg state side (str "uses " (:title card) " to unblank "
(card-str state malia-target)))
(enable-card state :runner (get-card state malia-target))
(when-let [reactivate-effect (:reactivate (card-def malia-target))]
(resolve-ability state :runner reactivate-effect (get-card state malia-target) nil)))))]
{:effect (effect (update! (assoc card :malia-target target))
(disable-card :runner target))
:msg (msg (str "blank the text box of " (card-str state target)))
:choices {:req #(and (= (:side %) "Runner") (installed? %) (resource? %)
:choices {:req #(and (= "Runner" (:side %))
(installed? %)
(resource? %)
(not (has-subtype? % "Virtual")))}
:leave-play re-enable-target
:move-zone re-enable-target})
Expand Down
2 changes: 1 addition & 1 deletion src/clj/game/cards/events.clj
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
{:msg (msg "place 3 virus tokens on " (:title target))
:choices {:req #(and (installed? %)
(= (:side %) "Runner")
(zero? (get-virus-counters state side %)))}
(zero? (get-virus-counters state %)))}
:effect (req (add-counter state :runner target :virus 3))}
card nil))}

Expand Down
4 changes: 2 additions & 2 deletions src/clj/game/cards/icebreakers.clj
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@
{:label "Add a virus counter"
:effect (effect (system-msg "manually adds a virus counter to Aumakua")
(add-counter card :virus 1))}]
:strength-bonus (req (get-virus-counters state side card))
:strength-bonus (req (get-virus-counters state card))
:events {:run-ends {:req (req (and (not (or (get-in @state [:run :did-trash])
(get-in @state [:run :did-steal])))
(get-in @state [:run :did-access])))
Expand Down Expand Up @@ -546,7 +546,7 @@
:req (req (:runner-phase-12 @state))
:effect (effect (add-counter card :virus 1)
(update-breaker-strength card))}]
:strength-bonus (req (or (get-virus-counters state side card) 0))}
:strength-bonus (req (or (get-virus-counters state card) 0))}

"Demara"
(auto-icebreaker ["Barrier"]
Expand Down
32 changes: 17 additions & 15 deletions src/clj/game/cards/programs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
(system-msg "places 1 [Credit] on Bankroll"))}}
:abilities [{:label "[Trash]: Take all credits from Bankroll"
:async true
;; Cannot trash unless there are counters (so game state changes)
:req (req (pos? (get-counters card :credit)))
:effect (req (let [credits-on-bankroll (get-counters card :credit)]
(wait-for (trash state :runner card {:cause :ability-cost})
(take-credits state :runner credits-on-bankroll)
Expand Down Expand Up @@ -114,7 +116,7 @@
:events {:successful-run {:silent (req true)
:req (req (= target :rd))
:effect (effect (add-counter card :virus 1))}
:pre-advancement-cost {:req (req (>= (get-virus-counters state side card) 3))
:pre-advancement-cost {:req (req (>= (get-virus-counters state card) 3))
:effect (effect (advancement-cost-bonus 1))}
:counter-added
{:req (req (or (= (:title target) "Hivemind") (= (:cid target) (:cid card))))
Expand Down Expand Up @@ -207,16 +209,16 @@
ab (if (get-in card [:special :auto-accept]) auto-ab ab)]
(continue-ability state side ab card targets)))}}
:effect (effect (toast "Tip: You can toggle automatically adding virus counters by clicking Consume."))
:abilities [{:req (req (pos? (get-virus-counters state side card)))
:abilities [{:req (req (pos? (get-virus-counters state card)))
:cost [:click 1]
:label "Gain 2 [Credits] for each hosted virus counter, then remove all virus counters."
:effect (req (gain-credits state side (* 2 (get-virus-counters state side card)))
:effect (req (gain-credits state side (* 2 (get-virus-counters state card)))
(update! state side (assoc-in card [:counter :virus] 0))
(when-let [hiveminds (filter #(= "Hivemind" (:title %)) (all-active-installed state :runner))]
(doseq [h hiveminds]
(update! state side (assoc-in h [:counter :virus] 0)))))
:msg (msg (let [local-virus (get-counters card :virus)
global-virus (get-virus-counters state side card)
global-virus (get-virus-counters state card)
hivemind-virus (- global-virus local-virus)]
(str "gain " (* 2 global-virus) " [Credits], removing " (quantify local-virus "virus counter") " from Consume"
(when (pos? hivemind-virus)
Expand Down Expand Up @@ -270,7 +272,7 @@
:effect (effect (add-counter card :virus 1))
:req (req (= target :rd))}
:runner-turn-begins
{:req (req (>= (get-virus-counters state side card) 3)) :msg "look at the top card of R&D"
{:req (req (>= (get-virus-counters state card) 3)) :msg "look at the top card of R&D"
:effect (effect (prompt! card (str "The top card of R&D is "
(:title (first (:deck corp)))) ["OK"] {}))}}}

Expand Down Expand Up @@ -454,9 +456,9 @@
card nil)))}]}

"Gorman Drip v1"
{:abilities [{:cost [:click 1] :effect (effect (gain-credits (get-virus-counters state side card))
{:abilities [{:cost [:click 1] :effect (effect (gain-credits (get-virus-counters state card))
(trash card {:cause :ability-cost}))
:msg (msg "gain " (get-virus-counters state side card) " [Credits]")}]
:msg (msg "gain " (get-virus-counters state card) " [Credits]")}]
:events {:corp-click-credit {:effect (effect (add-counter :runner card :virus 1))}
:corp-click-draw {:effect (effect (add-counter :runner card :virus 1))}}}

Expand Down Expand Up @@ -651,10 +653,10 @@
:pre-access {:async true
:req (req (= target :rd))
:effect (effect (continue-ability
{:req (req (< 1 (get-virus-counters state side card)))
{:req (req (< 1 (get-virus-counters state card)))
:prompt "Choose how many additional R&D accesses to make with Medium"
:choices {:number (req (dec (get-virus-counters state side card)))
:default (req (dec (get-virus-counters state side card)))}
:choices {:number (req (dec (get-virus-counters state card)))
:default (req (dec (get-virus-counters state card)))}
:msg (msg "access " target " additional cards from R&D")
:effect (effect (access-bonus (max 0 target)))}
card nil))}}}
Expand All @@ -676,10 +678,10 @@
:pre-access {:async true
:req (req (= target :hq))
:effect (effect (continue-ability
{:req (req (< 1 (get-virus-counters state side card)))
{:req (req (< 1 (get-virus-counters state card)))
:prompt "Choose how many additional HQ accesses to make with Nerve Agent"
:choices {:number (req (dec (get-virus-counters state side card)))
:default (req (dec (get-virus-counters state side card)))}
:choices {:number (req (dec (get-virus-counters state card)))
:default (req (dec (get-virus-counters state card)))}
:msg (msg "access " target " additional cards from HQ")
:effect (effect (access-bonus (max 0 target)))}
card nil))}}}
Expand Down Expand Up @@ -752,7 +754,7 @@
:effect (effect (update-ice-strength (:host card)))}
:pre-ice-strength
{:req (req (= (:cid target) (:cid (:host card))))
:effect (effect (ice-strength-bonus (- (get-virus-counters state side card)) target))}
:effect (effect (ice-strength-bonus (- (get-virus-counters state card)) target))}
:ice-strength-changed
{:req (req (and (= (:cid target) (:cid (:host card)))
(not (card-flag? (:host card) :untrashable-while-rezzed true))
Expand Down Expand Up @@ -1080,7 +1082,7 @@

"Trypano"
(let [trash-if-5 (req (when-let [h (get-card state (:host card))]
(if (and (>= (get-virus-counters state side card) 5)
(if (and (>= (get-virus-counters state card) 5)
(not (and (card-flag? h :untrashable-while-rezzed true)
(rezzed? h))))
(do (system-msg state :runner (str "uses Trypano to trash " (card-str state h)))
Expand Down
60 changes: 39 additions & 21 deletions src/clj/game/cards/resources.clj
Original file line number Diff line number Diff line change
Expand Up @@ -577,24 +577,30 @@
:abilities [{:msg "avoid 1 tag" :effect (effect (tag-prevent :runner 1) (trash card {:cause :ability-cost}))}]}

"District 99"
{:implementation "Adding power counters must be done manually for programs/hardware trashed manually (e.g. by being over MU)"
:abilities [{:label "Add a card from your heap to your grip"
:req (req (seq (filter #(= (:faction (:identity runner)) (:faction %)) (:discard runner))))
:counter-cost [:power 3] :cost [:click 1]
:prompt (msg "Which card to add to grip?")
:choices (req (filter #(= (:faction (:identity runner)) (:faction %)) (:discard runner)))
:effect (effect (move target :hand))
:msg (msg "Add " (:title target) " to grip")}
{:label "Add a power counter manually"
:once :per-turn
:effect (effect (add-counter card :power 1))
:msg (msg "manually add a power counter.")}]
:events (let [prog-or-hw (fn [t] (or (program? (first t)) (hardware? (first t))))
trash-event (fn [side-trash] {:once :per-turn
:req (req (first-event? state side side-trash prog-or-hw))
:effect (effect (add-counter card :power 1))})]
{:corp-trash (trash-event :corp-trash)
:runner-trash (trash-event :runner-trash)})}
(letfn [(eligible-cards [runner] (filter #(same-card? :faction (:identity runner) %)
(:discard runner)))]
{:implementation "Adding power counters must be done manually for programs/hardware trashed manually (e.g. by being over MU)"
:abilities [{:label "Add a card from your heap to your grip"
:req (req (seq (eligible-cards runner)))
:counter-cost [:power 3]
:cost [:click 1]
:prompt "Select a card to add to grip?"
:choices (req (eligible-cards runner))
:effect (effect (move target :hand))
:msg (msg "add " (:title target) " to grip")}
{:label "Add a power counter manually"
:once :per-turn
:effect (effect (add-counter card :power 1))
:msg "manually add a power counter"}]
:events (let [prog-or-hw #(or (program? (first %))
(hardware? (first %)))
trash-event (fn [side-trash] {:once :per-turn
:req (req (first-event? state side side-trash prog-or-hw))
:effect (effect (system-msg :runner "adds 1 power counter on District 99")
(add-counter card :power 1))})]
{:corp-trash (trash-event :corp-trash)
:runner-trash (trash-event :runner-trash)})})


"DJ Fenris"
(let [is-draft-id? #(.startsWith (:code %) "00")
Expand Down Expand Up @@ -622,8 +628,20 @@
(clear-wait-prompt state :corp)
(effect-completed state side eid)))}]
{:async true
:effect (effect (show-wait-prompt :corp "Runner to pick identity to host on DJ Fenris")
(continue-ability fenris-effect card nil))})
:effect (req (show-wait-prompt state :corp "Runner to pick identity to host on DJ Fenris")
(continue-ability state side fenris-effect card nil))
;; Handle Dr. Lovegood / Malia
:disable {:effect (req (doseq [hosted (:hosted card)]
(disable-card state side hosted)))}
:reactivate {:effect (req (doseq [hosted (:hosted card)
:let [c (dissoc hosted :disabled)
{:keys [effect events]} (card-def c)]]
;; Manually enable card to trigger `:effect`, similar to `enable-identity`
(update! state side c)
(when effect
(effect state side (make-eid state) c nil))
(when events
(register-events state side events c))))}})

"Donut Taganes"
{:msg "increase the play cost of operations and events by 1 [Credits]"
Expand Down Expand Up @@ -2072,7 +2090,7 @@
:effect (req (resolve-ability
state side
{:msg (msg "move 1 virus counter to " (:title target))
:choices {:req #(pos? (get-virus-counters state side %))}
:choices {:req #(pos? (get-virus-counters state %))}
:effect (req (add-counter state side card :virus -1)
(add-counter state side target :virus 1))}
card nil))}]}
Expand Down
42 changes: 26 additions & 16 deletions src/clj/game/core/actions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,32 @@
(same-side? s (:side card))
(or (= last-zone :play-area)
(same-side? side (:side card))))
(case server
("Heap" "Archives")
(let [action-str (if (= (first (:zone c)) :hand) "discards " "trashes ")]
(trash state s c {:unpreventable true})
(system-msg state side (str action-str label from-str)))
("Grip" "HQ")
(do (move state s (dissoc c :seen :rezzed) :hand {:force true})
(system-msg state side (str "moves " label from-str " to " server)))
("Stack" "R&D")
(do (move state s (dissoc c :seen :rezzed) :deck {:front true :force true})
(system-msg state side (str "moves " label from-str " to the top of " server)))
nil))))

(defn concede [state side args]
(system-msg state side "concedes")
(win state (if (= side :corp) :runner :corp) "Concede"))
(let [move-card-to (partial move state s (dissoc c :seen :rezzed))
log-move (fn [verb & text] (system-msg state side (str verb " " label from-str
(when (seq text) (apply str " " text)))))]
(case server
("Heap" "Archives")
(if (= :hand (first (:zone c)))
;; Discard from hand, do not trigger trash
(do (move-card-to :discard {:force true})
(log-move "discards"))
(do (trash state s c {:unpreventable true})
(log-move "trashes")))
("Grip" "HQ")
(do (move-card-to :hand {:force true})
(log-move "moves" "to " server))
("Stack" "R&D")
(do (move-card-to :deck {:front true :force true})
(log-move "moves" "to the top of " server))
;; default
nil)))))

(defn concede
"Trigger game concede by specified side. Takes a third argument for use with user commands."
([state side _] (concede state side))
([state side]
(system-msg state side "concedes")
(win state (if (= side :corp) :runner :corp) "Concede")))

(defn- finish-prompt [state side prompt card]
(when-let [end-effect (:end-effect prompt)]
Expand Down
Loading

0 comments on commit 2286b7d

Please sign in to comment.