Skip to content

Commit

Permalink
Close #210: Classic era support (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mctalian authored Dec 15, 2024
1 parent 813e664 commit 052435d
Show file tree
Hide file tree
Showing 34 changed files with 822 additions and 161 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,21 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
python-version: 3.13

- name: Install Python dependencies
run: pip install -r requirements.txt
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.5

- name: Install dependencies
run: poetry install

- name: Run translation check script
run: python .scripts/missing_translation_check.py
run: poetry run python .scripts/missing_translation_check.py

- name: Check for Hard-coded strings
run: python .scripts/hardcode_string_check.py
run: poetry run python .scripts/hardcode_string_check.py

run_tests:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .pkgmeta
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ externals:
Libs/AceLocale-3.0: https://repos.wowace.com/wow/ace3/trunk/AceLocale-3.0
Libs/LibSharedMedia-3.0: https://repos.curseforge.com/wow/libsharedmedia-3-0/trunk/LibSharedMedia-3.0
Libs/AceGUI-3.0-SharedMediaWidgets: https://repos.curseforge.com/wow/ace-gui-3-0-shared-media-widgets/trunk/AceGUI-3.0-SharedMediaWidgets
Libs/C_Everywhere: https://github.com/Jaliborc/C_Everywhere

enable-nolib-creation: yes

Expand All @@ -23,5 +24,7 @@ ignore:
- "*.ps1"
- "*.md"
- "*.rockspec"
- "*.gif"
- "example*.png"
- requirements.txt

4 changes: 3 additions & 1 deletion BlizzOverrides/BossBanner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ local addonName, G_RLF = ...
local BossBannerOverride = G_RLF.RLF:NewModule("BossBanner", "AceEvent-3.0", "AceHook-3.0", "AceTimer-3.0")

function BossBannerOverride:OnInitialize()
self:RegisterEvent("PLAYER_ENTERING_WORLD", "BossBannerHook")
if GetExpansionLevel() >= G_RLF.Expansion.WOD then
self:RegisterEvent("PLAYER_ENTERING_WORLD", "BossBannerHook")
end
end

local bossBannerAttempts = 0
Expand Down
175 changes: 175 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# Contributing Guidelines

Thank you for your interest in contributing to this project! Following these guidelines helps maintain consistency and ensures a smooth collaboration process.

---

## Table of Contents

