projects
/
super-star-trek.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Lexer fixes for Stas.
[super-star-trek.git]
/
src
/
sst.py
diff --git
a/src/sst.py
b/src/sst.py
index 3e7f2c2a94f4de890e9624e57917445909e53624..76f320346534b6a4a5292810a007f787d91a0696 100644
(file)
--- a/
src/sst.py
+++ b/
src/sst.py
@@
-179,13
+179,12
@@
more:
the LRSCAN command is no longer needed. (Controlled by OPTION_AUTOSCAN
and turned off if game type is "plain" or "almy".)
"""
the LRSCAN command is no longer needed. (Controlled by OPTION_AUTOSCAN
and turned off if game type is "plain" or "almy".)
"""
-import os, sys, math, curses, time, readline, cPickle, random, copy
+import os, sys, math, curses, time, readline, cPickle, random, copy
, gettext
SSTDOC = "/usr/share/doc/sst/sst.doc"
DOC_NAME = "sst.doc"
SSTDOC = "/usr/share/doc/sst/sst.doc"
DOC_NAME = "sst.doc"
-# Stub to be replaced
-def _(str): return str
+def _(str): return gettext.gettext(str)
PHASEFAC = 2.0
GALSIZE = 8
PHASEFAC = 2.0
GALSIZE = 8
@@
-653,7
+652,6
@@
def tryexit(enemy, look, irun):
break
return True; # success
break
return True; # success
-#
# The bad-guy movement algorithm:
#
# 1. Enterprise has "force" based on condition of phaser and photon torpedoes.
# The bad-guy movement algorithm:
#
# 1. Enterprise has "force" based on condition of phaser and photon torpedoes.
@@
-691,7
+689,6
@@
def tryexit(enemy, look, irun):
# retreat, especially at high skill levels.
#
# 5. Motion is limited to skill level, except for SC hi-tailing it out.
# retreat, especially at high skill levels.
#
# 5. Motion is limited to skill level, except for SC hi-tailing it out.
-#
def movebaddy(enemy):
"Tactical movement for the bad guys."
def movebaddy(enemy):
"Tactical movement for the bad guys."
@@
-904,7
+901,7
@@
def supercommander():
if not game.iscate and avoid:
# compute move away from Enterprise
idelta = game.state.kscmdr-game.quadrant
if not game.iscate and avoid:
# compute move away from Enterprise
idelta = game.state.kscmdr-game.quadrant
- if
math.sqrt(idelta.i*idelta.i+idelta.j*idelta.j
) > 2.0:
+ if
idelta.distance(
) > 2.0:
# circulate in space
idelta.i = game.state.kscmdr.j-game.quadrant.j
idelta.j = game.quadrant.i-game.state.kscmdr.i
# circulate in space
idelta.i = game.state.kscmdr.j-game.quadrant.j
idelta.j = game.quadrant.i-game.state.kscmdr.i
@@
-3307,6
+3304,8
@@
curwnd = None
def iostart():
global stdscr, rows
def iostart():
global stdscr, rows
+ gettext.bindtextdomain("sst", "/usr/local/share/locale")
+ gettext.textdomain("sst")
if not (game.options & OPTION_CURSES):
ln_env = os.getenv("LINES")
if ln_env:
if not (game.options & OPTION_CURSES):
ln_env = os.getenv("LINES")
if ln_env:
@@
-3358,7
+3357,7
@@
def pause_game():
if game.options & OPTION_CURSES:
drawmaps(0)
setwnd(prompt_window)
if game.options & OPTION_CURSES:
drawmaps(0)
setwnd(prompt_window)
- prompt_window.
w
clear()
+ prompt_window.clear()
prompt_window.addstr(prompt)
prompt_window.getstr()
prompt_window.clear()
prompt_window.addstr(prompt)
prompt_window.getstr()
prompt_window.clear()
@@
-3453,8
+3452,8
@@
def setwnd(wnd):
def clreol():
"Clear to end of line -- can be a no-op in tty mode"
if game.options & OPTION_CURSES:
def clreol():
"Clear to end of line -- can be a no-op in tty mode"
if game.options & OPTION_CURSES:
-
wclrtoeol(curwnd
)
-
wrefresh(curwnd
)
+
curwnd.clrtoeol(
)
+
curwnd.refresh(
)
def clrscr():
"Clear screen -- can be a no-op in tty mode."
def clrscr():
"Clear screen -- can be a no-op in tty mode."
@@
-3904,8
+3903,8
@@
def getcourse(isprobe):
prout(_("Ensign Chekov- \"Course laid in, Captain.\""))
# the actual deltas get computed here
delta = coord()
prout(_("Ensign Chekov- \"Course laid in, Captain.\""))
# the actual deltas get computed here
delta = coord()
- delta.j = dquad.j-game.quadrant.j +
0.1*(dsect.j-game.sector.j
)
- delta.i = game.quadrant.i-dquad.i +
0.1*(game.sector.i-dsect.i
)
+ delta.j = dquad.j-game.quadrant.j +
(dsect.j-game.sector.j)/(QUADSIZE*1.0
)
+ delta.i = game.quadrant.i-dquad.i +
(game.sector.i-dsect.i)/(QUADSIZE*1.0
)
else: # manual
while key == "IHEOL":
proutn(_("X and Y displacements- "))
else: # manual
while key == "IHEOL":
proutn(_("X and Y displacements- "))
@@
-5291,8
+5290,8
@@
def eta():
if not VALID_QUADRANT(w1.i, w1.j) or not VALID_SECTOR(w2.i, w2.j):
huh()
return
if not VALID_QUADRANT(w1.i, w1.j) or not VALID_SECTOR(w2.i, w2.j):
huh()
return
- game.dist = math.sqrt((w1.j-game.quadrant.j+
0.1*(w2.j-game.sector.j
))**2+
- (w1.i-game.quadrant.i+
0.1*(w2.i-game.sector.i
))**2)
+ game.dist = math.sqrt((w1.j-game.quadrant.j+
(w2.j-game.sector.j)/(QUADSIZE*1.0
))**2+
+ (w1.i-game.quadrant.i+
(w2.i-game.sector.i)/(QUADSIZE*1.0
))**2)
wfl = False
if prompt:
prout(_("Answer \"no\" if you don't know the value:"))
wfl = False
if prompt:
prout(_("Answer \"no\" if you don't know the value:"))
@@
-5389,18
+5388,17
@@
def prelim():
def freeze(boss):
"Save game."
if boss:
def freeze(boss):
"Save game."
if boss:
- scanner.token = "emsave.trk"
- else:
+ scanner.push("emsave.trk")
+ key = scanner.next()
+ if key == "IHEOL":
+ proutn(_("File name: "))
key = scanner.next()
key = scanner.next()
- if key == "IHEOL":
- proutn(_("File name: "))
- key = scanner.next()
- if key != "IHALPHA":
- huh()
- return
- scanner.chew()
- if '.' not in scanner.token:
- scanner.token += ".trk"
+ if key != "IHALPHA":
+ huh()
+ return
+ scanner.chew()
+ if '.' not in scanner.token:
+ scanner.token += ".trk"
try:
fp = open(scanner.token, "wb")
except IOError:
try:
fp = open(scanner.token, "wb")
except IOError:
@@
-5443,11
+5441,11
@@
systnames = (
_("Tellar Prime (Miracht)"), # TOS: "Journey to Babel"
_("Vulcan (T'Khasi)"), # many episodes
_("Medusa"), # TOS: "Is There in Truth No Beauty?"
_("Tellar Prime (Miracht)"), # TOS: "Journey to Babel"
_("Vulcan (T'Khasi)"), # many episodes
_("Medusa"), # TOS: "Is There in Truth No Beauty?"
- _("Argelius II (Nelphia)"),# TOS: "Wolf in the Fold" ("IV" in BSD)
+ _("Argelius II (Nelphia)"),
# TOS: "Wolf in the Fold" ("IV" in BSD)
_("Ardana"), # TOS: "The Cloud Minders"
_("Catulla (Cendo-Prae)"), # TOS: "The Way to Eden"
_("Gideon"), # TOS: "The Mark of Gideon"
_("Ardana"), # TOS: "The Cloud Minders"
_("Catulla (Cendo-Prae)"), # TOS: "The Way to Eden"
_("Gideon"), # TOS: "The Mark of Gideon"
- _("Aldebaran III"), # TOS: "The Deadly Years"
+ _("Aldebaran III"),
# TOS: "The Deadly Years"
_("Alpha Majoris I"), # TOS: "Wolf in the Fold"
_("Altair IV"), # TOS: "Amok Time
_("Ariannus"), # TOS: "Let That Be Your Last Battlefield"
_("Alpha Majoris I"), # TOS: "Wolf in the Fold"
_("Altair IV"), # TOS: "Amok Time
_("Ariannus"), # TOS: "Let That Be Your Last Battlefield"
@@
-5708,8
+5706,6
@@
def choose():
if not scanner.inqueue: # Can start with command line options
proutn(_("Would you like a regular, tournament, or saved game? "))
scanner.next()
if not scanner.inqueue: # Can start with command line options
proutn(_("Would you like a regular, tournament, or saved game? "))
scanner.next()
- if len(scanner.token)==0: # Try again
- continue
if scanner.sees("tournament"):
while scanner.next() == "IHEOL":
proutn(_("Type in tournament number-"))
if scanner.sees("tournament"):
while scanner.next() == "IHEOL":
proutn(_("Type in tournament number-"))
@@
-5777,7
+5773,7
@@
def choose():
# Approximates Tom Almy's version.
game.options &=~ (OPTION_THINGY | OPTION_BLKHOLE | OPTION_BASE | OPTION_WORLDS)
game.options |= OPTION_ALMY
# Approximates Tom Almy's version.
game.options &=~ (OPTION_THINGY | OPTION_BLKHOLE | OPTION_BASE | OPTION_WORLDS)
game.options |= OPTION_ALMY
- elif scanner.sees("fancy"):
+ elif scanner.sees("fancy")
or scanner.sees("\n")
:
pass
elif len(scanner.token):
proutn(_("What is \"%s\"?") % scanner.token)
pass
elif len(scanner.token):
proutn(_("What is \"%s\"?") % scanner.token)
@@
-6296,10
+6292,10
@@
class sstscanner:
if not line:
continue
else:
if not line:
continue
else:
- self.inqueue = line.lstrip().split() + ["
IHEOL"]
+ self.inqueue = line.lstrip().split() + ["
\n"]
# From here on in it's all looking at the queue
self.token = self.inqueue.pop(0)
# From here on in it's all looking at the queue
self.token = self.inqueue.pop(0)
- if self.token == "
IHEOL
":
+ if self.token == "
\n
":
self.type = "IHEOL"
return "IHEOL"
try:
self.type = "IHEOL"
return "IHEOL"
try:
@@
-6323,10
+6319,6
@@
class sstscanner:
# Demand input for next scan
self.inqueue = []
self.real = self.token = None
# Demand input for next scan
self.inqueue = []
self.real = self.token = None
- def chew2(self):
- # return "IHEOL" next time
- self.inqueue = ["IHEOL"]
- self.real = self.token = None
def sees(self, s):
# compares s to item and returns true if it matches to the length of s
return s.startswith(self.token)
def sees(self, s):
# compares s to item and returns true if it matches to the length of s
return s.startswith(self.token)
@@
-6530,7
+6522,8
@@
if __name__ == '__main__':
if game.tourn and game.alldone:
proutn(_("Do you want your score recorded?"))
if ja() == True:
if game.tourn and game.alldone:
proutn(_("Do you want your score recorded?"))
if ja() == True:
- scanner.chew2()
+ scanner.chew()
+ scanner.push("\n")
freeze(False)
scanner.chew()
proutn(_("Do you want to play again? "))
freeze(False)
scanner.chew()
proutn(_("Do you want to play again? "))
@@
-6545,4
+6538,3
@@
if __name__ == '__main__':
if logfp:
logfp.close()
print ""
if logfp:
logfp.close()
print ""
- pass