Skip to content

Commit

Permalink
Reset sync
Browse files Browse the repository at this point in the history
Sync reset, Sync next hunter with rotation
  • Loading branch information
Slivo-fr authored Jun 15, 2021
1 parent 1fb319d commit b4029ac
Show file tree
Hide file tree
Showing 16 changed files with 108 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
libs
copy.sh
copy.sh
package.sh
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Please report any issue on github : https://github.com/Slivo-fr/TranqRotate/issu
- Display the frenzy cooldown of each boss
- Optional automatic backup call when incapacitated
- Optional automatic timed backup call
- Prints to chat name and reason of a tranq fail (miss or resist)
- Prints to chat the reason of a tranq fail (miss or resist)
- Show an indicator on hunters that does not use the addon

## Usage
Expand All @@ -49,8 +49,7 @@ You can now just pull the boss and start shooting your tranqshots, TranqRotate w

**Warning** : if all of your hunters does not use the addon, make sure someone with the addon stay within 45m range of hunters without the addon or you won't be able to register their tranqshot. MC and AQ40 tranq encounters might lead to range issues. However, I didn't had any complain about this yet :)

You can use the reset button in the top bar to reset the rotation state if it do not clear itself.
The reset button is also able to resync raid hunters and rotation setup if you need.
You can use the reset button in the top bar to reset the rotation status

You may adds the `/tranq backup` command to a macro that you can use when you are unable to tranq and you need some help,
It will whisper all backup hunters the fail message.
Expand Down
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## TranqRotate Changelog

#### v2.1.0

- Removes server suffixes from player names everywhere (connected realms)
- Adds an option to re-add shortened or full server suffixes to player names (in case of unlikely namesake)
- Adds rotation reset sync
- Removes the ability to re-sync tranq order from the reset button
- Adds highlighted "next" hunter to the tranq rotation sync

#### v2.0.0

- Fix connected realms sync issues - **BREAKING CHANGES**
Expand Down
7 changes: 5 additions & 2 deletions locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,17 @@ local L = {
["BROADCAST_ROTATION_PREFIX"] = "Rotation",
["BROADCAST_BACKUP_PREFIX"] = "Backup",

--- Blind icon tooltip
-- Blind icon tooltip
["TOOLTIP_PLAYER_WITHOUT_ADDON"] = "This player does not use TranqRotate",
["TOOLTIP_MAY_RUN_OUDATED_VERSION"] = "Or runs an outdated version below 1.6.0",
["TOOLTIP_DISABLE_SETTINGS"] = "(You can disable this icon and/or this tooltip in the settings)",

--- Available update
-- Available update
["UPDATE_AVAILABLE"] = "A new TranqRotate version is available, update to get latest features",
["BREAKING_UPDATE_AVAILABLE"] = "A new BREAKING TranqRotate update is available, you MUST update AS SOON AS possible! TranqRotate may not work properly with up-to-date version users.",

-- Rotation reset
["RESET_UNAUTHORIZED"] = "You must be raid assist to reset the rotation",
}

TranqRotate.L = L
7 changes: 5 additions & 2 deletions locales/frFR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,17 @@ local L = {
["BROADCAST_ROTATION_PREFIX"] = "Rotation",
["BROADCAST_BACKUP_PREFIX"] = "Backup",

--- Blind icon tooltip
-- Blind icon tooltip
["TOOLTIP_PLAYER_WITHOUT_ADDON"] = "Ce joueur n'utilise pas TranqRotate",
["TOOLTIP_MAY_RUN_OUDATED_VERSION"] = "Ou possède une version obsolète inférieure à 1.6.0",
["TOOLTIP_DISABLE_SETTINGS"] = "(Il est possible de désactiver l'icone et/ou l'infobulle dans les options)",

--- Available update
-- Available update
["UPDATE_AVAILABLE"] = "Une nouvelle version est disponible, faites la mise à jour pour profiter des derniers ajouts",
["BREAKING_UPDATE_AVAILABLE"] = "Une nouvelle version MAJEURE est disponible, vous DEVEZ faire la mise à jour le plus rapidement possible! Votre version pourrait ne pas fonctionner correctement avec celle des utilisateurs disposant de la mise à jour.",

-- Rotation reset
["RESET_UNAUTHORIZED"] = "Vous devez être assistant raid pour réinitialiser la rotation",
}

