Skip to content

Commit

Permalink
Detect, and clean up, self-ownership/colonisation
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberiaResurrection committed Oct 26, 2024
1 parent 94166bd commit 5dab489
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions PyRoute/DeltaStar.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ def check_canonical(self):
line = '{}-{} Found invalid "{}" in trade codes: {}'.format(self, self.uwp, code, self.tradeCode.codeset)
msg.append(line)

if ('O:' + self.position) in self.tradeCode.codes:
line = '{}-{} Found invalid "{}" in trade codes: {}'.format(self, self.uwp, 'O:' + self.position, self.tradeCode.codes)
msg.append(line)
if ('C:' + self.position) in self.tradeCode.codeset:
line = '{}-{} Found invalid "{}" in trade codes: {}'.format(self, self.uwp, 'C:' + self.position, self.tradeCode.codes)
msg.append(line)

if self.social is not None:
symbols = self._ehex_to_int(self.social[4] if self.social is not None else '1') # TL + flux, min 1
strangeness = self._ehex_to_int(self.social[3] if self.social is not None else '1') # flux + 5
Expand Down
2 changes: 2 additions & 0 deletions PyRoute/TradeCodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,8 @@ def canonicalise(self, star):
self._fix_econ_code(star, 'Ri', '68', None, '678')

self._fix_all_pop_codes(star)
self._drop_invalid_trade_code('O:' + star.position)
self._drop_invalid_trade_code('C:' + star.position)

def _fix_trade_code(self, star, code, size, atmo, hydro):
size = '0123456789ABCDEF' if size is None else size
Expand Down
2 changes: 2 additions & 0 deletions Tests/Hypothesis/testDeltaStar.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ def test_canonicalise_cx_on_non_barren_worlds(self, starline):
@example('0101 0 A000000-0 As Ri { 0 } (000+0) [0000] B - A 000 0 NaHu G5 V')
@example('0101 0 A244500-0 As As { 0 } (000+0) [0000] B - A 000 0 NaHu G5 V')
@example('0101 0 A000000-0 As As { 0 } (001+0) [0000] B - A 000 0 NaHu G5 V')
@example('0101 0 A244500-0 As As O:0101 { 0 } (000+0) [0000] B - A 000 0 NaHu G5 V')
@example('0101 0 A244500-0 As As C:0101 { 0 } (000+0) [0000] B - A 000 0 NaHu G5 V')
@example('0101 000000000000000 ???????-? 000000000000000 - - A 000 0 00')
@example('0101 000000000000000 ???????-? 000000000000000 - - [0001] B - A 000 00')
def test_canonicalise_from_regex_match_and_verify_idempotency(self, starline):
Expand Down

0 comments on commit 5dab489

Please sign in to comment.