Module:VillageTest

From RetroMC
Revision as of 18:51, 17 January 2025 by Thecow275 (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:VillageTest/doc

local p  =  {}
local capiunto = require 'capiunto'


--[ Thecow275's WikiStats V2 VIllages MODULE PROTOTYPE ]
--[ Nicknamed: UUID and J-Village Update]

local function preprocessArg(s)
if not s then
    return nil 
end
s = s:match('^%s*(.-)%s*$') --trim whitespace
if s == '' then
    return nil
else
    return s
    end

end

function p.main(frame)
    local args = frame.args
    --local input = preprocessArg(args[1])
   -- local datatype = preprocessArg(args[2]) -- currently unused will be used whenever I implement more datatypes
   -- local UUIDORUSER = preprocessArg(args[3]) -- Selector for if input is username OR UUID
   -- local PlayerORVillage = preprocessArg(args[4]) -- Jesus christ argument just so you can specify if you are searching for village data YES village data
   -- this module will get bloated with the jvillage stuff but EHHH

   --if not input then -- CHECK FOR BLANK INPUT
   --    return 'INPUT ERROR INPUT IS NULL'
    --end

    local uuid = '8fa8f70d-eb7d-4743-b0ad-837cdfb69f4e'

    local villagedata = mw.ext.externalData.getExternalData({
        url =  "api.retromc.org/api/v1/village/getVillageList",
        format =  'json'

    })

    local playerVillages = mw.ext.externalData.getExternalData({
        url = "https://statistics.retromc.org/api/user_villages?uuid=" .. uuid,
        format = 'json',
        data = {data='data.assistant.village',status='status'}

    })
    
    local retval = capiunto.create({
        top = 'TESTING',
        bodyClass = 'icr-DiamondCitizenBodyStyle',
        topClass = 'icr-title'
    })

    retval:addRow('HOWDY', 'HOWDEE', '', 'icr-transparency1 icr-data')

    local villagels = {"first"}
    if playerVillages.data then

        table.insert(villagels, "1st layer works")

    
        for member in ipairs(playerVillages.data.member) do   --maybe this needs to be for pairs in data and then again for ipairs in owner, member and assistant ? so maybe I need to create 2 tables for this and then handle it through that ?
            table.insert(villagels, playerVillages.data.member)
            table.insert(villagels, "debug")
            table.insert(villagels, playerVillages.data.member.village)
            retval:addRow('HOWDY'..playerVillages.data.member.village, playerVillages.data.member.village, '', 'icr-transparency1 icr-data')
            retval:addRow('TESTING','IT.RAN', '', 'icr-transparency1 icr-data')
            
        end
            
            
        
        
        
    end
    
    return playerVillages.data
end
return p