From c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06 Mon Sep 17 00:00:00 2001 From: Alexander M Pickering Date: Mon, 29 Jan 2024 16:20:10 -0600 Subject: All the files --- src/ability_reg.moon | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/ability_reg.moon (limited to 'src/ability_reg.moon') diff --git a/src/ability_reg.moon b/src/ability_reg.moon new file mode 100644 index 0000000..4724043 --- /dev/null +++ b/src/ability_reg.moon @@ -0,0 +1,43 @@ +ui = require "ui" +reg = ... + +reg.list = {} + +-- name - string, the name of the ability +-- infocard, the table of info and description to draw when looking at the ability +-- data, the table that contains data and functions for running the ability +-- visuals, the table of sprites that the data needs to function +class Ability + @children = {} + new: (name, data) => + @sprite = @@sprite + @name = name or @.__class.__name + @data = data + + @__inherited: (child) => + assert(child.use, "abilities must have a .use") + assert(type(child.use) == "function", "abilities must have a .use() function") + assert(type(child.load) == "function", "abilities must have a .load() that shows their infocard") + assert(type(child.unload) == "function", "abilities must have an .unload() that removes their infocard") + assert(child.text, "ability must have text") + assert(child.description, "ability must have a description") + assert(child.hits_icon, "ability must have a hits icon") + assert(child.speed, "ability must have a speed") + @@.children[child.__name] = child + reg[child.__name] = child + + load: () => + main = require "main" + infocard = am.group!\tag("infocard") + main.root("screen")\append(infocard) + ui.build_infocard(infocard,@@) + + unload: () => + main = require "main" + main.root\remove("infocard") + --__tostring: () => + -- return string.format("<%s, %s>",@.__class.__name, @name or ".name missing") + +reg["Ability"] = Ability + +return reg -- cgit v1.2.3-70-g09d2