npm.io
7.36.0 • Published 3d ago

@quenty/adorneedata

Licence
MIT
Version
7.36.0
Deps
0
Vulns
0
Weekly
0
Stars
600

AdorneeData

Bridges attributes and serialization

Installation

npm install @quenty/adorneedata --save

Requirements

These are the requirements for this attribute data library.

  • Not like Tie in that it is focused on serialization/boundary between Roblox and our stuff (tie is interfaces separated by network boundary)
  • Easy to transform between data and attributes
  • No service bag requirements
Centralized definition with no server/client information
return AdorneeData.new({
  CurrencyColor = Color3.new();
  CurrencyNameTranslationKey = "";
  CurrencyFormatTranslationKey = "";
  CurrencyImageId = "";
  CurrencyShowType = CurrencyShowTypes.NONE;
  GivePlayerCurrency = false;
  CurrencySaves = false;
})
Easy to write/author

We should be able to create new data that is validated

CurrencyDefinitionData:CreateData({
  CurrencyKey = CurrencyDefinitionConstants.DEFAULT_CURRENCY_KEY
  CurrencyColor = Color3.fromRGB(55, 180, 74)
  CurrencyTranslationKey = "currency.default.name"
  CurrencyFormatTranslationKey = "currency.default.format"
  DoesSave = true
  ImageId = "rbxassetid://10049671651"
})

We should be able to create partial data

CurrencyDefinitionData:CreatePartialData({
  CurrencyKey = CurrencyDefinitionConstants.DEFAULT_CURRENCY_KEY
  CurrencyColor = Color3.fromRGB(55, 180, 74)
  CurrencyTranslationKey = "currency.default.name"
  CurrencyFormatTranslationKey = "currency.default.format"
  DoesSave = true
  ImageId = "rbxassetid://10049671651"
})
Additional authorship requirements
  • Should be able to set optional values
Easy to validate/assert/assign

We should be able to check data types

function CurrencyService:InitCurrencyDefinition(currencyDefinitionData)
  assert(CurrencyDefinitionData:IsData(currencyDefinitionData), "Bad currencyDefinitionData")

  local currencyDefinition = CurrencyDefinition:Create("Folder")
  CurrencyDefinitionData:SetAttributes(currencyDefinition, currencyDefinitionData)

  return currencyDefinition
end
Replacement files

Should replace following files:

  • CurrencyDefinitionDataUtils - Files with t interface asserting type
  • CurrencyDefinitionConstants - Files with constant attribute names
  • CurrencyDefinitionUtils - File that sets certain properties or attributes and do validation
Easy to serialize

Should be able to flash to constant

Keywords