aboutsummaryrefslogtreecommitdiff
path: root/gamemode/inventorysystem/skills/sh_skills.lua
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/inventorysystem/skills/sh_skills.lua')
-rw-r--r--gamemode/inventorysystem/skills/sh_skills.lua76
1 files changed, 54 insertions, 22 deletions
diff --git a/gamemode/inventorysystem/skills/sh_skills.lua b/gamemode/inventorysystem/skills/sh_skills.lua
index 27c3bad..9b6edd5 100644
--- a/gamemode/inventorysystem/skills/sh_skills.lua
+++ b/gamemode/inventorysystem/skills/sh_skills.lua
@@ -4,23 +4,29 @@
--local itm = nrequire("item.lua")
--local ste = nrequire("utility/stream.lua")
local inventory = nrequire("inventory/inventory.lua")
+local log = nrequire("log.lua")
--local col = nrequire("config/colortheme.lua")
+local sc = nrequire("skills/sh_skillcommon.lua")
local inv = {}
if CLIENT then inv = nrequire("cl_skills.lua") end
-inv.allskills = {
+--TODO: uncomment these as their minigames are implemented
+inv.allskills = {}
+--[[
["forageing"] = {
- "hunting",
- "butchering",
- "woodcutting",
- "plant identification",
- "archery",
+-- "Hunting",
+-- "Butchering",
+-- "Woodcutting",
+-- "plant identification",
+-- "archery",
+-- "fishing",
+-- "Mineing",
},
["farming"] = {
- "domestication",
- "sowing",
- "arboriculture",
- "apiarism",
- "reaping",
+-- "domestication",
+-- "sowing",
+-- "arboriculture",
+-- "apiarism",
+-- "reaping",
},
["artisanship"] = {
"pottery",
@@ -44,6 +50,8 @@ inv.allskills = {
"painting",
"performing",
"faith",
+ "engraving",
+ "architect",
},
["adventuring"] = {
"evasion",
@@ -51,6 +59,7 @@ inv.allskills = {
"lockpicking",
"willpower",
"dexterity",
+ "swimming",
"sailing",
},
["fighting"] = {
@@ -66,14 +75,20 @@ inv.allskills = {
"archery",
}
}
-
+]]
inv.Name = "Skills"
inv.skills = {}
-for k,v in pairs(inv.allskills) do
- for i,j in pairs(v) do
- inv.skills[j] = 0
+local function calculate_skills()
+ for k,v in pairs(sc.SkillList()) do
+ for i,j in pairs(v) do
+ print("settings inv's skills' ", j, " to 0")
+ inv.skills[j] = 0
+ end
end
+ print("After calculating skills, inv was")
+ PrintTable(inv)
end
+calculate_skills()
--[[
item should be
@@ -84,11 +99,16 @@ item should be
}
]]
inv.FindPlaceFor = function(self, item)
- if item.isskill == nil then
+ print("finding place for ")
+ PrintTable(item)
+ if not item.isskill then
return nil
end
-
- if self.skills[item.name] then
+ print("Skill inventory trying to find place for, looking in ")
+ PrintTable(inv.skills)
+ print("for")
+ print(item.name)
+ if inv.skills[item.name] then
return {item.name}
else
return nil
@@ -96,11 +116,13 @@ inv.FindPlaceFor = function(self, item)
end
inv.CanFitIn = function(self,position,item)
- return self.skills[position[1]] != nil
+ return sc.SkillList()[position[1]] != nil
end
inv.Put = function(self,position,item)
- self.skills[position[1]] = self.skills[position[1]] + item.ammt
+ print("item is")
+ PrintTable(item)
+ self.skills[position[1]] = (self.skills[position[1]] or 0) + item.ammt
end
inv.Has = function(self,string_or_compare_func)
@@ -130,10 +152,20 @@ end
inv.DeSerialize = function(self,data)
if data == nil or data == '' then
- return table.Copy(self)
+ return table.Copy(inv)
end
+ calculate_skills()
+ print("At the time we deserialized, sc.skilllist was")
+ PrintTable(sc.SkillList())
+ print("Before making a copy of, inv is")
+ PrintTable(inv)
local cpy = table.Copy(self)
- cpy.skills = util.JSONToTable(data)
+ local gen = util.JSONToTable(data)
+ for k,v in pairs(gen) do
+ cpy.skills[k] = v
+ end
+ print("AFter deserializing inventory, it is")
+ PrintTable(cpy)
return cpy
end