- [Getting Started](#getting-started)
- [Setting Up the Development Environment](#setting-up-the-development-environment)
- [Python](#python)
- [Lua](#lua)
- [Code Standards](#code-standards)
- [Testing](#testing)
- [Contributing Workflow](#contributing-workflow)
- [Common Commands](#common-commands)
- [Contact](#contact)

---

## Getting Started

1. Fork the repository and clone it to your local machine:

```bash
git clone https://github.com/<YOUR_USERNAME>/RPGLootFeed.git
cd RPGlootFeed
```

2. Review the [issues](https://github.com/RPGLootFeed/issues) to find something you'd like to work on, or propose a new feature by creating an issue.

---

## Setting Up the Development Environment

### Python

1. **Install Poetry**
Poetry is used for Python dependency and environment management:

```bash
curl -sSL https://install.python-poetry.org | python3 -
```

2. **Install Dependencies**
Install project dependencies into a virtual environment:

```bash
poetry install
```

3. **Run Scripts**
Use `make` to execute project-specific scripts, such as:
```bash
make hardcode_string_check
make missing_translation_check
make all_checks
make test
```

### Lua

1. **Install Lua**
Install Lua using your package manager or `luaenv`:
```bash
luaenv install
```
1. **Install LuaRocks**
[Install Luarocks for package management.](https://github.com/luarocks/luarocks?tab=readme-ov-file#installing)
1. **Install Dependencies**
Install project dependencies using `luarocks`:
```bash
luarocks install busted
luarocks install luassert
```
1. **Verify Installation**
Ensure the tools are available:
```bash
lua -v
busted --version
```

---

## Code Standards

Run [trunk](https://trunk.io) checks to ensure your code meets the project's standards:

```bash
./trunk fmt
./trunk check
```

---

## Testing

### Packaging

- Use `make local` to package the project for local testing:

```bash
make local
```

This will create an alpha build in the `.release` directory. It is recommended that you create a symlink to this directory in your game's `Interface/Addons` directory so that the latest changes are immediately available in the game after a `/reload`.

- Smoke tests are run automatically upon loading an alpha build of the addon (on login or `/reload`).
- Run `/rlf i` in the game to run integration tests (you will see a failure if you looted anything since the last `/reload` or if you already ran the integration tests since "loot history" is part of the integration tests).

### Lua Tests

- Use `busted` for unit tests:

```bash
busted
```

- Generate coverage reports:
```bash
busted --coverage && luarocks luacov
```

---

## Contributing Workflow

1. **Create a Feature Branch**
Branch from `main` and name your branch descriptively:

```bash
git checkout -b feature/your-feature
```

1. **Test Your Changes**
Run all checks and tests before opening a pull request:

```bash
make all_checks
make test
```

1. **Submit a Pull Request**
- Push your branch:
```bash
git push origin feature/your-feature
```
- Open a pull request to `main` with a clear title and description of your changes.

---

## Common Commands

### Development Commands

| Command | Description |
| -------------------------------- | ------------------------------------------- |
| `make hardcode_string_check` | Checks for hard-coded strings in Lua files. |
| `make missing_translation_check` | Detects missing translations in Lua files. |
| `make test` | Runs Lua unit tests. |
| `trunk check` | Lints all files. |

### Cleanup Commands

| Command | Description |
| ------------------------------------------ | ------------------------- |
| `rm -rf luacov-html && rm -rf luacov.*out` | Cleans up coverage files. |

---

## Contact

If you have any questions or need help, feel free to reach out by creating an issue in the repository.

---
25 changes: 19 additions & 6 deletions Features/Currency.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
local addonName, G_RLF = ...

local C = LibStub("C_Everywhere")

local Currency = G_RLF.RLF:NewModule("Currency", "AceEvent-3.0")

Currency.Element = {}
Expand Down Expand Up @@ -80,21 +82,32 @@ local function isHiddenCurrency(id)
end

function Currency:OnInitialize()
if G_RLF.db.global.currencyFeed then
if G_RLF.db.global.currencyFeed and GetExpansionLevel() >= G_RLF.Expansion.SL then
self:Enable()
else
self:Disable()
end
end

function Currency:OnDisable()
if GetExpansionLevel() < G_RLF.Expansion.SL then
return
end
self:UnregisterEvent("CURRENCY_DISPLAY_UPDATE")
self:UnregisterEvent("PERKS_PROGRAM_CURRENCY_AWARDED")
if G_RLF:IsRetail() then
self:UnregisterEvent("PERKS_PROGRAM_CURRENCY_AWARDED")
end
end

function Currency:OnEnable()
if GetExpansionLevel() < G_RLF.Expansion.SL then
return
end
self:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
self:RegisterEvent("PERKS_PROGRAM_CURRENCY_AWARDED")
if G_RLF:IsRetail() then
self:RegisterEvent("PERKS_PROGRAM_CURRENCY_AWARDED")
end
G_RLF:LogDebug("OnEnable", addonName, self.moduleName)
end

function Currency:Process(eventName, currencyType, quantityChange)
Expand Down Expand Up @@ -124,7 +137,7 @@ function Currency:Process(eventName, currencyType, quantityChange)
return
end

local info = C_CurrencyInfo.GetCurrencyInfo(currencyType)
local info = C.CurrencyInfo.GetCurrencyInfo(currencyType)
if info == nil or info.description == "" or info.iconFileID == nil then
G_RLF:LogDebug(
"Skip showing currency",
Expand All @@ -138,8 +151,8 @@ function Currency:Process(eventName, currencyType, quantityChange)
end

self:fn(function()
local basicInfo = C_CurrencyInfo.GetBasicCurrencyInfo(currencyType, quantityChange)
local e = self.Element:new(C_CurrencyInfo.GetCurrencyLink(currencyType), info, basicInfo)
local basicInfo = C.CurrencyInfo.GetBasicCurrencyInfo(currencyType, quantityChange)
local e = self.Element:new(C.CurrencyInfo.GetCurrencyLink(currencyType), info, basicInfo)
e:Show()
end)
end
Expand Down
1 change: 1 addition & 0 deletions Features/Experience.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function Xp:OnDisable()
end

function Xp:OnEnable()
G_RLF:LogDebug("OnEnable", addonName, self.moduleName)
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PLAYER_XP_UPDATE")
if currentXP == nil then
Expand Down
3 changes: 2 additions & 1 deletion Features/ItemLoot/AuctionIntegrations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function AuctionIntegrations:Init()
local possibleIntegrations = { Integ_Auctionator, Integ_TSM }
self.nilIntegration = Integ_Nil
self.activeIntegrations = {}
self.activeIntegration = nil

self.numActiveIntegrations = 0
for _, integration in ipairs(possibleIntegrations) do
Expand All @@ -39,7 +40,7 @@ function AuctionIntegrations:Init()
end
end

if G_RLF.db.global.auctionHouseSource ~= self.activeIntegration:ToString() then
if self.activeIntegration and G_RLF.db.global.auctionHouseSource ~= self.activeIntegration:ToString() then
G_RLF.db.global.auctionHouseSource = self.activeIntegration:ToString()
end
end
Expand Down
35 changes: 30 additions & 5 deletions Features/ItemLoot/ItemLoot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,37 @@ function ItemLoot.Element:new(...)
end
local quantity = ...
local atlasIconSize = G_RLF.db.global.fontSize * 1.5
local atlasIcon
local unitPrice
if G_RLF.db.global.pricesForSellableItems == G_RLF.PricesEnum.Vendor then
if not element.sellPrice or element.sellPrice == 0 then
return ""
end
local sellAtlasStr = "|A:spellicon-256x256-selljunk:" .. atlasIconSize .. ":" .. atlasIconSize .. ":0:0|a "
return " " .. sellAtlasStr .. C_CurrencyInfo.GetCoinTextureString(element.sellPrice * (quantity or 1))
if G_RLF:IsRetail() then
atlasIcon = "spellicon-256x256-selljunk"
elseif G_RLF:IsClassic() then
atlasIcon = "bags-junkcoin"
end
unitPrice = element.sellPrice
elseif G_RLF.db.global.pricesForSellableItems == G_RLF.PricesEnum.AH then
local marketPrice = G_RLF.AuctionIntegrations.activeIntegration:GetAHPrice(itemLink)
if not marketPrice or marketPrice == 0 then
return ""
end
local ahAtlasStr = "|A:auctioneer:" .. atlasIconSize .. ":" .. atlasIconSize .. ":0:0|a "
return " " .. ahAtlasStr .. C_CurrencyInfo.GetCoinTextureString(marketPrice * (quantity or 1))
unitPrice = marketPrice
if G_RLF:IsRetail() then
atlasIcon = "auctioneer"
elseif G_RLF:IsClassic() then
atlasIcon = "Auctioneer"
end
end
if unitPrice then
local str = " "
if atlasIcon then
str = str .. "|A:" .. atlasIcon .. ":" .. atlasIconSize .. ":" .. atlasIconSize .. ":0:0|a "
end
str = str .. C_CurrencyInfo.GetCoinTextureString(unitPrice * (quantity or 1))
return str
end

return ""
Expand Down Expand Up @@ -227,6 +245,7 @@ function ItemLoot:OnEnable()
self:RegisterEvent("GET_ITEM_INFO_RECEIVED")
self:RegisterEvent("GROUP_ROSTER_UPDATE")
self:SetNameUnitMap()
G_RLF:LogDebug("OnEnable", addonName, self.moduleName)
end

function ItemLoot:OnItemReadyToShow(info, amount)
Expand Down Expand Up @@ -304,7 +323,13 @@ function ItemLoot:CHAT_MSG_LOOT(eventName, ...)
return
end

local me = guid == GetPlayerGuid()
local me = false
if G_RLF:IsRetail() then
me = guid == GetPlayerGuid()
elseif G_RLF:IsClassic() then
me = playerName2 == UnitName("player")
end

if not me then
if not G_RLF.db.global.enablePartyLoot then
G_RLF:LogDebug("Party Loot Ignored", "WOWEVENT", self.moduleName, "", msg)
Expand Down
1 change: 1 addition & 0 deletions Features/LootDisplayProperties.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function G_RLF.InitializeLootDisplayProperties(self)
end

self.Show = function(element, itemName, itemQuality)
G_RLF:LogDebug("Show", addonName, element.type, element.key, nil, element.quantity)
if self:isPassingFilter(itemName, itemQuality) then
G_RLF:SendMessage("RLF_NEW_LOOT", self)
end
Expand Down
1 change: 1 addition & 0 deletions Features/Money.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function Money:OnEnable()
self:RegisterEvent("PLAYER_MONEY")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self.startingMoney = GetMoney()
G_RLF:LogDebug("OnEnable", addonName, self.moduleName)
end

function Money:PLAYER_ENTERING_WORLD(eventName)
Expand Down
Loading

0 comments on commit 052435d

Please sign in to comment.