Skip to content

Commit

Permalink
Merge branch 'master' into acme_tags
Browse files Browse the repository at this point in the history
  • Loading branch information
nealterrell authored Aug 24, 2018
2 parents eb9ad12 + 613ba1b commit e655e46
Show file tree
Hide file tree
Showing 30 changed files with 233 additions and 202 deletions.
2 changes: 1 addition & 1 deletion src/clj/game/cards/agendas.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[game.macros :refer [effect req msg wait-for continue-ability]]
[clojure.string :refer [split-lines split join lower-case includes? starts-with?]]
[clojure.stacktrace :refer [print-stack-trace]]
[jinteki.utils :refer [str->int other-side]]
[jinteki.utils :refer [str->int other-side is-tagged? count-tags]]
[jinteki.cards :refer [all-cards]]))

(defn ice-boost-agenda [subtype]
Expand Down
2 changes: 1 addition & 1 deletion src/clj/game/cards/assets.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[game.macros :refer [effect req msg wait-for continue-ability]]
[clojure.string :refer [split-lines split join lower-case includes? starts-with?]]
[clojure.stacktrace :refer [print-stack-trace]]
[jinteki.utils :refer [str->int other-side]]
[jinteki.utils :refer [str->int other-side is-tagged? count-tags]]
[jinteki.cards :refer [all-cards]]))

;;; Asset-specific helpers
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 @@ -4,7 +4,7 @@
[game.macros :refer [effect req msg wait-for continue-ability]]
[clojure.string :refer [split-lines split join lower-case includes? starts-with?]]
[clojure.stacktrace :refer [print-stack-trace]]
[jinteki.utils :refer [str->int other-side]]
[jinteki.utils :refer [str->int other-side is-tagged? count-tags]]
[jinteki.cards :refer [all-cards]]))

(defn- run-event
Expand Down
2 changes: 1 addition & 1 deletion src/clj/game/cards/hardware.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[game.macros :refer [effect req msg wait-for continue-ability]]
[clojure.string :refer [split-lines split join lower-case includes? starts-with?]]
[clojure.stacktrace :refer [print-stack-trace]]
[jinteki.utils :refer [str->int other-side]]
[jinteki.utils :refer [str->int other-side is-tagged? count-tags]]
[jinteki.cards :refer [all-cards]]))

(def card-definitions
Expand Down
2 changes: 1 addition & 1 deletion src/clj/game/cards/ice.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[game.macros :refer [effect req msg wait-for continue-ability]]
[clojure.string :refer [split-lines split join lower-case includes? starts-with?]]
[clojure.stacktrace :refer [print-stack-trace]]
[jinteki.utils :refer [str->int other-side]]
[jinteki.utils :refer [str->int other-side is-tagged? count-tags]]
[jinteki.cards :refer [all-cards]]))

;;;; Helper functions specific for ICE
Expand Down
2 changes: 1 addition & 1 deletion src/clj/game/cards/icebreakers.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[game.macros :refer [effect req msg wait-for continue-ability]]
[clojure.string :refer [split-lines split join lower-case includes? starts-with?]]
[clojure.stacktrace :refer [print-stack-trace]]
[jinteki.utils :refer [str->int other-side]]
[jinteki.utils :refer [str->int other-side is-tagged?]]
[jinteki.cards :refer [all-cards]]))

(def breaker-auto-pump
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 @@ -4,7 +4,7 @@
[game.macros :refer [effect req msg wait-for continue-ability]]
[clojure.string :refer [split-lines split join lower-case includes? starts-with?]]
[clojure.stacktrace :refer [print-stack-trace]]
[jinteki.utils :refer [str->int other-side]]
[jinteki.utils :refer [str->int other-side is-tagged?]]
[jinteki.cards :refer [all-cards]]))

