Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Base for powers
Browse files Browse the repository at this point in the history
  • Loading branch information
ShamblesSM committed Jan 11, 2023
1 parent 7f830d1 commit 0d9f500
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/ConfigManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local ConfigManager = class:derive("ConfigManager")
local CollectibleGeneratorManager = require("src/CollectibleGenerator/Manager")

local ShooterConfig = require("src/Configs/Shooter")
local Power = require("src/Configs/Power")



Expand Down Expand Up @@ -56,7 +57,7 @@ function ConfigManager:new()
self.collectibles = self:loadFolder("config/collectibles", "collectible")
self.spheres = self:loadFolder("config/spheres", "sphere", true)
self.sphereEffects = self:loadFolder("config/sphere_effects", "sphere effect")
self.colorGenerators = self:loadFolder("config/color_generators", "color generator")
self.colorGenerators = self:loadFolder("config/color_generators", "color generator")

self.collectibleGeneratorManager = CollectibleGeneratorManager()

Expand All @@ -82,6 +83,7 @@ end
---Loads config files which are implemented the new way so that they require to be loaded after the resources.
function ConfigManager:loadStuffAfterResources()
self.shooters = self:loadFolder("config/shooters", "shooter", false, ShooterConfig)
self.powers = self:loadFolder("config/powers", "power", false, Power)
end


Expand Down Expand Up @@ -123,6 +125,15 @@ end



---Returns a power config for a given shooter name.
---@param name string The name of the power.
---@return Power
function ConfigManager:getPower(name)
return self.powers[name]
end



---Returns the game name if specified, else the internal (folder) name.
---@return string
function ConfigManager:getGameName()
Expand Down
31 changes: 31 additions & 0 deletions src/Configs/Power.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
local class = require "com/class"

---@class Power
---@overload fun(data):Power
local Power = class:derive("Power")

local Profile = require("src/Profile")



---Initialize a new Power.
---@param data table Raw data parsed from `config/powers/*.json`.
---@param path string Path to the file. The file is not loaded here, but is used in error messages.
function Power:new(data, path)
self.name = data.name
self._path = path
self.displayName = data.displayName
self.type = data.type
end



function Power:isEquipped()
for i, power in ipairs(_Game:getCurrentProfile().equippedPowers) do

end
end



return Power
11 changes: 10 additions & 1 deletion src/Profile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ function Profile:new(data, name)
self.levels = {}
self.checkpoints = {}
self.variables = {}
self.equippedPowers = {}
self.equippedFood = nil
self.colorblindMode = false

if data then
self:deserialize(data)
Expand Down Expand Up @@ -511,7 +514,10 @@ function Profile:serialize()
session = self.session,
levels = self.levels,
checkpoints = self.checkpoints,
variables = self.variables,
variables = self.variables,
equippedPowers = self.equippedPowers,
equippedFood = self.equippedFood,
colorblindMode = self.colorblindMode,
ultimatelySatisfyingMode = self.ultimatelySatisfyingMode
}
return t
Expand All @@ -528,6 +534,9 @@ function Profile:deserialize(t)
if t.variables then
self.variables = t.variables
end
self.equippedPowers = t.equippedPowers
self.equippedFood = t.equippedPowers
self.colorblindMode = t.colorblindMode
self.ultimatelySatisfyingMode = t.ultimatelySatisfyingMode
end

Expand Down

0 comments on commit 0d9f500

Please sign in to comment.