TranqRotate.L = L
7 changes: 5 additions & 2 deletions locales/ruRU.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,17 @@ local L = {
["BROADCAST_ROTATION_PREFIX"] = "Очередность",
["BROADCAST_BACKUP_PREFIX"] = "Запасные",

--- Blind icon tooltip
-- Blind icon tooltip
["TOOLTIP_PLAYER_WITHOUT_ADDON"] = "Этот игрок не использует TranqRotate",
["TOOLTIP_MAY_RUN_OUDATED_VERSION"] = "Или используется версия ниже 1.6.0",
["TOOLTIP_DISABLE_SETTINGS"] = "(Вы можете отключить этот значок и/или эту подсказку в настройках)",

--- Available update
-- Available update
["UPDATE_AVAILABLE"] = "A new TranqRotate version is available, update to get latest features",
["BREAKING_UPDATE_AVAILABLE"] = "A new BREAKING TranqRotate update is available, you MUST update AS SOON AS possible! TranqRotate may not work properly with up-to-date version users.",

-- Rotation reset
["RESET_UNAUTHORIZED"] = "You must be raid assist to reset the rotation",
}

TranqRotate.L = L
7 changes: 5 additions & 2 deletions locales/zhCN.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,17 @@ local L = {
["BROADCAST_ROTATION_PREFIX"] = "循环",
["BROADCAST_BACKUP_PREFIX"] = "替补",

--- Blind icon tooltip
-- Blind icon tooltip
["TOOLTIP_PLAYER_WITHOUT_ADDON"] = "此玩家没有使用TranqRotate插件",
["TOOLTIP_MAY_RUN_OUDATED_VERSION"] = "或者运行低于1.6.0的过时版本",
["TOOLTIP_DISABLE_SETTINGS"] = "(您可以在设置中禁用此图标或此工具提示)",

--- Available update
-- Available update
["UPDATE_AVAILABLE"] = "A new TranqRotate version is available, update to get latest features",
["BREAKING_UPDATE_AVAILABLE"] = "A new BREAKING TranqRotate update is available, you MUST update AS SOON AS possible! TranqRotate may not work properly with up-to-date version users.",

-- Rotation reset
["RESET_UNAUTHORIZED"] = "You must be raid assist to reset the rotation",
}

TranqRotate.L = L
7 changes: 5 additions & 2 deletions locales/zhTW.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,17 @@ local L = {
["BROADCAST_ROTATION_PREFIX"] = "循環",
["BROADCAST_BACKUP_PREFIX"] = "替補",

--- Blind icon tooltip
-- Blind icon tooltip
["TOOLTIP_PLAYER_WITHOUT_ADDON"] = "This player does not use TranqRotate",
["TOOLTIP_MAY_RUN_OUDATED_VERSION"] = "Or runs an outdated version below 1.6.0",
["TOOLTIP_DISABLE_SETTINGS"] = "(You can disable this icon and/or this tooltip in the settings)",

--- Available update
-- Available update
["UPDATE_AVAILABLE"] = "A new TranqRotate version is available, update to get latest features",
["BREAKING_UPDATE_AVAILABLE"] = "A new BREAKING TranqRotate update is available, you MUST update AS SOON AS possible! TranqRotate may not work properly with up-to-date version users.",

-- Rotation reset
["RESET_UNAUTHORIZED"] = "You must be raid assist to reset the rotation",
}