;;; Helper functions for Draft cards
Expand Down
2 changes: 1 addition & 1 deletion src/clj/game/cards/operations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[game.macros :refer [effect req msg wait-for continue-ability]]
[clojure.string :refer [split-lines split join lower-case includes? starts-with?]]
[clojure.stacktrace :refer [print-stack-trace]]
[jinteki.utils :refer [str->int other-side]]
[jinteki.utils :refer [str->int other-side is-tagged? count-tags]]
[jinteki.cards :refer [all-cards]]))

(def card-definitions
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 @@ -4,7 +4,7 @@
[game.macros :refer [effect req msg wait-for continue-ability]]
[clojure.string :refer [split-lines split join lower-case includes? starts-with?]]
[clojure.stacktrace :refer [print-stack-trace]]
[jinteki.utils :refer [str->int other-side]]
[jinteki.utils :refer [str->int other-side is-tagged?]]
[jinteki.cards :refer [all-cards]]))

(def card-definitions
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 @@ -4,7 +4,7 @@
[game.macros :refer [effect req msg wait-for continue-ability]]
[clojure.string :refer [split-lines split join lower-case includes? starts-with?]]
[clojure.stacktrace :refer [print-stack-trace]]
[jinteki.utils :refer [str->int other-side]]
[jinteki.utils :refer [str->int other-side is-tagged? count-tags]]
[jinteki.cards :refer [all-cards]]))

(defn- genetics-trigger?
Expand Down
2 changes: 1 addition & 1 deletion src/clj/game/cards/upgrades.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[game.macros :refer [effect req msg wait-for continue-ability]]
[clojure.string :refer [split-lines split join lower-case includes? starts-with?]]
[clojure.stacktrace :refer [print-stack-trace]]
[jinteki.utils :refer [str->int other-side]]
[jinteki.utils :refer [str->int other-side is-tagged?]]
[jinteki.cards :refer [all-cards]]))

(def card-definitions
Expand Down
2 changes: 1 addition & 1 deletion src/clj/game/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[clojure.java.io :as io]
[clojure.core.match :refer [match]]
[clojure.stacktrace :refer [print-stack-trace]]
[jinteki.utils :refer [str->int other-side]]
[jinteki.utils :refer [str->int other-side is-tagged?]]
[jinteki.cards :refer [all-cards]]
[game.quotes :as quotes]))

Expand Down
14 changes: 14 additions & 0 deletions src/clj/game/core/actions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@
(str "sets unused MU to " (available-mu state)
" (" (if (pos? delta) (str "+" delta) delta) ")")))

(defn- change-tags
"Change a player's base tag count"
[state delta]
(if (neg? delta)
(deduct state :runner [:tag (Math/abs delta)])
(gain state :runner :tag delta))
(system-msg state :runner
(str "sets Tags to " (get-in @state [:runner :tag :base])
" (" (if (pos? delta) (str "+" delta) delta) ")")))

(defn change
"Increase/decrease a player's property (clicks, credits, MU, etc.) by delta."
[state side {:keys [key delta]}]
Expand All @@ -83,6 +93,10 @@
(= :hand-size key)
(change-map state side key delta)

;; Tags need special treatment since they are a more complex map
(= :tag key)
(change-tags state delta)

:else
(do (if (neg? delta)
(deduct state side [key (- delta)])
Expand Down
2 changes: 1 addition & 1 deletion src/clj/game/core/events.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

(declare can-trigger? card-def clear-wait-prompt effect-completed event-title get-card get-nested-host get-remote-names
get-runnable-zones get-zones installed? make-eid register-effect-completed register-suppress resolve-ability
show-wait-prompt trigger-suppress unregister-suppress is-tagged?)
show-wait-prompt trigger-suppress unregister-suppress)

; Functions for registering and dispatching events.
(defn register-events
Expand Down
13 changes: 0 additions & 13 deletions src/clj/game/core/misc.clj
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,6 @@
([state n]
(gain state :runner :memory {:used n})))

(defn count-tags
"Counts number of tags runner has (real + additional)"
[state]
(+ (get-in @state [:runner :tag :base] 0)
(get-in @state [:runner :tag :additional] 0)))

(defn is-tagged?
"Returns truthy if runner is tagged"
[state]
(or (pos? (get-in @state [:runner :tag :is-tagged] 0))
(pos? (count-tags state))))


;;; Other helpers

(defn swap-agendas
Expand Down
8 changes: 8 additions & 0 deletions src/clj/web/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
[ring.middleware.json :refer [wrap-json-body wrap-json-params wrap-json-response]]
[ring.middleware.session :refer [wrap-session]]
[ring.middleware.stacktrace :refer [wrap-stacktrace]]
[ring.util.response :refer [resource-response]]
[web.db :refer [db]]
[cheshire.generate :refer [add-encoder encode-str]]
[compojure.core :refer [defroutes wrap-routes GET POST DELETE PUT]]))
Expand Down Expand Up @@ -75,6 +76,12 @@
(wrap-routes auth/wrap-authorization-required))
public-routes)

