Skip to content

Commit

Permalink
Merge pull request #5312 from NoahTheDuke/nb/fix-pre-worlds-bugs
Browse files Browse the repository at this point in the history
Fix handsize and tags display, real vs additional tags, active cards
  • Loading branch information
NoahTheDuke authored Oct 10, 2020
2 parents b182ac7 + 8385568 commit 38d766b
Show file tree
Hide file tree
Showing 17 changed files with 168 additions and 62 deletions.
4 changes: 2 additions & 2 deletions src/clj/game/cards/events.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1901,7 +1901,7 @@

(defcard "Networking"
{:async true
:req (req (pos? (count-tags state)))
:req (req (pos? (count-real-tags state)))
:msg "remove 1 tag"
:effect (req (wait-for (lose-tags state side 1)
(continue-ability
Expand Down Expand Up @@ -1994,7 +1994,7 @@

(defcard "Paper Tripping"
{:async true
:req (req (pos? (count-tags state)))
:req (req (pos? (count-real-tags state)))
:msg "remove all tags"
:effect (effect (lose-tags eid :all))})

Expand Down
4 changes: 2 additions & 2 deletions src/clj/game/cards/hardware.clj
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
(continue-ability
state side
(let [deck (pos? (count (:deck runner)))
tags (pos? (count-tags state))]
tags (pos? (count-real-tags state))]
{:req (req (or deck tags))
:prompt "Draw 1 card or remove 1 tag"
:choices (concat (when deck ["Draw 1 card"])
Expand Down Expand Up @@ -678,7 +678,7 @@
:async true
:effect (effect (jack-out eid))}
{:label "Remove 1 tag"
:req (req (and (pos? (count-tags state))
:req (req (and (pos? (count-real-tags state))
(= :runner (:active-player @state))))
:msg "remove 1 tag"
:cost [:trash]
Expand Down
2 changes: 1 addition & 1 deletion src/clj/game/cards/identities.clj
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
card nil)))}]})

(defcard "Ayla \"Bios\" Rahim: Simulant Specialist"
{:abilities [{:label "[:click] Add 1 card from NVRAM to your grip"
{:abilities [{:label "Add 1 card from NVRAM to your grip"
:cost [:click 1]
:async true
:prompt "Choose a card from NVRAM"
Expand Down
8 changes: 7 additions & 1 deletion src/clj/game/cards/operations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@
(defcard "Observe and Destroy"
{:async true
:additional-cost [:tag 1]
:req (req (and (pos? (count-tags state))
:req (req (and (pos? (count-real-tags state))
(< (:credit runner) 6)))
:prompt "Select an installed card to trash"
:choices {:card #(and (runner? %)
Expand Down Expand Up @@ -1789,6 +1789,7 @@
:events [{:event :pass-ice
:condition :hosted
:req (req (same-card? target (:host card)))
:msg (msg "add 1 power counter to itself")
:effect (effect (add-counter card :power 1))}]})

(defcard "Sacrifice"
Expand Down Expand Up @@ -2074,6 +2075,11 @@
:async true
:effect (req (if (= (count targets) 2)
(do (swap-ice state side (first targets) (second targets))
(system-msg state side
(str "uses Sunset to swap "
(card-str state (first targets))
" with "
(card-str state (second targets))))
(continue-ability state side (sun serv) card nil))
(do (system-msg state side "has finished rearranging ICE")
(effect-completed state side eid))))})]
Expand Down
2 changes: 1 addition & 1 deletion src/clj/game/cards/resources.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2174,7 +2174,7 @@
(quantify (count cards) "card")
" (" (string/join ", " (map :title cards)) "),"
" lose " (quantify (:credit (:runner @state)) "credit")
", and lose " (quantify (count-tags state) "tag"))))
", and lose " (quantify (count-real-tags state) "tag"))))
:effect (req (damage-prevent state side :net Integer/MAX_VALUE)
(damage-prevent state side :meat Integer/MAX_VALUE)
(damage-prevent state side :brain Integer/MAX_VALUE)
Expand Down
7 changes: 2 additions & 5 deletions src/clj/game/core/change_vals.clj
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@
" (" (if (pos? delta) (str "+" delta) delta) ")")))

(defn- change-tags
"Change a player's tag count, using floating effects"
"Change a player's tag count"
[state delta]
(register-floating-effect
state :runner nil
{:type :user-tags
:value delta})
(gain state :runner :tag delta)
(update-tag-status state)
(system-msg state :runner
(str "sets Tags to " (get-in @state [:runner :tag :total])
Expand Down
10 changes: 5 additions & 5 deletions src/clj/game/core/moving.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(:require
[game.core.agendas :refer [update-all-agenda-points]]
[game.core.board :refer [all-active-installed]]
[game.core.card :refer [card-index facedown? fake-identity? get-card in-play-area? installed? resource? rezzed? runner?]]
[game.core.card :refer [card-index facedown? faceup? fake-identity? get-card in-play-area? installed? resource? rezzed? runner?]]
[game.core.card-defs :refer [card-def]]
[game.core.effects :refer [register-constant-effects unregister-constant-effects]]
[game.core.eid :refer [effect-completed make-eid make-result]]
Expand Down Expand Up @@ -158,6 +158,8 @@
front 0
:else (count (get-in @state (cons side dest))))]
(swap! state update-in (cons side dest) #(into [] (concat (take pos-to-move-to %) [moved-card] (drop pos-to-move-to %)))))
(when (seq zone)
(update-installed-card-indices state side zone))
(update-installed-card-indices state side dest)
(let [z (vec (cons :corp (butlast zone)))]
(when (and (not keep-server-alive)
Expand Down Expand Up @@ -390,12 +392,10 @@
(assoc-in [:zone] '(:onhost))
(assoc-in [:host :zone] (:zone newcard)))]
(update! state side newh)
(unregister-events state side h)
(when (rezzed? h)
(unregister-events state side newh)
(when (faceup? newh)
(register-events state side newh)))))
(trigger-event state side :swap a-new b-new)
(update-ice-strength state side a-new)
(update-ice-strength state side b-new)
(set-current-ice state)))

(defn swap-installed
Expand Down
3 changes: 2 additions & 1 deletion src/clj/game/core/runs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@
(print-stack-trace
(Exception. "Continue clicked at the wrong time")
2500)))
(.println *err* (str "Run: " (:run @state) "\n")))
(.println *err* (str "Run: " (:phase (:run @state)) "\n"))
)

(defn redirect-run
([state side server] (redirect-run state side server nil))
Expand Down
5 changes: 4 additions & 1 deletion src/clj/game/core/set_up.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:require
[game.core.card :refer [corp? runner?]]
[game.core.card-defs :refer [card-def]]
[game.core.checkpoint :refer [fake-checkpoint]]
[game.core.drawing :refer [draw]]
[game.core.eid :refer [make-eid]]
[game.core.events :refer [trigger-event trigger-event-sync]]
Expand Down Expand Up @@ -117,9 +118,11 @@
(card-init state :corp corp-identity)
(card-init state :runner runner-identity)
(create-basic-action-cards state)
(fake-checkpoint state)
(let [side :corp]
(wait-for (trigger-event-sync state side :pre-start-game nil)
(let [side :runner]
(wait-for (trigger-event-sync state side :pre-start-game nil)
(init-hands state)))))
(init-hands state)
(fake-checkpoint state)))))
state))
5 changes: 5 additions & 0 deletions src/cljc/jinteki/utils.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
[state]
(or (get-in @state [:runner :tag :total]) 0))

