1-
2-
3- class Destination ():
4- ''' Zero based, Map navigation '''
5- def __init__ (self , sector = - 1 , xpos = - 1 , ypos = - 1 , warp = 0 ):
1+ class WarpDest ():
2+ ''' Warp Speed:
3+ One's based GALAXY navigation.
4+ Guaranteed SAFE placement.
5+ '''
6+ def __init__ (self , sector = - 1 , warp = 0 ):
67 if sector > 64 : sector = 64 # zOuter Limits =)
7- if xpos > 7 : xpos = 7
8- if ypos > 7 : ypos = 7
9- if xpos < 0 : xpos = 0
10- if ypos < 0 : ypos = 0
118 if warp > 10 : warp = 10
129 if warp < 0 : warp = 0
1310 self .warp = warp
1411 self .sector = sector
15- self .xpos = xpos
16- self .ypos = ypos
1712
1813 @staticmethod
19- def parse_sector (dest , sep = ',' ):
14+ def parse (dest , sep = ',' ):
2015 '''
21- Parse: sector#, alpha-col, row-num
22- Example: 5,b, 1
16+ Parse: sector-num, speed-float - None on error
17+ Example: 5,1. 1
2318 '''
2419 dest = str (dest )
2520 cols = dest .split (sep )
26- if len (cols ) == 3 :
21+ if len (cols ) == 2 :
2722 try :
28- sector = int (cols [0 ]) % 8
29- if str (cols [1 ]).isalpha ():
30- xpos = ((ord (cols [1 ]) - ord ('a' )) % 8 )
31- ypos = int (cols [2 ]) % 8
32- return Destination (sector , xpos , ypos )
23+ sector = int (cols [0 ].strip ())
24+ if sector < 1 :
25+ sector = 1
26+ speed = float (cols [1 ].strip ())
27+ if speed < 0 : speed = 0.1
28+ if speed > 9 : speed = 9.0
29+ return WarpDest (sector , speed )
3330 except :
3431 pass
3532 return None
3633
34+
35+ class SubDest ():
36+ ''' Sublight Navigation:
37+ Zero based, AREA placement.
38+ Caveat, User! ;-)
39+ '''
40+ def __init__ (self , xpos = - 1 , ypos = - 1 ):
41+ if xpos > 7 : xpos = 7
42+ if ypos > 7 : ypos = 7
43+ if xpos < 0 : xpos = 0
44+ if ypos < 0 : ypos = 0
45+ self .xpos = xpos
46+ self .ypos = ypos
47+
3748 @staticmethod
38- def parse_xypos (dest , sep = ',' ):
49+ def parse (dest , sep = ',' ):
3950 '''
4051 WARNING: USER 1's -> 0-BASED TRANSLATION HERE
4152
@@ -57,34 +68,8 @@ def parse_xypos(dest, sep=','):
5768 num = int (alph )
5869 xpos = num
5970 ypos = int (cols [1 ].strip ()[0 ])
60- return Destination ( - 1 , xpos - 1 , ypos - 1 , - 1 )
71+ return SubDest ( xpos - 1 , ypos - 1 )
6172 except :
6273 pass
6374 return None
6475
65- @staticmethod
66- def parse_warp (dest , sep = ',' ):
67- '''
68- Parse: sector-num, speed-float - None on error
69- Example: 5,1.1
70- '''
71- dest = str (dest )
72- cols = dest .split (sep )
73- if len (cols ) == 2 :
74- try :
75- sector = int (cols [0 ].strip ())
76- if sector < 1 :
77- sector = 1
78- speed = float (cols [1 ].strip ())
79- if speed < 0 : speed = 0.1
80- if speed > 9 : speed = 9.0
81- return Destination (sector , - 1 , - 1 , speed )
82- except :
83- pass
84- return None
85-
86-
87-
88-
89-
90-
0 commit comments