diff options
| author | Alexander M Pickering <alex@cogarr.net> | 2024-01-29 16:20:10 -0600 |
|---|---|---|
| committer | Alexander M Pickering <alex@cogarr.net> | 2024-01-29 16:20:10 -0600 |
| commit | c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06 (patch) | |
| tree | ac2bb208dab1274cdc5e9059ffe014ae19181a4c /src/ability_reg.moon | |
| download | fools_rush_in-c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06.tar.gz fools_rush_in-c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06.tar.bz2 fools_rush_in-c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06.zip | |
All the files
Diffstat (limited to 'src/ability_reg.moon')
| -rw-r--r-- | src/ability_reg.moon | 43 |
1 files changed, 43 insertions, 0 deletions
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 |
