diff Main.lua @ 30:bdb3d8a2c3a7

Slight re-structuring for proper serialization in the web service.
author James D. Callahan III <jcallahan@curse.com>
date Tue, 22 May 2012 14:49:39 -0500
parents 5802628b2bf0
children 728f1e5dcdc8
line wrap: on
line diff
--- a/Main.lua	Tue May 22 12:38:35 2012 -0500
+++ b/Main.lua	Tue May 22 14:49:39 2012 -0500
@@ -109,6 +109,7 @@
     local instance_token = InstanceDifficultyToken()
     npc.encounter_data = npc.encounter_data or {}
     npc.encounter_data[instance_token] = npc.encounter_data[instance_token] or {}
+    npc.encounter_data[instance_token].stats = npc.encounter_data[instance_token].stats or {}
     return npc
 end
 
@@ -356,7 +357,7 @@
         return
     end
     local zone_name, area_id, x, y, map_level, instance_token = CurrentLocationData()
-    local npc_data = NPCEntry(unit_idnum).encounter_data[instance_token][("level_%d"):format(_G.UnitLevel("target"))]
+    local npc_data = NPCEntry(unit_idnum).encounter_data[instance_token].stats[("level_%d"):format(_G.UnitLevel("target"))]
     local location_token = ("%s:%d"):format(zone_name, area_id)
     npc_data.locations = npc_data.locations or {}
     npc_data.locations[location_token] = npc_data.locations[location_token] or {}
@@ -423,7 +424,7 @@
     if not npc then
         return
     end
-    local encounter_data = npc.encounter_data[InstanceDifficultyToken()]
+    local encounter_data = npc.encounter_data[InstanceDifficultyToken()].stats
     encounter_data[action_data.npc_level].reputations = encounter_data[action_data.npc_level].reputations or {}
     encounter_data[action_data.npc_level].reputations[faction_name] = amount
 end
@@ -777,7 +778,7 @@
         npc.is_pvp = _G.UnitIsPVP("target") and true or nil
         npc.reaction = ("%s:%s:%s"):format(_G.UnitLevel("player"), _G.UnitFactionGroup("player"), REACTION_NAMES[_G.UnitReaction("player", "target")])
 
-        local encounter_data = npc.encounter_data[InstanceDifficultyToken()]
+        local encounter_data = npc.encounter_data[InstanceDifficultyToken()].stats
         local npc_level = ("level_%d"):format(_G.UnitLevel("target"))
 
         if not encounter_data[npc_level] then