This commit is contained in:
2021-05-21 12:58:00 -06:00
parent 4f5f0a4d41
commit 64ea5c79c9
11 changed files with 32 additions and 19 deletions

View File

@@ -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

View File

@@ -1 +1 @@
{"name":"Villain Alcohol","id":"song1","components":{"Tag":["song"]}} {"name":"Villain Alcohol","id":"song1","components":[["Tag", ["song"]]]}

View File

@@ -10,6 +10,7 @@
"classPath": "src/", "classPath": "src/",
"main": "nap.Main", "main": "nap.Main",
"dependencies": { "dependencies": {
"kiss": "" "kiss": "",
"tink_json": ""
} }
} }

View File

@@ -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;

View File

@@ -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"))

View File

@@ -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 {}

View File

@@ -1,3 +0,0 @@
(defnew [&prop :String name]
[:String id (Uuid.v4)
:Map<String,kiss.List<Dynamic>> components (new Map)])

View File

@@ -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;

View File

@@ -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)))

View File

@@ -0,0 +1,2 @@
(defun :Array<String> getTags [:Entry e]
(or (dictGet e.components "Tag") []))

View File

@@ -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)))