Compare commits
4 Commits
f37559ad6a
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 6b152854bd | |||
| d29892eac5 | |||
| 218c022779 | |||
| af8b173abd |
+35
-10
@@ -8,6 +8,13 @@ Run `py -B provisional_valuelist.py` to regenerate:
|
|||||||
- `confidence_report.csv`: unrounded fits and leave-one-quote-out sensitivity by variant.
|
- `confidence_report.csv`: unrounded fits and leave-one-quote-out sensitivity by variant.
|
||||||
- `quote_impact.csv`: every variant's value after each connected quote is removed.
|
- `quote_impact.csv`: every variant's value after each connected quote is removed.
|
||||||
- `quote_conflicts.csv`: direct quotes for the same pair with incompatible ratios.
|
- `quote_conflicts.csv`: direct quotes for the same pair with incompatible ratios.
|
||||||
|
- `evidence_comparison.csv`: the weighted fit beside an explicit-only refit,
|
||||||
|
including changes and variants disconnected when inferred pairs are removed.
|
||||||
|
|
||||||
|
The detailed `trades.csv` keeps a pretrade unit in `offer`, marks an explicit
|
||||||
|
`PRE`/`Pretrade` listing in `pretrade`, and puts any already received
|
||||||
|
`BEST OFFER`/`HIGH OFFER` in `received_bid`. Received bids are not owned
|
||||||
|
inventory or completed trades. A request for the "best offer" remains in LF.
|
||||||
|
|
||||||
Record confirmed exchanges in `completed_trades.csv` before regenerating. Each
|
Record confirmed exchanges in `completed_trades.csv` before regenerating. Each
|
||||||
row needs a unique `trade_id`, ISO `trade_date`, exact `given` and `received`
|
row needs a unique `trade_id`, ISO `trade_date`, exact `given` and `received`
|
||||||
@@ -20,12 +27,14 @@ ambiguous wording and overlapping variants are rejected. To use another input
|
|||||||
file, pass `--completed-trades path/to/file.csv`. The checked-in file has only
|
file, pass `--completed-trades path/to/file.csv`. The checked-in file has only
|
||||||
a header until real completed trades are recorded.
|
a header until real completed trades are recorded.
|
||||||
|
|
||||||
The current snapshot contains 1,286 listings. The parser found 15 simple quotes
|
The current snapshot contains 1,759 listings. The parser found 24 simple quotes
|
||||||
and 17 bundle quotes, and no completed trades have been entered. Twenty-six
|
and 22 bundle quotes, and no completed trades have been entered. Forty-one
|
||||||
asking quotes connect 30 variants to Aizen Evo. Five
|
asking quotes connect 44 variants to Aizen Evo. Eight
|
||||||
previously eligible estimates are now marked `unstable` and unranked. Only Aizen
|
eligible estimates are marked `unstable` and unranked. Aizen Evo and Shiny
|
||||||
Evo and Shiny Dark Mage Evo retain numeric entries. The conflict report finds
|
Homura Evo have numeric entries. The direct-pair conflict report is empty after
|
||||||
one direct quote pair: Homura Evo and Alucard Evo are quoted at both 2:1 and 1:1.
|
stat-specific offers were removed from the base-variant quotes. An explicit
|
||||||
|
ask for six Aizen Evo in exchange for one Homura Evo remains in the evidence;
|
||||||
|
it makes Homura Evo unstable.
|
||||||
|
|
||||||
## How the estimates work
|
## How the estimates work
|
||||||
|
|
||||||
@@ -34,11 +43,18 @@ whose two sides contain only named variants and quantities. It rejects broad
|
|||||||
wish lists, alternatives, unspecified adds, stats and quality descriptions,
|
wish lists, alternatives, unspecified adds, stats and quality descriptions,
|
||||||
and inventory rows that do not clearly describe a bundle. Each offered unit
|
and inventory rows that do not clearly describe a bundle. Each offered unit
|
||||||
must appear in the listing's `offer` field. Repeated identical quotes from one
|
must appear in the listing's `offer` field. Repeated identical quotes from one
|
||||||
author count once.
|
author count once. A proposal is excluded from the base-variant fit when its
|
||||||
|
offered inventory identifies the unit only with specific stats. The current
|
||||||
|
audit excluded eight such proposals; they remain in `trades.csv` for later
|
||||||
|
stat-aware modeling.
|
||||||
|
|
||||||
The model fixes **Aizen Evo = 1,000 points**. It fits unit values so the sum of
|
The model fixes **Aizen Evo = 1,000 points**. It fits unit values so the sum of
|
||||||
points on each side of an exchange is approximately equal. Completed trades
|
points on each side of an exchange is approximately equal. Completed trades
|
||||||
have weight 9, direct unit asks weight 3, and bundle asks weight 1. The two ask
|
have weight 9. Explicit direct asks have weight 3 and explicit bundle asks
|
||||||
|
weight 1. Inferred offer/LF pairs get one-third of the matching explicit
|
||||||
|
weight: 1 for direct pairs and 1/3 for bundles. This snapshot contains 29
|
||||||
|
explicit proposals and 17 inferred pairs. The ValueList and confidence report
|
||||||
|
show their source counts separately. The two ask
|
||||||
files contain only proposed exchanges; completed records stay in their own
|
files contain only proposed exchanges; completed records stay in their own
|
||||||
input file. A small pull toward the 1,000-point reference keeps sparse equations
|
input file. A small pull toward the 1,000-point reference keeps sparse equations
|
||||||
solvable. Values are rounded to the nearest 50 points. The regularization
|
solvable. Values are rounded to the nearest 50 points. The regularization
|
||||||
@@ -46,7 +62,8 @@ affects thin estimates, and a manually recorded completion is only as reliable
|
|||||||
as its evidence reference.
|
as its evidence reference.
|
||||||
|
|
||||||
The ValueList and confidence report show separate `asking_quote_count` and
|
The ValueList and confidence report show separate `asking_quote_count` and
|
||||||
`completed_trade_count` columns. `quote_count` is the combined number of
|
`completed_trade_count` columns, plus `explicit_ask_count` and
|
||||||
|
`inferred_ask_count`. `quote_count` is the combined number of
|
||||||
distinct source listings and trade IDs. A variant with a completed trade and
|
distinct source listings and trade IDs. A variant with a completed trade and
|
||||||
at least one other independent source can become eligible for ranking; the
|
at least one other independent source can become eligible for ranking; the
|
||||||
leave-one-out stability gate still applies. `source_rows` uses normal row
|
leave-one-out stability gate still applies. `source_rows` uses normal row
|
||||||
@@ -65,6 +82,13 @@ has no numeric value or rank if any removal disconnects it or changes its fit
|
|||||||
by more than 25%. This is a practical screening threshold, not a statistical
|
by more than 25%. This is a practical screening threshold, not a statistical
|
||||||
confidence interval. The Aizen reference remains fixed by definition.
|
confidence interval. The Aizen reference remains fixed by definition.
|
||||||
|
|
||||||
|
`evidence_comparison.csv` refits the model using only explicit proposals and
|
||||||
|
completed trades. Its `all_fit` and `explicit_only_fit` are unrounded diagnostic
|
||||||
|
fits, even for unstable variants. The `*_ranked_value` columns remain blank
|
||||||
|
whenever the corresponding fit is unstable or insufficient. A disconnected
|
||||||
|
variant has no explicit-only fit or value. Shiny Dark Mage Evo is unstable and
|
||||||
|
unranked in both the weighted and explicit-only fits.
|
||||||
|
|
||||||
`quote_conflicts.csv` compares exact direct quotes for the same pair of variants.
|
`quote_conflicts.csv` compares exact direct quotes for the same pair of variants.
|
||||||
It lists both source texts when their implied value ratios differ by more than
|
It lists both source texts when their implied value ratios differ by more than
|
||||||
25%. Bundle quotes participate in the sensitivity check, but the direct-pair
|
25%. Bundle quotes participate in the sensitivity check, but the direct-pair
|
||||||
@@ -92,4 +116,5 @@ shiny state, stat quality, and date, then fit the model again.
|
|||||||
|
|
||||||
`interest_index.csv`, generated by `py -B calculate_interest_index.py`, is a
|
`interest_index.csv`, generated by `py -B calculate_interest_index.py`, is a
|
||||||
separate demand-versus-supply report. The current report covers 35 variants
|
separate demand-versus-supply report. The current report covers 35 variants
|
||||||
from 1,199 distinct authors. It must not be read as a value ranking.
|
from 1,550 distinct authors. In explicit `my X for Y` proposals, X counts as
|
||||||
|
offered and Y as requested. It must not be read as a value ranking.
|
||||||
|
|||||||
+14
-9
@@ -1,18 +1,23 @@
|
|||||||
source_row,quote_type,offered,requested,source_text
|
source_row,quote_type,offered,requested,source_text
|
||||||
47,explicit_for,"{""Shiny Piccolo Evo"": 1, ""Shiny Chuuni Evo"": 1, ""Shiny Elf Mage Evo"": 1}","{""Aizen Evo"": 1}",My Shiny Piccolo Evo + Shiny Chuuni Evo + Shiny Elf Mage Evo for Aizen Evo
|
47,explicit_for,"{""Shiny Piccolo Evo"": 1, ""Shiny Chuuni Evo"": 1, ""Shiny Elf Mage Evo"": 1}","{""Aizen Evo"": 1}",My Shiny Piccolo Evo + Shiny Chuuni Evo + Shiny Elf Mage Evo for Aizen Evo
|
||||||
|
52,explicit_for,"{""Android 21 Evo"": 1, ""Alucard Evo"": 1}","{""Shiny Homura Evo"": 1}",MY Android 21 Evo + Alucard Evo FOR Shiny Homura Evo
|
||||||
174,explicit_for,"{""Shiny Boros Evo"": 1, ""Shiny Gilgamesh Evo"": 1, ""Shiny Mamy Evo"": 2}","{""Shiny Homura Evo"": 1}","Shiny Homura Evo FOR Shiny Boros Evo, Shiny Gilgamesh Evo, 2x Shiny Mamy Evo"
|
174,explicit_for,"{""Shiny Boros Evo"": 1, ""Shiny Gilgamesh Evo"": 1, ""Shiny Mamy Evo"": 2}","{""Shiny Homura Evo"": 1}","Shiny Homura Evo FOR Shiny Boros Evo, Shiny Gilgamesh Evo, 2x Shiny Mamy Evo"
|
||||||
174,explicit_for,"{""Shiny Boros Evo"": 1, ""Shiny Gilgamesh Evo"": 1}","{""Shiny Emilia Evo"": 1}",Shiny Emilia Evo FOR Shiny Boros Evo AND Shiny Gilgamesh Evo
|
174,explicit_for,"{""Shiny Boros Evo"": 1, ""Shiny Gilgamesh Evo"": 1}","{""Shiny Emilia Evo"": 1}",Shiny Emilia Evo FOR Shiny Boros Evo AND Shiny Gilgamesh Evo
|
||||||
|
253,explicit_for,"{""Shiny Dark Mage Evo"": 1, ""Buddha Evo"": 1}","{""Homura Evo"": 1}",my Shiny Dark Mage Evo + Buddha Evo for Homura Evo
|
||||||
366,explicit_for,"{""Aizen Evo"": 1, ""Homura Evo"": 1}","{""Thorfinn Evo"": 1}",My Aizen Evo and Homura Evo for Thorfinn Evo
|
366,explicit_for,"{""Aizen Evo"": 1, ""Homura Evo"": 1}","{""Thorfinn Evo"": 1}",My Aizen Evo and Homura Evo for Thorfinn Evo
|
||||||
397,explicit_for,"{""Alucard Evo"": 1, ""Shiny Ice Queen Evo"": 1}","{""Aizen Evo"": 1}",MY Alucard Evo AND Shiny ICE QUEEN Evo FOR Aizen Evo
|
463,explicit_for,"{""Shiny Somber Evo"": 1, ""Shiny Sakamoto Evo"": 1, ""Jelly Evo"": 1, ""Cid Unevo"": 2, ""Nagumo Unevo"": 2}","{""Shiny Chuuni Evo"": 1}",Shiny Somber Evo + Shiny Sakamoto Evo + Jelly Evo + 2 x Cid Unevo + 2 x Nagumo Unevo for Shiny Chuuni Evo
|
||||||
536,listing_pair,"{""Shiny Buddha Evo"": 1}","{""Homura Evo"": 1, ""Chuuni Evo"": 1}",Shiny Buddha Evo -> Homura Evo + Chuuni Evo
|
536,listing_pair,"{""Shiny Buddha Evo"": 1}","{""Homura Evo"": 1, ""Chuuni Evo"": 1}",Shiny Buddha Evo -> Homura Evo + Chuuni Evo
|
||||||
636,listing_pair,"{""Poseidon Evo"": 2, ""Nami Evo"": 1}","{""Dark Mage Evo"": 1}",2 Poseidon Evo AND Nami Evo -> Dark Mage Evo
|
636,listing_pair,"{""Poseidon Evo"": 2, ""Nami Evo"": 1}","{""Dark Mage Evo"": 1}",2 Poseidon Evo AND Nami Evo -> Dark Mage Evo
|
||||||
712,explicit_for,"{""Roger Evo"": 1, ""Homura Evo"": 1}","{""Aizen Evo"": 1}",MY ROGER Evo AND Homura Evo FOR Aizen Evo
|
|
||||||
742,explicit_for,"{""Shiny Chuuni Evo"": 1, ""Gilgamesh Evo"": 1}","{""Homura Evo"": 1}",My Shiny Chuuni Evo and Gilgamesh Evo for Homura Evo
|
|
||||||
776,explicit_for,"{""Shiny Mamy Evo"": 1, ""Shiny Dark Mage Evo"": 1}","{""Aizen Evo"": 1}",My Shiny Mamy Evo and Shiny Dark Mage Evo for Aizen Evo
|
776,explicit_for,"{""Shiny Mamy Evo"": 1, ""Shiny Dark Mage Evo"": 1}","{""Aizen Evo"": 1}",My Shiny Mamy Evo and Shiny Dark Mage Evo for Aizen Evo
|
||||||
800,listing_pair,"{""Homura Evo"": 2, ""Buddha Evo"": 1}","{""Aizen Evo"": 1}",2 Homura Evo+Buddha Evo -> Aizen Evo
|
800,listing_pair,"{""Homura Evo"": 2, ""Buddha Evo"": 1}","{""Aizen Evo"": 1}",2 Homura Evo+Buddha Evo -> Aizen Evo
|
||||||
1100,listing_pair,"{""Chuuni Evo"": 1, ""Cream Evo"": 1}","{""Dark Mage Evo"": 1}",Chuuni Evo AND Cream Evo -> Dark Mage Evo
|
1101,listing_pair,"{""Chuuni Evo"": 1, ""Cream Evo"": 1}","{""Dark Mage Evo"": 1}",Chuuni Evo AND Cream Evo -> Dark Mage Evo
|
||||||
1137,explicit_for,"{""Aizen Evo"": 1, ""Shiny Power Evo"": 1}","{""Shiny Homura Evo"": 1}",my Aizen Evo and Shiny power Evo for Shiny Homura Evo
|
1138,explicit_for,"{""Aizen Evo"": 1, ""Shiny Power Evo"": 1}","{""Shiny Homura Evo"": 1}",my Aizen Evo and Shiny power Evo for Shiny Homura Evo
|
||||||
1194,explicit_for,"{""Shiny Yoshina Evo"": 1, ""Chuuni Evo"": 1, ""Buddha Evo"": 1, ""Kisuke Evo"": 1}","{""Homura Evo"": 1}",Homura Evo for my Shiny Yoshina Evo+Chuuni Evo+Buddha Evo+kisuke Evo
|
1195,explicit_for,"{""Shiny Yoshina Evo"": 1, ""Chuuni Evo"": 1, ""Buddha Evo"": 1, ""Kisuke Evo"": 1}","{""Homura Evo"": 1}",Homura Evo for my Shiny Yoshina Evo+Chuuni Evo+Buddha Evo+kisuke Evo
|
||||||
1231,listing_pair,"{""Shiny Deer Tan Evo"": 1, ""Deer Tan Evo"": 1}","{""Shiny Idol Evo"": 1}",Shiny Deer Tan Evo and Deer Tan Evo -> Shiny idol Evo
|
1195,explicit_for,"{""Shiny Yoshina Evo"": 1, ""Chuuni Evo"": 1}","{""Shiny Dark Mage Evo"": 1}",Shiny Dark Mage Evo for my Shiny Yoshina Evo and Chuuni Evo
|
||||||
1255,listing_pair,"{""Cid Evo"": 1, ""Poseidon Evo"": 1}","{""Dark Mage Evo"": 1}",Cid Evo and Poseidon Evo -> Dark Mage Evo
|
1232,listing_pair,"{""Shiny Deer Tan Evo"": 1, ""Deer Tan Evo"": 1}","{""Shiny Idol Evo"": 1}",Shiny Deer Tan Evo and Deer Tan Evo -> Shiny idol Evo
|
||||||
1264,explicit_for,"{""Cid Evo"": 1, ""Skull Knight Evo"": 1, ""Dark Mage Evo"": 3}","{""Homura Evo"": 1}","Cid Evo,Skull Knight Evo, 3 Dark Mage Evo FOR Homura Evo"
|
1256,listing_pair,"{""Cid Evo"": 1, ""Poseidon Evo"": 1}","{""Dark Mage Evo"": 1}",Cid Evo and Poseidon Evo -> Dark Mage Evo
|
||||||
|
1265,explicit_for,"{""Cid Evo"": 1, ""Skull Knight Evo"": 1, ""Dark Mage Evo"": 3}","{""Homura Evo"": 1}","Cid Evo,Skull Knight Evo, 3 Dark Mage Evo FOR Homura Evo"
|
||||||
|
1306,listing_pair,"{""Jiraiya Evo"": 1, ""Poseidon Evo"": 1}","{""Dark Mage Evo"": 1}",my Jiraiya Evo and Poseidon Evo -> Dark Mage Evo
|
||||||
|
1334,explicit_for,"{""Shiny Issei Evo"": 1, ""Shiny Nagumo Evo"": 1, ""Ice Lily Evo"": 1}","{""Shiny Buddha Evo"": 1}","Shiny Buddha Evo For Shiny Issei Evo, Shiny Nagumo Evo And Ice Lily Evo"
|
||||||
|
1543,listing_pair,"{""Cid Evo"": 1, ""Skull Knight Unevo"": 1}","{""Dark Mage Evo"": 1}",Cid Evo and Skull Knight Unevo -> Dark Mage Evo
|
||||||
|
1702,explicit_for,"{""Shiny Poseidon Evo"": 1, ""Shiny Saki Evo"": 1, ""Shiny Tiger Evo"": 1}","{""Homura Evo"": 1}",My Shiny Poseidon Evo + Shiny Saki Evo + Shiny Tiger Evo for Homura Evo
|
||||||
|
|||||||
|
+4
-1
@@ -6,7 +6,7 @@ from collections import Counter
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from calculate_interest_index import variants
|
from calculate_interest_index import variants
|
||||||
from extract_exchange_quotes import FOR, parse_side
|
from extract_exchange_quotes import FOR, only_stat_specific_inventory, parse_side
|
||||||
|
|
||||||
|
|
||||||
SEPARATOR = re.compile(r"\s*(?:\+|,|\band\b)\s*", re.IGNORECASE)
|
SEPARATOR = re.compile(r"\s*(?:\+|,|\band\b)\s*", re.IGNORECASE)
|
||||||
@@ -69,6 +69,9 @@ def extract_bundle_quotes(rows: list[dict[str, str]]) -> list[dict]:
|
|||||||
continue
|
continue
|
||||||
if not set(offered) <= inventory or set(offered) & set(requested):
|
if not set(offered) <= inventory or set(offered) & set(requested):
|
||||||
continue
|
continue
|
||||||
|
if any(only_stat_specific_inventory(row.get("offer") or "", unit)
|
||||||
|
for unit in offered):
|
||||||
|
continue
|
||||||
key = (author, tuple(sorted(offered.items())), tuple(sorted(requested.items())))
|
key = (author, tuple(sorted(offered.items())), tuple(sorted(requested.items())))
|
||||||
if key in seen:
|
if key in seen:
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -34,12 +34,24 @@ UNIT_PATTERN = re.compile(
|
|||||||
re.IGNORECASE,
|
re.IGNORECASE,
|
||||||
)
|
)
|
||||||
MY_PREFIX = re.compile(r"\bmy\s+$", re.IGNORECASE)
|
MY_PREFIX = re.compile(r"\bmy\s+$", re.IGNORECASE)
|
||||||
|
OWNED_BEFORE_FOR = re.compile(r"\bmy\b[^|]*?\bfor\b", re.IGNORECASE)
|
||||||
|
OWNED_AFTER_FOR = re.compile(r"\bfor\s+my\b[^|]*", re.IGNORECASE)
|
||||||
|
|
||||||
|
|
||||||
def variants(text: str, *, request: bool = False) -> set[str]:
|
def variants(text: str, *, request: bool = False) -> set[str]:
|
||||||
"""Find explicit unit variants, counting each at most once per side."""
|
"""Find explicit unit variants, counting each at most once per side."""
|
||||||
found: set[str] = set()
|
found: set[str] = set()
|
||||||
|
owned_spans: list[tuple[int, int]] = []
|
||||||
|
if request:
|
||||||
|
for match in OWNED_BEFORE_FOR.finditer(text):
|
||||||
|
# The units between 'my' and 'for' are the trader's offer.
|
||||||
|
owned_spans.append((match.start(), match.end() - len("for")))
|
||||||
|
for match in OWNED_AFTER_FOR.finditer(text):
|
||||||
|
if not any(start <= match.start() < end for start, end in owned_spans):
|
||||||
|
owned_spans.append((match.start(), match.end()))
|
||||||
for match in UNIT_PATTERN.finditer(text):
|
for match in UNIT_PATTERN.finditer(text):
|
||||||
|
if request and any(start <= match.start() < end for start, end in owned_spans):
|
||||||
|
continue
|
||||||
if request and MY_PREFIX.search(text[max(0, match.start() - 12):match.start()]):
|
if request and MY_PREFIX.search(text[max(0, match.start() - 12):match.start()]):
|
||||||
continue
|
continue
|
||||||
name = CANONICAL_NAMES[canonical_key(match.group("unit"))]
|
name = CANONICAL_NAMES[canonical_key(match.group("unit"))]
|
||||||
|
|||||||
+45
-31
@@ -1,31 +1,45 @@
|
|||||||
unit_variant,quote_count,asking_quote_count,completed_trade_count,full_fit_value,leave_one_out_min,leave_one_out_max,max_change_pct,most_influential_source_row,most_influential_evidence_type,most_influential_quote,disconnects_when_removed,status,conflicting_source_rows
|
unit_variant,quote_count,asking_quote_count,explicit_ask_count,inferred_ask_count,completed_trade_count,full_fit_value,leave_one_out_min,leave_one_out_max,max_change_pct,most_influential_source_row,most_influential_evidence_type,most_influential_quote,disconnects_when_removed,status,conflicting_source_rows
|
||||||
Aizen Evo,8,8,0,1000.0,1000.0,1000.0,0.0,,,,,reference,
|
Aizen Evo,8,8,6,2,0,1000.0,1000.0,1000.0,0.0,,,,,reference,
|
||||||
Alucard Evo,4,4,0,847.2,465.2,985.9,45.1,6,asking_direct,MY Alucard Evo FOR Aizen Evo,,unstable,187 | 946
|
Alucard Evo,2,2,2,0,0,2488.9,840.0,2908.9,66.3,187,asking_direct_explicit,2 Homura Evo FOR Alucard Evo,,insufficient,
|
||||||
Buddha Evo,3,3,0,245.4,13.8,611.9,149.3,800,asking_bundle,2 Homura Evo+Buddha Evo -> Aizen Evo,,unstable,
|
Alucard Unevo,1,1,1,0,0,1037.9,985.1,1077.5,5.1,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,65 | 536 | 1334,insufficient,
|
||||||
Chuuni Evo,4,4,0,104.1,9.2,134.6,91.2,750,asking_direct,Chuuni Evo -> Dark Mage Evo,,unstable,
|
Android 21 Evo,1,1,1,0,0,1.0,1.0,840.0,83896.7,187,asking_direct_explicit,2 Homura Evo FOR Alucard Evo,52,insufficient,
|
||||||
Cid Evo,2,2,0,282.7,1.0,462.2,99.6,636,asking_bundle,2 Poseidon Evo AND Nami Evo -> Dark Mage Evo,,insufficient,
|
Buddha Evo,5,5,3,2,0,258.1,172.2,441.4,71.1,800,asking_bundle_inferred,2 Homura Evo+Buddha Evo -> Aizen Evo,,unstable,
|
||||||
Cream Evo,1,1,0,221.3,202.2,296.8,34.1,750,asking_direct,Chuuni Evo -> Dark Mage Evo,1100,insufficient,
|
Chuuni Evo,6,6,2,4,0,254.2,154.5,328.3,39.2,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,,unstable,
|
||||||
Dark Mage Evo,10,10,0,115.2,80.6,149.2,30.0,6,asking_direct,MY Alucard Evo FOR Aizen Evo,,unstable,
|
Cid Evo,5,5,3,2,0,252.6,148.3,331.1,41.3,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,,unstable,
|
||||||
Gilgamesh Evo,1,1,0,572.6,375.5,684.7,34.4,47,asking_bundle,My Shiny Piccolo Evo + Shiny Chuuni Evo + Shiny Elf Mage Evo for Aizen Evo,742,insufficient,
|
Cid Unevo,1,1,1,0,0,65.8,17.7,70.3,73.1,228,asking_direct_explicit,Shiny Chuuni Evo for Aizen Evo,463,insufficient,
|
||||||
Gilgamesh Unevo,1,1,0,274.5,87.7,626.9,128.4,800,asking_bundle,2 Homura Evo+Buddha Evo -> Aizen Evo,115,insufficient,
|
Cream Evo,1,1,0,1,0,451.5,442.7,457.2,2.0,800,asking_bundle_inferred,2 Homura Evo+Buddha Evo -> Aizen Evo,1101,insufficient,
|
||||||
Homura Evo,12,12,0,577.9,352.2,800.1,39.1,6,asking_direct,MY Alucard Evo FOR Aizen Evo,,unstable,187 | 946
|
Dark Mage Evo,16,16,5,11,0,261.5,150.6,345.9,42.4,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,,unstable,
|
||||||
Kisuke Evo,1,1,0,355.8,213.2,496.1,40.1,6,asking_direct,MY Alucard Evo FOR Aizen Evo,1194,insufficient,
|
Elf Mage Evo,1,1,0,1,0,1000.0,1000.0,1000.0,0.0,52,asking_direct_explicit,MY Shiny Gilgamesh Evo FOR THORFINN Evo,1641,insufficient,
|
||||||
Nami Evo,1,1,0,551.1,473.3,670.9,21.7,1264,asking_bundle,"Cid Evo,Skull Knight Evo, 3 Dark Mage Evo FOR Homura Evo",636,insufficient,
|
Gilgamesh Unevo,1,1,1,0,0,286.6,204.0,462.9,61.5,800,asking_bundle_inferred,2 Homura Evo+Buddha Evo -> Aizen Evo,115,insufficient,
|
||||||
Poseidon Evo,2,2,0,1.0,1.0,327.9,32694.5,636,asking_bundle,2 Poseidon Evo AND Nami Evo -> Dark Mage Evo,,insufficient,
|
Homura Evo,12,12,8,4,0,1360.1,694.9,1858.5,48.9,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,,unstable,
|
||||||
Roger Evo,1,1,0,545.0,370.0,722.7,32.6,6,asking_direct,MY Alucard Evo FOR Aizen Evo,712,insufficient,
|
Ice Lily Evo,1,1,1,0,0,596.5,462.0,697.2,22.6,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,536 | 1334,insufficient,
|
||||||
Shiny Boros Evo,1,1,0,576.9,547.2,647.6,12.3,174,asking_bundle,Shiny Emilia Evo FOR Shiny Boros Evo AND Shiny Gilgamesh Evo,174,insufficient,
|
Jelly Evo,1,1,1,0,0,532.9,508.9,535.1,4.5,228,asking_direct_explicit,Shiny Chuuni Evo for Aizen Evo,463,insufficient,
|
||||||
Shiny Buddha Evo,1,1,0,749.6,547.5,948.6,27.0,6,asking_direct,MY Alucard Evo FOR Aizen Evo,536,insufficient,
|
Jiraiya Evo,1,1,0,1,0,526.3,494.7,593.0,12.7,1378,asking_direct_explicit,MY 2 Poseidon Evo FOR Dark Mage Evo,1306,insufficient,
|
||||||
Shiny Chuuni Evo,2,2,0,120.7,39.6,425.3,252.4,742,asking_bundle,My Shiny Chuuni Evo and Gilgamesh Evo for Homura Evo,,insufficient,
|
Kisuke Evo,1,1,1,0,0,520.5,372.4,614.9,28.5,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,1195,insufficient,
|
||||||
Shiny Dark Mage Evo,2,2,0,673.6,549.6,776.8,18.4,174,asking_bundle,"Shiny Homura Evo FOR Shiny Boros Evo, Shiny Gilgamesh Evo, 2x Shiny Mamy Evo",,ranked,
|
Nagumo Evo,1,1,0,1,0,340.6,241.6,416.0,29.1,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,1540,insufficient,
|
||||||
Shiny Elf Mage Evo,1,1,0,548.1,425.3,580.8,22.4,742,asking_bundle,My Shiny Chuuni Evo and Gilgamesh Evo for Homura Evo,47,insufficient,
|
Nagumo Unevo,1,1,1,0,0,65.8,17.7,70.3,73.1,228,asking_direct_explicit,Shiny Chuuni Evo for Aizen Evo,463,insufficient,
|
||||||
Shiny Emilia Evo,1,1,0,1121.1,1074.3,1154.9,4.2,1137,asking_bundle,my Aizen Evo and Shiny power Evo for Shiny Homura Evo,174,insufficient,
|
Nami Evo,1,1,0,1,0,599.9,591.8,698.6,16.5,1378,asking_direct_explicit,MY 2 Poseidon Evo FOR Dark Mage Evo,636,insufficient,
|
||||||
Shiny Gilgamesh Evo,1,1,0,576.9,547.2,647.6,12.3,174,asking_bundle,Shiny Emilia Evo FOR Shiny Boros Evo AND Shiny Gilgamesh Evo,174,insufficient,
|
Poseidon Evo,4,4,1,3,0,118.8,1.0,159.8,99.2,1378,asking_direct_explicit,MY 2 Poseidon Evo FOR Dark Mage Evo,,unstable,
|
||||||
Shiny Homura Evo,2,2,0,1609.5,1378.5,1637.7,14.4,1137,asking_bundle,my Aizen Evo and Shiny power Evo for Shiny Homura Evo,,insufficient,
|
Shiny Boros Evo,1,1,1,0,0,183.8,24.8,726.8,295.5,52,asking_direct_explicit,MY Shiny Gilgamesh Evo FOR THORFINN Evo,,insufficient,
|
||||||
Shiny Ice Queen Evo,1,1,0,332.9,223.7,633.7,90.4,6,asking_direct,MY Alucard Evo FOR Aizen Evo,397,insufficient,
|
Shiny Buddha Evo,2,2,1,1,0,1520.0,1157.6,1791.2,23.8,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,536,insufficient,
|
||||||
Shiny Killstreak Evo,1,1,0,149.2,116.0,181.9,22.3,6,asking_direct,MY Alucard Evo FOR Aizen Evo,490,insufficient,
|
Shiny Chuuni Evo,4,4,4,0,0,965.2,654.4,994.1,32.2,228,asking_direct_explicit,Shiny Chuuni Evo for Aizen Evo,,unstable,
|
||||||
Shiny Mamy Evo,2,2,0,341.1,283.4,567.3,66.3,174,asking_bundle,"Shiny Homura Evo FOR Shiny Boros Evo, Shiny Gilgamesh Evo, 2x Shiny Mamy Evo",,insufficient,
|
Shiny Dark Mage Evo,4,4,3,1,0,986.0,646.4,1304.6,34.4,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,,unstable,
|
||||||
Shiny Piccolo Evo,1,1,0,548.1,425.3,580.8,22.4,742,asking_bundle,My Shiny Chuuni Evo and Gilgamesh Evo for Homura Evo,47,insufficient,
|
Shiny Elf Mage Evo,1,1,1,0,0,207.6,198.6,332.9,60.4,228,asking_direct_explicit,Shiny Chuuni Evo for Aizen Evo,47,insufficient,
|
||||||
Shiny Power Evo,1,1,0,692.5,559.5,714.7,19.2,174,asking_bundle,"Shiny Homura Evo FOR Shiny Boros Evo, Shiny Gilgamesh Evo, 2x Shiny Mamy Evo",1137,insufficient,
|
Shiny Emilia Evo,1,1,1,0,0,1688.3,1357.1,1784.6,19.6,52,asking_direct_explicit,MY Shiny Gilgamesh Evo FOR THORFINN Evo,174,insufficient,
|
||||||
Shiny Yoshina Evo,1,1,0,355.8,213.2,496.1,40.1,6,asking_direct,MY Alucard Evo FOR Aizen Evo,1194,insufficient,
|
Shiny Gilgamesh Evo,2,2,2,0,0,1690.4,726.8,1971.6,57.0,52,asking_direct_explicit,MY Shiny Gilgamesh Evo FOR THORFINN Evo,,insufficient,
|
||||||
Skull Knight Evo,1,1,0,495.0,427.5,642.2,29.7,636,asking_bundle,2 Poseidon Evo AND Nami Evo -> Dark Mage Evo,1264,insufficient,
|
Shiny Homura Evo,3,3,3,0,0,2116.6,1602.2,2225.4,24.3,52,asking_bundle_explicit,MY Android 21 Evo + Alucard Evo FOR Shiny Homura Evo,,ranked,
|
||||||
Thorfinn Evo,1,1,0,1455.0,1277.3,1630.0,12.2,6,asking_direct,MY Alucard Evo FOR Aizen Evo,366,insufficient,
|
Shiny Issei Evo,1,1,1,0,0,596.5,462.0,697.2,22.6,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,536 | 1334,insufficient,
|
||||||
|
Shiny Killstreak Evo,1,1,0,1,0,340.6,241.6,416.0,29.1,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,490,insufficient,
|
||||||
|
Shiny Mamy Evo,2,2,2,0,0,169.2,1.0,347.2,105.2,776,asking_bundle_explicit,My Shiny Mamy Evo and Shiny Dark Mage Evo for Aizen Evo,,insufficient,
|
||||||
|
Shiny Nagumo Evo,2,2,2,0,0,520.7,491.9,577.3,10.9,65,asking_direct_explicit,2 Shiny Nagumo Evo for Alucard Unevo,536 | 1334,insufficient,
|
||||||
|
Shiny Piccolo Evo,1,1,1,0,0,207.6,198.6,332.9,60.4,228,asking_direct_explicit,Shiny Chuuni Evo for Aizen Evo,47,insufficient,
|
||||||
|
Shiny Poseidon Evo,2,2,2,0,0,942.0,525.8,988.0,44.2,1357,asking_direct_explicit,MY Shiny Poseidon Evo FOR Shiny Chuuni Evo,,insufficient,
|
||||||
|
Shiny Power Evo,1,1,1,0,0,1091.8,686.7,1177.4,37.1,52,asking_bundle_explicit,MY Android 21 Evo + Alucard Evo FOR Shiny Homura Evo,1138,insufficient,
|
||||||
|
Shiny Sakamoto Evo,1,1,1,0,0,532.9,508.9,535.1,4.5,228,asking_direct_explicit,Shiny Chuuni Evo for Aizen Evo,463,insufficient,
|
||||||
|
Shiny Saki Evo,1,1,1,0,0,362.1,101.5,557.4,72.0,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,1702,insufficient,
|
||||||
|
Shiny Somber Evo,1,1,1,0,0,532.9,508.9,535.1,4.5,228,asking_direct_explicit,Shiny Chuuni Evo for Aizen Evo,463,insufficient,
|
||||||
|
Shiny Tiger Evo,1,1,1,0,0,362.1,101.5,557.4,72.0,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,1702,insufficient,
|
||||||
|
Shiny Yoshina Evo,1,1,1,0,0,686.8,466.5,899.5,32.1,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,,insufficient,
|
||||||
|
Skull Knight Evo,1,1,1,0,0,674.5,564.9,754.6,16.3,1687,asking_direct_explicit,MY Homura Evo FOR 6 Aizen Evo,1265,insufficient,
|
||||||
|
Skull Knight Unevo,1,1,0,1,0,452.4,448.6,459.1,1.5,1624,asking_direct_explicit,MY Cid Evo FOR Dark Mage Evo,1543,insufficient,
|
||||||
|
Thorfinn Evo,2,2,2,0,0,1750.6,846.2,2116.1,51.7,366,asking_bundle_explicit,My Aizen Evo and Homura Evo for Thorfinn Evo,,insufficient,
|
||||||
|
|||||||
|
+733
-787
File diff suppressed because it is too large
Load Diff
+772
-34
@@ -21,6 +21,7 @@ Reported scam warnings with named accounts go to scammer_warnings.csv.
|
|||||||
Offer cleanup removes copied channel labels, timestamps, and chat instructions.
|
Offer cleanup removes copied channel labels, timestamps, and chat instructions.
|
||||||
Standalone SSS stat listings and broad offered options such as "All Gamepasses"
|
Standalone SSS stat listings and broad offered options such as "All Gamepasses"
|
||||||
remain in the CSV. A broad option does not mean every item will be exchanged.
|
remain in the CSV. A broad option does not mean every item will be exchanged.
|
||||||
|
Dyno bot notices are ignored before trade extraction.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
@@ -30,6 +31,7 @@ from collections import Counter
|
|||||||
import csv
|
import csv
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from difflib import SequenceMatcher
|
from difflib import SequenceMatcher
|
||||||
|
from functools import lru_cache
|
||||||
import glob
|
import glob
|
||||||
import hashlib
|
import hashlib
|
||||||
import html
|
import html
|
||||||
@@ -74,6 +76,7 @@ UNIT_NAME_RULES = tuple(
|
|||||||
for pattern, canonical in (
|
for pattern, canonical in (
|
||||||
(r"\bSHINNY\b", "Shiny"),
|
(r"\bSHINNY\b", "Shiny"),
|
||||||
(r"\bFRIREN\b", "Frieren"),
|
(r"\bFRIREN\b", "Frieren"),
|
||||||
|
(r"\bFREIREN\b", "Elf Mage"),
|
||||||
(r"\bUMBRA\b", "Cid"),
|
(r"\bUMBRA\b", "Cid"),
|
||||||
(r"\bZABUZA\b", "Mist Ninja"),
|
(r"\bZABUZA\b", "Mist Ninja"),
|
||||||
(r"\bDAZAI\b", "Inhuman"),
|
(r"\bDAZAI\b", "Inhuman"),
|
||||||
@@ -106,12 +109,15 @@ UNIT_NAME_RULES = tuple(
|
|||||||
(r"\bHEATHCLIFF\b", "Heathcliff"),
|
(r"\bHEATHCLIFF\b", "Heathcliff"),
|
||||||
(r"\bBLACK\s*DOG\b", "Black Dog"),
|
(r"\bBLACK\s*DOG\b", "Black Dog"),
|
||||||
(r"\bSEA\s+GOD\b", "Poseidon"),
|
(r"\bSEA\s+GOD\b", "Poseidon"),
|
||||||
|
(r"\bSEAGOD\b", "Poseidon"),
|
||||||
(r"\b(?:ENLIGHTENED|ENLIGTHENED|ELIGHTEND)\b", "Buddha"),
|
(r"\b(?:ENLIGHTENED|ENLIGTHENED|ELIGHTEND)\b", "Buddha"),
|
||||||
|
(r"\bENLIGHTENET\b", "Buddha"),
|
||||||
(r"\bGOLDEN\s+KING\b", "Gilgamesh"),
|
(r"\bGOLDEN\s+KING\b", "Gilgamesh"),
|
||||||
(r"\bDRACULA\b", "Alucard"),
|
(r"\bDRACULA\b", "Alucard"),
|
||||||
(r"\bVIKING\b", "Thorfinn"),
|
(r"\bVIKING\b", "Thorfinn"),
|
||||||
(r"\bSHADOWGIRL\b", "Homura"),
|
(r"\bSHADOWGIRL\b", "Homura"),
|
||||||
(r"\bLEGENDARY\s+ASSASSIN\b", "Sakamoto"),
|
(r"\bLEGENDARY\s+ASSASSIN\b", "Sakamoto"),
|
||||||
|
(r"\bLEGENDARY\s+ASSASIN\b", "Sakamoto"),
|
||||||
(r"\bPRIME\s+ASSASSIN\b", "Sakamoto"),
|
(r"\bPRIME\s+ASSASSIN\b", "Sakamoto"),
|
||||||
(r"\bSK\s*/\s*SKULL\s*/\s*SKELETON\s+KNIGHT\b", "Skull Knight"),
|
(r"\bSK\s*/\s*SKULL\s*/\s*SKELETON\s+KNIGHT\b", "Skull Knight"),
|
||||||
(r"\bSHINY\s+SK\b", "Shiny Skull Knight"),
|
(r"\bSHINY\s+SK\b", "Shiny Skull Knight"),
|
||||||
@@ -127,29 +133,74 @@ UNIT_NAME_RULES = tuple(
|
|||||||
(r"\bVENG(?:E)?FULL?\b(?!\s+SWORD)", "Vengeful Swordsman"),
|
(r"\bVENG(?:E)?FULL?\b(?!\s+SWORD)", "Vengeful Swordsman"),
|
||||||
(r"\b(?:FRIEND|FIEND)\s+GIRL\b", "Fiend Girl"),
|
(r"\b(?:FRIEND|FIEND)\s+GIRL\b", "Fiend Girl"),
|
||||||
(r"\bSKULL\s*(?:NIGHT|KNIGHT)\b", "Skull Knight"),
|
(r"\bSKULL\s*(?:NIGHT|KNIGHT)\b", "Skull Knight"),
|
||||||
|
(r"\bSKELETON\s+KNIGHT\b", "Skull Knight"),
|
||||||
(r"\bSWITCH\s*BLADES?\b", "Nagumo"),
|
(r"\bSWITCH\s*BLADES?\b", "Nagumo"),
|
||||||
(r"\bSWITH\s*BLADES?\b", "Nagumo"),
|
(r"\bSWITH\s*BLADES?\b", "Nagumo"),
|
||||||
|
(r"\bSWICTH\s*BLADES?\b", "Nagumo"),
|
||||||
(r"\bNAGOMO\b", "Nagumo"),
|
(r"\bNAGOMO\b", "Nagumo"),
|
||||||
|
(r"\bNAGOMU\b", "Nagumo"),
|
||||||
(r"\bNAGUMO\b", "Nagumo"),
|
(r"\bNAGUMO\b", "Nagumo"),
|
||||||
(r"\bDARK\s*(?:MAGES?|MAE)\b", "Dark Mage"),
|
(r"\bDARK\s*(?:MAGES?|MAE)\b", "Dark Mage"),
|
||||||
(r"\bELF\s+MAGE\b", "Elf Mage"),
|
(r"\bELF\s+MAGE\b", "Elf Mage"),
|
||||||
|
(r"\bELF\s+MAGES\b", "Elf Mage"),
|
||||||
(r"\bSLIVER\s+KING\b", "Silver King"),
|
(r"\bSLIVER\s+KING\b", "Silver King"),
|
||||||
(r"\bERZA\s+LIGHTING\b", "Erza Lightning"),
|
(r"\bERZA\s+LIGHTING\b", "Erza Lightning"),
|
||||||
(r"\bMIST\s+NINJA\b", "Mist Ninja"),
|
(r"\bMIST\s+NINJA\b", "Mist Ninja"),
|
||||||
(r"\b(?:HOMURU|HOMURA|HOMURUS)\b", "Homura"),
|
(r"\b(?:HOMURU|HOMURA|HOMURUS)\b", "Homura"),
|
||||||
(r"\b(?:VIOLETINE|VIOLENTINE)\b", "Violentine"),
|
(r"\b(?:VIOLETINE|VIOLENTINE|VIOLENTIN|VIOLTINE|VIOLANTINE|VIOLENTE)\b", "Violentine"),
|
||||||
(r"\b(?:SOMBRE|SOMBER)\b", "Somber"),
|
(r"\b(?:SOMBRE|SOMBER)\b", "Somber"),
|
||||||
(r"\b(?:POSIDON|POSIEDON|POSSEIDON|POSEIDON)\b", "Poseidon"),
|
(r"\b(?:POSIDON|POSIEDON|POSSEIDON|POSEIDON|POSIDEN|POSAIDON|POSIDEON|POSEDION)\b", "Poseidon"),
|
||||||
(r"\b(?:CHUNI|CHUNNI|CHUNII|CHUUNI|CHUUNIS)\b", "Chuuni"),
|
(r"\b(?:CHUNI|CHUNNI|CHUNII|CHUUNI|CHUUNII|CHUUNIS|CHUNNIS|SHUUNI)\b", "Chuuni"),
|
||||||
(r"\bBUDDHAS\b", "Buddha"),
|
(r"\bBUDDHAS\b", "Buddha"),
|
||||||
(r"\bNAGUMOS\b", "Nagumo"),
|
(r"\bNAGUMOS\b", "Nagumo"),
|
||||||
(r"\bDAKR\s+MAGE\b", "Dark Mage"),
|
(r"\bDAKR\s+MAGE\b", "Dark Mage"),
|
||||||
|
(r"\bDRAK\s+MAGE\b", "Dark Mage"),
|
||||||
(r"\bGLIGAMESH\b", "Gilgamesh"),
|
(r"\bGLIGAMESH\b", "Gilgamesh"),
|
||||||
(r"\b(?:KILL\s*STREAK|KILLSTEAK|KILSTREAK|KILLSTRIKE)\b", "Killstreak"),
|
(r"\b(?:KILL\s*STREAK|KILLSTEAK|KILSTREAK|KILLSTRIKE)\b", "Killstreak"),
|
||||||
(r"\bMAMMY\b", "Mamy"),
|
(r"\bMAMMY\b", "Mamy"),
|
||||||
(r"\bAIZENS\b", "Aizen"),
|
(r"\bAIZENS\b", "Aizen"),
|
||||||
(r"\bALUCARDS\b", "Alucard"),
|
(r"\bALUCARDS\b", "Alucard"),
|
||||||
(r"\bBUDDA\b", "Buddha"),
|
(r"\bBUDDA\b", "Buddha"),
|
||||||
|
(r"\b(?:BUDDAH|BUDHA|BUDA)\b", "Buddha"),
|
||||||
|
(r"\bRAUKAI\b", "Rukia"),
|
||||||
|
(r"\bANGLE\b", "Angel"),
|
||||||
|
(r"\bANGEL\b", "Angel"),
|
||||||
|
(r"\bMERLYN\b", "Merlin"),
|
||||||
|
(r"\bSAKAMUTO\b", "Sakamoto"),
|
||||||
|
(r"\bDAKY\b", "Daki"),
|
||||||
|
(r"\bDOFAMINGO\b", "Doflamingo"),
|
||||||
|
(r"\bISSAI\b", "Issei"),
|
||||||
|
(r"\bKILLSREAK\b", "Killstreak"),
|
||||||
|
(r"\bAVDO\b", "Avdol"),
|
||||||
|
(r"\bKOBENO\b", "Kobeni"),
|
||||||
|
(r"\bHIDON\b", "Hidan"),
|
||||||
|
(r"\bYAMOMOTO\b", "Yamamoto"),
|
||||||
|
(r"\bWEATHERGIRL\b", "Weather Girl"),
|
||||||
|
(r"\bSCARLED\s+SLAYER\b", "Scarlet Slayer"),
|
||||||
|
(r"\bSHARK\s+FIN\b", "Sharkfin"),
|
||||||
|
(r"\bIN\s+HUMAN\b", "Inhuman"),
|
||||||
|
(r"\bFLAME\s+FEATHER\b", "Flamefeather"),
|
||||||
|
(r"\bVENGEFULSWORDMAN\b", "Vengeful Swordsman"),
|
||||||
|
(r"\bVENGEFULSWORDSMAN\b", "Vengeful Swordsman"),
|
||||||
|
(r"\bVEGENFUL\s+SWORDSMAN\b", "Vengeful Swordsman"),
|
||||||
|
(r"\bVANDERFUL\s+SWORDSMAN\b", "Vengeful Swordsman"),
|
||||||
|
(r"\bVENGEFUL\s+SWORDSTMAN\b", "Vengeful Swordsman"),
|
||||||
|
(r"\bVENGEFUL\s+SWORDSMEN\b", "Vengeful Swordsman"),
|
||||||
|
(r"\bVIOLENTINR\b", "Violentine"),
|
||||||
|
(r"\bSHIZU\b", "Shizo"),
|
||||||
|
(r"\bHIDEN\b", "Hidan"),
|
||||||
|
(r"\bSOMBR\b", "Somber"),
|
||||||
|
(r"\bKAGURABACHI\b", "Kagura Bachi"),
|
||||||
|
(r"\bYOSHINO\b", "Yoshina"),
|
||||||
|
(r"\bMAGIC\s+GIRL\b", "Madoka"),
|
||||||
|
(r"\bINFINITY\s+MAGE\b", "Merlin"),
|
||||||
|
(r"\bVALENTINE\b(?!\s+BUNDLE)", "Violentine"),
|
||||||
|
(r"\bSAKA\b", "Sakamoto"),
|
||||||
|
(r"\bNAVI\b", "Nami"),
|
||||||
|
(r"\bHIME\b", "Himeno"),
|
||||||
|
(r"\bAKU\b", "Gaku"),
|
||||||
|
(r"\bOSARAGI\b", "Somber"),
|
||||||
|
(r"\bGOWTHER\b", "Doll"),
|
||||||
(r"\b(?:GILGA|GILG)\b", "Gilgamesh"),
|
(r"\b(?:GILGA|GILG)\b", "Gilgamesh"),
|
||||||
(r"\bJIRAYA\b", "Jiraiya"),
|
(r"\bJIRAYA\b", "Jiraiya"),
|
||||||
(r"\bHEALTCLIFF\b", "Heathcliff"),
|
(r"\bHEALTCLIFF\b", "Heathcliff"),
|
||||||
@@ -180,7 +231,7 @@ KNOWN_UNIT_NAMES = tuple(sorted(
|
|||||||
"Death Ninja", "Ice Lily", "Illusionist", "Doflamingo", "Doffy",
|
"Death Ninja", "Ice Lily", "Illusionist", "Doflamingo", "Doffy",
|
||||||
"Viking", "Gohan", "Issei", "Mami", "Mamy", "Millie", "Merlin",
|
"Viking", "Gohan", "Issei", "Mami", "Mamy", "Millie", "Merlin",
|
||||||
"Yamamoto", "Scarlet Slayer", "Flash Ninja", "Heart Princess",
|
"Yamamoto", "Scarlet Slayer", "Flash Ninja", "Heart Princess",
|
||||||
"Angel Devil", "Esdeath", "Erza", "Lucy", "Zabuza", "Kagura Bachi",
|
"Angel", "Angel Devil", "Esdeath", "Erza", "Lucy", "Zabuza", "Kagura Bachi",
|
||||||
"Saki", "Gaku", "Rukia", "Hinami", "Julias", "Umbra", "Rohan",
|
"Saki", "Gaku", "Rukia", "Hinami", "Julias", "Umbra", "Rohan",
|
||||||
"Daki", "Caesar", "Lelouch", "Flamingo", "Veko", "Ichigo",
|
"Daki", "Caesar", "Lelouch", "Flamingo", "Veko", "Ichigo",
|
||||||
"Mangaka", "Oshy", "Akeno", "Akena", "Bomb Angel", "Kisame",
|
"Mangaka", "Oshy", "Akeno", "Akena", "Bomb Angel", "Kisame",
|
||||||
@@ -203,11 +254,77 @@ UNIT_MENTION = re.compile(
|
|||||||
for name in KNOWN_UNIT_NAMES) + r")(?!\w)",
|
for name in KNOWN_UNIT_NAMES) + r")(?!\w)",
|
||||||
re.I,
|
re.I,
|
||||||
)
|
)
|
||||||
|
AUTOCORRECT_NAMES = tuple(sorted(
|
||||||
|
{name for name in KNOWN_UNIT_NAMES if len(name.replace(" ", "")) >= 5},
|
||||||
|
key=str.casefold,
|
||||||
|
))
|
||||||
|
AUTOCORRECT_EXACT = frozenset(name.casefold() for name in KNOWN_UNIT_NAMES)
|
||||||
|
|
||||||
|
|
||||||
|
def one_typo_apart(left: str, right: str) -> bool:
|
||||||
|
"""Accept one insertion, deletion, replacement, or adjacent swap."""
|
||||||
|
left, right = left.casefold(), right.casefold()
|
||||||
|
if left == right:
|
||||||
|
return False
|
||||||
|
if abs(len(left) - len(right)) > 1:
|
||||||
|
return False
|
||||||
|
if len(left) == len(right):
|
||||||
|
different = [i for i, (a, b) in enumerate(zip(left, right)) if a != b]
|
||||||
|
return len(different) == 1 or (
|
||||||
|
len(different) == 2 and different[1] == different[0] + 1
|
||||||
|
and left[different[0]] == right[different[1]]
|
||||||
|
and left[different[1]] == right[different[0]]
|
||||||
|
)
|
||||||
|
short, long = sorted((left, right), key=len)
|
||||||
|
return any(short == long[:i] + long[i + 1:] for i in range(len(long)))
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache(maxsize=4096)
|
||||||
|
def correct_unit_typo(name: str) -> str:
|
||||||
|
if name.casefold() in AUTOCORRECT_EXACT:
|
||||||
|
return name
|
||||||
|
matches = [known for known in AUTOCORRECT_NAMES if one_typo_apart(name, known)]
|
||||||
|
return matches[0] if len(matches) == 1 else name
|
||||||
|
|
||||||
|
|
||||||
|
def autocorrect_unit_names(value: str) -> str:
|
||||||
|
"""Correct one clear typo beside a variant cue or in a bare item."""
|
||||||
|
|
||||||
|
def before_status(match: re.Match[str]) -> str:
|
||||||
|
words = match.group("phrase").split()
|
||||||
|
for width in range(min(3, len(words)), 0, -1):
|
||||||
|
candidate = " ".join(words[-width:])
|
||||||
|
fixed = correct_unit_typo(candidate)
|
||||||
|
if fixed != candidate:
|
||||||
|
return " ".join(words[:-width] + [fixed]) + " " + match.group("status")
|
||||||
|
return match.group()
|
||||||
|
|
||||||
|
value = re.sub(
|
||||||
|
r"(?<!\w)(?P<phrase>[A-Za-z]+(?:\s+[A-Za-z]+){0,2})\s+"
|
||||||
|
r"(?P<status>Evo|Unevo)\b",
|
||||||
|
before_status, value, flags=re.I,
|
||||||
|
)
|
||||||
|
value = re.sub(
|
||||||
|
r"\bShiny\s+(?P<name>[A-Za-z]+)\b(?=\s*(?:[|,;/)]|$))",
|
||||||
|
lambda m: "Shiny " + correct_unit_typo(m.group("name")), value, flags=re.I,
|
||||||
|
)
|
||||||
|
parts = value.split("|")
|
||||||
|
for index, part in enumerate(parts):
|
||||||
|
bare = re.fullmatch(
|
||||||
|
r"(?P<prefix>\s*(?:(?:x?\d+x?)\s+)?(?:Shiny\s+)?)"
|
||||||
|
r"(?P<name>[A-Za-z]+(?:\s+[A-Za-z]+){0,2})(?P<trailing>\s*)",
|
||||||
|
part, flags=re.I,
|
||||||
|
)
|
||||||
|
if bare:
|
||||||
|
parts[index] = (bare.group("prefix") + correct_unit_typo(bare.group("name")) +
|
||||||
|
bare.group("trailing"))
|
||||||
|
return "|".join(parts)
|
||||||
ALIASED_UNITS = ("Cid", "Mist Ninja", "Inhuman", "Aizen", "Elf Mage",
|
ALIASED_UNITS = ("Cid", "Mist Ninja", "Inhuman", "Aizen", "Elf Mage",
|
||||||
"Boros", "Poseidon", "Buddha", "Gilgamesh", "Alucard",
|
"Boros", "Poseidon", "Buddha", "Gilgamesh", "Alucard",
|
||||||
"Thorfinn", "Homura", "Sakamoto", "Shizo", "Doflamingo",
|
"Thorfinn", "Homura", "Sakamoto", "Shizo", "Doflamingo",
|
||||||
"Nagumo", "Rias", "Mamy", "Dark Mage", "Vengeful Swordsman",
|
"Nagumo", "Rias", "Mamy", "Dark Mage", "Vengeful Swordsman",
|
||||||
"Harribel", "Violentine", "Dog Demon", "Heathcliff")
|
"Harribel", "Violentine", "Dog Demon", "Heathcliff",
|
||||||
|
"Skull Knight")
|
||||||
_ALIAS_NAMES = "|".join(re.escape(name).replace(r"\ ", r"\s+")
|
_ALIAS_NAMES = "|".join(re.escape(name).replace(r"\ ", r"\s+")
|
||||||
for name in sorted(ALIASED_UNITS, key=len, reverse=True))
|
for name in sorted(ALIASED_UNITS, key=len, reverse=True))
|
||||||
ALIAS_PAIR = re.compile(
|
ALIAS_PAIR = re.compile(
|
||||||
@@ -380,7 +497,12 @@ CHALLENGE_NOTE = re.compile(
|
|||||||
r"\(?\s*\bup\s+from\s+[^|)\n]{1,100}?\s+to\s+[^|)\n]{1,100}\)?",
|
r"\(?\s*\bup\s+from\s+[^|)\n]{1,100}?\s+to\s+[^|)\n]{1,100}\)?",
|
||||||
re.I,
|
re.I,
|
||||||
)
|
)
|
||||||
REPORT_HANDLE = re.compile(r"(?<![\w@])@[A-Za-z0-9_.-]{2,32}")
|
REPORT_HANDLE = re.compile(r"(?<![\w@])@[A-Za-z0-9_.-]{2,32}(?:#\d{4})?")
|
||||||
|
SCAM_LIST_HEADING = re.compile(r"^\s*scammers?\s+list\s*:\s*(.*)$", re.I)
|
||||||
|
SCAM_LIST_HANDLES = re.compile(
|
||||||
|
r"\s*@[A-Za-z0-9_.-]{2,32}(?:#\d{4})?"
|
||||||
|
r"(?:\s*[/,;|]\s*@[A-Za-z0-9_.-]{2,32}(?:#\d{4})?)*\s*"
|
||||||
|
)
|
||||||
SCAM_WARNING_START = re.compile(
|
SCAM_WARNING_START = re.compile(
|
||||||
r"\bscamm?er\s+@[A-Za-z0-9_.-]{2,32}|"
|
r"\bscamm?er\s+@[A-Za-z0-9_.-]{2,32}|"
|
||||||
r"['\"`]?@[A-Za-z0-9_.-]{2,32}['\"`]?"
|
r"['\"`]?@[A-Za-z0-9_.-]{2,32}['\"`]?"
|
||||||
@@ -475,6 +597,34 @@ NON_ITEM_OFFER = re.compile(
|
|||||||
re.I,
|
re.I,
|
||||||
)
|
)
|
||||||
OFFER_TIMESTAMP = re.compile(r"\d+\s*[•·]\s*\d{1,2}:\d{2}")
|
OFFER_TIMESTAMP = re.compile(r"\d+\s*[•·]\s*\d{1,2}:\d{2}")
|
||||||
|
REQUEST_META = re.compile(
|
||||||
|
r"^(?:also|only|\(\s*lf\s*\)|keyword\s*:|"
|
||||||
|
r"\(message:\s*i\s+have\b.*|no\s+give\s+offer|"
|
||||||
|
r"this\s+post\s+was\s+sent\s+by|"
|
||||||
|
r"\(?\s*no\s+i\s+am\s+not\s+a\s+bot\s*\)?|"
|
||||||
|
r"(?:no\s+reply|no\s+response)\s*=\s*nty|"
|
||||||
|
r"(?:ignore\s*=\s*(?:nty|afk)|nty\s*=\s*ignore)\b.*|"
|
||||||
|
r"(?:i\s+respond|will\s+always\s+try\s+to\s+respond|"
|
||||||
|
r"will\s+read\s+all\s+dms|reply\s+to\s+all\s+dms)\b.*|"
|
||||||
|
r"(?:ill\s+respond\s+everyone|\+?\s*i['’]?ll\s+reply\s+to\s+all\s+dm)\b.*|"
|
||||||
|
r"(?:i\s+dont\s+make\s+an?\s+offer|im\s+not\s+making\s+offers)\b.*|"
|
||||||
|
r"dont\s+even\s+try\s+to\s+scam\s+me\b.*|"
|
||||||
|
r"no\s+pearn\s+scam|just\s+dm\s+me|"
|
||||||
|
r"(?:scammer\s+list|people\s+who\s+ask\s+if\s+they\s+may\s+offer)\b.*|"
|
||||||
|
r"(?:ignoring\s+clowns|clown|i\s+dont\s+make\s+offer)\b.*|"
|
||||||
|
r"i\s+won.t\s+offer\s+for\s+ur\s+units/items\b.*|"
|
||||||
|
r"please\s+dm\s+me\s+with\s+an\s+offer\b.*|"
|
||||||
|
r"dm\s+for\s+pics/offer|"
|
||||||
|
r"send\s+me\s+offers|"
|
||||||
|
r"(?:scammers?|switching\s+shiny\s+scammer|scammer\s+percentage)\s*:.+|"
|
||||||
|
r"(?:come\s+with\s+offers?(?:\s+please)?|just\s+dm\s+me|"
|
||||||
|
r"drop\s+ur\s+offer,?\s*im\s+not\s+offering|friend\s*#\s*\d+|"
|
||||||
|
r"i\s+don.?t\s+bite\s+send\s+whatever)\b.*|"
|
||||||
|
r"(?:please\s+come\s+to\s+my|feel\s+free\s+to\s+Dark\s+Mage\s+Evo)\b.*i\s+don.?t\s+bite.*|"
|
||||||
|
r"@[\w.-]+(?:\s+@?[\w.()@-]+)*|"
|
||||||
|
r"[\W_]+)$", re.I,
|
||||||
|
)
|
||||||
|
EMBEDDED_REQUEST_LABEL = re.compile(r"\(\s*(MLF|NLF|NFL)\s*:?\s*([^()]*)\)", re.I)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
@@ -483,6 +633,15 @@ class Message:
|
|||||||
body: str
|
body: str
|
||||||
|
|
||||||
|
|
||||||
|
def is_dyno_message(msg: Message) -> bool:
|
||||||
|
"""Identify Dyno by its Discord author, never by text in a user's offer."""
|
||||||
|
identity = msg.author.casefold()
|
||||||
|
return bool(re.fullmatch(
|
||||||
|
r"(?:display:dyno(?:#\d{4}|\s*\(bot\))?|handle:dyno(?:\.gg)?)",
|
||||||
|
identity,
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class ScamWarning:
|
class ScamWarning:
|
||||||
reported_handles: str
|
reported_handles: str
|
||||||
@@ -573,7 +732,8 @@ def iter_messages(lines: Iterable[str]) -> Iterator[Message]:
|
|||||||
text = "\n".join(body).strip()
|
text = "\n".join(body).strip()
|
||||||
if not text:
|
if not text:
|
||||||
return None
|
return None
|
||||||
return Message(author or "unknown:" + uuid.uuid4().hex, text)
|
message = Message(author or "unknown:" + uuid.uuid4().hex, text)
|
||||||
|
return None if is_dyno_message(message) else message
|
||||||
|
|
||||||
while peek(0) is not None:
|
while peek(0) is not None:
|
||||||
p0 = peek(0)
|
p0 = peek(0)
|
||||||
@@ -622,7 +782,34 @@ def extract_scam_warnings(msg: Message) -> tuple[Message, list[ScamWarning]]:
|
|||||||
"""Keep reported allegations separate from the surrounding trade text."""
|
"""Keep reported allegations separate from the surrounding trade text."""
|
||||||
kept_lines: list[str] = []
|
kept_lines: list[str] = []
|
||||||
warnings: list[ScamWarning] = []
|
warnings: list[ScamWarning] = []
|
||||||
for raw in msg.body.splitlines():
|
lines = msg.body.splitlines()
|
||||||
|
index = 0
|
||||||
|
while index < len(lines):
|
||||||
|
raw = lines[index]
|
||||||
|
heading = SCAM_LIST_HEADING.fullmatch(raw)
|
||||||
|
if heading:
|
||||||
|
list_lines = [heading.group(1)] if heading.group(1) else []
|
||||||
|
next_index = index + 1
|
||||||
|
while next_index < len(lines):
|
||||||
|
candidate = lines[next_index].strip()
|
||||||
|
if not candidate:
|
||||||
|
next_index += 1
|
||||||
|
continue
|
||||||
|
if not SCAM_LIST_HANDLES.fullmatch(candidate):
|
||||||
|
break
|
||||||
|
list_lines.append(candidate)
|
||||||
|
next_index += 1
|
||||||
|
handles = list(dict.fromkeys(
|
||||||
|
match.group()[1:] for line in list_lines
|
||||||
|
for match in REPORT_HANDLE.finditer(line)
|
||||||
|
))
|
||||||
|
if handles:
|
||||||
|
warnings.append(ScamWarning(" | ".join(handles),
|
||||||
|
"Scammer List: " + " / ".join(list_lines),
|
||||||
|
hash_author(msg.author)))
|
||||||
|
index = next_index
|
||||||
|
continue
|
||||||
|
index += 1
|
||||||
fragments = raw.split("|")
|
fragments = raw.split("|")
|
||||||
kept_fragments: list[str] = []
|
kept_fragments: list[str] = []
|
||||||
found = False
|
found = False
|
||||||
@@ -737,6 +924,13 @@ def normalize_fodder_units(value: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def normalize_unit_names(value: str) -> str:
|
def normalize_unit_names(value: str) -> str:
|
||||||
|
value = re.sub(r"(?<!\w)×\s*(\d+)(?=\s+\w)", r"\1x", value)
|
||||||
|
value = re.sub(r"\b(\d+)\s*×\s*(?=\w)", r"\1x ", value)
|
||||||
|
value = re.sub(r"\bInfinity\s+Mage\s*/\s*Merlin\s+(Evo|Unevo)\b",
|
||||||
|
lambda m: "Merlin " + m.group(1).capitalize(), value, flags=re.I)
|
||||||
|
value = re.sub(r"\bShiny(?=Heathcliff\b)", "Shiny ", value, flags=re.I)
|
||||||
|
value = re.sub(r"\b(\d+)x(?=Chuuni\b|Nagumo\b|DM\b)", r"\1x ", value, flags=re.I)
|
||||||
|
value = re.sub(r"\b(\d+)(?=Nagumo\b|DM\b)", r"\1x ", value, flags=re.I)
|
||||||
def collapse_shiny_named_alias(match: re.Match[str]) -> str:
|
def collapse_shiny_named_alias(match: re.Match[str]) -> str:
|
||||||
if match.group("first").casefold() == match.group("second").casefold():
|
if match.group("first").casefold() == match.group("second").casefold():
|
||||||
return match.group()
|
return match.group()
|
||||||
@@ -780,6 +974,31 @@ def normalize_unit_names(value: str) -> str:
|
|||||||
value = MAMY_ALIAS_CHAIN.sub(collapse_mamy_aliases, value)
|
value = MAMY_ALIAS_CHAIN.sub(collapse_mamy_aliases, value)
|
||||||
for pattern, canonical in UNIT_NAME_RULES:
|
for pattern, canonical in UNIT_NAME_RULES:
|
||||||
value = pattern.sub(canonical, value)
|
value = pattern.sub(canonical, value)
|
||||||
|
value = autocorrect_unit_names(value)
|
||||||
|
value = re.sub(r"\b(?:1\s+)?Evo\s+Shiny\s+Somber\s*\(\s*Somber Evo\s*\)",
|
||||||
|
"1x Shiny Somber Evo", value, flags=re.I)
|
||||||
|
value = re.sub(r"\bEvo\s+Shiny\s+Doll\s*\(\s*Doll Evo\s*\)",
|
||||||
|
"Shiny Doll Evo", value, flags=re.I)
|
||||||
|
value = re.sub(r"\bShiny\s+Doll\s*\(\s*Doll Evo\s*\)",
|
||||||
|
"Shiny Doll Evo", value, flags=re.I)
|
||||||
|
value = re.sub(r"\bShiny\s+(Somber|Doll)\s*(?:Evo\s*)?/\s*\1\s+Evo\b",
|
||||||
|
lambda m: "Shiny " + m.group(1).title() + " Evo", value, flags=re.I)
|
||||||
|
value = re.sub(r"\bShiny\s+Skull\s+Knight\s+Evo\s*/\s*Skull\s+Knight(?:\s+Evo)?\b",
|
||||||
|
"Shiny Skull Knight Evo", value, flags=re.I)
|
||||||
|
value = re.sub(r"\bDeer\s+Tan\s+Evo\s+Shiny\s+AND\s+NON\b",
|
||||||
|
"Shiny Deer Tan Evo | Deer Tan Evo", value, flags=re.I)
|
||||||
|
value = re.sub(r"\bCid\s+Evo\s+Shiny\s+Unevo\b",
|
||||||
|
"Shiny Cid Evo", value, flags=re.I)
|
||||||
|
value = re.sub(r"\bJin\s+Mori\s*\(\s*Shiny\s*\)",
|
||||||
|
"Shiny Jin Mori", value, flags=re.I)
|
||||||
|
value = re.sub(r"\bGreen\s+alien\s*\(\s*Shiny\s*\)",
|
||||||
|
"Shiny Green Alien", value, flags=re.I)
|
||||||
|
value = re.sub(r"\bDeer\s+Tan\s+Evo\s*/\s*noko\s+tan\s*\(\s*Shiny\s*\)",
|
||||||
|
"Shiny Deer Tan Evo", value, flags=re.I)
|
||||||
|
value = re.sub(r"\bDark\s+Mage\s+Evo\s+Shiny\b",
|
||||||
|
"Shiny Dark Mage Evo", value, flags=re.I)
|
||||||
|
value = re.sub(r"\bUnevo\s+Shiny\s+Vanilla\s+Ice\s*\(\s*Cream Evo\s*\)",
|
||||||
|
"Shiny Cream Unevo", value, flags=re.I)
|
||||||
def drop_admin_alias(match: re.Match[str]) -> str:
|
def drop_admin_alias(match: re.Match[str]) -> str:
|
||||||
status = (match.group("status") or "").strip().capitalize()
|
status = (match.group("status") or "").strip().capitalize()
|
||||||
if status == "Unevo" or re.search(r"\bUnevo\s+$", value[:match.start()], re.I):
|
if status == "Unevo" or re.search(r"\bUnevo\s+$", value[:match.start()], re.I):
|
||||||
@@ -1190,6 +1409,15 @@ def normalize_shiny_evo_order(value: str) -> str:
|
|||||||
rf"(?P<unit>{unit})\s+Evo\s+Shiny(?=\s*(?:\||$|[,;/)]))",
|
rf"(?P<unit>{unit})\s+Evo\s+Shiny(?=\s*(?:\||$|[,;/)]))",
|
||||||
lambda m: "Shiny " + m.group("unit") + " Evo", value, flags=re.I,
|
lambda m: "Shiny " + m.group("unit") + " Evo", value, flags=re.I,
|
||||||
)
|
)
|
||||||
|
value = re.sub(
|
||||||
|
r"\b(?P<unit>Silver Slayer|Toad Sensei|Doll|Violentine)\s+Evo\s+Shiny\b"
|
||||||
|
r"(?!\s+(?:pass|hunter)\b)",
|
||||||
|
lambda m: "Shiny " + m.group("unit").title() + " Evo", value, flags=re.I,
|
||||||
|
)
|
||||||
|
value = re.sub(r"\bUnevo\s+Shiny\s+Cream\b",
|
||||||
|
"Shiny Cream Unevo", value, flags=re.I)
|
||||||
|
value = re.sub(r"\bEvo\s+Shiny\s+Chuuni\b",
|
||||||
|
"Shiny Chuuni Evo", value, flags=re.I)
|
||||||
parts = value.split("|")
|
parts = value.split("|")
|
||||||
for i, part in enumerate(parts):
|
for i, part in enumerate(parts):
|
||||||
part = re.sub(
|
part = re.sub(
|
||||||
@@ -1245,12 +1473,105 @@ def normalize_evo_status(value: str) -> str:
|
|||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def normalize_variant_quantities(value: str) -> str:
|
||||||
|
"""Expand explicit inventory totals without losing their shiny or Evo status."""
|
||||||
|
unit = UNIT_MENTION.pattern
|
||||||
|
value = re.sub(
|
||||||
|
rf"(?P<unit>{unit})\s+(?P<status>Evo|Unevo)\s+×(?P<count>\d+)\b",
|
||||||
|
lambda m: f'{m.group("count")}x {m.group("unit")} {m.group("status")}',
|
||||||
|
value, flags=re.I,
|
||||||
|
)
|
||||||
|
value = re.sub(r"\b3\s+Fodder\s+Units\s*\(\s*2\s+Unevo\s*,\s*1\s+Evo\s*\)",
|
||||||
|
"2x Fodder Units Unevo | 1x Fodder Units Evo", value, flags=re.I)
|
||||||
|
|
||||||
|
def shiny_remainder(match: re.Match[str]) -> str:
|
||||||
|
total, shiny = int(match.group("total")), int(match.group("shiny_count"))
|
||||||
|
if shiny > total:
|
||||||
|
return match.group()
|
||||||
|
name, status = match.group("unit").title(), match.group("status").capitalize()
|
||||||
|
output = [f"{shiny}x Shiny {name} {status}"]
|
||||||
|
if total > shiny:
|
||||||
|
output.append(f"{total - shiny}x {name} {status}")
|
||||||
|
return " | ".join(output)
|
||||||
|
|
||||||
|
value = re.sub(
|
||||||
|
rf"(?<!\w)(?P<total>\d+)\s*[xX]?\s+(?P<unit>{unit})\s+"
|
||||||
|
rf"(?P<status>Evo|Unevo)\s*\(\s*(?P<shiny_count>\d+)\s*[xX]?\s+Shiny\s*\)",
|
||||||
|
shiny_remainder, value, flags=re.I,
|
||||||
|
)
|
||||||
|
value = re.sub(
|
||||||
|
rf"(?<!\w)(?P<unit>{unit})\s+(?P<status>Evo|Unevo)\s*\(\s*Shiny\s*\)",
|
||||||
|
lambda m: f'Shiny {m.group("unit").title()} {m.group("status").capitalize()}',
|
||||||
|
value, flags=re.I,
|
||||||
|
)
|
||||||
|
|
||||||
|
def counted_variants(match: re.Match[str]) -> str:
|
||||||
|
total = int(match.group("total"))
|
||||||
|
first_count = int(match.group("first_count"))
|
||||||
|
second_count = (int(match.group("second_count"))
|
||||||
|
if match.group("second_count") else total - first_count)
|
||||||
|
if (first_count > total or second_count < 0 or
|
||||||
|
first_count + second_count != total):
|
||||||
|
return match.group()
|
||||||
|
first_status = match.group("first_status").capitalize()
|
||||||
|
second_status = ((match.group("second_status") or
|
||||||
|
("Unevo" if first_status == "Evo" else "Evo")).capitalize())
|
||||||
|
if first_status == second_status:
|
||||||
|
return match.group()
|
||||||
|
name = ("Shiny " if match.group("shiny") else "") + match.group("unit").title()
|
||||||
|
variants = []
|
||||||
|
for count, status in ((first_count, first_status), (second_count, second_status)):
|
||||||
|
if count:
|
||||||
|
variants.append(f"{count}x {name} {status}")
|
||||||
|
return " | ".join(variants)
|
||||||
|
|
||||||
|
value = re.sub(
|
||||||
|
rf"(?<!\w)(?P<total>\d+)\s*[xX]?\s+(?P<shiny>Shiny\s+)?"
|
||||||
|
rf"(?P<unit>{unit})\s*\(\s*(?P<first_count>\d+)\s+"
|
||||||
|
rf"(?P<first_status>Evo|Unevo)\s*,?\s*"
|
||||||
|
rf"(?:(?P<second_count>\d+)\s+(?P<second_status>Evo|Unevo))?\s*\)",
|
||||||
|
counted_variants, value, flags=re.I,
|
||||||
|
)
|
||||||
|
value = re.sub(
|
||||||
|
rf"(?<!\w)(?P<first_count>\d+)\s+(?P<unit>{unit})\s+"
|
||||||
|
rf"(?P<first_status>Evo|Unevo)\s+(?P<second_count>\d+)\s+"
|
||||||
|
rf"(?P<second_status>Evo|Unevo)\b",
|
||||||
|
lambda m: (f'{m.group("first_count")}x {m.group("unit").title()} '
|
||||||
|
f'{m.group("first_status").capitalize()} | '
|
||||||
|
f'{m.group("second_count")}x {m.group("unit").title()} '
|
||||||
|
f'{m.group("second_status").capitalize()}'),
|
||||||
|
value, flags=re.I,
|
||||||
|
)
|
||||||
|
value = re.sub(
|
||||||
|
rf"(?<!\w)(?P<unit>{unit})\s+(?P<first_count>\d+)\s+"
|
||||||
|
rf"(?P<first_status>Evo|Unevo)\s*[/,]\s*"
|
||||||
|
rf"(?P<second_count>\d+)\s+(?P<second_status>Evo|Unevo)\b",
|
||||||
|
lambda m: (f'{m.group("first_count")}x {m.group("unit").title()} '
|
||||||
|
f'{m.group("first_status").capitalize()} | '
|
||||||
|
f'{m.group("second_count")}x {m.group("unit").title()} '
|
||||||
|
f'{m.group("second_status").capitalize()}'),
|
||||||
|
value, flags=re.I,
|
||||||
|
)
|
||||||
|
value = re.sub(r"\b(\d+)\s*Evo\s+Nagumo\s+Evo\b", r"\1x Nagumo Evo", value, flags=re.I)
|
||||||
|
value = re.sub(r"\b(\d+)\s+Evo\s+Chuuni\b", r"\1x Chuuni Evo", value, flags=re.I)
|
||||||
|
value = re.sub(r"\bNagumo\s+(\d+)\s+Evo\b", r"\1x Nagumo Evo", value, flags=re.I)
|
||||||
|
value = re.sub(r"\b2\s+Skull\s+Knight\s+1\s+Unevo\b",
|
||||||
|
"1x Skull Knight Evo | 1x Skull Knight Unevo", value, flags=re.I)
|
||||||
|
value = re.sub(r"\b3\s+Nagumo\s+2\s+Unevo\s+1\s+Evo\b",
|
||||||
|
"2x Nagumo Unevo | 1x Nagumo Evo", value, flags=re.I)
|
||||||
|
value = re.sub(r"\bBuddha\s*\(\s*Buddha Evo\s*\)\s*Evo\b",
|
||||||
|
"Buddha Evo", value, flags=re.I)
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
def normalize_body_line(raw: str) -> str:
|
def normalize_body_line(raw: str) -> str:
|
||||||
value = tidy_line(raw)
|
value = tidy_line(raw)
|
||||||
value = remove_unicode_emoji(value)
|
value = remove_unicode_emoji(value)
|
||||||
value = normalize_shiny_evo_order(normalize_unit_names(
|
# In copied reposts, the next Trading label can touch the word "units".
|
||||||
|
value = re.sub(r"\bunitstrade\b", "units | Trading:", value, flags=re.I)
|
||||||
|
value = normalize_shiny_evo_order(normalize_variant_quantities(normalize_unit_names(
|
||||||
remove_non_trade_notices(remove_decorative_marks(remove_emoji_codes(value)))
|
remove_non_trade_notices(remove_decorative_marks(remove_emoji_codes(value)))
|
||||||
))
|
)))
|
||||||
value = value.replace("!", "")
|
value = value.replace("!", "")
|
||||||
value = normalize_shiny_evo_order(normalize_evo_status(normalize_shiny_evo_order(value)))
|
value = normalize_shiny_evo_order(normalize_evo_status(normalize_shiny_evo_order(value)))
|
||||||
value = re.sub(r"^\s*[-•]+\s+", "", value)
|
value = re.sub(r"^\s*[-•]+\s+", "", value)
|
||||||
@@ -1308,6 +1629,360 @@ def clean_offer_items(offer: str) -> str:
|
|||||||
return " | ".join(kept)
|
return " | ".join(kept)
|
||||||
|
|
||||||
|
|
||||||
|
def separate_received_bid(offer: str) -> tuple[str, str]:
|
||||||
|
"""Keep an already received best/high offer out of owned inventory."""
|
||||||
|
owned: list[str] = []
|
||||||
|
bids: list[str] = []
|
||||||
|
for raw in offer.split("|"):
|
||||||
|
part = raw.strip()
|
||||||
|
match = re.search(r"\b(?:BEST|HIGH)\s+OFFER\s*:?\s*", part, re.I)
|
||||||
|
if match:
|
||||||
|
if part[:match.start()].strip(" ,;:-"):
|
||||||
|
owned.append(part[:match.start()].strip(" ,;:-"))
|
||||||
|
bid = part[match.end():].strip(" ,;:-")
|
||||||
|
if bid:
|
||||||
|
bids.append(bid)
|
||||||
|
continue
|
||||||
|
part = re.sub(r"^PRE[-\s]?TRADE\s+", "", part, flags=re.I)
|
||||||
|
if part:
|
||||||
|
owned.append(part)
|
||||||
|
return " | ".join(owned), " | ".join(bids)
|
||||||
|
|
||||||
|
|
||||||
|
def clean_request_segments(value: str) -> str:
|
||||||
|
"""Keep requested units and conditions, discarding clear UI/chat fragments."""
|
||||||
|
kept = []
|
||||||
|
for raw in value.split("|"):
|
||||||
|
segment = raw.strip().strip(" ,;#'\"")
|
||||||
|
if segment.casefold() == "ignoring clowns/lowballs":
|
||||||
|
segment = "Lowballs"
|
||||||
|
if not segment or REQUEST_META.fullmatch(segment):
|
||||||
|
continue
|
||||||
|
segment = re.sub(r"\s+IF\s+NO\s+REPLY\s+means\s+ignore\s*$", "", segment, flags=re.I)
|
||||||
|
segment = re.sub(r"\s+NOT\s+A\s+BOT\s*$", "", segment, flags=re.I)
|
||||||
|
segment = re.sub(r"(?:\s*\W+\s*|\s+)(?:PLEASE\s+)?DM\s+(?:ME|YOUR\s+OFFERS|ME\s+FOR\s+OFFERS)\]?\s*$",
|
||||||
|
"", segment, flags=re.I)
|
||||||
|
segment = re.sub(r"\s+I\s+REPLY\s+ALWAYS\s*$", "", segment, flags=re.I)
|
||||||
|
segment = re.sub(r"\s+i\s+don.?t\s+bite\s+send\s+whatever\s*$", "", segment, flags=re.I)
|
||||||
|
segment = re.sub(r"\s*(?:/|,)\s*(?:ignore\s*=\s*nty|no\s+response\s*=\s*nty)\s*$",
|
||||||
|
"", segment, flags=re.I)
|
||||||
|
segment = segment.strip(" ,;#'\"")
|
||||||
|
if segment and not REQUEST_META.fullmatch(segment):
|
||||||
|
kept.append(segment)
|
||||||
|
return " | ".join(kept)
|
||||||
|
|
||||||
|
|
||||||
|
def clean_request_fields(lf: str, mlf: str, nlf: str,
|
||||||
|
looking_for: str = "") -> tuple[str, str, str, str]:
|
||||||
|
"""Repair explicit MLF/NLF labels and rebuild the compatibility field."""
|
||||||
|
# A copied repost joined 'GOOD OFFERS' to its next Trading label and then
|
||||||
|
# repeated the same offer inventory in LF.
|
||||||
|
if re.fullmatch(r"GOOD OFFERSTrading\s*\|.*\|\s*GOOD OFFERS", lf, re.I):
|
||||||
|
lf = "GOOD OFFERS"
|
||||||
|
# In one listing, the NLF section names excluded low-value offers and then
|
||||||
|
# states a positive stat requirement for the offered Homura.
|
||||||
|
wanted_stat = "Only SSS stats (for Homura Evo)"
|
||||||
|
if wanted_stat in nlf:
|
||||||
|
nlf = nlf.replace("; " + wanted_stat, "").replace(wanted_stat, "").strip(" ;|")
|
||||||
|
lf = " | ".join(value for value in (lf, wanted_stat) if value)
|
||||||
|
if not lf and mlf and looking_for.upper().startswith("MLF: "):
|
||||||
|
combined = looking_for[5:].strip()
|
||||||
|
if combined.endswith(mlf) and combined != mlf:
|
||||||
|
mlf = combined # A legacy export lost the leading MLF fragment.
|
||||||
|
# One stored repost put a repeated offer inventory into MLF after a glued label.
|
||||||
|
mlf = re.sub(r"\bunits(?:trade|\s*\|\s*Trading:)\s*\|.*$", "units", mlf, flags=re.I)
|
||||||
|
|
||||||
|
moved_mlf: list[str] = []
|
||||||
|
moved_nlf: list[str] = []
|
||||||
|
|
||||||
|
def move_label(match: re.Match[str]) -> str:
|
||||||
|
destination = moved_mlf if match.group(1).upper() == "MLF" else moved_nlf
|
||||||
|
destination.append(match.group(2).strip())
|
||||||
|
return ""
|
||||||
|
|
||||||
|
lf = EMBEDDED_REQUEST_LABEL.sub(move_label, lf)
|
||||||
|
lf_parts = []
|
||||||
|
for segment in clean_request_segments(lf).split(" | "):
|
||||||
|
negative = re.fullmatch(r"(?:NO\s+WANT\s+(.+)|NO\s+(LOW\s*BALLS?))", segment, re.I)
|
||||||
|
if negative:
|
||||||
|
moved_nlf.append((negative.group(1) or negative.group(2)).strip())
|
||||||
|
elif segment:
|
||||||
|
lf_parts.append(segment)
|
||||||
|
lf = " | ".join(lf_parts)
|
||||||
|
mlf = clean_request_segments(" | ".join(part for part in [mlf, *moved_mlf] if part))
|
||||||
|
nlf = clean_request_segments(" | ".join(part for part in [nlf, *moved_nlf] if part))
|
||||||
|
return Listing("", "", lf, mlf, nlf).looking_for, lf, mlf, nlf
|
||||||
|
|
||||||
|
|
||||||
|
def separate_friend_offer(mlf: str) -> tuple[str, str | None]:
|
||||||
|
"""A copied 'My Friend is | X' section describes the friend's inventory."""
|
||||||
|
parts = [part.strip() for part in mlf.split("|")]
|
||||||
|
for index, part in enumerate(parts[:-1]):
|
||||||
|
if part.casefold() == "my friend is" and parts[index + 1]:
|
||||||
|
friend_offer = parts[index + 1]
|
||||||
|
remaining = " | ".join(part for i, part in enumerate(parts)
|
||||||
|
if i not in (index, index + 1) and part)
|
||||||
|
return remaining, friend_offer
|
||||||
|
return mlf, None
|
||||||
|
|
||||||
|
|
||||||
|
def repair_misfiled_inventory(offer: str, lf: str, nlf: str) -> tuple[str, str, str]:
|
||||||
|
"""Repair a confirmed legacy listing whose inventory followed an NLF label."""
|
||||||
|
if not (nlf.startswith("Shiny Gilgamesh Evo | x1 FULL SSS Aizen Evo")
|
||||||
|
and "x1 FULL SSS Homura Evo (LF " in nlf):
|
||||||
|
return offer, lf, nlf
|
||||||
|
items = []
|
||||||
|
for part in nlf.split("|"):
|
||||||
|
if "WILL READ ALL DMS" in part.upper():
|
||||||
|
continue
|
||||||
|
embedded_lf = re.search(r"\(\s*LF\s+([^)]*)\)", part, re.I)
|
||||||
|
if embedded_lf:
|
||||||
|
lf = " | ".join(value for value in (lf, embedded_lf.group(1).strip()) if value)
|
||||||
|
part = part[:embedded_lf.start()] + part[embedded_lf.end():]
|
||||||
|
items.append(part.strip())
|
||||||
|
return clean_offer_items(offer + " | " + " | ".join(items)), lf, ""
|
||||||
|
|
||||||
|
|
||||||
|
def repair_misfiled_mlf_inventory(offer: str, lf: str,
|
||||||
|
mlf: str) -> tuple[str, str, str]:
|
||||||
|
"""Repair the confirmed repost where normal-unit inventory followed MLF."""
|
||||||
|
marker = "OVERPAY | NORMAL UNITS | x1 Aizen Evo (FULL S) | x6 Homura Evo ALL GOOD STATS"
|
||||||
|
if not mlf.startswith(marker):
|
||||||
|
return offer, lf, mlf
|
||||||
|
parts = [part.strip() for part in mlf.split("|")]
|
||||||
|
inventory = []
|
||||||
|
for part in parts[2:]:
|
||||||
|
embedded_lf = re.search(r"\(\s*LF\s+([^)]*)\)", part, re.I)
|
||||||
|
if embedded_lf:
|
||||||
|
lf = " | ".join(value for value in (lf, embedded_lf.group(1).strip()) if value)
|
||||||
|
part = part[:embedded_lf.start()] + part[embedded_lf.end():]
|
||||||
|
inventory.append(part.strip())
|
||||||
|
return clean_offer_items(offer + " | " + " | ".join(inventory)), lf, "OVERPAY"
|
||||||
|
|
||||||
|
|
||||||
|
def repair_glued_reposts(offer: str, lf: str, mlf: str) -> tuple[str, str, str]:
|
||||||
|
"""Repair two confirmed reposts where a Trading label joined a request."""
|
||||||
|
if (re.search(r"Homura(?: Evo)?, Battlepass and addTrade\s*\|", lf, re.I)
|
||||||
|
and re.search(r"\|\s*Chuuni(?: Evo)? too\s*\|", lf, re.I)):
|
||||||
|
lf = lf.split("Trade | ", 1)[0]
|
||||||
|
offer = clean_offer_items(offer + " | Chuuni Evo")
|
||||||
|
if (mlf.startswith("UPGRADEtrading | Buddha Evo with SSS spa ")
|
||||||
|
and " | UPGRADE | Buddha Evo with SSS spa " in mlf):
|
||||||
|
buddha = mlf.split(" | ", 2)[1]
|
||||||
|
offer = clean_offer_items(offer + " | " + buddha)
|
||||||
|
mlf = "UPGRADE"
|
||||||
|
return offer, lf, mlf
|
||||||
|
|
||||||
|
|
||||||
|
def repair_misfiled_lf_inventory(offer: str, lf: str) -> tuple[str, str]:
|
||||||
|
"""Move three confirmed inventory lists out of the LF section."""
|
||||||
|
parts = [part.strip() for part in lf.split("|")]
|
||||||
|
if (lf.startswith("2X SSS DMG FOR MY Shiny Poseidon Evo | Evo MYTIC's | ")
|
||||||
|
and parts[-1].startswith("Shiny POSEI/Chuuni Evo AND ADDS FOR MY ROGER Evo")):
|
||||||
|
offer = clean_offer_items(offer + " | " + " | ".join(parts[1:-1]))
|
||||||
|
return offer, " | ".join((parts[0], parts[-1]))
|
||||||
|
if (lf.startswith("S stat Fodder Units | 4 Deer Tan Evo | ")
|
||||||
|
and parts[-1].startswith("Vip and Shiny hunter(")):
|
||||||
|
inventory = list(dict.fromkeys(parts[:-1]))
|
||||||
|
offer = clean_offer_items(offer + " | " + " | ".join(inventory))
|
||||||
|
return offer, parts[-1]
|
||||||
|
if (" | Shiny UNITS | " in lf and " | NON-Shiny UNITS | " in lf
|
||||||
|
and parts[-1].startswith("s tier upgrade for my Shiny units")):
|
||||||
|
inventory = [part for part in parts[1:-1]
|
||||||
|
if part.casefold() not in {"shiny units", "non-shiny units"}]
|
||||||
|
offer = clean_offer_items(offer + " | " + " | ".join(inventory))
|
||||||
|
return offer, " | ".join((parts[0], parts[-1]))
|
||||||
|
return offer, lf
|
||||||
|
|
||||||
|
|
||||||
|
def repair_inline_side_cues(offer: str, lf: str, nlf: str) -> tuple[str, str, str]:
|
||||||
|
"""Separate explicit requests and exclusions embedded in offered items."""
|
||||||
|
offered = []
|
||||||
|
wanted = []
|
||||||
|
excluded = []
|
||||||
|
for raw in offer.split("|"):
|
||||||
|
item = raw.strip()
|
||||||
|
if re.fullmatch(r"Shiny Mist Ninja Evo LOOKIN FOR FAIR TRADE NO SCAM", item, re.I):
|
||||||
|
offered.append("Shiny Mist Ninja Evo")
|
||||||
|
wanted.append("FAIR TRADE")
|
||||||
|
elif re.fullmatch(r"\(my My SS SPA AND SS RNG FOR Battlepass\)", item, re.I):
|
||||||
|
offered.append("My SS SPA AND SS RNG")
|
||||||
|
wanted.append("Battlepass")
|
||||||
|
elif match := re.fullmatch(r"(Homura Evo sss rng)\s*\(\s*for\s+(4 sss dmg/spa)\)", item, re.I):
|
||||||
|
offered.append(match.group(1))
|
||||||
|
wanted.append(match.group(2))
|
||||||
|
elif item.casefold() == "or pick) (almost all for aizen evo btw)":
|
||||||
|
if not re.search(r"\bAizen Evo\b", lf, re.I):
|
||||||
|
wanted.append("Aizen Evo")
|
||||||
|
elif item.casefold() == "my units for good offers":
|
||||||
|
wanted.append("GOOD OFFERS")
|
||||||
|
elif re.fullmatch(r"Chuuni Evo WITH S\+ SPA FOR SOMETHING", item, re.I):
|
||||||
|
offered.append("Chuuni Evo WITH S+ SPA")
|
||||||
|
wanted.append("SOMETHING")
|
||||||
|
elif item.casefold() == "battlepass (will not trade for dark mage evo + adds)":
|
||||||
|
offered.append("Battlepass")
|
||||||
|
excluded.append("Dark Mage Evo + ADDS")
|
||||||
|
elif item.casefold() == "my 3 units display for good damage unit":
|
||||||
|
offered.append("3 UNITS DISPLAY")
|
||||||
|
wanted.append("GOOD DAMAGE UNIT")
|
||||||
|
elif item.casefold() == "or bundle for ssss":
|
||||||
|
offered.append("bundle")
|
||||||
|
wanted.append("SSS")
|
||||||
|
elif item.casefold() == "buhha + cid evo for shiny or sss or":
|
||||||
|
offered.append("Buddha + Cid Evo")
|
||||||
|
wanted.extend(("Shiny", "SSS", "OFFER"))
|
||||||
|
elif item.casefold().startswith("olf homura evo/overpays/chuuni evo item"):
|
||||||
|
wanted.append("Homura Evo/overpays/Chuuni Evo item")
|
||||||
|
elif item.casefold() == "upgrades/":
|
||||||
|
wanted.append("UPGRADES")
|
||||||
|
elif item.casefold() == "6x dark mage evo (all good stats) [2x for any sss]":
|
||||||
|
offered.append("6x Dark Mage Evo (ALL GOOD STATS)")
|
||||||
|
wanted.append("ANY SSS for 2 Dark Mage Evo")
|
||||||
|
elif item.casefold() == "100+ fodder units (9 for 10rr)":
|
||||||
|
offered.append("100+ Fodder Units")
|
||||||
|
wanted.append("10 RR for 9 Fodder Units")
|
||||||
|
else:
|
||||||
|
offered.append(item)
|
||||||
|
lf_parts = [lf] if lf else []
|
||||||
|
for request in wanted:
|
||||||
|
if request and not any(request.casefold() == part.casefold() for part in lf_parts):
|
||||||
|
lf_parts.append(request)
|
||||||
|
lf = " | ".join(lf_parts)
|
||||||
|
nlf = " | ".join(part for part in (nlf, *excluded) if part)
|
||||||
|
return clean_offer_items(" | ".join(offered)), lf, nlf
|
||||||
|
|
||||||
|
|
||||||
|
def repair_standalone_lf_inventory(offer: str, lf: str,
|
||||||
|
mlf: str) -> tuple[str, str]:
|
||||||
|
"""Move two confirmed Homura listings' inventory lists out of LF."""
|
||||||
|
if ("My Alucard" not in mlf and "my Alucard" not in mlf):
|
||||||
|
return offer, lf
|
||||||
|
if not ("Shiny Dark Mage" in mlf and lf.startswith("Alucard")
|
||||||
|
and " | Aizen" in lf):
|
||||||
|
return offer, lf
|
||||||
|
parts = [part.strip() for part in lf.split("|")]
|
||||||
|
if len(parts) < 5 or not re.search(r"Aizen.*UPGRADES", parts[-1], re.I):
|
||||||
|
return offer, lf
|
||||||
|
inventory = parts[:-1]
|
||||||
|
if not any("Shiny Dark Mage" in item for item in inventory):
|
||||||
|
inventory.append("Shiny Dark Mage Evo")
|
||||||
|
return clean_offer_items(offer + " | " + " | ".join(inventory)), parts[-1]
|
||||||
|
|
||||||
|
|
||||||
|
def repair_confirmed_long_lf_inventory(offer: str, lf: str) -> tuple[str, str]:
|
||||||
|
"""Move two confirmed offered inventories out of long LF sections."""
|
||||||
|
parts = [part.strip() for part in lf.split("|")]
|
||||||
|
if (lf.startswith("Sss for Each | 3Dark Mage Evo | ") and len(parts) >= 9
|
||||||
|
and "my Homura" in parts[8]):
|
||||||
|
inventory = [parts[index] for index in (1, 3, 5, 6)]
|
||||||
|
offer = clean_offer_items(offer + " | " + " | ".join(inventory))
|
||||||
|
return offer, " | ".join(("SSS for each", "SSS Stats", parts[8]))
|
||||||
|
if (lf.startswith("FULL SSS Aizen Evo LOW % FOR MY Aizen Evo | ")
|
||||||
|
and len(parts) == 17 and parts[14].startswith("HIGH SSS DMG")):
|
||||||
|
offer = clean_offer_items(offer + " | " + " | ".join(parts[1:14]))
|
||||||
|
return offer, " | ".join((parts[0], *parts[14:]))
|
||||||
|
return offer, lf
|
||||||
|
|
||||||
|
|
||||||
|
def repair_alucard_lf_inventory(offer: str, lf: str) -> tuple[str, str]:
|
||||||
|
"""Separate confirmed offered units from two Alucard stat requests."""
|
||||||
|
parts = [part.strip() for part in lf.split("|")]
|
||||||
|
if not (re.match(r"%29\+ high sss dmg or aizen", lf, re.I)
|
||||||
|
and len(parts) >= 12
|
||||||
|
and re.match(r"shiny\s+(?:chunni|chuuni)\b", parts[3], re.I)
|
||||||
|
and parts[11].casefold().startswith("offers")):
|
||||||
|
return offer, lf
|
||||||
|
inventory = ["Shiny Chuuni Evo", "Dark Mage Evo", *parts[4:7], *parts[8:11]]
|
||||||
|
offer = clean_offer_items(offer + " | " + " | ".join(inventory))
|
||||||
|
lf = " | ".join((*parts[:3], "sss dmg or spa", parts[7], parts[11]))
|
||||||
|
return offer, lf
|
||||||
|
|
||||||
|
|
||||||
|
OWNED_VARIANT = re.compile(
|
||||||
|
r"(?<!\w)(?P<shiny>Shiny\s+)?(?P<name>"
|
||||||
|
+ "|".join(re.escape(name).replace(r"\ ", r"\s+") for name in KNOWN_UNIT_NAMES)
|
||||||
|
+ r")\s+(?P<state>Evo|Unevo)\b", re.I,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def recover_explicit_my_offers(offer: str, lf: str, mlf: str) -> str:
|
||||||
|
"""Add named units explicitly owned in full LF/MLF exchange proposals."""
|
||||||
|
known = {name.casefold(): name for name in KNOWN_UNIT_NAMES}
|
||||||
|
|
||||||
|
def key(match: re.Match[str]) -> tuple[bool, str, str]:
|
||||||
|
return bool(match.group("shiny")), match.group("name").casefold(), match.group("state").casefold()
|
||||||
|
|
||||||
|
offered = {key(match) for match in OWNED_VARIANT.finditer(normalize_unit_names(offer))}
|
||||||
|
additions = []
|
||||||
|
for request in (lf, mlf):
|
||||||
|
for segment in request.split("|"):
|
||||||
|
for clause in re.finditer(r"\bmy\s+(.{0,130}?)\s+for\b", segment, re.I):
|
||||||
|
left = normalize_unit_names(clause.group(1))
|
||||||
|
for match in OWNED_VARIANT.finditer(left):
|
||||||
|
variant = key(match)
|
||||||
|
if variant in offered:
|
||||||
|
continue
|
||||||
|
shiny, name, state = variant
|
||||||
|
# Both phrases already describe owned units, despite
|
||||||
|
# unusual stat placement or a plural unit name.
|
||||||
|
if (shiny and name == "scarlet slayer"
|
||||||
|
and re.search(r"Shiny SS DMG SCARLET SLAYER Evo", offer, re.I)):
|
||||||
|
continue
|
||||||
|
if (not shiny and name == "homura" and state == "evo"
|
||||||
|
and re.search(r"\b\d+\s+homuras\b", offer, re.I)):
|
||||||
|
continue
|
||||||
|
additions.append(f"{'Shiny ' if shiny else ''}{known[name]} {state.capitalize()}")
|
||||||
|
offered.add(variant)
|
||||||
|
return clean_offer_items(offer + " | " + " | ".join(additions)) if additions else offer
|
||||||
|
|
||||||
|
|
||||||
|
def recover_partial_proposal_offers(offer: str, lf: str, mlf: str) -> str:
|
||||||
|
"""Complete offered sides stated in otherwise partial inventory lists."""
|
||||||
|
additions = []
|
||||||
|
if ("Shiny Somber Evo + Shiny Sakamoto Evo + Jelly Evo + " in lf
|
||||||
|
and "2 x Cid Unevo + 2 x Nagumo Unevo for Shiny Chuuni Evo" in lf):
|
||||||
|
additions.extend(("2 x Cid Unevo", "2 x Nagumo Unevo"))
|
||||||
|
if "GIVING CLEAN BD AND Shiny Skull Knight Evo FOR Shiny Alucard Evo" in lf:
|
||||||
|
additions.append("Shiny Skull Knight Evo")
|
||||||
|
if (re.search(r"Shiny toad sensei Evo and Nagumo Evo for Shiny Cid Evo", lf, re.I)
|
||||||
|
and not re.search(r"\bNagumo Evo\b", offer, re.I)):
|
||||||
|
additions.append("Nagumo Evo")
|
||||||
|
if "Chuuni Evo/Evo ITEM FOR Chuuni Evo AND Buddha Unevo" in mlf:
|
||||||
|
additions.extend(("Chuuni Evo", "Evo ITEM"))
|
||||||
|
return clean_offer_items(offer + " | " + " | ".join(additions)) if additions else offer
|
||||||
|
|
||||||
|
|
||||||
|
def repair_confirmed_proposal_sides(offer: str, lf: str,
|
||||||
|
mlf: str) -> tuple[str, str, str]:
|
||||||
|
"""Apply confirmed directions of three ambiguous full proposals."""
|
||||||
|
gohan_request = "Shiny Gohan Evo / Gohan Evo / Shiny Android 21 Evo for bundles or RR"
|
||||||
|
if gohan_request in lf:
|
||||||
|
offer = clean_offer_items(
|
||||||
|
offer + " | Shiny Gohan Evo | Gohan Evo | Shiny Android 21 Evo")
|
||||||
|
lf = lf.replace(gohan_request, "bundles or RR", 1)
|
||||||
|
if "Shiny Chuuni Evo for Aizen Evo" in mlf:
|
||||||
|
offer = clean_offer_items(offer + " | Shiny Chuuni Evo")
|
||||||
|
if ("S TIER UNITS, Alucard Evo, Aizen Evo, X2 Shiny Chuuni Evo + "
|
||||||
|
"Gilgamesh Evo FOR Shiny Mamy Evo" in mlf):
|
||||||
|
offer = clean_offer_items(
|
||||||
|
offer + " | S TIER UNITS | Alucard Evo | Aizen Evo | "
|
||||||
|
"X2 Shiny Chuuni Evo | Gilgamesh Evo")
|
||||||
|
return offer, lf, mlf
|
||||||
|
|
||||||
|
|
||||||
|
def expand_friend_listings(listings: list[Listing]) -> list[Listing]:
|
||||||
|
expanded = []
|
||||||
|
for listing in listings:
|
||||||
|
mlf, friend_offer = separate_friend_offer(listing.mlf)
|
||||||
|
if not friend_offer:
|
||||||
|
expanded.append(listing)
|
||||||
|
continue
|
||||||
|
expanded.append(Listing(listing.author, listing.offer, listing.lf, mlf, listing.nlf))
|
||||||
|
expanded.append(Listing(f"friend:{hash_author(listing.author)}:my_friend_is",
|
||||||
|
clean_offer_items(friend_offer)))
|
||||||
|
return expanded
|
||||||
|
|
||||||
|
|
||||||
def normalized_chunk(lines: list[str]) -> str:
|
def normalized_chunk(lines: list[str]) -> str:
|
||||||
cleaned: list[str] = []
|
cleaned: list[str] = []
|
||||||
for raw in lines:
|
for raw in lines:
|
||||||
@@ -1475,19 +2150,30 @@ def parse_listing(msg: Message) -> Listing | None:
|
|||||||
return None
|
return None
|
||||||
lf = distinct_chunks(groups["lf"])
|
lf = distinct_chunks(groups["lf"])
|
||||||
offer, lf = split_inline_offer_for(offer, lf)
|
offer, lf = split_inline_offer_for(offer, lf)
|
||||||
return Listing(
|
offer, lf, nlf = repair_inline_side_cues(
|
||||||
author=msg.author, offer=offer,
|
offer, lf, distinct_chunks(groups["nlf"]))
|
||||||
lf=lf,
|
offer, lf, nlf = repair_misfiled_inventory(offer, lf, nlf)
|
||||||
mlf=distinct_chunks(groups["mlf"]),
|
offer, lf, mlf = repair_misfiled_mlf_inventory(
|
||||||
nlf=distinct_chunks(groups["nlf"]),
|
offer, lf, distinct_chunks(groups["mlf"]))
|
||||||
)
|
offer, lf, mlf = repair_glued_reposts(offer, lf, mlf)
|
||||||
|
offer, lf = repair_misfiled_lf_inventory(offer, lf)
|
||||||
|
offer, lf = repair_standalone_lf_inventory(offer, lf, mlf)
|
||||||
|
offer, lf = repair_confirmed_long_lf_inventory(offer, lf)
|
||||||
|
offer, lf = repair_alucard_lf_inventory(offer, lf)
|
||||||
|
_, lf, mlf, nlf = clean_request_fields(lf, mlf, nlf)
|
||||||
|
offer, lf, mlf = repair_confirmed_proposal_sides(offer, lf, mlf)
|
||||||
|
offer = recover_explicit_my_offers(offer, lf, mlf)
|
||||||
|
offer = recover_partial_proposal_offers(offer, lf, mlf)
|
||||||
|
return Listing(author=msg.author, offer=offer, lf=lf, mlf=mlf, nlf=nlf)
|
||||||
|
|
||||||
|
|
||||||
def parse_listings(msg: Message) -> list[Listing]:
|
def parse_listings(msg: Message) -> list[Listing]:
|
||||||
"""Split explicit Friend(s) sections into trades with a separate identity."""
|
"""Split explicit Friend(s) sections into trades with a separate identity."""
|
||||||
|
if is_dyno_message(msg):
|
||||||
|
return []
|
||||||
if not any(FRIEND_BOUNDARY.search(line) for line in msg.body.splitlines()):
|
if not any(FRIEND_BOUNDARY.search(line) for line in msg.body.splitlines()):
|
||||||
listing = parse_listing(msg)
|
listing = parse_listing(msg)
|
||||||
return [listing] if listing else []
|
return expand_friend_listings([listing]) if listing else []
|
||||||
parts: list[str] = []
|
parts: list[str] = []
|
||||||
sections: list[Message] = []
|
sections: list[Message] = []
|
||||||
author = msg.author
|
author = msg.author
|
||||||
@@ -1526,7 +2212,7 @@ def parse_listings(msg: Message) -> list[Listing]:
|
|||||||
if merged:
|
if merged:
|
||||||
listings[-1] = merged
|
listings[-1] = merged
|
||||||
parsed_sections[-1] = combined
|
parsed_sections[-1] = combined
|
||||||
return listings
|
return expand_friend_listings(listings)
|
||||||
|
|
||||||
|
|
||||||
def canon(value: str) -> str:
|
def canon(value: str) -> str:
|
||||||
@@ -1588,7 +2274,7 @@ def clean_export_text(value: str) -> str:
|
|||||||
# Remove an Excel escape added by an earlier export before an arrow.
|
# Remove an Excel escape added by an earlier export before an arrow.
|
||||||
value = re.sub(r"^'(?=-+>+|-[A-Za-z])", "", value)
|
value = re.sub(r"^'(?=-+>+|-[A-Za-z])", "", value)
|
||||||
cleaned = OFFER_HEADING.sub("", remove_non_trade_notices(remove_decorative_marks(remove_emoji_codes(value))))
|
cleaned = OFFER_HEADING.sub("", remove_non_trade_notices(remove_decorative_marks(remove_emoji_codes(value))))
|
||||||
cleaned = normalize_shiny_evo_order(normalize_unit_names(cleaned))
|
cleaned = normalize_shiny_evo_order(normalize_variant_quantities(normalize_unit_names(cleaned)))
|
||||||
cleaned = collapse_alias_pairs(strip_category_headings(cleaned))
|
cleaned = collapse_alias_pairs(strip_category_headings(cleaned))
|
||||||
cleaned = normalize_shiny_evo_order(normalize_evo_status(cleaned.replace("!", "")))
|
cleaned = normalize_shiny_evo_order(normalize_evo_status(cleaned.replace("!", "")))
|
||||||
if cleaned != original or re.search(r"^\s*\||\|\s*$|\|\s*\|", cleaned):
|
if cleaned != original or re.search(r"^\s*\||\|\s*$|\|\s*\|", cleaned):
|
||||||
@@ -1602,6 +2288,24 @@ def csv_safe(value: str) -> str:
|
|||||||
return excel_safe(value)
|
return excel_safe(value)
|
||||||
|
|
||||||
|
|
||||||
|
def normalize_request_segments(value: str) -> str:
|
||||||
|
"""Normalize unit names without treating request headings as offer headings."""
|
||||||
|
normalized = []
|
||||||
|
for part in value.split("|"):
|
||||||
|
part = part.strip()
|
||||||
|
if not part:
|
||||||
|
continue
|
||||||
|
shiny_list = re.fullmatch(r"SHINIES:\s*(.+)", part, re.I)
|
||||||
|
if shiny_list:
|
||||||
|
normalized.append(",".join(
|
||||||
|
clean_export_text("Shiny " + unit.strip())
|
||||||
|
for unit in shiny_list.group(1).split(",") if unit.strip()
|
||||||
|
))
|
||||||
|
else:
|
||||||
|
normalized.append(clean_export_text(part))
|
||||||
|
return clean_request_segments(" | ".join(normalized))
|
||||||
|
|
||||||
|
|
||||||
def excel_safe(value: str) -> str:
|
def excel_safe(value: str) -> str:
|
||||||
# Prevent formula injection if opening arbitrary user text in Excel.
|
# Prevent formula injection if opening arbitrary user text in Excel.
|
||||||
return "'" + value if value and value.lstrip().startswith(("=", "+", "-", "@")) else value
|
return "'" + value if value and value.lstrip().startswith(("=", "+", "-", "@")) else value
|
||||||
@@ -1851,34 +2555,66 @@ def resolve_files(arguments: list[str]) -> list[Path]:
|
|||||||
def export_csv(conn: sqlite3.Connection, output: Path, detailed: bool) -> int:
|
def export_csv(conn: sqlite3.Connection, output: Path, detailed: bool) -> int:
|
||||||
output.parent.mkdir(parents=True, exist_ok=True)
|
output.parent.mkdir(parents=True, exist_ok=True)
|
||||||
count = 0
|
count = 0
|
||||||
|
emitted_friends: set[tuple[str, str]] = set()
|
||||||
with output.open("w", encoding="utf-8-sig", newline="") as stream:
|
with output.open("w", encoding="utf-8-sig", newline="") as stream:
|
||||||
writer = csv.writer(stream)
|
writer = csv.writer(stream)
|
||||||
if detailed:
|
if detailed:
|
||||||
writer.writerow(["offer", "looking_for", "lf", "mlf", "nlf",
|
writer.writerow(["offer", "looking_for", "lf", "mlf", "nlf",
|
||||||
"author_hash", "reposts_seen", "updates_seen"])
|
"author_hash", "reposts_seen", "updates_seen",
|
||||||
|
"pretrade", "received_bid"])
|
||||||
|
else:
|
||||||
|
writer.writerow(["offer", "looking_for"])
|
||||||
rows = conn.execute(
|
rows = conn.execute(
|
||||||
"""SELECT offer,looking_for,lf,mlf,nlf,author_hash,seen_count,update_count
|
"""SELECT offer,looking_for,lf,mlf,nlf,author_hash,seen_count,update_count
|
||||||
FROM trades ORDER BY id"""
|
FROM trades ORDER BY id"""
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
writer.writerow(["offer", "looking_for"])
|
|
||||||
rows = conn.execute("SELECT offer,looking_for FROM trades ORDER BY id")
|
|
||||||
for row in rows:
|
for row in rows:
|
||||||
|
pretrade = bool(re.search(r"\b(?:PRE|PRE[-\s]?TRADE)\b", row[0], re.I))
|
||||||
offer = clean_offer_items(clean_export_text(row[0]))
|
offer = clean_offer_items(clean_export_text(row[0]))
|
||||||
|
offer, received_bid = separate_received_bid(offer)
|
||||||
if not offer:
|
if not offer:
|
||||||
continue
|
continue
|
||||||
values = list(row)
|
values = list(row)
|
||||||
if detailed:
|
offer, raw_lf = split_inline_offer_for(offer, values[2])
|
||||||
old_lf = clean_export_text(values[2])
|
offer, raw_lf, values[4] = repair_inline_side_cues(
|
||||||
moved_offer, lf = split_inline_offer_for(offer, old_lf)
|
offer, raw_lf, values[4])
|
||||||
if (moved_offer, lf) != (offer, old_lf):
|
values[3], friend_offer = separate_friend_offer(values[3])
|
||||||
values[2] = lf
|
offer, raw_lf, values[4] = repair_misfiled_inventory(offer, raw_lf, values[4])
|
||||||
values[1] = Listing("", moved_offer, lf, values[3], values[4]).looking_for
|
offer, raw_lf, values[3] = repair_misfiled_mlf_inventory(
|
||||||
offer = moved_offer
|
offer, raw_lf, values[3])
|
||||||
else:
|
offer, raw_lf, values[3] = repair_glued_reposts(
|
||||||
offer, values[1] = split_inline_offer_for(offer, values[1])
|
offer, raw_lf, values[3])
|
||||||
|
offer, raw_lf = repair_misfiled_lf_inventory(offer, raw_lf)
|
||||||
|
offer, raw_lf = repair_standalone_lf_inventory(
|
||||||
|
offer, raw_lf, values[3])
|
||||||
|
offer, raw_lf = repair_confirmed_long_lf_inventory(offer, raw_lf)
|
||||||
|
offer, raw_lf = repair_alucard_lf_inventory(offer, raw_lf)
|
||||||
|
offer = clean_offer_items(clean_export_text(offer))
|
||||||
|
values[1:5] = clean_request_fields(raw_lf, values[3], values[4], values[1])
|
||||||
|
values[1:5] = clean_request_fields(*(
|
||||||
|
normalize_request_segments(value) for value in values[2:5]))
|
||||||
|
offer, values[2], values[3] = repair_confirmed_proposal_sides(
|
||||||
|
offer, values[2], values[3])
|
||||||
|
values[1] = Listing("", "", values[2], values[3], values[4]).looking_for
|
||||||
|
offer = recover_explicit_my_offers(offer, values[2], values[3])
|
||||||
|
offer = recover_partial_proposal_offers(offer, values[2], values[3])
|
||||||
values[0] = offer
|
values[0] = offer
|
||||||
writer.writerow([csv_safe(v) if isinstance(v, str) else v for v in values])
|
values.extend(["yes" if pretrade else "", received_bid])
|
||||||
|
export_values = values if detailed else values[:2]
|
||||||
|
writer.writerow([excel_safe(v) if isinstance(v, str) else v for v in export_values])
|
||||||
|
count += 1
|
||||||
|
if friend_offer:
|
||||||
|
friend_offer = clean_offer_items(clean_export_text(friend_offer))
|
||||||
|
friend_hash = hash_author(f"friend:{values[5]}:my_friend_is")
|
||||||
|
key = (friend_hash, canon(friend_offer))
|
||||||
|
already_stored = conn.execute(
|
||||||
|
"SELECT 1 FROM trades WHERE author_hash=? AND canon_offer=? LIMIT 1", key
|
||||||
|
).fetchone()
|
||||||
|
if (friend_offer and key not in emitted_friends and not already_stored):
|
||||||
|
friend_values = [friend_offer, "", "", "", "", friend_hash, 1, 0, "", ""]
|
||||||
|
writer.writerow([excel_safe(v) if isinstance(v, str) else v
|
||||||
|
for v in (friend_values if detailed else friend_values[:2])])
|
||||||
|
emitted_friends.add(key)
|
||||||
count += 1
|
count += 1
|
||||||
return count
|
return count
|
||||||
|
|
||||||
@@ -1887,7 +2623,9 @@ def export_scam_warnings(conn: sqlite3.Connection, output: Path) -> int:
|
|||||||
output.parent.mkdir(parents=True, exist_ok=True)
|
output.parent.mkdir(parents=True, exist_ok=True)
|
||||||
count = 0
|
count = 0
|
||||||
with output.open("w", encoding="utf-8-sig", newline="") as stream:
|
with output.open("w", encoding="utf-8-sig", newline="") as stream:
|
||||||
writer = csv.writer(stream)
|
# Explicit quoting keeps spreadsheet editors from treating the leading
|
||||||
|
# apostrophe in an Excel-escaped @handle as a CSV quote character.
|
||||||
|
writer = csv.writer(stream, quoting=csv.QUOTE_ALL)
|
||||||
writer.writerow(["reported_handles", "warning_text", "reporter_hash", "reports_seen"])
|
writer.writerow(["reported_handles", "warning_text", "reporter_hash", "reports_seen"])
|
||||||
for handles, warning_text, reporter_hash, seen in conn.execute(
|
for handles, warning_text, reporter_hash, seen in conn.execute(
|
||||||
"""SELECT reported_handles,warning_text,reporter_hash,reports_seen
|
"""SELECT reported_handles,warning_text,reporter_hash,reports_seen
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
unit_variant,all_fit,all_ranked_value,all_confidence,all_explicit_asks,all_inferred_asks,explicit_only_fit,explicit_only_ranked_value,explicit_only_confidence,change_pct_without_inferred,explicit_only_connection
|
||||||
|
Aizen Evo,1000.0,1000,low,6,2,1000.0,1000,low,0.0,connected
|
||||||
|
Alucard Evo,2488.9,,insufficient,2,0,3033.2,,insufficient,21.9,connected
|
||||||
|
Alucard Unevo,1037.9,,insufficient,1,0,,,disconnected,,disconnected
|
||||||
|
Android 21 Evo,1.0,,insufficient,1,0,1.0,,insufficient,0.0,connected
|
||||||
|
Buddha Evo,258.1,,unstable,3,2,804.8,,unstable,211.8,connected
|
||||||
|
Chuuni Evo,254.2,,unstable,2,4,348.1,,insufficient,36.9,connected
|
||||||
|
Cid Evo,252.6,,unstable,3,2,350.7,,unstable,38.8,connected
|
||||||
|
Cid Unevo,65.8,,insufficient,1,0,66.5,,insufficient,1.1,connected
|
||||||
|
Cream Evo,451.5,,insufficient,0,1,,,disconnected,,disconnected
|
||||||
|
Dark Mage Evo,261.5,,unstable,5,11,340.8,,unstable,30.3,connected
|
||||||
|
Elf Mage Evo,1000.0,,insufficient,0,1,,,disconnected,,disconnected
|
||||||
|
Gilgamesh Unevo,286.6,,insufficient,1,0,812.3,,insufficient,183.4,connected
|
||||||
|
Homura Evo,1360.1,,unstable,8,4,1669.1,,unstable,22.7,connected
|
||||||
|
Ice Lily Evo,596.5,,insufficient,1,0,,,disconnected,,disconnected
|
||||||
|
Jelly Evo,532.9,,insufficient,1,0,533.2,,insufficient,0.1,connected
|
||||||
|
Jiraiya Evo,526.3,,insufficient,0,1,,,disconnected,,disconnected
|
||||||
|
Kisuke Evo,520.5,,insufficient,1,0,455.6,,insufficient,-12.5,connected
|
||||||
|
Nagumo Evo,340.6,,insufficient,0,1,,,disconnected,,disconnected
|
||||||
|
Nagumo Unevo,65.8,,insufficient,1,0,66.5,,insufficient,1.1,connected
|
||||||
|
Nami Evo,599.9,,insufficient,0,1,,,disconnected,,disconnected
|
||||||
|
Poseidon Evo,118.8,,unstable,1,3,188.6,,insufficient,58.8,connected
|
||||||
|
Shiny Aizen Evo,,,constraint_only,0,0,,,constraint_only,,constraint_only
|
||||||
|
Shiny Boros Evo,183.8,,insufficient,1,0,67.0,,insufficient,-63.5,connected
|
||||||
|
Shiny Buddha Evo,1520.0,,insufficient,1,1,,,disconnected,,disconnected
|
||||||
|
Shiny Chuuni Evo,965.2,,unstable,4,0,969.4,,unstable,0.4,connected
|
||||||
|
Shiny Dark Mage Evo,986.0,,unstable,3,1,820.6,,unstable,-16.8,connected
|
||||||
|
Shiny Elf Mage Evo,207.6,,insufficient,1,0,205.9,,insufficient,-0.8,connected
|
||||||
|
Shiny Emilia Evo,1688.3,,insufficient,1,0,1730.7,,insufficient,2.5,connected
|
||||||
|
Shiny Gilgamesh Evo,1690.4,,insufficient,2,0,1861.1,,insufficient,10.1,connected
|
||||||
|
Shiny Homura Evo,2116.6,2100,very_low,3,0,2312.0,,unstable,9.2,connected
|
||||||
|
Shiny Issei Evo,596.5,,insufficient,1,0,,,disconnected,,disconnected
|
||||||
|
Shiny Killstreak Evo,340.6,,insufficient,0,1,,,disconnected,,disconnected
|
||||||
|
Shiny Mamy Evo,169.2,,insufficient,2,0,267.8,,insufficient,58.3,connected
|
||||||
|
Shiny Nagumo Evo,520.7,,insufficient,2,0,,,disconnected,,disconnected
|
||||||
|
Shiny Piccolo Evo,207.6,,insufficient,1,0,205.9,,insufficient,-0.8,connected
|
||||||
|
Shiny Poseidon Evo,942.0,,insufficient,2,0,950.7,,insufficient,0.9,connected
|
||||||
|
Shiny Power Evo,1091.8,,insufficient,1,0,1245.6,,insufficient,14.1,connected
|
||||||
|
Shiny Sakamoto Evo,532.9,,insufficient,1,0,533.2,,insufficient,0.1,connected
|
||||||
|
Shiny Saki Evo,362.1,,insufficient,1,0,483.2,,insufficient,33.4,connected
|
||||||
|
Shiny Somber Evo,532.9,,insufficient,1,0,533.2,,insufficient,0.1,connected
|
||||||
|
Shiny Tiger Evo,362.1,,insufficient,1,0,483.2,,insufficient,33.4,connected
|
||||||
|
Shiny Yoshina Evo,686.8,,insufficient,1,0,468.9,,insufficient,-31.7,connected
|
||||||
|
Skull Knight Evo,674.5,,insufficient,1,0,661.6,,insufficient,-1.9,connected
|
||||||
|
Skull Knight Unevo,452.4,,insufficient,0,1,,,disconnected,,disconnected
|
||||||
|
Thorfinn Evo,1750.6,,insufficient,2,0,1932.8,,insufficient,10.4,connected
|
||||||
|
+14
-5
@@ -1,16 +1,25 @@
|
|||||||
source_row,quote_type,offered_unit,offered_qty,requested_unit,requested_qty,requested_units_per_offered_unit,source_text
|
source_row,quote_type,offered_unit,offered_qty,requested_unit,requested_qty,requested_units_per_offered_unit,source_text
|
||||||
6,explicit_for,Alucard Evo,1,Aizen Evo,1,1.0,MY Alucard Evo FOR Aizen Evo
|
52,explicit_for,Shiny Gilgamesh Evo,1,Thorfinn Evo,1,1.0,MY Shiny Gilgamesh Evo FOR THORFINN Evo
|
||||||
65,explicit_for,Shiny Nagumo Evo,2,Alucard Unevo,1,0.5,2 Shiny Nagumo Evo for Alucard Unevo
|
65,explicit_for,Shiny Nagumo Evo,2,Alucard Unevo,1,0.5,2 Shiny Nagumo Evo for Alucard Unevo
|
||||||
115,explicit_for,Buddha Evo,1,Gilgamesh Unevo,1,1.0,Gilgamesh Unevo for my Buddha Evo
|
115,explicit_for,Buddha Evo,1,Gilgamesh Unevo,1,1.0,Gilgamesh Unevo for my Buddha Evo
|
||||||
187,explicit_for,Homura Evo,2,Alucard Evo,1,0.5,2 Homura Evo FOR Alucard Evo
|
187,explicit_for,Homura Evo,2,Alucard Evo,1,0.5,2 Homura Evo FOR Alucard Evo
|
||||||
|
228,explicit_for,Shiny Chuuni Evo,1,Aizen Evo,1,1.0,Shiny Chuuni Evo for Aizen Evo
|
||||||
377,explicit_for,Shiny Siren Unevo,1,Shiny Elf Mage Unevo,1,1.0,My Shiny Siren Unevo for Shiny Elf Mage Unevo
|
377,explicit_for,Shiny Siren Unevo,1,Shiny Elf Mage Unevo,1,1.0,My Shiny Siren Unevo for Shiny Elf Mage Unevo
|
||||||
379,listing_pair,Shiny Dark Mage Evo,1,Dark Mage Evo,5,5.0,Shiny Dark Mage Evo -> 5 Dark Mage Evo
|
379,listing_pair,Shiny Dark Mage Evo,1,Dark Mage Evo,5,5.0,Shiny Dark Mage Evo -> 5 Dark Mage Evo
|
||||||
|
468,listing_pair,Buddha Evo,1,Chuuni Evo,1,1.0,Buddha Evo -> Chuuni Evo
|
||||||
490,listing_pair,Shiny Killstreak Evo,1,Dark Mage Evo,1,1.0,Shiny Killstreak Evo -> Dark Mage Evo
|
490,listing_pair,Shiny Killstreak Evo,1,Dark Mage Evo,1,1.0,Shiny Killstreak Evo -> Dark Mage Evo
|
||||||
588,explicit_for,Shiny Cream Evo,1,Shiny Deer Tan Evo,1,1.0,Shiny Cream Evo for Shiny Deer Tan Evo
|
588,explicit_for,Shiny Cream Evo,1,Shiny Deer Tan Evo,1,1.0,Shiny Cream Evo for Shiny Deer Tan Evo
|
||||||
715,explicit_for,Shiny Siren Unevo,1,Shiny Elf Mage Unevo,1,1.0,My Shiny Siren Unevo for Shiny Elf Mage Unevo
|
715,explicit_for,Shiny Siren Unevo,1,Shiny Elf Mage Unevo,1,1.0,My Shiny Siren Unevo for Shiny Elf Mage Unevo
|
||||||
750,listing_pair,Chuuni Evo,1,Dark Mage Evo,1,1.0,Chuuni Evo -> Dark Mage Evo
|
750,listing_pair,Chuuni Evo,1,Dark Mage Evo,1,1.0,Chuuni Evo -> Dark Mage Evo
|
||||||
756,listing_pair,Shizo Evo,1,Rohan Evo,1,1.0,SHIZO Evo -> ROHAN Evo
|
756,listing_pair,Shizo Evo,1,Rohan Evo,1,1.0,SHIZO Evo -> ROHAN Evo
|
||||||
946,explicit_for,Homura Evo,1,Alucard Evo,1,1.0,my Homura Evo for Alucard Evo
|
1078,listing_pair,Dark Mage Evo,6,Homura Evo,1,0.1667,6 Dark Mage Evo -> Homura Evo
|
||||||
1077,listing_pair,Dark Mage Evo,6,Homura Evo,1,0.1667,6 Dark Mage Evo -> Homura Evo
|
1112,explicit_for,Dark Mage Evo,5,Homura Evo,1,0.2,MY 5 Dark Mage Evo FOR Homura Evo
|
||||||
1111,explicit_for,Dark Mage Evo,5,Homura Evo,1,0.2,MY 5 Dark Mage Evo FOR Homura Evo
|
1241,listing_pair,Dark Mage Evo,6,Homura Evo,1,0.1667,6 Dark Mage Evo -> Homura Evo
|
||||||
1240,listing_pair,Dark Mage Evo,6,Homura Evo,1,0.1667,6 Dark Mage Evo -> Homura Evo
|
1357,explicit_for,Shiny Poseidon Evo,1,Shiny Chuuni Evo,1,1.0,MY Shiny Poseidon Evo FOR Shiny Chuuni Evo
|
||||||
|
1378,explicit_for,Poseidon Evo,2,Dark Mage Evo,1,0.5,MY 2 Poseidon Evo FOR Dark Mage Evo
|
||||||
|
1540,listing_pair,Nagumo Evo,1,Dark Mage Evo,1,1.0,Nagumo Evo -> Dark Mage Evo
|
||||||
|
1624,explicit_for,Cid Evo,1,Dark Mage Evo,1,1.0,MY Cid Evo FOR Dark Mage Evo
|
||||||
|
1641,listing_pair,Aizen Evo,1,Elf Mage Evo,1,1.0,Aizen Evo -> Elf Mage Evo
|
||||||
|
1675,explicit_for,Chuuni Evo,1,Dark Mage Evo,1,1.0,Chuuni Evo for Dark Mage Evo
|
||||||
|
1675,explicit_for,Chuuni Evo,1,Cid Evo,1,1.0,Cid Evo for Chuuni Evo
|
||||||
|
1687,explicit_for,Homura Evo,1,Aizen Evo,6,6.0,MY Homura Evo FOR 6 Aizen Evo
|
||||||
|
|||||||
|
@@ -21,6 +21,18 @@ FOR = re.compile(r"\bfor\b", re.IGNORECASE)
|
|||||||
FIELDS = ("source_row", "quote_type", "offered_unit", "offered_qty",
|
FIELDS = ("source_row", "quote_type", "offered_unit", "offered_qty",
|
||||||
"requested_unit", "requested_qty", "requested_units_per_offered_unit",
|
"requested_unit", "requested_qty", "requested_units_per_offered_unit",
|
||||||
"source_text")
|
"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:
|
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
|
continue
|
||||||
if offered[0] not in offered_inventory:
|
if offered[0] not in offered_inventory:
|
||||||
continue
|
continue
|
||||||
|
if only_stat_specific_inventory(row.get("offer") or "", offered[0]):
|
||||||
|
continue
|
||||||
key = (author, offered[0], offered[1], requested[0], requested[1])
|
key = (author, offered[0], offered[1], requested[0], requested[1])
|
||||||
if key in seen:
|
if key in seen:
|
||||||
continue
|
continue
|
||||||
|
|||||||
+35
-35
@@ -1,36 +1,36 @@
|
|||||||
unit_variant,interest_index,requested_by,offered_by,total_mentions
|
unit_variant,interest_index,requested_by,offered_by,total_mentions
|
||||||
Thorfinn Evo,1689,35,6,41
|
Thorfinn Evo,2243,50,6,56
|
||||||
Aizen Evo,324,146,181,327
|
Aizen Evo,307,195,243,438
|
||||||
Homura Evo,229,150,264,414
|
Dio Evo,279,8,12,20
|
||||||
Shiny Aizen Evo,217,10,21,31
|
Shiny Aizen Evo,218,13,25,38
|
||||||
Mamy Evo,200,11,25,36
|
Homura Evo,213,200,360,560
|
||||||
Shiny Skull Knight Evo,192,9,22,31
|
Shiny Skull Knight Evo,185,15,34,49
|
||||||
Shiny Idol Evo,190,7,18,25
|
Shiny Homura Evo,163,15,39,54
|
||||||
Shiny Homura Evo,189,14,33,47
|
Mamy Evo,163,12,32,44
|
||||||
Alucard Evo,176,49,115,164
|
Alucard Evo,162,62,150,212
|
||||||
Shiny Vengeful Swordsman Evo,176,8,22,30
|
Shiny Yoshina Evo,133,11,37,48
|
||||||
Shiny Power Evo,160,5,17,22
|
Shiny Vengeful Swordsman Evo,131,9,32,41
|
||||||
Shiny Cid Evo,154,12,36,48
|
Shiny Dark Mage Evo,128,27,86,113
|
||||||
Shiny Dark Mage Evo,133,19,63,82
|
Shiny Mamy Evo,118,20,71,91
|
||||||
Shiny Mamy Evo,113,12,50,62
|
Shiny Boros Evo,111,6,28,34
|
||||||
Roger Evo,112,15,61,76
|
Shiny Idol Evo,111,6,28,34
|
||||||
Shiny Chuuni Evo,108,23,93,116
|
Shiny Cid Evo,106,12,51,63
|
||||||
Chuuni Evo,100,43,181,224
|
Shiny Chuuni Evo,103,31,123,154
|
||||||
Shiny Buddha Evo,100,7,37,44
|
Roger Evo,100,18,77,95
|
||||||
Dark Mage Unevo,95,7,39,46
|
Shiny Buddha Evo,82,9,53,62
|
||||||
Somber Evo,86,6,39,45
|
Dark Mage Evo,67,79,464,543
|
||||||
Dark Mage Evo,85,70,341,411
|
Chuuni Evo,67,43,260,303
|
||||||
Shiny Inhuman Evo,83,7,45,52
|
Shiny Inhuman Evo,61,7,59,66
|
||||||
Shiny Poseidon Evo,73,5,41,46
|
Shiny Gilgamesh Evo,55,9,80,89
|
||||||
Gilgamesh Evo,62,28,198,226
|
Shiny Poseidon Evo,54,6,60,66
|
||||||
Shiny Gilgamesh Evo,62,6,55,61
|
Gilgamesh Evo,52,33,259,292
|
||||||
Emilia Evo,54,6,64,70
|
Dark Mage Unevo,50,5,58,63
|
||||||
Buddha Evo,51,23,202,225
|
Somber Evo,50,5,58,63
|
||||||
Sakamoto Evo,51,5,60,65
|
Skull Knight Evo,44,7,83,90
|
||||||
Poseidon Evo,49,10,103,113
|
Buddha Evo,37,25,285,310
|
||||||
Shiny Elf Mage Evo,47,7,83,90
|
Vengeful Swordsman Evo,36,14,176,190
|
||||||
Shiny Nagumo Evo,45,5,68,73
|
Shiny Nagumo Evo,34,6,98,104
|
||||||
Shiny Somber Evo,43,5,72,77
|
Cid Evo,30,20,288,308
|
||||||
Cid Evo,42,20,214,234
|
Shiny Elf Mage Evo,26,6,128,134
|
||||||
Vengeful Swordsman Evo,41,11,132,143
|
Poseidon Evo,24,7,156,163
|
||||||
Nagumo Evo,27,13,235,248
|
Nagumo Evo,18,12,312,324
|
||||||
|
|||||||
|
+46
-32
@@ -1,32 +1,46 @@
|
|||||||
rank,unit_variant,relative_value,confidence,quote_count,asking_quote_count,completed_trade_count,source_rows,basis,note
|
rank,unit_variant,relative_value,confidence,quote_count,asking_quote_count,explicit_ask_count,inferred_ask_count,completed_trade_count,source_rows,basis,note
|
||||||
1,Shiny Aizen Evo,,constraint_only,0,0,0,,user_supplied_ordering,Worth more than Aizen Evo; multiplier unknown
|
1,Shiny Homura Evo,2100,very_low,3,3,3,0,0,52 | 174 | 1138,asking_quotes,
|
||||||
2,Aizen Evo,1000,low,8,8,0,6 | 47 | 366 | 397 | 712 | 776 | 800 | 1137,asking_quotes,Aizen Evo = 1000 reference
|
2,Shiny Aizen Evo,,constraint_only,0,0,0,0,0,,user_supplied_ordering,Worth more than Aizen Evo; multiplier unknown
|
||||||
3,Shiny Dark Mage Evo,650,very_low,2,2,0,379 | 776,asking_quotes,
|
3,Aizen Evo,1000,low,8,8,6,2,0,47 | 228 | 366 | 776 | 800 | 1138 | 1641 | 1687,asking_quotes,Aizen Evo = 1000 reference
|
||||||
,Alucard Evo,,unstable,4,4,0,6 | 187 | 397 | 946,asking_quotes,Estimate changes or disconnects when one quote is removed
|
,Alucard Evo,,insufficient,2,2,2,0,0,52 | 187,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Buddha Evo,,unstable,3,3,0,115 | 800 | 1194,asking_quotes,Estimate changes or disconnects when one quote is removed
|
,Alucard Unevo,,insufficient,1,1,1,0,0,65,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Chuuni Evo,,unstable,4,4,0,536 | 750 | 1100 | 1194,asking_quotes,Estimate changes or disconnects when one quote is removed
|
,Android 21 Evo,,insufficient,1,1,1,0,0,52,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Cid Evo,,insufficient,2,2,0,1255 | 1264,asking_quotes,Too few independent quotes for a numeric estimate
|
,Buddha Evo,,unstable,5,5,3,2,0,115 | 253 | 468 | 800 | 1195,asking_quotes,Estimate changes or disconnects when one quote is removed
|
||||||
,Cream Evo,,insufficient,1,1,0,1100,asking_quotes,Too few independent quotes for a numeric estimate
|
,Chuuni Evo,,unstable,6,6,2,4,0,468 | 536 | 750 | 1101 | 1195 | 1675,asking_quotes,Estimate changes or disconnects when one quote is removed
|
||||||
,Dark Mage Evo,,unstable,10,10,0,379 | 490 | 636 | 750 | 1077 | 1100 | 1111 | 1240 | 1255 | 1264,asking_quotes,Estimate changes or disconnects when one quote is removed
|
,Cid Evo,,unstable,5,5,3,2,0,1256 | 1265 | 1543 | 1624 | 1675,asking_quotes,Estimate changes or disconnects when one quote is removed
|
||||||
,Gilgamesh Evo,,insufficient,1,1,0,742,asking_quotes,Too few independent quotes for a numeric estimate
|
,Cid Unevo,,insufficient,1,1,1,0,0,463,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Gilgamesh Unevo,,insufficient,1,1,0,115,asking_quotes,Too few independent quotes for a numeric estimate
|
,Cream Evo,,insufficient,1,1,0,1,0,1101,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Homura Evo,,unstable,12,12,0,187 | 366 | 536 | 712 | 742 | 800 | 946 | 1077 | 1111 | 1194 | 1240 | 1264,asking_quotes,Estimate changes or disconnects when one quote is removed
|
,Dark Mage Evo,,unstable,16,16,5,11,0,379 | 490 | 636 | 750 | 1078 | 1101 | 1112 | 1241 | 1256 | 1265 | 1306 | 1378 | 1540 | 1543 | 1624 | 1675,asking_quotes,Estimate changes or disconnects when one quote is removed
|
||||||
,Kisuke Evo,,insufficient,1,1,0,1194,asking_quotes,Too few independent quotes for a numeric estimate
|
,Elf Mage Evo,,insufficient,1,1,0,1,0,1641,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Nami Evo,,insufficient,1,1,0,636,asking_quotes,Too few independent quotes for a numeric estimate
|
,Gilgamesh Unevo,,insufficient,1,1,1,0,0,115,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Poseidon Evo,,insufficient,2,2,0,636 | 1255,asking_quotes,Too few independent quotes for a numeric estimate
|
,Homura Evo,,unstable,12,12,8,4,0,187 | 253 | 366 | 536 | 800 | 1078 | 1112 | 1195 | 1241 | 1265 | 1687 | 1702,asking_quotes,Estimate changes or disconnects when one quote is removed
|
||||||
,Roger Evo,,insufficient,1,1,0,712,asking_quotes,Too few independent quotes for a numeric estimate
|
,Ice Lily Evo,,insufficient,1,1,1,0,0,1334,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Shiny Boros Evo,,insufficient,1,1,0,174,asking_quotes,Too few independent quotes for a numeric estimate
|
,Jelly Evo,,insufficient,1,1,1,0,0,463,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Shiny Buddha Evo,,insufficient,1,1,0,536,asking_quotes,Too few independent quotes for a numeric estimate
|
,Jiraiya Evo,,insufficient,1,1,0,1,0,1306,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Shiny Chuuni Evo,,insufficient,2,2,0,47 | 742,asking_quotes,Too few independent quotes for a numeric estimate
|
,Kisuke Evo,,insufficient,1,1,1,0,0,1195,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Shiny Elf Mage Evo,,insufficient,1,1,0,47,asking_quotes,Too few independent quotes for a numeric estimate
|
,Nagumo Evo,,insufficient,1,1,0,1,0,1540,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Shiny Emilia Evo,,insufficient,1,1,0,174,asking_quotes,Too few independent quotes for a numeric estimate
|
,Nagumo Unevo,,insufficient,1,1,1,0,0,463,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Shiny Gilgamesh Evo,,insufficient,1,1,0,174,asking_quotes,Too few independent quotes for a numeric estimate
|
,Nami Evo,,insufficient,1,1,0,1,0,636,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Shiny Homura Evo,,insufficient,2,2,0,174 | 1137,asking_quotes,Too few independent quotes for a numeric estimate
|
,Poseidon Evo,,unstable,4,4,1,3,0,636 | 1256 | 1306 | 1378,asking_quotes,Estimate changes or disconnects when one quote is removed
|
||||||
,Shiny Ice Queen Evo,,insufficient,1,1,0,397,asking_quotes,Too few independent quotes for a numeric estimate
|
,Shiny Boros Evo,,insufficient,1,1,1,0,0,174,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Shiny Killstreak Evo,,insufficient,1,1,0,490,asking_quotes,Too few independent quotes for a numeric estimate
|
,Shiny Buddha Evo,,insufficient,2,2,1,1,0,536 | 1334,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Shiny Mamy Evo,,insufficient,2,2,0,174 | 776,asking_quotes,Too few independent quotes for a numeric estimate
|
,Shiny Chuuni Evo,,unstable,4,4,4,0,0,47 | 228 | 463 | 1357,asking_quotes,Estimate changes or disconnects when one quote is removed
|
||||||
,Shiny Piccolo Evo,,insufficient,1,1,0,47,asking_quotes,Too few independent quotes for a numeric estimate
|
,Shiny Dark Mage Evo,,unstable,4,4,3,1,0,253 | 379 | 776 | 1195,asking_quotes,Estimate changes or disconnects when one quote is removed
|
||||||
,Shiny Power Evo,,insufficient,1,1,0,1137,asking_quotes,Too few independent quotes for a numeric estimate
|
,Shiny Elf Mage Evo,,insufficient,1,1,1,0,0,47,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Shiny Yoshina Evo,,insufficient,1,1,0,1194,asking_quotes,Too few independent quotes for a numeric estimate
|
,Shiny Emilia Evo,,insufficient,1,1,1,0,0,174,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Skull Knight Evo,,insufficient,1,1,0,1264,asking_quotes,Too few independent quotes for a numeric estimate
|
,Shiny Gilgamesh Evo,,insufficient,2,2,2,0,0,52 | 174,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
,Thorfinn Evo,,insufficient,1,1,0,366,asking_quotes,Too few independent quotes for a numeric estimate
|
,Shiny Issei Evo,,insufficient,1,1,1,0,0,1334,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
|
,Shiny Killstreak Evo,,insufficient,1,1,0,1,0,490,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
|
,Shiny Mamy Evo,,insufficient,2,2,2,0,0,174 | 776,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
|
,Shiny Nagumo Evo,,insufficient,2,2,2,0,0,65 | 1334,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
|
,Shiny Piccolo Evo,,insufficient,1,1,1,0,0,47,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
|
,Shiny Poseidon Evo,,insufficient,2,2,2,0,0,1357 | 1702,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
|
,Shiny Power Evo,,insufficient,1,1,1,0,0,1138,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
|
,Shiny Sakamoto Evo,,insufficient,1,1,1,0,0,463,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
|
,Shiny Saki Evo,,insufficient,1,1,1,0,0,1702,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
|
,Shiny Somber Evo,,insufficient,1,1,1,0,0,463,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
|
,Shiny Tiger Evo,,insufficient,1,1,1,0,0,1702,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
|
,Shiny Yoshina Evo,,insufficient,1,1,1,0,0,1195,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
|
,Skull Knight Evo,,insufficient,1,1,1,0,0,1265,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
|
,Skull Knight Unevo,,insufficient,1,1,0,1,0,1543,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
|
,Thorfinn Evo,,insufficient,2,2,2,0,0,52 | 366,asking_quotes,Too few independent quotes for a numeric estimate
|
||||||
|
|||||||
|
@@ -24,9 +24,11 @@ SHINY_AIZEN = "Shiny Aizen Evo"
|
|||||||
ANCHOR_VALUE = 1000.0
|
ANCHOR_VALUE = 1000.0
|
||||||
RIDGE = 0.03
|
RIDGE = 0.03
|
||||||
COMPLETED_WEIGHT = 9.0
|
COMPLETED_WEIGHT = 9.0
|
||||||
|
INFERRED_WEIGHT_FACTOR = 1.0 / 3.0
|
||||||
MAX_STABLE_CHANGE_PCT = 25.0
|
MAX_STABLE_CHANGE_PCT = 25.0
|
||||||
CONFLICT_RATIO = 1.25
|
CONFLICT_RATIO = 1.25
|
||||||
CONFIDENCE_FIELDS = ("unit_variant", "quote_count", "asking_quote_count",
|
CONFIDENCE_FIELDS = ("unit_variant", "quote_count", "asking_quote_count",
|
||||||
|
"explicit_ask_count", "inferred_ask_count",
|
||||||
"completed_trade_count", "full_fit_value",
|
"completed_trade_count", "full_fit_value",
|
||||||
"leave_one_out_min", "leave_one_out_max", "max_change_pct",
|
"leave_one_out_min", "leave_one_out_max", "max_change_pct",
|
||||||
"most_influential_source_row", "most_influential_evidence_type",
|
"most_influential_source_row", "most_influential_evidence_type",
|
||||||
@@ -37,6 +39,10 @@ CONFLICT_FIELDS = ("unit_a", "unit_b", "source_row_a", "source_row_b",
|
|||||||
"source_text_a", "source_text_b")
|
"source_text_a", "source_text_b")
|
||||||
IMPACT_FIELDS = ("unit_variant", "removed_source_row", "removed_evidence_type", "removed_quote",
|
IMPACT_FIELDS = ("unit_variant", "removed_source_row", "removed_evidence_type", "removed_quote",
|
||||||
"leave_one_out_value", "change_pct", "disconnected")
|
"leave_one_out_value", "change_pct", "disconnected")
|
||||||
|
COMPARISON_FIELDS = ("unit_variant", "all_fit", "all_ranked_value", "all_confidence",
|
||||||
|
"all_explicit_asks", "all_inferred_asks", "explicit_only_fit",
|
||||||
|
"explicit_only_ranked_value", "explicit_only_confidence",
|
||||||
|
"change_pct_without_inferred", "explicit_only_connection")
|
||||||
|
|
||||||
|
|
||||||
def source_order(source: int | str) -> tuple[int, int | str]:
|
def source_order(source: int | str) -> tuple[int, int | str]:
|
||||||
@@ -143,12 +149,18 @@ def fit_values(direct: list[dict], bundles: list[dict], completed: list[dict] |
|
|||||||
*, include_report: bool = False) -> tuple:
|
*, include_report: bool = False) -> tuple:
|
||||||
quotes = []
|
quotes = []
|
||||||
for item in direct:
|
for item in direct:
|
||||||
|
inferred = item.get("quote_type") == "listing_pair"
|
||||||
quotes.append(({item["offered_unit"]: int(item["offered_qty"])},
|
quotes.append(({item["offered_unit"]: int(item["offered_qty"])},
|
||||||
{item["requested_unit"]: int(item["requested_qty"])},
|
{item["requested_unit"]: int(item["requested_qty"])},
|
||||||
int(item["source_row"]), 3.0, item.get("source_text", ""), "asking_direct"))
|
int(item["source_row"]), 3.0 * (INFERRED_WEIGHT_FACTOR if inferred else 1.0),
|
||||||
|
item.get("source_text", ""),
|
||||||
|
"asking_direct_inferred" if inferred else "asking_direct_explicit"))
|
||||||
for item in bundles:
|
for item in bundles:
|
||||||
|
inferred = item.get("quote_type") == "listing_pair"
|
||||||
quotes.append((item["offered"], item["requested"], int(item["source_row"]),
|
quotes.append((item["offered"], item["requested"], int(item["source_row"]),
|
||||||
1.0, item.get("source_text", ""), "asking_bundle"))
|
INFERRED_WEIGHT_FACTOR if inferred else 1.0,
|
||||||
|
item.get("source_text", ""),
|
||||||
|
"asking_bundle_inferred" if inferred else "asking_bundle_explicit"))
|
||||||
for item in completed or []:
|
for item in completed or []:
|
||||||
quotes.append((item["offered"], item["requested"], item["source_row"],
|
quotes.append((item["offered"], item["requested"], item["source_row"],
|
||||||
COMPLETED_WEIGHT, item.get("source_text", ""), "completed_trade"))
|
COMPLETED_WEIGHT, item.get("source_text", ""), "completed_trade"))
|
||||||
@@ -168,6 +180,10 @@ def fit_values(direct: list[dict], bundles: list[dict], completed: list[dict] |
|
|||||||
completed_count = len({q[2] for q in connected if q[5] == "completed_trade"
|
completed_count = len({q[2] for q in connected if q[5] == "completed_trade"
|
||||||
and unit in set(q[0]) | set(q[1])})
|
and unit in set(q[0]) | set(q[1])})
|
||||||
asking_count = count - completed_count
|
asking_count = count - completed_count
|
||||||
|
explicit_sources = {q[2] for q in connected if q[5].endswith("_explicit")
|
||||||
|
and unit in set(q[0]) | set(q[1])}
|
||||||
|
inferred_sources = {q[2] for q in connected if q[5].endswith("_inferred")
|
||||||
|
and unit in set(q[0]) | set(q[1])} - explicit_sources
|
||||||
omitted_values = [(quote, fitted.get(unit)) for quote, fitted in omissions]
|
omitted_values = [(quote, fitted.get(unit)) for quote, fitted in omissions]
|
||||||
for quote, fitted in omitted_values:
|
for quote, fitted in omitted_values:
|
||||||
impacts.append({
|
impacts.append({
|
||||||
@@ -197,6 +213,8 @@ def fit_values(direct: list[dict], bundles: list[dict], completed: list[dict] |
|
|||||||
report.append({
|
report.append({
|
||||||
"unit_variant": unit, "quote_count": count,
|
"unit_variant": unit, "quote_count": count,
|
||||||
"asking_quote_count": asking_count, "completed_trade_count": completed_count,
|
"asking_quote_count": asking_count, "completed_trade_count": completed_count,
|
||||||
|
"explicit_ask_count": len(explicit_sources),
|
||||||
|
"inferred_ask_count": len(inferred_sources),
|
||||||
"full_fit_value": round(value, 1),
|
"full_fit_value": round(value, 1),
|
||||||
"leave_one_out_min": round(min(fitted for _, fitted in retained), 1) if retained else "",
|
"leave_one_out_min": round(min(fitted for _, fitted in retained), 1) if retained else "",
|
||||||
"leave_one_out_max": round(max(fitted for _, fitted in retained), 1) if retained else "",
|
"leave_one_out_max": round(max(fitted for _, fitted in retained), 1) if retained else "",
|
||||||
@@ -214,6 +232,8 @@ def fit_values(direct: list[dict], bundles: list[dict], completed: list[dict] |
|
|||||||
"confidence": confidence,
|
"confidence": confidence,
|
||||||
"quote_count": count,
|
"quote_count": count,
|
||||||
"asking_quote_count": asking_count,
|
"asking_quote_count": asking_count,
|
||||||
|
"explicit_ask_count": len(explicit_sources),
|
||||||
|
"inferred_ask_count": len(inferred_sources),
|
||||||
"completed_trade_count": completed_count,
|
"completed_trade_count": completed_count,
|
||||||
"source_rows": source_list(sources[unit]),
|
"source_rows": source_list(sources[unit]),
|
||||||
"basis": ("completed_and_asking" if completed_count and asking_count else
|
"basis": ("completed_and_asking" if completed_count and asking_count else
|
||||||
@@ -234,6 +254,8 @@ def fit_values(direct: list[dict], bundles: list[dict], completed: list[dict] |
|
|||||||
"confidence": "constraint_only",
|
"confidence": "constraint_only",
|
||||||
"quote_count": 0,
|
"quote_count": 0,
|
||||||
"asking_quote_count": 0,
|
"asking_quote_count": 0,
|
||||||
|
"explicit_ask_count": 0,
|
||||||
|
"inferred_ask_count": 0,
|
||||||
"completed_trade_count": 0,
|
"completed_trade_count": 0,
|
||||||
"source_rows": "",
|
"source_rows": "",
|
||||||
"basis": "user_supplied_ordering",
|
"basis": "user_supplied_ordering",
|
||||||
@@ -259,6 +281,40 @@ def fit_values(direct: list[dict], bundles: list[dict], completed: list[dict] |
|
|||||||
return result, summary
|
return result, summary
|
||||||
|
|
||||||
|
|
||||||
|
def compare_evidence_modes(all_values: list[dict], all_report: list[dict],
|
||||||
|
explicit_values: list[dict], explicit_report: list[dict]) -> list[dict]:
|
||||||
|
"""Show the diagnostic fit and published value with inferred asks removed."""
|
||||||
|
all_rows = {row["unit_variant"]: row for row in all_values}
|
||||||
|
explicit_rows = {row["unit_variant"]: row for row in explicit_values}
|
||||||
|
all_fits = {row["unit_variant"]: row for row in all_report}
|
||||||
|
explicit_fits = {row["unit_variant"]: row for row in explicit_report}
|
||||||
|
result = []
|
||||||
|
for unit in sorted(all_rows.keys() | explicit_rows.keys()):
|
||||||
|
full = all_rows.get(unit, {})
|
||||||
|
reduced = explicit_rows.get(unit, {})
|
||||||
|
full_fit = all_fits.get(unit, {}).get("full_fit_value", "")
|
||||||
|
reduced_fit = explicit_fits.get(unit, {}).get("full_fit_value", "")
|
||||||
|
change = (round(100 * (reduced_fit - full_fit) / full_fit, 1)
|
||||||
|
if isinstance(full_fit, (int, float)) and full_fit
|
||||||
|
and isinstance(reduced_fit, (int, float)) else "")
|
||||||
|
result.append({
|
||||||
|
"unit_variant": unit,
|
||||||
|
"all_fit": full_fit,
|
||||||
|
"all_ranked_value": full.get("relative_value", ""),
|
||||||
|
"all_confidence": full.get("confidence", ""),
|
||||||
|
"all_explicit_asks": full.get("explicit_ask_count", 0),
|
||||||
|
"all_inferred_asks": full.get("inferred_ask_count", 0),
|
||||||
|
"explicit_only_fit": reduced_fit,
|
||||||
|
"explicit_only_ranked_value": reduced.get("relative_value", ""),
|
||||||
|
"explicit_only_confidence": reduced.get(
|
||||||
|
"confidence", "disconnected" if unit in all_fits else ""),
|
||||||
|
"change_pct_without_inferred": change,
|
||||||
|
"explicit_only_connection": ("connected" if unit in explicit_fits else
|
||||||
|
"disconnected" if unit in all_fits else "constraint_only"),
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
parser.add_argument("--input", type=Path, default=Path("trades.csv"))
|
parser.add_argument("--input", type=Path, default=Path("trades.csv"))
|
||||||
@@ -269,10 +325,11 @@ def main() -> None:
|
|||||||
parser.add_argument("--confidence-output", type=Path, default=Path("confidence_report.csv"))
|
parser.add_argument("--confidence-output", type=Path, default=Path("confidence_report.csv"))
|
||||||
parser.add_argument("--conflicts-output", type=Path, default=Path("quote_conflicts.csv"))
|
parser.add_argument("--conflicts-output", type=Path, default=Path("quote_conflicts.csv"))
|
||||||
parser.add_argument("--impact-output", type=Path, default=Path("quote_impact.csv"))
|
parser.add_argument("--impact-output", type=Path, default=Path("quote_impact.csv"))
|
||||||
|
parser.add_argument("--comparison-output", type=Path, default=Path("evidence_comparison.csv"))
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
destinations = [args.output.resolve(), args.bundle_output.resolve(), args.direct_output.resolve(),
|
destinations = [args.output.resolve(), args.bundle_output.resolve(), args.direct_output.resolve(),
|
||||||
args.confidence_output.resolve(), args.conflicts_output.resolve(),
|
args.confidence_output.resolve(), args.conflicts_output.resolve(),
|
||||||
args.impact_output.resolve()]
|
args.impact_output.resolve(), args.comparison_output.resolve()]
|
||||||
inputs = {args.input.resolve(), args.completed_trades.resolve()}
|
inputs = {args.input.resolve(), args.completed_trades.resolve()}
|
||||||
if len(inputs) != 2 or len(set(destinations)) != len(destinations) or inputs.intersection(destinations):
|
if len(inputs) != 2 or len(set(destinations)) != len(destinations) or inputs.intersection(destinations):
|
||||||
parser.error("input and output paths must all differ")
|
parser.error("input and output paths must all differ")
|
||||||
@@ -288,6 +345,11 @@ def main() -> None:
|
|||||||
completed = load_completed_trades(args.completed_trades)
|
completed = load_completed_trades(args.completed_trades)
|
||||||
values, summary, report, conflicts, impacts = fit_values(
|
values, summary, report, conflicts, impacts = fit_values(
|
||||||
direct, bundles, completed, include_report=True)
|
direct, bundles, completed, include_report=True)
|
||||||
|
explicit_values, _, explicit_report, _, _ = fit_values(
|
||||||
|
[quote for quote in direct if quote["quote_type"] == "explicit_for"],
|
||||||
|
[quote for quote in bundles if quote["quote_type"] == "explicit_for"],
|
||||||
|
completed, include_report=True)
|
||||||
|
comparison = compare_evidence_modes(values, report, explicit_values, explicit_report)
|
||||||
for destination in destinations:
|
for destination in destinations:
|
||||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||||
with args.direct_output.open("w", encoding="utf-8-sig", newline="") as stream:
|
with args.direct_output.open("w", encoding="utf-8-sig", newline="") as stream:
|
||||||
@@ -305,6 +367,7 @@ def main() -> None:
|
|||||||
with args.output.open("w", encoding="utf-8-sig", newline="") as stream:
|
with args.output.open("w", encoding="utf-8-sig", newline="") as stream:
|
||||||
writer = csv.DictWriter(stream, fieldnames=("rank", "unit_variant", "relative_value",
|
writer = csv.DictWriter(stream, fieldnames=("rank", "unit_variant", "relative_value",
|
||||||
"confidence", "quote_count", "asking_quote_count",
|
"confidence", "quote_count", "asking_quote_count",
|
||||||
|
"explicit_ask_count", "inferred_ask_count",
|
||||||
"completed_trade_count", "source_rows",
|
"completed_trade_count", "source_rows",
|
||||||
"basis", "note"))
|
"basis", "note"))
|
||||||
writer.writeheader()
|
writer.writeheader()
|
||||||
@@ -321,6 +384,10 @@ def main() -> None:
|
|||||||
writer = csv.DictWriter(stream, fieldnames=IMPACT_FIELDS)
|
writer = csv.DictWriter(stream, fieldnames=IMPACT_FIELDS)
|
||||||
writer.writeheader()
|
writer.writeheader()
|
||||||
writer.writerows(impacts)
|
writer.writerows(impacts)
|
||||||
|
with args.comparison_output.open("w", encoding="utf-8-sig", newline="") as stream:
|
||||||
|
writer = csv.DictWriter(stream, fieldnames=COMPARISON_FIELDS)
|
||||||
|
writer.writeheader()
|
||||||
|
writer.writerows(comparison)
|
||||||
except (OSError, ValueError) as error:
|
except (OSError, ValueError) as error:
|
||||||
parser.error(str(error))
|
parser.error(str(error))
|
||||||
print(f"Saved {len(values)} provisional entries from {len(rows)} listings; "
|
print(f"Saved {len(values)} provisional entries from {len(rows)} listings; "
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
unit_a,unit_b,source_row_a,source_row_b,value_ratio_a,value_ratio_b,ratio_difference_pct,source_text_a,source_text_b
|
unit_a,unit_b,source_row_a,source_row_b,value_ratio_a,value_ratio_b,ratio_difference_pct,source_text_a,source_text_b
|
||||||
Alucard Evo,Homura Evo,187,946,2.0,1.0,100.0,2 Homura Evo FOR Alucard Evo,my Homura Evo for Alucard Evo
|
|
||||||
|
|||||||
|
+1804
-780
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
|||||||
reported_handles,warning_text,reporter_hash,reports_seen
|
"reported_handles","warning_text","reporter_hash","reports_seen"
|
||||||
Alejandrooooo | XxPaulGamerxX12,Scammer @Alejandrooooo (@XxPaulGamerxX12) forge photo,dc8e87ecefbf9b0c3a6172bc,2
|
"Alejandrooooo | XxPaulGamerxX12","Scammer @Alejandrooooo (@XxPaulGamerxX12) forge photo","dc8e87ecefbf9b0c3a6172bc","2"
|
||||||
zxcebaaakaa,'@zxcebaaakaa is a scammer dont trade him.,58cfc864cecc252a28dca73a,2
|
"zxcebaaakaa","'@zxcebaaakaa is a scammer dont trade him.","58cfc864cecc252a28dca73a","2"
|
||||||
higherfischeran | franklin_orbit_83651,User report: IRL trading and possible scamming; profile screenshot supplied. Not independently verified.,756e53c0d3685517b913749a,1
|
"higherfischeran | franklin_orbit_83651","User report: IRL trading and possible scamming; profile screenshot supplied. Not independently verified.","756e53c0d3685517b913749a","1"
|
||||||
|
"itsme_you1#0000 | darkwwee#0000 | p3reira._16913 | Never_ItsNever123 | teahmyeah | csmcsmcsm11","Scammer List: @itsme_you1#0000/ @darkwwee#0000/ @p3reira._16913/ @Never_ItsNever123/ @teahmyeah/@csmcsmcsm11","053369d6bf84388577b1a565","2"
|
||||||
|
|||||||
|
@@ -17,6 +17,14 @@ class ValueListTests(unittest.TestCase):
|
|||||||
variants("my Aizen Evo for Homura Evo", request=True),
|
variants("my Aizen Evo for Homura Evo", request=True),
|
||||||
{"Homura Evo"},
|
{"Homura Evo"},
|
||||||
)
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
variants("my Alucard Evo + Shiny Dark Mage Evo for Aizen Evo", request=True),
|
||||||
|
{"Aizen Evo"},
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
variants("Homura Evo for my Shiny Poseidon Evo + Dark Mage Evo", request=True),
|
||||||
|
{"Homura Evo"},
|
||||||
|
)
|
||||||
|
|
||||||
def test_counts_authors_once_and_excludes_nlf(self):
|
def test_counts_authors_once_and_excludes_nlf(self):
|
||||||
stream = StringIO(newline="")
|
stream = StringIO(newline="")
|
||||||
|
|||||||
@@ -5,7 +5,21 @@ import sqlite3
|
|||||||
import unittest
|
import unittest
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from discord_trade_parser import Message, clean_offer_items, export_csv, parse_listing
|
from discord_trade_parser import (Message, clean_export_text, clean_offer_items, clean_request_fields,
|
||||||
|
export_csv, export_scam_warnings, extract_scam_warnings, iter_messages,
|
||||||
|
normalize_request_segments, separate_received_bid,
|
||||||
|
parse_listing, parse_listings,
|
||||||
|
repair_glued_reposts,
|
||||||
|
repair_misfiled_lf_inventory,
|
||||||
|
repair_misfiled_inventory,
|
||||||
|
repair_misfiled_mlf_inventory,
|
||||||
|
repair_standalone_lf_inventory,
|
||||||
|
repair_inline_side_cues,
|
||||||
|
recover_explicit_my_offers,
|
||||||
|
recover_partial_proposal_offers,
|
||||||
|
repair_confirmed_long_lf_inventory,
|
||||||
|
repair_confirmed_proposal_sides,
|
||||||
|
repair_alucard_lf_inventory)
|
||||||
|
|
||||||
|
|
||||||
class OpenStringIO(StringIO):
|
class OpenStringIO(StringIO):
|
||||||
@@ -15,6 +29,117 @@ class OpenStringIO(StringIO):
|
|||||||
|
|
||||||
|
|
||||||
class TradeItemCleanupTests(unittest.TestCase):
|
class TradeItemCleanupTests(unittest.TestCase):
|
||||||
|
def test_multiplication_sign_quantities(self):
|
||||||
|
self.assertEqual(clean_export_text("2\u00d7 Homura Evo | \u00d71 Shizo Evo | Chuuni Evo \u00d72"),
|
||||||
|
"2x Homura Evo | 1x Shizo Evo | 2x Chuuni Evo")
|
||||||
|
|
||||||
|
def test_received_bid_is_not_owned_inventory(self):
|
||||||
|
self.assertEqual(
|
||||||
|
separate_received_bid("Shiny Megumin Evo | best offer: Shiny Aizen Evo"),
|
||||||
|
("Shiny Megumin Evo", "Shiny Aizen Evo"),
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
separate_received_bid("Shiny Mist Ninja Evo | HIGH OFFER Shiny Homura Evo, 2 Aizen Evo"),
|
||||||
|
("Shiny Mist Ninja Evo", "Shiny Homura Evo, 2 Aizen Evo"),
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_warning_csv_quotes_apostrophe_prefixed_text(self):
|
||||||
|
with sqlite3.connect(":memory:") as conn:
|
||||||
|
conn.execute("CREATE TABLE scam_warnings (id INTEGER PRIMARY KEY, "
|
||||||
|
"reported_handles TEXT, warning_text TEXT, "
|
||||||
|
"reporter_hash TEXT, reports_seen INTEGER)")
|
||||||
|
conn.executemany("INSERT INTO scam_warnings "
|
||||||
|
"(reported_handles,warning_text,reporter_hash,reports_seen) "
|
||||||
|
"VALUES (?,?,?,?)", [
|
||||||
|
("a", "@a is a scammer", "one", 1),
|
||||||
|
("b | c", "Scammer List: @b/@c", "two", 1),
|
||||||
|
])
|
||||||
|
stream = OpenStringIO()
|
||||||
|
with patch.object(Path, "open", return_value=stream):
|
||||||
|
self.assertEqual(export_scam_warnings(conn, Path("warnings.csv")), 2)
|
||||||
|
lines = stream.getvalue().splitlines()
|
||||||
|
self.assertTrue(all(line.startswith('"') and line.endswith('"') for line in lines))
|
||||||
|
rows = list(csv.DictReader(StringIO(stream.getvalue())))
|
||||||
|
self.assertEqual(len(rows), 2)
|
||||||
|
self.assertEqual(rows[0]["warning_text"], "'@a is a scammer")
|
||||||
|
self.assertEqual(rows[1]["reported_handles"], "b | c")
|
||||||
|
|
||||||
|
def test_multiline_scammer_list_is_extracted_from_trade(self):
|
||||||
|
message = Message("display:trader", "Trading: Aizen Evo\nLF: Homura Evo\n"
|
||||||
|
"Scammer List:\n\n"
|
||||||
|
" @itsme_you1#0000/ @darkwwee#0000/ @p3reira._16913/ "
|
||||||
|
"@Never_ItsNever123/ @teahmyeah/@csmcsmcsm11\n\n"
|
||||||
|
"I answer every dm")
|
||||||
|
trade, warnings = extract_scam_warnings(message)
|
||||||
|
self.assertEqual(len(warnings), 1)
|
||||||
|
self.assertEqual(warnings[0].reported_handles,
|
||||||
|
"itsme_you1#0000 | darkwwee#0000 | p3reira._16913 | "
|
||||||
|
"Never_ItsNever123 | teahmyeah | csmcsmcsm11")
|
||||||
|
self.assertNotIn("Scammer List", trade.body)
|
||||||
|
self.assertNotIn("@itsme_you1", trade.body)
|
||||||
|
self.assertEqual(parse_listings(trade)[0].offer, "Aizen Evo")
|
||||||
|
|
||||||
|
def test_dyno_notices_are_skipped_without_dropping_user_trades(self):
|
||||||
|
paste = ("[\n14:06\n]\nDyno\n:\nYour message was too long.\n"
|
||||||
|
"[\n14:07\n]\nAlice\n:\nTrading Aizen Evo\nLF Homura Evo\n"
|
||||||
|
"[14:08]\nDyno (@Dyno) [BOT],\n:\nTrading Aizen Evo\n"
|
||||||
|
"[14:09]\nBob\n:\nTrading Dyno pet and Homura Evo\n")
|
||||||
|
messages = list(iter_messages(paste.splitlines()))
|
||||||
|
self.assertEqual([msg.author for msg in messages],
|
||||||
|
["display:alice", "display:bob"])
|
||||||
|
self.assertEqual([listing.offer for msg in messages
|
||||||
|
for listing in parse_listings(msg)],
|
||||||
|
["Aizen Evo", "Dyno pet and Homura Evo"])
|
||||||
|
self.assertEqual(parse_listings(Message("display:dyno#3861", "Trading Aizen Evo")), [])
|
||||||
|
|
||||||
|
def test_autocorrects_clear_unit_typos_with_variant_cues(self):
|
||||||
|
self.assertEqual(clean_export_text("Homurra Evo | Dark Mgae Unevo | Shiny Homurra"),
|
||||||
|
"Homura Evo | Dark Mage Unevo | Shiny Homura Evo")
|
||||||
|
self.assertEqual(clean_export_text("2 Homurra | Offers"),
|
||||||
|
"2 Homura Evo | Offers")
|
||||||
|
|
||||||
|
def test_autocorrect_keeps_ambiguous_and_unrelated_words(self):
|
||||||
|
self.assertEqual(clean_export_text("Aken Evo | Shiny Hunter"),
|
||||||
|
"Aken Evo | Shiny Hunter")
|
||||||
|
|
||||||
|
def test_confirmed_name_aliases_preserve_distinct_variant_status(self):
|
||||||
|
self.assertEqual(clean_export_text("Shiny Raukai Evo | Angle Unevo | Yoshino Evo"),
|
||||||
|
"Shiny Rukia Evo | Angel Unevo | Yoshina Evo")
|
||||||
|
self.assertEqual(clean_export_text("Magic Girl Evo | Infinity Mage Evo | Saka Evo"),
|
||||||
|
"Madoka Evo | Merlin Evo | Sakamoto Evo")
|
||||||
|
self.assertEqual(clean_export_text("Infinity Mage / Merlin Evo"),
|
||||||
|
"Merlin Evo")
|
||||||
|
self.assertEqual(clean_export_text("Valentine Bundle (100RR)"),
|
||||||
|
"Valentine Bundle (100RR)")
|
||||||
|
self.assertEqual(clean_export_text("Shiny Skull Knight Evo / Skeleton Knight"),
|
||||||
|
"Shiny Skull Knight Evo")
|
||||||
|
self.assertEqual(clean_export_text("Shiny Gowther / Doll Evo"),
|
||||||
|
"Shiny Doll Evo")
|
||||||
|
self.assertEqual(clean_export_text("Deer Tan Evo / noko tan (Shiny)"),
|
||||||
|
"Shiny Deer Tan Evo")
|
||||||
|
|
||||||
|
def test_explicit_inventory_splits_preserve_totals_and_shiny_status(self):
|
||||||
|
self.assertEqual(clean_export_text("7x Shiny Siren (2 Evo)"),
|
||||||
|
"2x Shiny Siren Evo | 5x Shiny Siren Unevo")
|
||||||
|
self.assertEqual(clean_export_text("14X Chuuni (11 Unevo 3 Evo) (HAVE 1 Evo ITEM)"),
|
||||||
|
"11x Chuuni Unevo | 3x Chuuni Evo (HAVE 1 Evo ITEM)")
|
||||||
|
self.assertEqual(clean_export_text("4x Poseidon Evo (1x Shiny)"),
|
||||||
|
"1x Shiny Poseidon Evo | 3x Poseidon Evo")
|
||||||
|
self.assertEqual(clean_export_text("2 Chuuni Evo 1 Unevo"),
|
||||||
|
"2x Chuuni Evo | 1x Chuuni Unevo")
|
||||||
|
self.assertEqual(clean_export_text("Toad Sensei Evo Shiny s/s-/sss"),
|
||||||
|
"Shiny Toad Sensei Evo s/s-/sss")
|
||||||
|
self.assertEqual(clean_export_text("3x Unevo Shiny Cream"),
|
||||||
|
"3x Shiny Cream Unevo")
|
||||||
|
self.assertEqual(clean_export_text("Deer Tan Evo Shiny AND NON"),
|
||||||
|
"Shiny Deer Tan Evo | Deer Tan Evo")
|
||||||
|
self.assertEqual(clean_export_text("Cid Evo Shiny Unevo"),
|
||||||
|
"Shiny Cid Evo")
|
||||||
|
self.assertEqual(clean_export_text("Dark Mage Evo Shiny for my Chuuni Evo"),
|
||||||
|
"Shiny Dark Mage Evo for my Chuuni Evo")
|
||||||
|
self.assertEqual(clean_export_text("Unevo Shiny Vanilla Ice (Cream Evo)"),
|
||||||
|
"Shiny Cream Unevo")
|
||||||
|
|
||||||
def test_keeps_stats_broad_options_and_owned_best_offer(self):
|
def test_keeps_stats_broad_options_and_owned_best_offer(self):
|
||||||
offer = ("SSS DMG 23.1% | All Gamepasses | ALL SKINS | "
|
offer = ("SSS DMG 23.1% | All Gamepasses | ALL SKINS | "
|
||||||
"BEST OFFER:Aizen Evo FULL SSS | HIGH OFFER Shiny Homura Evo")
|
"BEST OFFER:Aizen Evo FULL SSS | HIGH OFFER Shiny Homura Evo")
|
||||||
@@ -36,6 +161,234 @@ class TradeItemCleanupTests(unittest.TestCase):
|
|||||||
listing = parse_listing(Message("b", "Trading: Aizen Evo | no response = nty\nLF: Homura Evo"))
|
listing = parse_listing(Message("b", "Trading: Aizen Evo | no response = nty\nLF: Homura Evo"))
|
||||||
self.assertEqual(listing.offer, "Aizen Evo")
|
self.assertEqual(listing.offer, "Aizen Evo")
|
||||||
|
|
||||||
|
def test_request_cleanup_moves_explicit_labels_and_keeps_trade_requests(self):
|
||||||
|
looking, lf, mlf, nlf = clean_request_fields(
|
||||||
|
"PRE | OFFERS | SSS DMG 23% | (MLF: ALL FOR Dio Evo) | (NLF bundles 1-3) | "
|
||||||
|
"No reply = nty | NO WANT GP/ clown offers",
|
||||||
|
"Shiny Hunter", "Skins")
|
||||||
|
self.assertEqual(lf, "PRE | OFFERS | SSS DMG 23%")
|
||||||
|
self.assertEqual(mlf, "Shiny Hunter | ALL FOR Dio Evo")
|
||||||
|
self.assertEqual(nlf, "Skins | bundles 1-3 | GP/ clown offers")
|
||||||
|
self.assertEqual(looking, "PRE | OFFERS | SSS DMG 23% | MLF: Shiny Hunter | ALL FOR Dio Evo")
|
||||||
|
|
||||||
|
def test_request_cleanup_recovers_missing_mlf_and_removes_ui(self):
|
||||||
|
looking, lf, mlf, nlf = clean_request_fields(
|
||||||
|
"OFFERS | #【】 | My 4 units for one SSS SPA#",
|
||||||
|
"Offers | Nail relic", "Ignore = NTY | Battlepass",
|
||||||
|
"MLF: SSS Stats | Offers | Nail relic")
|
||||||
|
self.assertEqual(lf, "OFFERS | My 4 units for one SSS SPA")
|
||||||
|
self.assertEqual(mlf, "Offers | Nail relic")
|
||||||
|
self.assertEqual(nlf, "Battlepass")
|
||||||
|
self.assertIn("MLF: Offers | Nail relic", looking)
|
||||||
|
_, lf, mlf, _ = clean_request_fields("", "Offers | Nail relic", "",
|
||||||
|
"MLF: SSS Stats | Offers | Nail relic")
|
||||||
|
self.assertEqual((lf, mlf), ("", "SSS Stats | Offers | Nail relic"))
|
||||||
|
self.assertEqual(clean_request_fields("", "", "Rerolls | Ignoring Clowns/Lowballs")[3],
|
||||||
|
"Rerolls | Lowballs")
|
||||||
|
_, lf, _, nlf = clean_request_fields(
|
||||||
|
"Offers", "", "very low value offers; low demand; Only SSS stats (for Homura Evo)")
|
||||||
|
self.assertEqual(lf, "Offers | Only SSS stats (for Homura Evo)")
|
||||||
|
self.assertEqual(nlf, "very low value offers; low demand")
|
||||||
|
self.assertEqual(clean_request_fields(
|
||||||
|
"GOOD OFFERSTrading | Aizen Evo | Homura Evo | GOOD OFFERS", "", "")[1],
|
||||||
|
"GOOD OFFERS")
|
||||||
|
self.assertEqual(clean_request_fields("Keyword:", "", "")[1], "")
|
||||||
|
self.assertEqual(normalize_request_segments("SHINIES:Cid,Dark Mage"),
|
||||||
|
"Shiny Cid Evo,Shiny Dark Mage Evo")
|
||||||
|
|
||||||
|
def test_glued_trade_label_does_not_put_inventory_in_mlf(self):
|
||||||
|
message = Message("a", "Trade\nShiny Inhuman Evo\nLF offers "
|
||||||
|
"MLF all for Alucard Evo i can add more unitstrade\n"
|
||||||
|
"Shiny Inhuman Evo\nLF offers")
|
||||||
|
listing = parse_listing(message)
|
||||||
|
self.assertEqual(listing.offer, "Shiny Inhuman Evo")
|
||||||
|
self.assertEqual(listing.mlf, "all for Alucard Evo i can add more units")
|
||||||
|
_, _, mlf, _ = clean_request_fields(
|
||||||
|
"offers", "all for Alucard Evo i can add more unitstrade | Shiny Inhuman Evo | "
|
||||||
|
"all for Alucard Evo i can add more units", "")
|
||||||
|
self.assertEqual(mlf, "all for Alucard Evo i can add more units")
|
||||||
|
|
||||||
|
def test_friend_inventory_is_a_separate_offer(self):
|
||||||
|
message = Message("a", "Trading: Aizen Evo\nMLF: Shiny Chuuni Evo\n"
|
||||||
|
"My Friend is\nShiny Buddha Evo")
|
||||||
|
listings = parse_listings(message)
|
||||||
|
self.assertEqual(len(listings), 2)
|
||||||
|
self.assertEqual(listings[0].mlf, "Shiny Chuuni Evo")
|
||||||
|
self.assertEqual(listings[1].offer, "Shiny Buddha Evo")
|
||||||
|
self.assertEqual(listings[1].looking_for, "")
|
||||||
|
|
||||||
|
def test_confirmed_misfiled_nlf_inventory_becomes_offer(self):
|
||||||
|
offer, lf, nlf = repair_misfiled_inventory(
|
||||||
|
"Shiny Homura Evo", "OVERPAYS",
|
||||||
|
"Shiny Gilgamesh Evo | x1 FULL SSS Aizen Evo 23%/10.7%/12.1% | "
|
||||||
|
"x1 FULL SSS Homura Evo (LF 6 SSS DMG / Aizen) | "
|
||||||
|
"BUNDLES/RR/ASSASIN UPD UNITS/GAMEPASS | WILL READ ALL DMS ( NO RESPONSE = AFK)")
|
||||||
|
self.assertIn("Shiny Gilgamesh Evo", offer)
|
||||||
|
self.assertIn("x1 FULL SSS Homura Evo", offer)
|
||||||
|
self.assertIn("6 SSS DMG / Aizen", lf)
|
||||||
|
self.assertEqual(nlf, "")
|
||||||
|
|
||||||
|
def test_confirmed_misfiled_mlf_inventory_becomes_offer(self):
|
||||||
|
offer, lf, mlf = repair_misfiled_mlf_inventory(
|
||||||
|
"Shiny Homura Evo", "OVERPAYS",
|
||||||
|
"OVERPAY | NORMAL UNITS | x1 Aizen Evo (FULL S) | "
|
||||||
|
"x6 Homura Evo ALL GOOD STATS (LF Aizen Evo/ FULL SSS Homura/ FOR MY 2 Homura)")
|
||||||
|
self.assertIn("x1 Aizen Evo (FULL S)", offer)
|
||||||
|
self.assertIn("x6 Homura Evo ALL GOOD STATS", offer)
|
||||||
|
self.assertIn("Aizen Evo/ FULL SSS Homura/ FOR MY 2 Homura", lf)
|
||||||
|
self.assertEqual(mlf, "OVERPAY")
|
||||||
|
|
||||||
|
def test_glued_reposts_keep_requests_and_recover_offers(self):
|
||||||
|
offer, lf, mlf = repair_glued_reposts(
|
||||||
|
"Nagumo Evo | Homura Evo", "Battlepass | Homura Evo, Battlepass and addTrade | "
|
||||||
|
"Nagumo Evo | Chuuni Evo too | Homura Evo, Battlepass and add", "")
|
||||||
|
self.assertEqual(lf, "Battlepass | Homura Evo, Battlepass and add")
|
||||||
|
self.assertIn("Chuuni Evo", offer)
|
||||||
|
self.assertEqual(mlf, "")
|
||||||
|
|
||||||
|
offer, lf, mlf = repair_glued_reposts(
|
||||||
|
"Cid Evo", "", "UPGRADEtrading | Buddha Evo with SSS spa 11.7 | "
|
||||||
|
"Cid Evo | UPGRADE | Buddha Evo with SSS spa 11.7")
|
||||||
|
self.assertIn("Buddha Evo with SSS spa 11.7", offer)
|
||||||
|
self.assertEqual((lf, mlf), ("", "UPGRADE"))
|
||||||
|
|
||||||
|
def test_confirmed_lf_inventory_moves_to_offer(self):
|
||||||
|
cases = [
|
||||||
|
("2X SSS DMG FOR MY Shiny Poseidon Evo | Evo MYTIC's | "
|
||||||
|
"6x Dark Mage Evo | SKINS | 2x ERWIN DELINQUENT | "
|
||||||
|
"Shiny POSEI/Chuuni Evo AND ADDS FOR MY ROGER Evo",
|
||||||
|
"6x Dark Mage Evo", "2X SSS DMG FOR MY Shiny Poseidon Evo | "
|
||||||
|
"Shiny POSEI/Chuuni Evo AND ADDS FOR MY ROGER Evo"),
|
||||||
|
("S stat Fodder Units | 4 Deer Tan Evo | 2 Dark Mage Unevo | "
|
||||||
|
"S stat Fodder Units | 2 Merlin Evo | "
|
||||||
|
"Vip and Shiny hunter(Must be both in 1 trade) for Emilia Evo",
|
||||||
|
"4 Deer Tan Evo", "Vip and Shiny hunter(Must be both in 1 trade) for Emilia Evo"),
|
||||||
|
("both Homura Evo for Aizen Evo | Shiny UNITS | Shiny esdeath Evo | "
|
||||||
|
"NON-Shiny UNITS | Violentine Evo | "
|
||||||
|
"s tier upgrade for my Shiny units",
|
||||||
|
"Shiny esdeath Evo", "both Homura Evo for Aizen Evo | "
|
||||||
|
"s tier upgrade for my Shiny units"),
|
||||||
|
]
|
||||||
|
for lf, moved, expected_lf in cases:
|
||||||
|
with self.subTest(moved=moved):
|
||||||
|
offer, result_lf = repair_misfiled_lf_inventory("Aizen Evo", lf)
|
||||||
|
self.assertIn(moved, offer)
|
||||||
|
self.assertEqual(result_lf, expected_lf)
|
||||||
|
|
||||||
|
def test_inline_side_cues_keep_owned_items_and_move_requests(self):
|
||||||
|
offer, lf, nlf = repair_inline_side_cues(
|
||||||
|
"Shiny Mist Ninja Evo LOOKIN FOR FAIR TRADE NO SCAM | "
|
||||||
|
"Homura Evo sss rng ( for 4 sss dmg/spa) | "
|
||||||
|
"Battlepass (WILL NOT TRADE FOR Dark Mage Evo + ADDS)", "", "")
|
||||||
|
self.assertIn("Shiny Mist Ninja Evo", offer)
|
||||||
|
self.assertIn("Homura Evo sss rng", offer)
|
||||||
|
self.assertIn("Battlepass", offer)
|
||||||
|
self.assertEqual(lf, "FAIR TRADE | 4 sss dmg/spa")
|
||||||
|
self.assertEqual(nlf, "Dark Mage Evo + ADDS")
|
||||||
|
offer, lf, _ = repair_inline_side_cues(
|
||||||
|
"Dark Mage Evo | olf Homura Evo/overpays/Chuuni Evo item(please chooms ) | "
|
||||||
|
"UPGRADES/", "OFFERS", "")
|
||||||
|
self.assertEqual(offer, "Dark Mage Evo")
|
||||||
|
self.assertEqual(lf, "OFFERS | Homura Evo/overpays/Chuuni Evo item | UPGRADES")
|
||||||
|
offer, lf, _ = repair_inline_side_cues(
|
||||||
|
"6x Dark Mage Evo (ALL GOOD STATS) [2x FOR ANY SSS] | "
|
||||||
|
"100+ Fodder Units (9 for 10rr)", "", "")
|
||||||
|
self.assertEqual(offer, "6x Dark Mage Evo (ALL GOOD STATS) | 100+ Fodder Units")
|
||||||
|
self.assertEqual(lf, "ANY SSS for 2 Dark Mage Evo | 10 RR for 9 Fodder Units")
|
||||||
|
|
||||||
|
def test_owned_standalone_lf_list_moves_to_offer(self):
|
||||||
|
offer, lf = repair_standalone_lf_inventory(
|
||||||
|
"Homura Evo SS/SSS/SSS",
|
||||||
|
"Alucard Evo | Shiny Chuuni Evo | 4x SSS spa | Buddha Evo | "
|
||||||
|
"Aizen Evo/UPGRADES",
|
||||||
|
"my 4x SSS spa + Shiny Somber Evo for Alucard Evo | "
|
||||||
|
"My Alucard Evo + Shiny Dark Mage Evo for Aizen Evo")
|
||||||
|
self.assertIn("Alucard Evo", offer)
|
||||||
|
self.assertIn("4x SSS spa", offer)
|
||||||
|
self.assertIn("Shiny Dark Mage Evo", offer)
|
||||||
|
self.assertEqual(lf, "Aizen Evo/UPGRADES")
|
||||||
|
|
||||||
|
def test_my_proposal_recovers_missing_owned_variants(self):
|
||||||
|
offer = recover_explicit_my_offers(
|
||||||
|
"Shiny Boros Evo | Dark Mage Unevo",
|
||||||
|
"My Boros Evo for Thorfinn Evo | my Dark Mage Evo for SSS DMG",
|
||||||
|
"")
|
||||||
|
self.assertIn("Boros Evo", offer)
|
||||||
|
self.assertIn("Dark Mage Evo", offer)
|
||||||
|
self.assertEqual(offer.count("Shiny Boros Evo"), 1)
|
||||||
|
self.assertNotIn("Thorfinn Evo", offer)
|
||||||
|
|
||||||
|
def test_partial_proposal_recovers_confirmed_offered_units(self):
|
||||||
|
offer = recover_partial_proposal_offers(
|
||||||
|
"Shiny Toad Sensei Evo",
|
||||||
|
"Shiny Toad Sensei Evo and Nagumo Evo for Shiny Cid Evo", "")
|
||||||
|
self.assertIn("Nagumo Evo", offer)
|
||||||
|
offer = recover_partial_proposal_offers(
|
||||||
|
"Shiny Nagumo Evo", "",
|
||||||
|
"Chuuni Evo/Evo ITEM FOR Chuuni Evo AND Buddha Unevo OR OFFER")
|
||||||
|
self.assertIn("Chuuni Evo | Evo ITEM", offer)
|
||||||
|
|
||||||
|
def test_confirmed_proposal_directions(self):
|
||||||
|
offer, lf, _ = repair_confirmed_proposal_sides(
|
||||||
|
"Battlepass",
|
||||||
|
"Shiny Gohan Evo / Gohan Evo / Shiny Android 21 Evo for bundles or RR",
|
||||||
|
"")
|
||||||
|
self.assertIn("Shiny Android 21 Evo", offer)
|
||||||
|
self.assertEqual(lf, "bundles or RR")
|
||||||
|
offer, _, _ = repair_confirmed_proposal_sides(
|
||||||
|
"SSS DMG", "", "Shiny Chuuni Evo for Aizen Evo")
|
||||||
|
self.assertIn("Shiny Chuuni Evo", offer)
|
||||||
|
self.assertNotIn("Aizen Evo", offer)
|
||||||
|
|
||||||
|
def test_confirmed_long_lf_inventory_moves_to_offer(self):
|
||||||
|
offer, lf = repair_confirmed_long_lf_inventory(
|
||||||
|
"Homura Evo",
|
||||||
|
"Sss for Each | 3Dark Mage Evo | Sss for Each | Chuuni Evo | "
|
||||||
|
"Sss | Boros Evo | Cid Evo | Sss Stats | "
|
||||||
|
"my Homura Evo for Aizen Evo")
|
||||||
|
self.assertIn("3Dark Mage Evo", offer)
|
||||||
|
self.assertIn("Cid Evo", offer)
|
||||||
|
self.assertEqual(lf, "SSS for each | SSS Stats | my Homura Evo for Aizen Evo")
|
||||||
|
|
||||||
|
def test_alucard_list_preserves_wanted_adds(self):
|
||||||
|
original = ("%29+ high sss dmg or Aizen Evo | HIGH SSS %14+/28+ | "
|
||||||
|
"SSS DMG 21.6 | Shiny Chuuni Evo or some Dark Mage Evo for sss dmg or spa | "
|
||||||
|
"SSS SPA 11.5 | SSS SPA Chuuni Evo | Shiny Killstreak Evo | "
|
||||||
|
"Dark Mage Evo/Buddha Evo adds for my Shiny units | Elf Mage Evo | "
|
||||||
|
"Inhuman Evo S+ spa | Dark Mage Unevo | offers Aizen Evo,Alucard Evo,high sss stats")
|
||||||
|
offer, lf = repair_alucard_lf_inventory("Alucard Evo", original)
|
||||||
|
self.assertIn("SSS SPA 11.5", offer)
|
||||||
|
self.assertIn("Shiny Killstreak Evo", offer)
|
||||||
|
self.assertIn("Elf Mage Evo", offer)
|
||||||
|
self.assertIn("Dark Mage Evo/Buddha Evo adds", lf)
|
||||||
|
self.assertNotIn("SSS SPA 11.5", lf)
|
||||||
|
raw = original.replace("Aizen Evo", "aizen", 1).replace(
|
||||||
|
"Shiny Chuuni Evo or some Dark Mage Evo", "shiny chunni or some dark mage")
|
||||||
|
raw += " | Dm offers"
|
||||||
|
raw_offer, raw_lf = repair_alucard_lf_inventory("Alucard Evo", raw)
|
||||||
|
self.assertIn("SSS SPA 11.5", raw_offer)
|
||||||
|
self.assertNotIn("Dm offers", raw_lf)
|
||||||
|
|
||||||
|
def test_export_separates_pretrade_and_received_bid(self):
|
||||||
|
conn = sqlite3.connect(":memory:")
|
||||||
|
conn.execute("""CREATE TABLE trades (
|
||||||
|
id INTEGER PRIMARY KEY, offer TEXT, looking_for TEXT, lf TEXT,
|
||||||
|
mlf TEXT, nlf TEXT, author_hash TEXT, seen_count INTEGER,
|
||||||
|
update_count INTEGER, canon_offer TEXT)""")
|
||||||
|
conn.execute(
|
||||||
|
"INSERT INTO trades VALUES (?,?,?,?,?,?,?,?,?,?)",
|
||||||
|
(1, "PRE | Shiny Megumin | best offer: Shiny Aizen",
|
||||||
|
"", "", "", "", "a", 1, 0, "pretrade megumin"),
|
||||||
|
)
|
||||||
|
stream = OpenStringIO(newline="")
|
||||||
|
with patch.object(Path, "open", return_value=stream):
|
||||||
|
self.assertEqual(export_csv(conn, Path("trades.csv"), detailed=True), 1)
|
||||||
|
stream.seek(0)
|
||||||
|
row = next(csv.DictReader(stream))
|
||||||
|
self.assertEqual(row["offer"], "Shiny Megumin")
|
||||||
|
self.assertEqual(row["pretrade"], "yes")
|
||||||
|
self.assertEqual(row["received_bid"], "Shiny Aizen Evo")
|
||||||
|
|
||||||
def test_export_filters_old_database_rows(self):
|
def test_export_filters_old_database_rows(self):
|
||||||
conn = sqlite3.connect(":memory:")
|
conn = sqlite3.connect(":memory:")
|
||||||
conn.execute("""CREATE TABLE trades (
|
conn.execute("""CREATE TABLE trades (
|
||||||
@@ -46,18 +399,62 @@ class TradeItemCleanupTests(unittest.TestCase):
|
|||||||
"INSERT INTO trades VALUES (?,?,?,?,?,?,?,?,?)",
|
"INSERT INTO trades VALUES (?,?,?,?,?,?,?,?,?)",
|
||||||
[(1, "channel for Server Boosters", "", "", "", "", "a", 1, 0),
|
[(1, "channel for Server Boosters", "", "", "", "", "a", 1, 0),
|
||||||
(2, "Aizen Evo | no response = nty", "Homura Evo", "Homura Evo", "", "", "b", 1, 0),
|
(2, "Aizen Evo | no response = nty", "Homura Evo", "Homura Evo", "", "", "b", 1, 0),
|
||||||
(3, "ILLUSIONST (TRANSCENDED) FOR BUNDLE 2", "", "", "", "", "c", 1, 0)],
|
(3, "ILLUSIONST (TRANSCENDED) FOR BUNDLE 2", "", "", "", "", "c", 1, 0),
|
||||||
|
(4, "Homura Evo", "SSS Stats | Evo mythics", "SSS Stats | Evo mythics",
|
||||||
|
"", "", "d", 1, 0)],
|
||||||
)
|
)
|
||||||
stream = OpenStringIO(newline="")
|
stream = OpenStringIO(newline="")
|
||||||
with patch.object(Path, "open", return_value=stream):
|
with patch.object(Path, "open", return_value=stream):
|
||||||
count = export_csv(conn, Path("trades.csv"), detailed=True)
|
count = export_csv(conn, Path("trades.csv"), detailed=True)
|
||||||
stream.seek(0)
|
stream.seek(0)
|
||||||
rows = list(csv.DictReader(stream))
|
rows = list(csv.DictReader(stream))
|
||||||
self.assertEqual(count, 2)
|
self.assertEqual(count, 3)
|
||||||
self.assertEqual(rows[0]["offer"], "Aizen Evo")
|
self.assertEqual(rows[0]["offer"], "Aizen Evo")
|
||||||
self.assertEqual(rows[0]["lf"], "Homura Evo")
|
self.assertEqual(rows[0]["lf"], "Homura Evo")
|
||||||
self.assertEqual(rows[1]["offer"], "Aizen Evo")
|
self.assertEqual(rows[1]["offer"], "Aizen Evo")
|
||||||
self.assertEqual(rows[1]["lf"], "BUNDLE 2")
|
self.assertEqual(rows[1]["lf"], "BUNDLE 2")
|
||||||
|
self.assertEqual(rows[2]["lf"], "SSS Stats | Evo mythics")
|
||||||
|
|
||||||
|
def test_export_recovers_one_friend_row_from_repeated_legacy_listings(self):
|
||||||
|
conn = sqlite3.connect(":memory:")
|
||||||
|
conn.execute("""CREATE TABLE trades (
|
||||||
|
id INTEGER PRIMARY KEY, offer TEXT, looking_for TEXT, lf TEXT,
|
||||||
|
mlf TEXT, nlf TEXT, author_hash TEXT, seen_count INTEGER,
|
||||||
|
update_count INTEGER, canon_offer TEXT)""")
|
||||||
|
for row_id in (1, 2):
|
||||||
|
conn.execute(
|
||||||
|
"INSERT INTO trades VALUES (?,?,?,?,?,?,?,?,?,?)",
|
||||||
|
(row_id, "Aizen Evo", "MLF: Shiny Chuuni Evo | My Friend is | Shiny Buddha Evo",
|
||||||
|
"", "Shiny Chuuni Evo | My Friend is | Shiny Buddha Evo", "",
|
||||||
|
"parent", 1, 0, "aizen evo"),
|
||||||
|
)
|
||||||
|
stream = OpenStringIO(newline="")
|
||||||
|
with patch.object(Path, "open", return_value=stream):
|
||||||
|
count = export_csv(conn, Path("trades.csv"), detailed=True)
|
||||||
|
stream.seek(0)
|
||||||
|
rows = list(csv.DictReader(stream))
|
||||||
|
self.assertEqual(count, 3)
|
||||||
|
self.assertEqual(sum(row["offer"] == "Shiny Buddha Evo" for row in rows), 1)
|
||||||
|
self.assertTrue(all("My Friend is" not in row["mlf"] for row in rows))
|
||||||
|
|
||||||
|
def test_export_keeps_stat_condition_inside_recovered_offer(self):
|
||||||
|
conn = sqlite3.connect(":memory:")
|
||||||
|
conn.execute("""CREATE TABLE trades (
|
||||||
|
id INTEGER PRIMARY KEY, offer TEXT, looking_for TEXT, lf TEXT,
|
||||||
|
mlf TEXT, nlf TEXT, author_hash TEXT, seen_count INTEGER,
|
||||||
|
update_count INTEGER)""")
|
||||||
|
request = ("2X SSS DMG FOR MY Shiny Poseidon Evo | Evo MYTIC's | "
|
||||||
|
"6x Dark Mage Evo (ALL GOOD STATS) [2x FOR ANY SSS] | "
|
||||||
|
"Shiny POSEI/Chuuni Evo AND ADDS FOR MY ROGER Evo")
|
||||||
|
conn.execute("INSERT INTO trades VALUES (?,?,?,?,?,?,?,?,?)",
|
||||||
|
(1, "Shiny Poseidon Evo", request, request, "", "", "a", 1, 0))
|
||||||
|
stream = OpenStringIO(newline="")
|
||||||
|
with patch.object(Path, "open", return_value=stream):
|
||||||
|
export_csv(conn, Path("trades.csv"), detailed=True)
|
||||||
|
stream.seek(0)
|
||||||
|
row = next(csv.DictReader(stream))
|
||||||
|
self.assertIn("[2x FOR ANY SSS]", row["offer"])
|
||||||
|
self.assertNotIn("ANY SSS]", row["lf"])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -1,9 +1,25 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from bundle_quotes import extract_bundle_quotes
|
||||||
from extract_exchange_quotes import extract_quotes, parse_side
|
from extract_exchange_quotes import extract_quotes, parse_side
|
||||||
|
|
||||||
|
|
||||||
class ExchangeQuoteTests(unittest.TestCase):
|
class ExchangeQuoteTests(unittest.TestCase):
|
||||||
|
def test_stat_specific_inventory_is_not_a_base_variant_quote(self):
|
||||||
|
rows = [
|
||||||
|
{"author_hash": "a", "offer": "Homura Evo (SSS RNG)",
|
||||||
|
"lf": "my Homura Evo for Alucard Evo", "mlf": ""},
|
||||||
|
{"author_hash": "b", "offer": "Homura Evo (SSS RNG) | Homura Evo",
|
||||||
|
"lf": "my Homura Evo for Alucard Evo", "mlf": ""},
|
||||||
|
{"author_hash": "c", "offer": "Shiny Poseidon Evo | 14x Dark Mage Evo (A+/SSS/SS) | 2x Chuuni Evo",
|
||||||
|
"lf": "My Shiny Poseidon Evo, 1 Dark Mage Evo, 2x Chuuni Evo for Homura Evo",
|
||||||
|
"mlf": ""},
|
||||||
|
{"author_hash": "d", "offer": "2x Homura Evo 1 s,s,A, Alucard Evo",
|
||||||
|
"lf": "", "mlf": "my 2x Homura Evo for Aizen Evo"},
|
||||||
|
]
|
||||||
|
self.assertEqual([q["source_row"] for q in extract_quotes(rows)], [3])
|
||||||
|
self.assertEqual(extract_bundle_quotes(rows), [])
|
||||||
|
|
||||||
def test_only_exact_variant_and_quantity(self):
|
def test_only_exact_variant_and_quantity(self):
|
||||||
self.assertEqual(parse_side("my 2 Shiny Aizen Evo"),
|
self.assertEqual(parse_side("my 2 Shiny Aizen Evo"),
|
||||||
("Shiny Aizen Evo", 2, "my"))
|
("Shiny Aizen Evo", 2, "my"))
|
||||||
|
|||||||
@@ -1,10 +1,65 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from bundle_quotes import extract_bundle_quotes, parse_bundle
|
from bundle_quotes import extract_bundle_quotes, parse_bundle
|
||||||
from provisional_valuelist import conflicting_quotes, fit_values
|
from provisional_valuelist import compare_evidence_modes, conflicting_quotes, fit_values
|
||||||
|
|
||||||
|
|
||||||
class ProvisionalValueListTests(unittest.TestCase):
|
class ProvisionalValueListTests(unittest.TestCase):
|
||||||
|
def test_inferred_pairs_have_lower_weight_and_separate_comparison(self):
|
||||||
|
direct = [
|
||||||
|
{"offered_unit": "Homura Evo", "offered_qty": quantity,
|
||||||
|
"requested_unit": "Aizen Evo", "requested_qty": 1,
|
||||||
|
"source_row": row, "quote_type": kind, "source_text": "proposal"}
|
||||||
|
for row, quantity, kind in ((1, 2, "explicit_for"), (2, 2, "explicit_for"),
|
||||||
|
(3, 2, "explicit_for"), (4, 1, "listing_pair"))
|
||||||
|
]
|
||||||
|
all_values, _, all_report, _, impacts = fit_values(direct, [], include_report=True)
|
||||||
|
explicit_values, _, explicit_report, _, _ = fit_values(
|
||||||
|
direct[:3], [], include_report=True)
|
||||||
|
comparison = compare_evidence_modes(
|
||||||
|
all_values, all_report, explicit_values, explicit_report)
|
||||||
|
row = next(item for item in comparison if item["unit_variant"] == "Homura Evo")
|
||||||
|
self.assertEqual((row["all_explicit_asks"], row["all_inferred_asks"]), (3, 1))
|
||||||
|
self.assertGreater(row["all_fit"], row["explicit_only_fit"])
|
||||||
|
self.assertLess(row["all_fit"], 600) # The one-for-one inferred ask cannot dominate.
|
||||||
|
self.assertEqual((row["all_ranked_value"], row["explicit_only_ranked_value"]),
|
||||||
|
(550, 500))
|
||||||
|
self.assertTrue(any(item["removed_evidence_type"] == "asking_direct_inferred"
|
||||||
|
for item in impacts))
|
||||||
|
|
||||||
|
def test_comparison_keeps_unstable_variants_unranked(self):
|
||||||
|
direct = [
|
||||||
|
{"offered_unit": "Homura Evo", "offered_qty": quantity,
|
||||||
|
"requested_unit": "Aizen Evo", "requested_qty": 1,
|
||||||
|
"source_row": row, "quote_type": "explicit_for", "source_text": "proposal"}
|
||||||
|
for row, quantity in ((2, 1), (3, 1), (4, 10))
|
||||||
|
]
|
||||||
|
values, _, report, _, _ = fit_values(direct, [], include_report=True)
|
||||||
|
row = next(item for item in compare_evidence_modes(values, report, values, report)
|
||||||
|
if item["unit_variant"] == "Homura Evo")
|
||||||
|
self.assertEqual(row["all_confidence"], "unstable")
|
||||||
|
self.assertEqual((row["all_ranked_value"], row["explicit_only_ranked_value"]),
|
||||||
|
("", ""))
|
||||||
|
|
||||||
|
def test_comparison_marks_variant_disconnected_without_inferred_pair(self):
|
||||||
|
direct = [
|
||||||
|
{"offered_unit": "Homura Evo", "offered_qty": 1,
|
||||||
|
"requested_unit": "Aizen Evo", "requested_qty": 1,
|
||||||
|
"source_row": 2, "quote_type": "explicit_for", "source_text": "proposal"},
|
||||||
|
{"offered_unit": "Chuuni Evo", "offered_qty": 1,
|
||||||
|
"requested_unit": "Homura Evo", "requested_qty": 1,
|
||||||
|
"source_row": 3, "quote_type": "listing_pair", "source_text": "listing"},
|
||||||
|
]
|
||||||
|
values, _, report, _, _ = fit_values(direct, [], include_report=True)
|
||||||
|
explicit_values, _, explicit_report, _, _ = fit_values(
|
||||||
|
direct[:1], [], include_report=True)
|
||||||
|
row = next(item for item in compare_evidence_modes(
|
||||||
|
values, report, explicit_values, explicit_report)
|
||||||
|
if item["unit_variant"] == "Chuuni Evo")
|
||||||
|
self.assertEqual(row["explicit_only_connection"], "disconnected")
|
||||||
|
self.assertEqual(row["explicit_only_confidence"], "disconnected")
|
||||||
|
self.assertEqual(row["explicit_only_fit"], "")
|
||||||
|
|
||||||
def test_explicit_quantified_bundle_and_ambiguous_alternative(self):
|
def test_explicit_quantified_bundle_and_ambiguous_alternative(self):
|
||||||
self.assertEqual(parse_bundle("my 2 Homura Evo + Buddha Evo")[0],
|
self.assertEqual(parse_bundle("my 2 Homura Evo + Buddha Evo")[0],
|
||||||
{"Homura Evo": 2, "Buddha Evo": 1})
|
{"Homura Evo": 2, "Buddha Evo": 1})
|
||||||
|
|||||||
+1760
-1287
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user