add Mirrored Tablet

Co-authored-by: sithrebel15 <anthonycorrado2@gmail.com>
This commit is contained in:
Alexander Drozdov
2022-09-13 23:20:47 +03:00
co-authored by sithrebel15
parent cf321af2eb
commit 2beef00db8
6 changed files with 99 additions and 6 deletions
+25 -1
View File
@@ -52,6 +52,7 @@ const parsers: Array<ParserFn | { virtual: VirtualParserFn }> = [
parseHeistBlueprint,
parseAreaLevel,
parseAtzoatlRooms,
parseMirroredTablet,
parseMirrored,
parseSentinelCharge,
parseLogbookArea,
@@ -784,7 +785,8 @@ function parseAreaLevelNested (section: string[], item: ParsedItem) {
function parseAreaLevel (section: string[], item: ParsedItem) {
if (
item.info.refName !== 'Chronicle of Atzoatl' &&
item.info.refName !== 'Expedition Logbook'
item.info.refName !== 'Expedition Logbook' &&
item.info.refName !== 'Mirrored Tablet'
) return 'PARSER_SKIPPED'
parseAreaLevelNested(section, item)
@@ -830,6 +832,28 @@ function parseAtzoatlRooms (section: string[], item: ParsedItem) {
return 'SECTION_PARSED'
}
function parseMirroredTablet (section: string[], item: ParsedItem) {
if (item.info.refName !== 'Mirrored Tablet') return 'PARSER_SKIPPED'
if (section.length < 8) return 'SECTION_SKIPPED'
for (const line of section) {
const found = tryParseTranslation({ string: line, unscalable: true }, ModifierType.Pseudo)
if (found) {
item.newMods.push({
info: { tags: [], type: ModifierType.Pseudo },
stats: [found]
})
} else {
item.unknownModifiers.push({
text: line,
type: ModifierType.Pseudo
})
}
}
return 'SECTION_PARSED'
}
function markupConditionParser (text: string) {
// ignores state set by <<set:__>>
// always evaluates first condition to true <if:__>{...}
+8 -4
View File
@@ -63,15 +63,19 @@ export function sumStatsByModType (mods: readonly ParsedModifier[]): StatCalcula
}
export function statSourcesTotal (
sources: StatSource[]
sources: StatSource[],
mode: 'sum' | 'max' = 'sum'
): StatRoll | undefined {
const fn = (mode === 'sum')
? ((a: number, b: number) => a + b)
: ((a: number, b: number) => Math.max(a, b))
return (sources.length === 1)
? (sources[0].contributes)
: (sources.reduce((sum, { contributes }) => {
contributes = contributes ?? { value: 1, min: 1, max: 1 }
sum.value += contributes.value
sum.min += contributes.min
sum.max += contributes.max
sum.value = fn(sum.value, contributes.value)
sum.min = fn(sum.min, contributes.min)
sum.max = fn(sum.max, contributes.max)
return sum
}, { value: 0, min: 0, max: 0 }))
}
@@ -99,6 +99,7 @@ export default defineComponent({
props.filter.tag !== FilterTag.Property &&
props.filter.tradeId[0] !== 'item.has_empty_modifier' &&
props.item.info.refName !== 'Chronicle of Atzoatl' &&
props.item.info.refName !== 'Mirrored Tablet' &&
!(props.item.rarity === ItemRarity.Unique && (
props.filter.tag === FilterTag.Explicit ||
props.filter.tag === FilterTag.Pseudo))
@@ -81,6 +81,12 @@ export function createFilters (
disabled: false
}
}
if (item.info.refName === 'Mirrored Tablet') {
filters.areaLevel = {
value: item.areaLevel!,
disabled: false
}
}
return filters
}
@@ -4,6 +4,7 @@ import { percentRoll, percentRollDelta, roundRoll } from './util'
import { FilterTag, ItemHasEmptyModifier, StatFilter } from './interfaces'
import { filterPseudo } from './pseudo'
import { applyRules as applyAtzoatlRules } from './pseudo/atzoatl-rules'
import { applyRules as applyMirroredTabletRules } from './pseudo/reflection-rules'
import { filterItemProp } from './pseudo/item-property'
import { decodeOils, applyAnointmentRules } from './pseudo/anointments'
import { StatBetter, CLIENT_STRINGS } from '@/assets/data'
@@ -66,6 +67,10 @@ export function createExactStatFilters (
applyAtzoatlRules(ctx.filters)
return ctx.filters
}
if (item.info.refName === 'Mirrored Tablet') {
applyMirroredTabletRules(ctx.filters)
return ctx.filters
}
for (const filter of ctx.filters) {
filter.hidden = undefined
@@ -168,7 +173,10 @@ export function calculatedStatToFilter (
}
}
const roll = statSourcesTotal(calc.sources)
const roll = statSourcesTotal(
calc.sources,
(item.info.refName === 'Mirrored Tablet') ? 'max' : 'sum'
)
const translation = translateStatWithRoll(calc, roll)
filter ??= {
@@ -0,0 +1,50 @@
import { stat } from '@/assets/data'
import type { StatFilter } from '../interfaces'
interface FilterRule {
ref: string
disabled?: boolean
difficulty?: 'any'
}
const RULES: FilterRule[] = [
{ ref: stat('Reflection of the Breachlord (Difficulty #)') },
{ ref: stat('Reflection of Delirium (Difficulty #)'), difficulty: 'any' },
{ ref: stat('Reflection of Tyranny (Difficulty #)') },
{ ref: stat('Reflection of the Trove (Difficulty #)') },
{ ref: stat('Reflection of Thralldom (Difficulty #)') },
{ ref: stat('Reflection of Phaaryl (Difficulty #)') },
{ ref: stat('Reflection of Perverted Faith (Difficulty #)') },
{ ref: stat('Reflection of Kalandra (Difficulty #)'), disabled: false },
{ ref: stat('Reflection of Experimentation (Difficulty #)') },
{ ref: stat('Reflection of the Sun (Difficulty #)'), disabled: false },
{ ref: stat('Reflection of the Monolith (Difficulty #)') },
{ ref: stat('Reflection of the Nightmare (Difficulty #)') },
{ ref: stat('Reflection of Azurite (Difficulty #)') },
{ ref: stat('Reflection of Paradise (Difficulty #)'), disabled: false },
{ ref: stat('Reflection of Angling (Difficulty #)'), disabled: false },
]
export function applyRules (filters: StatFilter[]) {
for (let i = 0; i < filters.length;) {
const filter = filters[i]
const rule = RULES.find(rule => rule.ref === filter.statRef)
if (!rule) {
const difficulty = filter.roll!.value
if (difficulty < 8) {
filters.splice(i, 1)
continue
} else {
filter.hidden = 'low_tier_reflection'
}
} else {
if (rule.difficulty === 'any') {
filter.roll = undefined
}
if (rule.disabled !== undefined) {
filter.disabled = rule.disabled
}
}
i += 1
}
}