danreeves / dt-exchange

40 stars 17 forks source link

Allow using non-array values for filter rules #37

Closed errnoh closed 1 year ago

errnoh commented 1 year ago

Automatic formatting of the filter rules made me think that maybe its finally time to not force people to use arrays for everything to avoid unnecessary verbosity on the configuration.

Initial thought was that doing so might make the filter code too branchy, but maybe this would be one way to do it without code being too ugly.

errnoh commented 1 year ago

To compare outputs, this would be before:

[
    {
        "character": [
            "veteran"
        ],
        "item": [
            "Power Sword"
        ],
        "blessing": [
            "Power Cycler"
        ]
    },
    {
        "item": [
            "Obscurus Mk II Blaze Force Sword"
        ],
        "blessing": [
            "Deflector"
        ]
    },
    {
        "minStats": 360
    },
    {
        "store": "marks"
    },
    {
        "minBlessingRarity": 3,
        "store": "credits"
    },
    {
        "item": [
            "(Reliquary)",
            "(Caged)",
            "(Casket)"
        ],
        "blessing": [
            "Toughness"
        ],
        "perk": [
            "Toughness"
        ],
        "minRating": 80
    },
    {
        "item": [
            "Antax Mk V Combat Axe"
        ],
        "blessing": [
            "Brutal Momentum"
        ]
    },
    {
        "blessing": [
            "Pinning Fire"
        ]
    },
    {
        "item": [
            "Recon Lasgun"
        ],
        "blessing": [
            "Infernus"
        ]
    },
    {
        "character": [
            "veteran"
        ],
        "item": [
            "Kantrael MG XII Infantry Lasgun"
        ],
        "blessing": [
            "Infernus",
            "Ghost"
        ]
    }
]

and this is after:

[
    {
        "character": "veteran",
        "item": "Power Sword",
        "blessing": "Power Cycler"
    },
    {
        "item": "Obscurus Mk II Blaze Force Sword",
        "blessing": "Deflector"
    },
    {
        "minStats": 360
    },
    {
        "store": "marks"
    },
    {
        "minBlessingRarity": 3,
        "store": "credits"
    },
    {
        "item": [
            "(Reliquary)",
            "(Caged)",
            "(Casket)"
        ],
        "blessing": "Toughness",
        "perk": "Toughness",
        "minRating": 80
    },
    {
        "item": "Antax Mk V Combat Axe",
        "blessing": "Brutal Momentum"
    },
    {
        "blessing": "Pinning Fire"
    },
    {
        "item": "Recon Lasgun",
        "blessing": "Infernus"
    },
    {
        "character": "veteran",
        "item": "Kantrael MG XII Infantry Lasgun",
        "blessing": [
            "Infernus",
            "Ghost"
        ]
    }
]