Two or more Chakanas disable advancing agendas
At one point my opponent had 3 Chakanas out and I was not able to advance my agenda at all. Later he had 2, same happened. When he only had 1 I was able to advance. When I was not able to advance the log said I advanced a card (didn't specify in which server) but the agenda never got an advancement token, even after multiple times.
I wanted to try this and the following happened:
New game.
Corp installs agenda, take credit, take credit.
Runner installs Chakana, take credit, take credit, take credit.
Corp starts turn, exception:
game.main=> Error do start-turn nil #
Stack trace: [clojure.lang.Numbers.ops(Numbers.java:961), clojure.lang.Numbers.gte(Numbers.java:231), clojure.lang.Numbers.gte(Numbers.java:3811), game.core$fn__7716.invoke(cards-programs.clj:46), game.core$trigger_event.doInvoke(core.clj:409), clojure.lang.RestFn.invoke(RestFn.java:467), game.core$update_advancement_cost.invoke(core.clj:1110), game.core$update_all_advancement_costs.invoke(core.clj:1106), game.core$start_turn.invoke(core.clj:917), game.main$run$fn__10149.invoke(main.clj:61), game.main$run.invoke(main.clj:57), game.main$dev.invoke(main.clj:83), clojure.core$binding_conveyor_fn$fn__4145.invoke(core.clj:1910), clojure.lang.AFn.call(AFn.java:18), java.util.concurrent.FutureTask.run(Unknown Source), java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source), java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source), java.lang.Thread.run(Unknown Source)]
The problem is that the card that gets passed to Chakana's {:req (req... via the event system is not the actual card that is in play. It has no :counter property, hence get-virus-counters returns nil.
It could be improved to
--- a/src/clj/game/core.clj
+++ b/src/clj/game/core.clj
@@ -941,7 +941,7 @@
(defn get-virus-counters [state side card]
(let [hiveminds (filter #(= (:title %) "Hivemind") (all-installed state :runner))]
- (reduce + (map :counter (cons card hiveminds)))))
+ (reduce + (map #(get :counter % 0) (cons card hiveminds)))))
but still Chakana would not work because if the card passed to req has no counter, it effect will never fire.
The card passed to an event is supposed to always be the data of the card handling the event. (trigger-event calls get-card to get the most recent version of the card handling the event, and then passes that copy of the card data to the event handler.) Something is wrong if that's not the case... hmm...
I'll will further investigate this
Any progress on this?
Uh... Sorry, totally forgot about this one
I have verified @queueseven's proposed fix and will submit a patch. The issue is that get-virus-counters doesn't like it when the virus in question doesn't have any counters (specifically, if it started with 0 counters and hasn't gained any -- it's fine if counters have been spent down to 0).
There are a few things that I don't quite understand... Parasite works just fine without any counters, but Chakana was definitely crashing without any, and I don't see why Parasite's (- (get-virus- counters ...)) is fine with nil as the counters, but Chakana's (>= (get-virus-counters ...) 3) isn't. Oh well.
In the end, it's not 2 Chakanas causing the crash, it's a single Chakana with no counters.