nap work
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
-lib uuid
|
||||
-lib kiss
|
||||
-lib hscript
|
||||
-lib tink_json
|
||||
-cp src
|
||||
--main nap.Main
|
||||
--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/",
|
||||
"main": "nap.Main",
|
||||
"dependencies": {
|
||||
"kiss": ""
|
||||
"kiss": "",
|
||||
"tink_json": ""
|
||||
}
|
||||
}
|
@@ -3,7 +3,8 @@ package nap;
|
||||
import kiss.Prelude;
|
||||
import sys.FileSystem;
|
||||
import sys.io.File;
|
||||
import haxe.Json;
|
||||
import tink.Json;
|
||||
import nap.systems.TagSystem;
|
||||
|
||||
using haxe.io.Path;
|
||||
|
||||
|
@@ -1,10 +1,13 @@
|
||||
(defnew [archiveDir]
|
||||
[:Map<String,Entry> entries
|
||||
(let [entryFiles (FileSystem.readDirectory archiveDir)]
|
||||
(for file entryFiles =>(file.withoutExtension) ~(Json.parse (File.getContent (Path.join [archiveDir file])))))
|
||||
:Array<System> systems []] // TODO also create systems
|
||||
// TODO register entities to systems that want them
|
||||
)
|
||||
(for file entryFiles =>(file.withoutExtension) ~(the Entry (Json.parse (File.getContent (Path.join [archiveDir file]))))))
|
||||
:Array<System> systems [
|
||||
(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]
|
||||
(throw "can't handle $e"))
|
||||
|
@@ -1,8 +1,7 @@
|
||||
package nap;
|
||||
|
||||
import kiss.Kiss;
|
||||
import kiss.Prelude;
|
||||
import uuid.Uuid;
|
||||
|
||||
@:build(kiss.Kiss.build())
|
||||
class Entry {}
|
||||
typedef Entry = {
|
||||
id:String,
|
||||
name:String,
|
||||
components:Map<String, Array<Dynamic>>
|
||||
};
|
||||
|
@@ -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;
|
||||
|
||||
import uuid.Uuid;
|
||||
import kiss.Prelude;
|
||||
import kiss.Stream;
|
||||
import hscript.Parser;
|
||||
|
@@ -7,3 +7,9 @@
|
||||
(doFor condition activeConditions
|
||||
(interp.variables.set condition true))
|
||||
?(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]
|
||||
)
|
||||
(Lib.evalBoolExp tagFilterString (getTags e)))
|
Reference in New Issue
Block a user