(defn count-real-tags
"Count number of non-additional tags"
[state]
(or (get-in @state [:runner :tag :base]) 0))

(defn is-tagged?
"Returns truthy if runner is tagged"
[state]
Expand Down
1 change: 1 addition & 0 deletions src/cljs/nr/account.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@
{:name "Find The Truth" :ref "find-the-truth-bg"}
{:name "Push Your Luck" :ref "push-your-luck-bg"}
{:name "Apex" :ref "apex-bg"}
{:name "Worlds 2020" :ref "worlds2020"}
{:name "Monochrome" :ref "monochrome-bg"}]]
[:div.radio {:key (:name option)}
[:label [:input {:type "radio"
Expand Down
58 changes: 49 additions & 9 deletions src/cljs/nr/gameboard.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(:require [cljs.core.async :refer [chan put! <!] :as async]
[clojure.string :as s :refer [capitalize includes? join lower-case split]]
[differ.core :as differ]
[game.core.card :refer [active? has-subtype? asset? rezzed? ice? corp?
[game.core.card :refer [has-subtype? asset? rezzed? ice? corp?
faceup? installed? same-card? in-scored?]]
[jinteki.utils :refer [str->int is-tagged? add-cost-to-label] :as utils]
[jinteki.cards :refer [all-cards]]
Expand Down Expand Up @@ -699,6 +699,46 @@
(render-icons (add-cost-to-label ab))])
corp-abilities)]))

;; TODO (2020-10-08): We're using json as the transport layer for server-client
;; communication, so every non-key keyword is converted to a string, which blows.
;; Until this is changed, it's better to redefine this stuff in here and just not
;; worry about it.
(letfn
[(is-type? [card value] (= value (:type card)))
(identity? [card] (or (is-type? card "Fake-Identity")
(is-type? card "Identity")))
(get-nested-host [card] (if (:host card)
(recur (:host card))
card))
(get-zone [card] (:zone (get-nested-host card)))
(in-play-area? [card] (= (get-zone card) ["play-area"]))
(in-current? [card] (= (get-zone card) ["current"]))
(in-scored? [card] (= (get-zone card) ["scored"]))
(corp? [card] (= (:side card) "Corp"))
(installed? [card] (or (:installed card)
(= "servers" (first (get-zone card)))))
(rezzed? [card] (:rezzed card))
(runner? [card] (= (:side card) "Runner"))
(condition-counter? [card] (and (:condition card)
(or (is-type? card "Event")
(is-type? card "Operation"))))
(facedown? [card] (or (when (not (condition-counter? card))
(= (get-zone card) ["rig" "facedown"]))
(:facedown card)))]
(defn active?
"Checks if the card is active and should receive game events/triggers."
[card]
(or (identity? card)
(in-play-area? card)
(in-current? card)
(in-scored? card)
(and (corp? card)
(installed? card)
(rezzed? card))
(and (runner? card)
(installed? card)
(not (facedown? card))))))

(defn card-abilities [card c-state abilities subroutines]
(let [actions (action-list card)
dynabi-count (count (filter :dynamic abilities))]
Expand All @@ -718,10 +758,10 @@
:on-click #(do (send-command action {:card card}))}
(capitalize action)])
actions))
(when (and (or (active? card) (in-scored? card))
(when (and (active? card)
(seq abilities))
[:span.float-center "Abilities:"])
(when (and (or (active? card) (in-scored? card))
(when (and (active? card)
(seq abilities))
(map-indexed
(fn [i ab]
Expand Down Expand Up @@ -1137,16 +1177,16 @@
[:div (str agenda-point " Agenda Point"
(when (not= agenda-point 1) "s"))
(when me? (controls :agenda-point))]
(let [{:keys [base additional is-tagged]} tag
tag-count (+ base additional)
show-tagged (or (pos? tag-count) (pos? is-tagged))]
[:div (str base (when (pos? additional) (str " + " additional)) " Tag" (if (not= tag-count 1) "s" ""))
(let [{:keys [base total is-tagged]} tag
additional (- total base)
show-tagged (or is-tagged (pos? total))]
[:div (str base (when (pos? additional) (str " + " additional)) " Tag" (if (not= total 1) "s" ""))
(when show-tagged [:div.warning "!"])
(when me? (controls :tag))])
[:div (str brain-damage " Brain Damage")
(when me? (controls :brain-damage))]
(let [{:keys [base mod]} hand-size]
[:div (str (+ base mod) " Max hand size")
(let [{:keys [total]} hand-size]
[:div (str total " Max hand size")
(when me? (controls :hand-size))])]))))

(defmethod stats-view "Corp" [corp]
Expand Down
3 changes: 3 additions & 0 deletions src/css/base.styl
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,9 @@ nav ul
.freelancer-bg
cover-img: url('/img/bg/Freelancer.jpg')

.worlds2020
cover-img: url('/img/bg/Worlds2020.jpg')

.monochrome-bg
cover-color: obsidian

Expand Down
27 changes: 26 additions & 1 deletion test/clj/game/cards/ice_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4052,7 +4052,32 @@
(click-card state :corp "Drafter")
(run-jack-out state)
(is (= ["Thimblerig"] (map :title (get-ice state :rd))))
(is (= ["Drafter" "Vanilla"] (map :title (get-ice state :hq)))))))
(is (= ["Drafter" "Vanilla"] (map :title (get-ice state :hq))))))
(testing "Duplication bug"
(do-game
(new-game {:corp {:deck [(qty "Hedge Fund" 3)]
:hand ["Thimblerig" "Ice Wall" "Vanilla" "Hostile Takeover"]
:credits 10}
:runner {:id "Leela Patel: Trained Pragmatist"
:hand ["Gordian Blade"]
:credits 10}})
(core/gain state :corp :click 3)
(play-from-hand state :corp "Vanilla" "HQ")
(play-from-hand state :corp "Ice Wall" "HQ")
(play-from-hand state :corp "Thimblerig" "HQ")
(rez state :corp (get-ice state :hq 2))
(play-and-score state "Hostile Takeover")
(click-card state :runner "Vanilla")
(take-credits state :corp)
(play-from-hand state :runner "Gordian Blade")
(run-on state "HQ")
(run-continue state)
(card-ability state :runner (get-program state 0) 0)
(click-prompt state :runner "End the run")
(run-continue state)
(click-prompt state :corp "Yes")
(click-card state :corp "Ice Wall")
(is (= ["Thimblerig" "Ice Wall"] (map :title (get-ice state :hq)))))))

(deftest tithonium
;; Tithonium - Forfeit option as rez cost, can have hosted condition counters
Expand Down
Loading

0 comments on commit 38d766b

Please sign in to comment.