From cf44afc6dfaf277292125eedcc0de5159353b038 Mon Sep 17 00:00:00 2001 From: = Date: Mon, 15 Sep 2014 12:50:35 -0700 Subject: [PATCH] simplifying script api. --- desktop/src-common/advent/action_test2.clj | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/desktop/src-common/advent/action_test2.clj b/desktop/src-common/advent/action_test2.clj index 94fb1d36..51c99b18 100644 --- a/desktop/src-common/advent/action_test2.clj +++ b/desktop/src-common/advent/action_test2.clj @@ -1,5 +1,5 @@ (ns advent.action-test2 - (:require [clojure.core.async :refer [put! ! chan go take! alts!!]])) + (:require [clojure.core.async :refer [put! ! chan go thread take! alts!!]])) (defprotocol IAction (begin [this state]) @@ -30,7 +30,7 @@ (terminate [this state] (put! c state) state))) - c)) + (! action-channel :end)))) + (talk action-channel :ego "I have enough money to buy something") + (talk action-channel :ego "I'm broke.")))))) (defn test-run [] (let [state {:x 0 :y 0 :time 0 :items #{} :current-action nil} action-channel (chan) - actions (run-script state action-channel)] + script (run-script state action-channel) + ] + (script action-channel) (loop [state state current-action nil started? false]