- for enemy in game.enemies:
- enemy.kavgd = enemy.kdist
- newcnd()
- drawmaps(0)
- setwnd(message_window)
-
- if game.inorbit:
- prout(_("Helmsman Sulu- \"Leaving standard orbit.\""))
- game.inorbit = False
- # If tractor beam is to occur, don't move full distance
- if game.state.date+game.optime >= scheduled(FTBEAM):
- trbeam = True
- game.condition = "red"
- course.distance = course.distance*(scheduled(FTBEAM)-game.state.date)/game.optime + 0.1
- game.optime = scheduled(FTBEAM) - game.state.date + 1e-5
- # Move within the quadrant
- game.quad[game.sector.i][game.sector.j] = IHDOT
- for m in range(course.moves):
- course.next()
- w = course.sector()
- if course.origin.quadrant() != course.location.quadrant():
- # Leaving quadrant -- allow final enemy attack
- # Don't do it if being pushed by Nova
- if len(game.enemies) != 0 and not novapush:
- newcnd()
- for enemy in game.enemies:
- finald = (w - enemy.kloc).distance()
- enemy.kavgd = 0.5 * (finald + enemy.kdist)
- # Stas Sergeev added the condition
- # that attacks only happen if Klingons
- # are present and your skill is good.
- if game.skill > SKILL_GOOD and game.klhere > 0 and not game.state.galaxy[game.quadrant.i][game.quadrant.j].supernova:
- attack(torps_ok=False)
- if game.alldone:
- return
- # check for edge of galaxy
- kinks = 0
- while True:
- kink = False
- if course.final.i < 0:
- course.final.i = -course.final.i
- kink = True
- if course.final.j < 0:
- course.final.j = -course.final.j
- kink = True
- if course.final.i >= GALSIZE*QUADSIZE:
- course.final.i = (GALSIZE*QUADSIZE*2) - course.final.i
- kink = True
- if course.final.j >= GALSIZE*QUADSIZE:
- course.final.j = (GALSIZE*QUADSIZE*2) - course.final.j
- kink = True
- if kink:
- kinks += 1
- else:
- break
- if kinks:
- game.nkinks += 1
- if game.nkinks == 3:
- # Three strikes -- you're out!
- finish(FNEG3)
- return
- skip(1)
- prout(_("YOU HAVE ATTEMPTED TO CROSS THE NEGATIVE ENERGY BARRIER"))
- prout(_("AT THE EDGE OF THE GALAXY. THE THIRD TIME YOU TRY THIS,"))
- prout(_("YOU WILL BE DESTROYED."))
- # Compute final position in new quadrant
- if trbeam: # Don't bother if we are to be beamed
+ if game.alldone:
+ return
+ # check for edge of galaxy
+ kinks = 0
+ while True:
+ kink = False
+ if course.final.i < 0:
+ course.final.i = -course.final.i
+ kink = True
+ if course.final.j < 0:
+ course.final.j = -course.final.j
+ kink = True
+ if course.final.i >= GALSIZE*QUADSIZE:
+ course.final.i = (GALSIZE*QUADSIZE*2) - course.final.i
+ kink = True
+ if course.final.j >= GALSIZE*QUADSIZE:
+ course.final.j = (GALSIZE*QUADSIZE*2) - course.final.j
+ kink = True
+ if kink:
+ kinks += 1
+ else:
+ break
+ if kinks:
+ game.nkinks += 1
+ if game.nkinks == 3:
+ # Three strikes -- you're out!
+ finish(FNEG3)