Update Discord trade listings
This commit is contained in:
@@ -21,6 +21,18 @@ FOR = re.compile(r"\bfor\b", re.IGNORECASE)
|
||||
FIELDS = ("source_row", "quote_type", "offered_unit", "offered_qty",
|
||||
"requested_unit", "requested_qty", "requested_units_per_offered_unit",
|
||||
"source_text")
|
||||
STAT_QUALITY = re.compile(
|
||||
r"\b(?:SSS|SS|FULL\s+S|PERF(?:ECT)?\s+SPA)\b|"
|
||||
r"\b[A-S][+-]?\s*/\s*(?:SSS|SS|[A-S][+-]?)\b|"
|
||||
r"\b\d+\s+[A-S][+-]?\s*,\s*[A-S][+-]?\s*,\s*[A-S][+-]?\b|"
|
||||
r"\b\d+(?:[.,]\d+)?\s*%", re.I,
|
||||
)
|
||||
|
||||
|
||||
def only_stat_specific_inventory(offer: str, unit: str) -> bool:
|
||||
"""An unqualified quote cannot price a unit only listed with stat quality."""
|
||||
mentions = [part for part in offer.split("|") if unit in variants(part)]
|
||||
return bool(mentions) and all(STAT_QUALITY.search(part) for part in mentions)
|
||||
|
||||
|
||||
def parse_side(text: str) -> tuple[str, int, str | None] | None:
|
||||
@@ -77,6 +89,8 @@ def extract_quotes(rows: list[dict[str, str]]) -> list[dict[str, str | int | flo
|
||||
continue
|
||||
if offered[0] not in offered_inventory:
|
||||
continue
|
||||
if only_stat_specific_inventory(row.get("offer") or "", offered[0]):
|
||||
continue
|
||||
key = (author, offered[0], offered[1], requested[0], requested[1])
|
||||
if key in seen:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user