(defn wrap-return-favicon [handler]
(fn [req]
(if (= [:get "/favicon.ico"] [(:request-method req) (:uri req)])
(resource-response "jinteki.ico" {:root "public/img"})
(handler req))))

(def app
(-> routes
auth/wrap-user
Expand All @@ -84,4 +91,5 @@
wrap-session
(wrap-json-body {:keywords? true})
admin/wrap-version
wrap-return-favicon
wrap-stacktrace))
12 changes: 12 additions & 0 deletions src/cljc/jinteki/utils.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,15 @@
(defn other-side [side]
(cond (= side :corp) :runner
(= side :runner) :corp))

(defn count-tags
"Counts number of tags runner has (real + additional)"
[state]
(+ (get-in @state [:runner :tag :base] 0)
(get-in @state [:runner :tag :additional] 0)))

(defn is-tagged?
"Returns truthy if runner is tagged"
[state]
(or (pos? (get-in @state [:runner :tag :is-tagged] 0))
(pos? (count-tags state))))
10 changes: 4 additions & 6 deletions src/cljs/nr/gameboard.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
(:require [cljs.core.async :refer [chan put! <!] :as async]
[clojure.string :refer [capitalize includes? join lower-case split]]
[differ.core :as differ]
[jinteki.utils :refer [str->int]]
[jinteki.utils :refer [str->int is-tagged?] :as utils]
[jinteki.cards :refer [all-cards]]
[nr.appstate :refer [app-state]]
[nr.auth :refer [avatar] :as auth]
[nr.cardbrowser :refer [add-symbols] :as cb]
[nr.utils :refer [influence-dot map-longest toastr-options]]
[nr.ws :as ws]
[reagent.core :as r]
[jinteki.utils :as utils]))
[reagent.core :as r]))

(defonce game-state (r/atom {}))
(defonce last-state (atom {}))
Expand Down Expand Up @@ -1519,7 +1518,7 @@
[cond-button "Remove Tag"
(and (pos? (:click @me))
(>= (:credit @me) (- 2 (or (:tag-remove-bonus @me) 0)))
(pos? (:tag @me)))
(pos? (get-in @me [:tag :base])))
#(send-command "remove-tag")]
[:div.run-button
[cond-button "Run" (and (pos? (:click @me))
Expand All @@ -1537,8 +1536,7 @@
(when (= side :corp)
[cond-button "Trash Resource" (and (pos? (:click @me))
(>= (:credit @me) (- 2 (or (:trash-cost-bonus @me) 0)))
(or (pos? (:tagged @opponent))
(pos? (:tag @opponent))))
(is-tagged? game-state))
#(send-command "trash-resource")])
[cond-button "Draw" (and (pos? (:click @me)) (not-empty (:deck @me))) #(send-command "draw")]
[cond-button "Gain Credit" (pos? (:click @me)) #(send-command "credit")]]))])})))
Expand Down
Loading

0 comments on commit e655e46

Please sign in to comment.