├── figwheel-main.edn ├── .gitignore ├── resources └── public │ ├── ohno.png │ ├── oops.gif │ ├── yay.png │ ├── welcome.png │ ├── good-luck.png │ ├── you-did-it.gif │ ├── math.html │ ├── migration.html │ ├── style.css │ ├── index.html │ └── js │ └── prod2.js ├── .dir-locals.el ├── prod.cljs.edn ├── dev.cljs.edn ├── deps.edn └── src └── kittycatmeowmeow ├── main.cljs ├── migration.cljs └── math.cljs /figwheel-main.edn: -------------------------------------------------------------------------------- 1 | {:css-dirs ["resources/public"] 2 | :ring-server-options {:port 8765}} 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.cpcache/ 2 | /.nrepl-port 3 | /resources/public/js/dev.js 4 | /resources/public/js/dev 5 | -------------------------------------------------------------------------------- /resources/public/ohno.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magnars/kittycatmeowmeow/master/resources/public/ohno.png -------------------------------------------------------------------------------- /resources/public/oops.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magnars/kittycatmeowmeow/master/resources/public/oops.gif -------------------------------------------------------------------------------- /resources/public/yay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magnars/kittycatmeowmeow/master/resources/public/yay.png -------------------------------------------------------------------------------- /resources/public/welcome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magnars/kittycatmeowmeow/master/resources/public/welcome.png -------------------------------------------------------------------------------- /resources/public/good-luck.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magnars/kittycatmeowmeow/master/resources/public/good-luck.png -------------------------------------------------------------------------------- /resources/public/you-did-it.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magnars/kittycatmeowmeow/master/resources/public/you-did-it.gif -------------------------------------------------------------------------------- /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ((nil 2 | (cider-clojure-cli-global-options . "-A:dev") 3 | (cider-default-cljs-repl . figwheel-main) 4 | (cider-figwheel-main-default-options . ":dev"))) 5 | -------------------------------------------------------------------------------- /prod.cljs.edn: -------------------------------------------------------------------------------- 1 | {:main kittycatmeowmeow.main 2 | :optimizations :advanced 3 | :asset-path "/js/prod2" 4 | :output-to "resources/public/js/prod2.js" 5 | :output-dir "resources/public/js/prod2"} 6 | -------------------------------------------------------------------------------- /dev.cljs.edn: -------------------------------------------------------------------------------- 1 | {:main kittycatmeowmeow.main 2 | :optimizations :none 3 | :pretty-print true 4 | :source-map true 5 | :asset-path "/js/dev" 6 | :output-to "resources/public/js/dev.js" 7 | :output-dir "resources/public/js/dev"} 8 | -------------------------------------------------------------------------------- /deps.edn: -------------------------------------------------------------------------------- 1 | {:paths ["src"] 2 | :deps {org.clojure/clojure {:mvn/version "1.10.0"} 3 | org.clojure/clojurescript {:mvn/version "1.10.439"} 4 | cjohansen/dumdom {:mvn/version "2019.02.03-3"} 5 | org.clojure/core.async {:mvn/version "0.4.490"}} 6 | :aliases {:dev {:extra-paths ["resources"] 7 | :extra-deps {com.bhauman/figwheel-main {:mvn/version "0.2.0-SNAPSHOT"}}}}} 8 | -------------------------------------------------------------------------------- /resources/public/math.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/kittycatmeowmeow/migration.cljs:
--------------------------------------------------------------------------------
1 | (ns kittycatmeowmeow.migration
2 | (:require [cljs.core.async :refer [ current-question 1)
22 | "correct")} "Sad"]
23 | [:button {:onClick #(question-answered 1)} "Angry"]
24 | [:button {:onClick #(question-answered 1)} "Emotionless"]]
25 | (when (>= current-question 2)
26 | [:div
27 | [:p "How did people migrate far away in the old days?"]
28 | [:button {:onClick #(question-answered 2)
29 | :className (when (> current-question 2)
30 | "correct")} "Boat"]
31 | [:button {:onClick #(question-answered 2)} "Walk"]
32 | [:button {:onClick #(question-answered 2)} "Plane"]
33 | [:button {:onClick #(question-answered 2)} "Car"]])
34 | (when (>= current-question 3)
35 | [:div
36 | [:p "How do most people migrate now?"]
37 | [:button {:onClick #(question-answered 3)} "Walk"]
38 | [:button {:onClick #(question-answered 3)} "Car"]
39 | [:button {:onClick #(question-answered 3)} "Boat"]
40 | [:button {:onClick #(question-answered 3)
41 | :className (when (> current-question 3)
42 | "correct")} "Plane"]])
43 | (when (>= current-question 4)
44 | [:div
45 | [:p "What is another way to say migrating to another country?"]
46 | [:button {:onClick #(question-answered 4)} "Moving To Another Place"]
47 | [:button {:onClick #(question-answered 4)
48 | :className (when (> current-question 4)
49 | "correct")} "External Migration"]
50 | [:button {:onClick #(question-answered 4)} "Internal Migration"]
51 | [:button {:onClick #(question-answered 4)} "Extreme Migration"]])
52 | (when (>= current-question 5)
53 | [:div
54 | [:p "What is another way to say migrating but you stay in the country"]
55 | [:button {:onClick #(question-answered 5)} "External Migration"]
56 | [:button {:onClick #(question-answered 5)} "Dangerous Migration"]
57 | [:button {:onClick #(question-answered 5)} "Closeby Migration"]
58 | [:button {:onClick #(question-answered 5)
59 | :className (when (> current-question 5)
60 | "correct")} "Internal Migration"]])])
61 |
62 | (defn render [state container]
63 | (dumdom/render [quiz state] container))
64 |
65 | (defn start! [container]
66 | (add-watch status ::me (fn [_ _ _ new-state]
67 | (render new-state container)))
68 | (render @status container))
69 |
70 | (swap! status update ::reload (fnil inc 0))
71 |
--------------------------------------------------------------------------------
/src/kittycatmeowmeow/math.cljs:
--------------------------------------------------------------------------------
1 | (ns kittycatmeowmeow.math
2 | (:require [cljs.core.async :refer [ %
50 | (assoc :hermione-img "good-luck.png")
51 | (assoc :current-question (create-addition-question))
52 | (assoc :show-correct-answer? false)
53 | (cond-> correct-answer?
54 | (update :questions-left dec))
55 | (cond-> (not correct-answer?)
56 | (update :remaining-lives dec))
57 | ))))))
58 |
59 | (defcomponent game [status]
60 | (let [question (:current-question status)]
61 | [:div
62 | [:img.right-img {:src (:hermione-img status)}]
63 | [:h1 "KittyCatMeowMeow Math Game"]
64 | (when (:won-the-game!!!!! status)
65 | [:p "You did it! Congratulations! You are really good at math!"])
66 | (when (:lost-the-game!!!!!!!!!!!! status)
67 | [:p "Oh, no! You lost the game! Maybe you want to try again?"])
68 | (when question
69 | [:div
70 | [:p
71 | (if (= 1 (:remaining-lives status))
72 | [:span "This is your last life! Don't get wrong! "]
73 | [:span "You have " (:remaining-lives status) " lives. "])
74 | (if (= 1 (:questions-left status))
75 | [:span "This is the final question!"]
76 | [:span "There are " (:questions-left status) " questions left."])]
77 | [:h2
78 | "What is "
79 | (:first-number question)
80 | (:operation question)
81 | (:second-number question)
82 | "?"]
83 | (for [answer (:possible-answers question)]
84 | [:button {:className (when (and (:show-correct-answer? status)
85 | (= answer (:correct-answer question)))
86 | "correct")
87 | :onClick #(check-answer question answer)}
88 | answer])])
89 | (when (not question)
90 | [:button {:onClick start-game}
91 | "Play Again"])
92 |
93 | ]))
94 |
95 | (defn render [state container]
96 | (dumdom/render [game state] container))
97 |
98 | (defn start! [container]
99 | (start-game)
100 | (add-watch status ::me (fn [_ _ _ new-state]
101 | (render new-state container)))
102 | (render @status container))
103 |
104 | (swap! status update ::reload (fnil inc 0))
105 |
--------------------------------------------------------------------------------
/resources/public/js/prod2.js:
--------------------------------------------------------------------------------
1 | if(typeof Math.imul == "undefined" || (Math.imul(0xffffffff,5) == 0)) {
2 | Math.imul = function (a, b) {
3 | var ah = (a >>> 16) & 0xffff;
4 | var al = a & 0xffff;
5 | var bh = (b >>> 16) & 0xffff;
6 | var bl = b & 0xffff;
7 | // the shift by 0 fixes the sign on the high part
8 | // the final |0 converts the unsigned value into a signed value
9 | return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
10 | }
11 | }
12 |
13 | !function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.snabbdom=a()}}(function(){return function(){function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c||a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;ga.Xa.length))throw Error(["Assert failed: ",y.b(["No more than ",y.b(1024)," pending takes are allowed on a single channel."].join("")),"\n(\x3c (.-length takes) impl/MAX-QUEUE-SIZE)"].join(""));qk(a.Xa,c)}return null} 407 | Nk.prototype.eb=function(){var a=this;if(!a.closed)for(a.closed=!0,t(function(){var b=a.F;return t(b)?0===a.wa.length:b}())&&(a.na.b?a.na.b(a.F):a.na.call(null,a.F));;){var c=a.Xa.pop();if(null!=c){var b=c.oa,d=t(function(){var b=a.F;return t(b)?0
b)return a;a:for(;;){var e=b