2 sst.py =-- Super Star Trek in Python
8 NINHAB = GALSIZE * GALSIZE / 2
10 PLNETMAB = NINHAB + MAXUNINHAB
13 FULLCREW = 428 # BSD Trek was 387, that's wrong
39 def __init(self, x=None, y=None):
43 self.x = self.y = None
45 return self.x != None and self.y != None
46 def __eq__(self, other):
47 return self.x == other.y and self.x == other.y
48 def distance(self, other):
49 return math.sqrt((self.x - other.x)**2 + (self.y - other.y)**2)
55 self.crystals = None # "absent", "present", or "mined"
56 self.known = "unknown" # Other values: "known" and "shuttle down"
67 self.status = "secure" # Other valuues: "distressed", "enslaved"
70 "A chart page. The starchart is a 2D array of these."
72 self.stars = None # Will hold a number
73 self.starbase = None # Will hold a bool
74 self.klingons = None # Will hold a number
77 "State of the universe. The galaxy is a 2D array of these."
79 self.crew = None # crew complement
80 self.remkl = None # remaining klingons
81 self.remcom = None # remaining commanders
82 self.nscrem = None # remaining super commanders
83 self.rembase = None # remaining bases
84 self.starkl = None # destroyed stars
85 self.basekl = None # destroyed bases
86 self.nromrem = None # Romulans remaining
87 self.nplankl = None # destroyed uninhabited planets
88 self.nworldkl = None # destroyed inhabited planets
89 self.plnets = []; # List of planets known
90 self.date = None # stardate
91 self.remres = None # remaining resources
92 self. remtime = None # remaining time
93 self.bases = [] # Base quadrant coordinates
94 self.kcmdr = [] # Commander quadrant coordinates
95 self.kscmdr = None # Supercommander quadrant coordinates
96 self.galaxy = {} # Dictionary of quadrant objects
97 self.chart = {} # Dictionary of page objects
100 return game.damage[dev] != 0.0
104 self.date = None # The only mandatory attribute
108 self.options = [] # List of option strings
109 self.state = snapshot() # State of the universe
110 self.snapsht = snapshot() # For backwards timetravel
111 self.quad = {} # contents of our quadrant
112 self.kpower = {} # enemy energy levels
113 self.kdist = {} # enemy distances
114 self.kavgd = {} # average distances
115 self.damage = {} # damage encountered
116 self.future = [] # future events
117 self.passwd = None # Self Destruct password
118 # Coordinate members start here
119 self.ks = {} # enemy sector locations
120 self.quadrant = None # where we are
122 self.tholian = None # coordinates of Tholian
123 self.base = None # position of base in current quadrant
124 self.battle = None # base coordinates being attacked
125 self.plnet = None # location of planet in quadrant
126 self.probec = None # current probe quadrant
127 # Flag members start here
128 self.gamewon = None # Finished!
129 self.ididit = None # action taken -- allows enemy to attack
130 self.alive = None # we are alive (not killed)
131 self.justin = None # just entered quadrant
132 self.shldup = None # shields are up
133 self.shldchg = None # shield changing (affects efficiency)
134 self.comhere = None # commander here
135 self.ishere = None # super-commander in quadrant
136 self.iscate = None # super commander is here
137 self.ientesc = None # attempted escape from supercommander
138 self.ithere = None # Tholian is here
139 self.resting = None # rest time
140 self.icraft = None # Kirk in Galileo
141 self.landed = None # party on planet or on ship
142 self.alldone = None # game is now finished
143 self.neutz = None # Romulan Neutral Zone
144 self.isarmed = None # probe is armed
145 self.inorbit = None # orbiting a planet
146 self.imine = None # mining
147 self.icrystl = None # dilithium crystals aboard
148 self.iseenit = None # seen base attack report
149 self.thawed = None # thawed game
150 # String members start here
151 self.condition = None # green, yellow, red, docked, dead,
152 self.iscraft = None # onship, offship, removed
153 self.skill = None # levels: none, novice, fair, good,
155 # Integer nembers sart here
156 self.inkling = None # initial number of klingons
157 self.inbase = None # initial number of bases
158 self.incom = None # initial number of commanders
159 self.inscom = None # initial number of commanders
160 self.inrom = None # initial number of commanders
161 self.instar = None # initial stars
162 self.intorps = None # initial/max torpedoes
163 self.torps = None # number of torpedoes
164 self.ship = None # ship type -- 'E' is Enterprise
165 self.abandoned = None # count of crew abandoned in space
166 self.length = None # length of game
167 self.klhere = None # klingons here
168 self.casual = None # causalties
169 self.nhelp = None # calls for help
170 self.nkinks = None # count of energy-barrier crossings
171 self.iplnet = None # planet # in quadrant
172 self.inplan = None # initial planets
173 self.nenhere = None # number of enemies in quadrant
174 self.irhere = None # Romulans in quadrant
175 self.isatb = None # =1 if super commander is attacking base
176 self.tourn = None # tournament number
177 self.proben = None # number of moves for probe
178 self.nprobes = None # number of probes available
179 # Float members start here
180 self.inresor = None # initial resources
181 self.intime = None # initial time
182 self.inenrg = None # initial/max energy
183 self.inshld = None # initial/max shield
184 self.inlsr = None # initial life support resources
185 self.indate = None # initial date
186 self.energy = None # energy level
187 self.shield = None # shield level
188 self.warpfac = None # warp speed
189 self.wfacsq = None # squared warp factor
190 self.lsupres = None # life support reserves
191 self.dist = None # movement distance
192 self.direc = None # movement direction
193 self.optime = None # time taken by current operation
194 self.docfac = None # repair factor when docking (constant?)
195 self.damfac = None # damage factor
196 self.lastchart = None # time star chart was last updated
197 self.cryprob = None # probability that crystal will work
198 self.probex = None # location of probe
200 self.probeinx = None # probe x,y increment
201 self.probeiny = None #
202 self.height = None # height of orbit around planet