nap work
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
-lib uuid
|
-lib uuid
|
||||||
-lib kiss
|
-lib kiss
|
||||||
-lib hscript
|
-lib hscript
|
||||||
|
-lib tink_json
|
||||||
-cp src
|
-cp src
|
||||||
--main nap.Main
|
--main nap.Main
|
||||||
--interp
|
--interp
|
@@ -1 +1 @@
|
|||||||
{"name":"Villain Alcohol","id":"song1","components":{"Tag":["song"]}}
|
{"name":"Villain Alcohol","id":"song1","components":[["Tag", ["song"]]]}
|
@@ -10,6 +10,7 @@
|
|||||||
"classPath": "src/",
|
"classPath": "src/",
|
||||||
"main": "nap.Main",
|
"main": "nap.Main",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"kiss": ""
|
"kiss": "",
|
||||||
|
"tink_json": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -3,7 +3,8 @@ package nap;
|
|||||||
import kiss.Prelude;
|
import kiss.Prelude;
|
||||||
import sys.FileSystem;
|
import sys.FileSystem;
|
||||||
import sys.io.File;
|
import sys.io.File;
|
||||||
import haxe.Json;
|
import tink.Json;
|
||||||
|
import nap.systems.TagSystem;
|
||||||
|
|
||||||
using haxe.io.Path;
|
using haxe.io.Path;
|
||||||
|
|
||||||
|
@@ -1,10 +1,13 @@
|
|||||||
(defnew [archiveDir]
|
(defnew [archiveDir]
|
||||||
[:Map<String,Entry> entries
|
[:Map<String,Entry> entries
|
||||||
(let [entryFiles (FileSystem.readDirectory archiveDir)]
|
(let [entryFiles (FileSystem.readDirectory archiveDir)]
|
||||||
(for file entryFiles =>(file.withoutExtension) ~(Json.parse (File.getContent (Path.join [archiveDir file])))))
|
(for file entryFiles =>(file.withoutExtension) ~(the Entry (Json.parse (File.getContent (Path.join [archiveDir file]))))))
|
||||||
:Array<System> systems []] // TODO also create systems
|
:Array<System> systems [
|
||||||
// TODO register entities to systems that want them
|
(the System (new TagSystem "song"))]]
|
||||||
)
|
(doFor system systems
|
||||||
|
(doFor =>id entry entries
|
||||||
|
(when (system.canProcessEntry entry)
|
||||||
|
(system.entries.push entry)))))
|
||||||
|
|
||||||
(defmethod :Void handleEvent [:Event e]
|
(defmethod :Void handleEvent [:Event e]
|
||||||
(throw "can't handle $e"))
|
(throw "can't handle $e"))
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
package nap;
|
package nap;
|
||||||
|
|
||||||
import kiss.Kiss;
|
typedef Entry = {
|
||||||
import kiss.Prelude;
|
id:String,
|
||||||
import uuid.Uuid;
|
name:String,
|
||||||
|
components:Map<String, Array<Dynamic>>
|
||||||
@:build(kiss.Kiss.build())
|
};
|
||||||
class Entry {}
|
|
||||||
|
@@ -1,3 +0,0 @@
|
|||||||
(defnew [&prop :String name]
|
|
||||||
[:String id (Uuid.v4)
|
|
||||||
:Map<String,kiss.List<Dynamic>> components (new Map)])
|
|
@@ -1,5 +1,6 @@
|
|||||||
package nap;
|
package nap;
|
||||||
|
|
||||||
|
import uuid.Uuid;
|
||||||
import kiss.Prelude;
|
import kiss.Prelude;
|
||||||
import kiss.Stream;
|
import kiss.Stream;
|
||||||
import hscript.Parser;
|
import hscript.Parser;
|
||||||
|
@@ -6,4 +6,10 @@
|
|||||||
(new BoolExpInterp)]
|
(new BoolExpInterp)]
|
||||||
(doFor condition activeConditions
|
(doFor condition activeConditions
|
||||||
(interp.variables.set condition true))
|
(interp.variables.set condition true))
|
||||||
?(interp.execute hscriptExp)))
|
?(interp.execute hscriptExp)))
|
||||||
|
|
||||||
|
(defun :Entry newEntry [:String name]
|
||||||
|
(object
|
||||||
|
id (Uuid.v4)
|
||||||
|
name name
|
||||||
|
components (new Map)))
|
@@ -0,0 +1,2 @@
|
|||||||
|
(defun :Array<String> getTags [:Entry e]
|
||||||
|
(or (dictGet e.components "Tag") []))
|
@@ -1,4 +1,6 @@
|
|||||||
(defnew [&prop :String tagFilterString])
|
(load "../components/Tag.kiss")
|
||||||
|
|
||||||
|
(defnew [&prop :String tagFilterString] [])
|
||||||
|
|
||||||
(defmethod &override :Bool canProcessEntry [:Entry e]
|
(defmethod &override :Bool canProcessEntry [:Entry e]
|
||||||
)
|
(Lib.evalBoolExp tagFilterString (getTags e)))
|
Reference in New Issue
Block a user