TranqRotate.L = L
36 changes: 36 additions & 0 deletions src/comms.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function TranqRotate.OnCommReceived(prefix, data, channel, sender)
TranqRotate:receiveSyncRequest(prefix, message, channel, sender)
elseif (message.type == TranqRotate.constants.commsTypes.backupRequest) then
TranqRotate:receiveBackupRequest(prefix, message, channel, sender)
elseif (message.type == TranqRotate.constants.commsTypes.reset) then
TranqRotate:receiveResetRequest(prefix, message, channel, sender)
end
end
end
Expand Down Expand Up @@ -90,6 +92,11 @@ function TranqRotate:sendSyncOrder(whisper, name)
['addonVersion'] = TranqRotate.version,
}

local nextHunter = TranqRotate:getHighlightedHunter()
if (nil ~= nextHunter) then
message.nextHunter = nextHunter.GUID
end

if (whisper) then
TranqRotate:sendWhisperAddonMessage(message, name)
else
Expand Down Expand Up @@ -121,6 +128,16 @@ function TranqRotate:sendBackupRequest(name)
TranqRotate:sendWhisperAddonMessage(message, name)
end

-- Broadcast a reset of the rotation to other players
function TranqRotate:sendResetBroadcast()

local message = {
['type'] = TranqRotate.constants.commsTypes.reset,
}

TranqRotate:sendRaidAddonMessage(message)
end

-----------------------------------------------------------------------------------------------------------------------
-- INPUT
-----------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -156,6 +173,11 @@ function TranqRotate:receiveSyncOrder(prefix, message, channel, sender)
-- todo : translation
TranqRotate:printPrefixedMessage('Received new rotation configuration from ' .. TranqRotate:formatPlayerName(sender))
TranqRotate:applyRotationConfiguration(message.rotation)

local nextHunter = TranqRotate:getHunter(message.nextHunter)
if (nil ~= nextHunter) then
TranqRotate:setNextTranq(nextHunter)
end
end

TranqRotate:updatePlayerAddonVersion(sender, message.addonVersion)
Expand All @@ -173,3 +195,17 @@ function TranqRotate:receiveBackupRequest(prefix, message, channel, sender)
TranqRotate:printPrefixedMessage(TranqRotate:formatPlayerName(sender) .. ' asked for backup !')
TranqRotate:throwTranqAlert()
end

-- Received a rotation reset request
function TranqRotate:receiveResetRequest(prefix, message, channel, sender)

if (not TranqRotate:isUnitAllowedToManageRotation(sender)) then
return
end

if (TranqRotate.lastRotationReset < GetTime() - 2) then
-- todo: translations
TranqRotate:printPrefixedMessage(TranqRotate:formatPlayerName(sender) .. ' has reset the rotation.')
TranqRotate:resetRotation()
end
end
1 change: 1 addition & 0 deletions src/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ TranqRotate.constants = {
['syncOrder'] = 'sync-order',
['syncRequest'] = 'sync-request',
['backupRequest'] = 'backup-request',
['reset'] = 'reset',
},

['printPrefix'] = 'TranqRotate - ',
Expand Down
2 changes: 1 addition & 1 deletion src/dragdrop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,5 @@ end

