Compare commits

..

No commits in common. "865404ffb75d5761fda5c8ac6863fe5cc86c89f6" and "158c1742fe2bfcff855ebf617ea24d46a71fe212" have entirely different histories.

3 changed files with 16 additions and 39 deletions

View file

@ -12,15 +12,11 @@ AltSystem.Data.SkillLevels = {
["Master"] = 4, ["Master"] = 4,
} }
-- The "Base roll" entry is always the first (default) skill -- The "Inept" entry is always the first (default) skill
local BASE_ROLL_ENTRY = { name = "Base roll", level = "Base", modifier = 0 }
-- The "Inept" entry is always the second skill
local UNSKILLED_ENTRY = { name = "Inept", level = "Inept", modifier = -4 } local UNSKILLED_ENTRY = { name = "Inept", level = "Inept", modifier = -4 }
-- Default/fallback skill list used when no TRP3 profile skills are found -- Default/fallback skill list used when no TRP3 profile skills are found
local DEFAULT_SKILLS = { local DEFAULT_SKILLS = {
{ name = "Base roll", level = "Base", modifier = 0 },
{ name = "Inept", level = "Inept", modifier = -4 }, { name = "Inept", level = "Inept", modifier = -4 },
{ name = "Novice Skill", level = "Novice", modifier = -2 }, { name = "Novice Skill", level = "Novice", modifier = -2 },
{ name = "Adept Skill", level = "Adept", modifier = 0 }, { name = "Adept Skill", level = "Adept", modifier = 0 },
@ -60,13 +56,12 @@ local function ParseSkillLevel(numericValue)
end end
-- Fetch skills from the current TRP3 profile's personality traits. -- Fetch skills from the current TRP3 profile's personality traits.
-- Returns an array of skill entries, always starting with "Base roll" and "Inept". -- Returns an array of skill entries, always starting with "Inept".
-- Falls back to the default list if no profile or no valid skills are found. -- Falls back to the default list if no profile or no valid skills are found.
function AltSystem.Data:RefreshSkills() function AltSystem.Data:RefreshSkills()
local skills = {} local skills = {}
-- Always add Base roll as the first entry, then Inept -- Always add Inept as the first entry
table.insert(skills, { name = BASE_ROLL_ENTRY.name, level = BASE_ROLL_ENTRY.level, modifier = BASE_ROLL_ENTRY.modifier })
table.insert(skills, { name = UNSKILLED_ENTRY.name, level = UNSKILLED_ENTRY.level, modifier = UNSKILLED_ENTRY.modifier }) table.insert(skills, { name = UNSKILLED_ENTRY.name, level = UNSKILLED_ENTRY.level, modifier = UNSKILLED_ENTRY.modifier })
local foundAny = false local foundAny = false
@ -94,7 +89,7 @@ function AltSystem.Data:RefreshSkills()
end end
end end
-- If no valid skills were found, use the default fallback list -- If no valid skills were found, use the default fallback list (skip first "Inept" since we already added it)
if not foundAny then if not foundAny then
skills = {} skills = {}
for _, skill in ipairs(DEFAULT_SKILLS) do for _, skill in ipairs(DEFAULT_SKILLS) do

View file

@ -20,26 +20,14 @@ end
local function BuildModifierString(modifiers) local function BuildModifierString(modifiers)
local parts = {} local parts = {}
for _, mod in ipairs(modifiers) do for _, mod in ipairs(modifiers) do
local sign = mod.value >= 0 and "+" or "" if mod.value ~= 0 then
table.insert(parts, sign .. mod.value .. " (" .. mod.name .. ")") local sign = mod.value >= 0 and "+" or ""
table.insert(parts, sign .. mod.value .. " (" .. mod.name .. ")")
end
end end
return table.concat(parts, " ") return table.concat(parts, " ")
end end
-- Send a message to the given channel, handling EMOTE specially
-- to avoid the message being redirected to raid chat when in a raid group.
local function SendToChannel(msg, channel)
if channel == "EMOTE" then
local editBox = ChatFrame1 and ChatFrame1.editBox or ChatFrame1EditBox
if editBox then
ChatFrame_OpenChat("/e " .. msg, ChatFrame1)
ChatEdit_SendText(editBox)
end
return
end
SendChatMessage(msg, channel)
end
-- Announce the roll result to the selected chat channel -- Announce the roll result to the selected chat channel
local function AnnounceRoll(rollValue, modifiers, total) local function AnnounceRoll(rollValue, modifiers, total)
if not AltSystem.State.announceEnabled then return end if not AltSystem.State.announceEnabled then return end
@ -57,7 +45,7 @@ local function AnnounceRoll(rollValue, modifiers, total)
msg = name .. " rolled " .. rollValue .. " = " .. total msg = name .. " rolled " .. rollValue .. " = " .. total
end end
SendToChannel(msg, channelDef.channel) SendChatMessage(msg, channelDef.channel)
end end
-- Perform a roll: triggers the WoW native /roll 20 command -- Perform a roll: triggers the WoW native /roll 20 command
@ -94,7 +82,7 @@ function AltSystem:CalculateAndDisplayResult(rollType, rollValue)
if AltSystem.State.announceEnabled then if AltSystem.State.announceEnabled then
local channelDef = AltSystem.AnnounceChannels[AltSystem.State.announceChannelIndex] local channelDef = AltSystem.AnnounceChannels[AltSystem.State.announceChannelIndex]
if channelDef then if channelDef then
SendToChannel(GetCharacterName() .. " rolled a Critical Failure!", channelDef.channel) SendChatMessage(GetCharacterName() .. " rolled a Critical Failure!", channelDef.channel)
end end
end end
return return
@ -105,7 +93,7 @@ function AltSystem:CalculateAndDisplayResult(rollType, rollValue)
if AltSystem.State.announceEnabled then if AltSystem.State.announceEnabled then
local channelDef = AltSystem.AnnounceChannels[AltSystem.State.announceChannelIndex] local channelDef = AltSystem.AnnounceChannels[AltSystem.State.announceChannelIndex]
if channelDef then if channelDef then
SendToChannel(GetCharacterName() .. " rolled a Critical Success!", channelDef.channel) SendChatMessage(GetCharacterName() .. " rolled a Critical Success!", channelDef.channel)
end end
end end
return return
@ -123,16 +111,12 @@ function AltSystem:CalculateAndDisplayResult(rollType, rollValue)
local modifiers = {} local modifiers = {}
local isBaseRoll = skill and skill.name == "Base roll"
if rollType == "attack" then if rollType == "attack" then
-- Attack Roll = roll + skill modifier + item modifier -- Attack Roll = roll + skill modifier + item modifier
total = rollValue + skillMod + itemMod total = rollValue + skillMod + itemMod
if not isBaseRoll then breakdown = breakdown .. "\nSkill: " .. FormatModifier(skillMod)
breakdown = breakdown .. "\nSkill: " .. FormatModifier(skillMod) table.insert(modifiers, { name = skill and skill.name or "Skill", value = skillMod })
table.insert(modifiers, { name = skill and skill.name or "Skill", value = skillMod })
end
if itemMod ~= 0 then if itemMod ~= 0 then
breakdown = breakdown .. " | Item: " .. FormatModifier(itemMod) breakdown = breakdown .. " | Item: " .. FormatModifier(itemMod)
table.insert(modifiers, { name = item and item.name or "Item", value = itemMod }) table.insert(modifiers, { name = item and item.name or "Item", value = itemMod })
@ -147,10 +131,8 @@ function AltSystem:CalculateAndDisplayResult(rollType, rollValue)
total = rollValue + skillMod + itemMod + defenseMod + shieldMod total = rollValue + skillMod + itemMod + defenseMod + shieldMod
if not isBaseRoll then breakdown = breakdown .. "\nSkill: " .. FormatModifier(skillMod)
breakdown = breakdown .. "\nSkill: " .. FormatModifier(skillMod) table.insert(modifiers, { name = skill and skill.name or "Skill", value = skillMod })
table.insert(modifiers, { name = skill and skill.name or "Skill", value = skillMod })
end
if itemMod ~= 0 then if itemMod ~= 0 then
breakdown = breakdown .. " | Item: " .. FormatModifier(itemMod) breakdown = breakdown .. " | Item: " .. FormatModifier(itemMod)
table.insert(modifiers, { name = item and item.name or "Item", value = itemMod }) table.insert(modifiers, { name = item and item.name or "Item", value = itemMod })

2
UI.lua
View file

@ -16,7 +16,7 @@ local function BuildSkillOptions()
for _, skill in ipairs(AltSystem.Data.Skills) do for _, skill in ipairs(AltSystem.Data.Skills) do
local sign = skill.modifier >= 0 and "+" or "" local sign = skill.modifier >= 0 and "+" or ""
local text local text
if skill.level == "Base" or skill.level == "Inept" then if skill.level == "Inept" then
text = skill.name .. " (" .. sign .. skill.modifier .. ")" text = skill.name .. " (" .. sign .. skill.modifier .. ")"
else else
text = skill.name .. " (" .. skill.level .. " " .. sign .. skill.modifier .. ")" text = skill.name .. " (" .. skill.level .. " " .. sign .. skill.modifier .. ")"