From 661c723d1847624887ffcd62a48212e78021a924 Mon Sep 17 00:00:00 2001 From: Brandon Jensen Date: Thu, 25 Apr 2024 15:43:34 -0400 Subject: [PATCH 1/3] added a switch that displays only ammo that is buyable from traders at user's current level --- src/pages/ammo/index.js | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/pages/ammo/index.js b/src/pages/ammo/index.js index 30960f59e..1e4cf8462 100644 --- a/src/pages/ammo/index.js +++ b/src/pages/ammo/index.js @@ -21,6 +21,8 @@ import { formatCaliber } from '../../modules/format-ammo.mjs'; import symbols from '../../symbols.json'; import './index.css'; +import { useSelector } from 'react-redux'; +import { selectAllTraders } from '../../features/settings/settingsSlice.js'; const MAX_DAMAGE = 170; const MAX_PENETRATION = 70; @@ -34,6 +36,7 @@ const skipTypes = [ ]; function Ammo() { + const allTraders = useSelector(selectAllTraders); const { currentAmmo } = useParams(); let currentAmmoList = useMemo(() => [], []); let redirect = false; @@ -54,7 +57,8 @@ function Ammo() { navigate(`/ammo/${currentAmmoList.join(',')}`); } }, [redirect, currentAmmoList, navigate]); - + + const [showOnlyTraderAmmo, setShowOnlyTraderAmmo] = useState(false); const [selectedLegendName, setSelectedLegendName] = useState(currentAmmoList); const [showAllTraderPrices, setShowAllTraderPrices] = useState(false); const [useAllProjectileDamage, setUseAllProjectileDamage] = useState(false); @@ -158,6 +162,16 @@ function Ammo() { !selectedLegendName || selectedLegendName.length === 0 || selectedLegendName.includes(ammo.type), + ).filter(ammo => { + if (showOnlyTraderAmmo) { + if (!ammo.buyFor.some(buyForEntry => + buyForEntry.vendor.normalizedName !== 'flea-market' && + buyForEntry.vendor.minTraderLevel <= allTraders[buyForEntry.vendor.normalizedName]) + ) + return false; + } + return true; + } ).filter(ammo => { if (minPen === 0 && maxPen === 60) { return true; @@ -194,9 +208,8 @@ function Ammo() { chartName: `${ammo.chartName} (${ammo.fragmentationChance})`, }; }); - return returnData; - }, [selectedLegendName, shiftPress, ammoData, minPen, maxPen]); + }, [selectedLegendName, shiftPress, ammoData, minPen, maxPen, showOnlyTraderAmmo, allTraders]); const handleLegendClick = useCallback( (event, { datum: { name } }) => { @@ -269,6 +282,18 @@ function Ammo() { } /> + + setShowOnlyTraderAmmo(!showOnlyTraderAmmo) + } + tooltipContent={ + <> + {t('Only show ammo available from traders on your settings')} + + } + /> Date: Thu, 25 Apr 2024 15:54:29 -0400 Subject: [PATCH 2/3] fixed typo from purpose your change, to propose your change --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 026138097..a3ed43cc7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,7 @@ ## Opening a Pull Request 🌟 -If you have a fix for a bug or a feature request, follow the flow below to purpose your change +If you have a fix for a bug or a feature request, follow the flow below to propose your change > If you are new to creating pull requests from a repository fork, check out this [guide](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) From 26639f9d5468f890d6c7cc2e5df743dca96950cc Mon Sep 17 00:00:00 2001 From: Brandon Jensen Date: Fri, 26 Apr 2024 00:17:44 -0400 Subject: [PATCH 3/3] added new text to translation file --- src/translations/en/translation.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/translations/en/translation.json b/src/translations/en/translation.json index 1651389c6..5b8aaa09e 100644 --- a/src/translations/en/translation.json +++ b/src/translations/en/translation.json @@ -600,5 +600,7 @@ "{{count}} days_other": "{{count}} days", "Wipe Length": "Wipe Length", "wipe-length-description": "Get the latest information on the average wipe length in Escape from Tarkov. Find out how long wipes typically last, and prepare for the next wipe.", - "Average Wipe Length among last 6 wipes:": "Average Wipe Length among last 6 wipes:" + "Average Wipe Length among last 6 wipes:": "Average Wipe Length among last 6 wipes:", + "Trader Ammo": "Trader Ammo", + "Only show ammo available from traders on your settings": "Only show ammo available from traders on your settings" }