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 kiss
-lib hscript
-lib tink_json
-cp src
--main nap.Main
--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/",
"main": "nap.Main",
"dependencies": {
"kiss": ""
"kiss": "",
"tink_json": ""
}
}

View File

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

View File

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

View File

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

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;
import uuid.Uuid;
import kiss.Prelude;
import kiss.Stream;
import hscript.Parser;

View File

@@ -6,4 +6,10 @@
(new BoolExpInterp)]
(doFor condition activeConditions
(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]
)
(Lib.evalBoolExp tagFilterString (getTags e)))