Skip to content

Commit

Permalink
Mid implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahTheDuke committed Jun 11, 2019
1 parent 895e645 commit f784aac
Show file tree
Hide file tree
Showing 7 changed files with 523 additions and 165 deletions.
35 changes: 32 additions & 3 deletions src/clj/game/cards/agendas.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1024,8 +1024,23 @@
"Project Kusanagi"
{:silent (req true)
:effect (effect (add-counter card :agenda (- (get-counters card :advancement) 2)))
:abilities [{:counter-cost [:agenda 1]
:msg "make a piece of ICE gain \"[Subroutine] Do 1 net damage\" after all its other subroutines for the remainder of the run"}]}
:events {:run-ends
{:effect (req (let [cid (:cid card)
ices (get-in card [:special :kusanagi])]
(doseq [i ices]
(when-let [ice (get-card state i)]
(remove-sub! state side ice #(= cid (:from-cid %))))))
(update! state side (dissoc-in card [:special :kusanagi])))}}
:abilities [{:req (req (and (ice? current-ice)
(rezzed? current-ice)
(has-subtype? current-ice "Bioroid")))
:counter-cost [:agenda 1]
:msg (str "make a piece of ICE gain \"[Subroutine] Do 1 net damage\" "
"after all its other subroutines for the remainder of the run")
:effect (effect (add-extra-sub! (get-card state current-ice)
(do-net-damage 1)
(:cid card) {:back true})
(update! (update-in card [:special :kusanagi] #(conj % current-ice))))}]}

"Project Vitruvius"
{:silent (req true)
Expand All @@ -1045,12 +1060,26 @@
"Project Wotan"
{:silent (req true)
:effect (effect (add-counter card :agenda 3))
:events {:run-ends
{:effect (req (let [cid (:cid card)
ices (get-in card [:special :wotan])]
(doseq [i ices]
(when-let [ice (get-card state i)]
(remove-sub! state side ice #(= cid (:from-cid %))))))
(update! state side (dissoc-in card [:special :wotan])))}}
:abilities [{:req (req (and (ice? current-ice)
(rezzed? current-ice)
(has-subtype? current-ice "Bioroid")))
:counter-cost [:agenda 1]
:msg (str "make the approached piece of Bioroid ICE gain \"[Subroutine] End the run\""
"after all its other subroutines for the remainder of this run")}]}
"after all its other subroutines for the remainder of this run")
:effect (effect (add-extra-sub! (get-card state current-ice)
{:label "End the run"
:msg "end the run"
:async true
:effect (effect (end-run eid card))}
(:cid card) {:back true})
(update! (update-in card [:special :wotan] #(conj % current-ice))))}]}

"Project Yagi-Uda"
(letfn [(put-back-counter [state side card]
Expand Down
318 changes: 201 additions & 117 deletions src/clj/game/cards/ice.clj

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions src/clj/game/core/ice.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
(defn add-sub
([ice sub] (add-sub ice sub (:cid ice) nil))
([ice sub cid] (add-sub ice sub cid nil))
([ice sub cid {:keys [front back printed] :as args}]
([ice sub cid {:keys [front back printed variable] :as args}]
(let [curr-subs (:subroutines ice [])
position (cond
back 1
Expand All @@ -16,17 +16,19 @@
:from-cid cid
:sub-effect sub
:position position
:variable (or variable false)
:printed (or printed false)}
new-subs (into [] (sort-by :position (conj curr-subs new-sub)))]
(assoc ice :subroutines new-subs))))

(defn add-sub!
([state side ice sub] (update! state :corp (add-sub ice sub (:cid ice) {:printed false})))
([state side ice sub cid] (update! state :corp (add-sub ice sub cid {:printed false})))
([state side ice sub] (update! state :corp (add-sub ice sub (:cid ice) nil)))
([state side ice sub cid] (update! state :corp (add-sub ice sub cid nil)))
([state side ice sub cid args] (update! state :corp (add-sub ice sub cid args))))

(defn remove-sub
"Removes a single sub from"
"Removes a single sub from a piece of ice. By default removes the first subroutine
with the same cid as the given ice."
([ice] (remove-sub ice #(= (:cid ice) (:from-cid %))))
([ice pred]
(let [curr-subs (:subroutines ice)
Expand Down
7 changes: 7 additions & 0 deletions src/clj/game/core/rules.clj
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,13 @@
{:priority 10}))
(resolve-bad-publicity state side eid n args))))))

(defn lose-bad-publicity
([state side n] (lose-tags state side (make-eid state) n))
([state side eid n]
(if (= n :all)
(lose-bad-publicity state side eid (get-in @state [:corp :bad-publicity]))
(do (lose state :corp :bad-publicity n)
(trigger-event-sync state side eid :corp-lose-bad-publicity n side)))))

;;; Trashing
(defn trash-resource-bonus
Expand Down
6 changes: 6 additions & 0 deletions src/cljc/jinteki/utils.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
(+ (get-in @state [:runner :tag :base] 0)
(get-in @state [:runner :tag :additional] 0)))

(defn count-bad-pub
"Counts number of bad publicity corp has (real + additional)"
[state]
(+ (get-in @state [:corp :bad-publicity] 0)
(get-in @state [:corp :has-bad-pub] 0)))

(defn is-tagged?
"Returns truthy if runner is tagged"
[state]
Expand Down
2 changes: 1 addition & 1 deletion test/clj/game_test/cards/agendas.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@
(click-prompt state :runner "0")
(is (= 2 (count-tags state)))
(run-on state "R&D")
(card-ability state :corp io 1)
(card-ability state :corp io 0)
(is (zero? (-> (get-corp) :prompt first :bonus)) "Should gain 0 bonus trace strength, as it's an encounter ability"))))

(deftest jumon
Expand Down
Loading

0 comments on commit f784aac

Please sign in to comment.