From 213fbe9a8e002fe85ef59f6d8b0ea8d78ba4d18f Mon Sep 17 00:00:00 2001 From: zhaochunyou Date: Fri, 1 Apr 2022 12:15:29 +0800 Subject: [PATCH] Add bonus filter --- .../easy-highlight-artifacts/plugin.js | 103 ++++++++++++------ 1 file changed, 68 insertions(+), 35 deletions(-) diff --git a/content/artifacts/easy-highlight-artifacts/plugin.js b/content/artifacts/easy-highlight-artifacts/plugin.js index 7439b9f7..0a232cd7 100644 --- a/content/artifacts/easy-highlight-artifacts/plugin.js +++ b/content/artifacts/easy-highlight-artifacts/plugin.js @@ -25,6 +25,7 @@ const PLANET_LEVELS = Object.values(PlanetLevel).map((level) => ({ const PLANET_ANY_TYPE = -1; const ARTIFACT_ANY_TYPE = -1; const ARTIFACT_ANY_RARITY = -1; +const BONUS_ANY = -1; const PLANET_TYPES = [ { @@ -47,22 +48,10 @@ const OwnerType = { }; const OWNER_TYPES_MAPPING = [ - { - value: OwnerType.ANYONE, - text: "Anyone", - }, - { - value: OwnerType.UNCLAIMED, - text: "Unclaimed", - }, - { - value: OwnerType.CLAIMED_BY_OTHERS, - text: "Claimed by others", - }, - { - value: OwnerType.CLAIMED_BY_MYSELF, - text: "Claimed by myself", - }, + { value: OwnerType.ANYONE, text: "Anyone" }, + { value: OwnerType.UNCLAIMED, text: "Nobody" }, + { value: OwnerType.CLAIMED_BY_OTHERS, text: "Owned by others" }, + { value: OwnerType.CLAIMED_BY_MYSELF, text: "Owned by myself" }, ]; const ARTIFACT_TYPES = [ @@ -91,6 +80,37 @@ const ARTIFACT_RARITIES = [ })), ]; +const BONUS = [ + { + value: BONUS_ANY, + text: "Any", + }, + { + value: 0, + text: "Double Energy Cap", + }, + { + value: 1, + text: "Double Energy Growth", + }, + { + value: 2, + text: "Double Range", + }, + { + value: 3, + text: "Double Speed", + }, + { + value: 4, + text: "Double Defense", + }, + { + value: 5, + text: "Half Junk", + }, +]; + function CreateSelectFilter({ items, selectedValue, onSelect }) { const selectStyle = { background: "rgb(8,8,8)", @@ -217,6 +237,7 @@ function App({}) { const [selectedPlanetType, setSelectedPlanetType] = useState(-1); const [selectedArtifactType, setSelectedArtifactType] = useState(-1); const [selectedArtifactRarity, setSelectedArtifactRarity] = useState(-1); + const [selectedBonus, setSelectedBonus] = useState(-1); const [selectedOwnerType, setSelectedOwnerType] = useState( OwnerType.CLAIMED_BY_MYSELF ); @@ -280,6 +301,14 @@ function App({}) { continue; } + // check bonus + if ( + selectedBonus != BONUS_ANY && + !planet.bonus[selectedBonus] + ) { + continue; + } + // if artifact type or rarity selected, then we require a planet contain a artifact satisfying // requirements const mustHoldArtifacts = @@ -316,6 +345,7 @@ function App({}) { selectedOwnerType, selectedArtifactType, selectedArtifactRarity, + selectedBonus, onlyShowZeroJunk, ]); @@ -390,18 +420,6 @@ function App({}) { `; - const planetUnionFilters = html` -
- ${planetTypeFilter} ${ownerTypeFilter} -
- `; - const artifactTypeFilter = html`
Artifacts Type
<${CreateSelectFilter} @@ -422,11 +440,16 @@ function App({}) {
`; - const artifactFilters = html`
- ${artifactTypeFilter} ${artifactRarityFilter} -
`; + const bonusFilter = html` +
+
Bonus
+ <${CreateSelectFilter} + items=${BONUS} + selectedValue=${selectedBonus} + onSelect=${setSelectedBonus} + /> +
+ `; const [loading, setLoading] = useState(false); @@ -447,9 +470,19 @@ function App({}) { ctaText=${"Reset"} />`; + function row(...children) { + return html`
+ ${children} +
`; + } + return html` - ${zeroJunkCheckBox} ${planetLevelFilter} ${planetUnionFilters} - ${artifactFilters} + ${planetLevelFilter} + ${row(planetTypeFilter, ownerTypeFilter)} + ${row(artifactTypeFilter, artifactRarityFilter)} + ${row(bonusFilter, zeroJunkCheckBox)} <${createDivider} />