-- Update drag and drop status to match player status
function TranqRotate:updateDragAndDrop()
TranqRotate:toggleListSorting(TranqRotate:isPlayerAllowedToSortHunterList())
TranqRotate:toggleListSorting(TranqRotate:isPlayerAllowedToManageRotation())
end
5 changes: 4 additions & 1 deletion src/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ function TranqRotate:COMBAT_LOG_EVENT_UNFILTERED()
elseif (event == "SPELL_AURA_REMOVED" and TranqRotate:isBossFrenzy(spellName, sourceGUID)) then
TranqRotate.frenzy = false
elseif (event == "UNIT_DIED" and TranqRotate:isTranqableBoss(destGUID)) then
TranqRotate:resetRotation()
if (TranqRotate:isPlayerAllowedToManageRotation()) then
TranqRotate:resetRotation()
TranqRotate:sendResetBroadcast()
end
TranqRotate.mainFrame.frenzyFrame:Hide()
end
end
Expand Down
8 changes: 2 additions & 6 deletions src/frames.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ function TranqRotate:createButtons()
},
{
['texture'] = 'Interface/Buttons/UI-RefreshButton',
['callback'] = function()
TranqRotate:updateRaidStatus()
TranqRotate:resetRotation()
TranqRotate:sendSyncOrderRequest()
end
['callback'] = TranqRotate.handleResetButton
},
{
['texture'] = 'Interface/Buttons/UI-GuildButton-MOTD-Up',
Expand Down Expand Up @@ -159,7 +155,7 @@ function TranqRotate:createHunterFrame(hunter, parentFrame)
TranqRotate:createBlindIconFrame(hunter)
TranqRotate:configureHunterFrameDrag(hunter)

TranqRotate:toggleHunterFrameDragging(hunter, TranqRotate:isPlayerAllowedToSortHunterList())
TranqRotate:toggleHunterFrameDragging(hunter, TranqRotate:isPlayerAllowedToManageRotation())
end

-- Create the cooldown frame
Expand Down
19 changes: 18 additions & 1 deletion src/rotation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ end

-- Init/Reset rotation status, next tranq is the first hunter on the list
function TranqRotate:resetRotation()

TranqRotate.lastRotationReset = GetTime()

for key, hunter in pairs(TranqRotate.rotationTables.rotation) do
hunter.nextTranq = false
TranqRotate:refreshHunterFrame(hunter)
Expand Down Expand Up @@ -252,8 +255,12 @@ end
-- Return our hunter object from name or GUID
function TranqRotate:getHunter(searchTerm)

if (searchTerm == nil) then
return nil
end

for _, hunter in pairs(TranqRotate.hunterTable) do
if (searchTerm ~= nil and (hunter.GUID == searchTerm or hunter.name == searchTerm)) then
if (hunter.GUID == searchTerm or hunter.name == searchTerm) then
return hunter
end
end
Expand Down Expand Up @@ -550,3 +557,13 @@ function TranqRotate:getTranqFailMessage(targetName, raidIconFlags)

return message
end

function TranqRotate:handleResetButton()
TranqRotate:updateRaidStatus()
if (TranqRotate:isPlayerAllowedToManageRotation()) then
TranqRotate:resetRotation()
TranqRotate:sendResetBroadcast()
else
TranqRotate:printPrefixedMessage(L["RESET_UNAUTHORIZED"])
end
end
1 change: 1 addition & 0 deletions src/tranqRotate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function TranqRotate:init()
TranqRotate.raidInitialized = false
TranqRotate.testMode = false
TranqRotate.frenzy = false
TranqRotate.lastRotationReset = 0

TranqRotate:initGui()
TranqRotate:updateRaidStatus()
Expand Down
11 changes: 8 additions & 3 deletions src/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,15 @@ function TranqRotate:isPlayerRaidAssist(name)
return false
end

-- Checks if condition to enable drag and drop are met
function TranqRotate:isPlayerAllowedToSortHunterList()
-- Checks if player is allowed to manage rotation
function TranqRotate:isPlayerAllowedToManageRotation()
local playerName = UnitName("player")
return TranqRotate:isHunter(playerName) or TranqRotate:isPlayerRaidAssist(playerName)
return TranqRotate:isUnitAllowedToManageRotation(playerName)
end

-- Checks if unit is allowed to manage rotation
function TranqRotate:isUnitAllowedToManageRotation(unitName)
return TranqRotate:isHunter(unitName) or TranqRotate:isPlayerRaidAssist(unitName)
end

-- Format the player name and server suffix
Expand Down

0 comments on commit b4029ac

Please sign in to comment.