- game.quad[scratch.x][scratch.y] = IHDOT
- elif iquad == IHP: # Destroy planet
- game.state.galaxy[game.quadrant.x][game.quadrant.y].planet = NOPLANET
- game.state.nplankl += 1
- crmena(True, IHP, sector, scratch)
- prout(_(" destroyed."))
- game.state.planets[game.iplnet].pclass = destroyed
- game.iplnet = 0
- invalidate(game.plnet)
- if game.landed:
- finish(FPNOVA)
- return
- game.quad[scratch.x][scratch.y] = IHDOT
- elif iquad == IHB: # Destroy base
- game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase = False
- for i in range(1, game.state.rembase+1):
- if game.state.baseq[i] == game.quadrant:
- break
- game.state.baseq[i] = game.state.baseq[game.state.rembase]
- game.state.rembase -= 1
- invalidate(game.base)
- game.state.basekl += 1
- newcnd()
- crmena(True, IHB, sector, scratch)
- prout(_(" destroyed."))
- game.quad[scratch.x][scratch.y] = IHDOT
- elif iquad in (IHE, IHF): # Buffet ship
- prout(_("***Starship buffeted by nova."))
- if game.shldup:
- if game.shield >= 2000.0:
- game.shield -= 2000.0
- else:
- diff = 2000.0 - game.shield
- game.energy -= diff
- game.shield = 0.0
- game.shldup = False
- prout(_("***Shields knocked out."))
- game.damage[DSHIELD] += 0.005*game.damfac*random.random()*diff
- else:
- game.energy -= 2000.0
- if game.energy <= 0:
- finish(FNOVA)
- return
- # add in course nova contributes to kicking starship
- icx += game.sector.x-hits[mm][1]
- icy += game.sector.y-hits[mm][2]
- kount += 1
- elif iquad == IHK: # kill klingon
- deadkl(scratch,iquad, scratch)
- elif iquad in (IHC,IHS,IHR): # Damage/destroy big enemies
- for ll in range(1, game.nenhere+1):
- if game.ks[ll] == scratch:
- break
- game.kpower[ll] -= 800.0 # If firepower is lost, die
- if game.kpower[ll] <= 0.0:
- deadkl(scratch, iquad, scratch)
- break
- newc.x = scratch.x + scratch.x - hits[mm][1]
- newc.y = scratch.y + scratch.y - hits[mm][2]
- crmena(True, iquad, sector, scratch)
- proutn(_(" damaged"))
- if not VALID_SECTOR(newc.x, newc.y):
- # can't leave quadrant
- skip(1)
- break
- iquad1 = game.quad[newc.x][newc.y]
- if iquad1 == IHBLANK:
- proutn(_(", blasted into "))
- crmena(False, IHBLANK, sector, newc)
- skip(1)
- deadkl(scratch, iquad, newc)
- break
- if iquad1 != IHDOT:
- # can't move into something else
- skip(1)
- break
- proutn(_(", buffeted to Sector %s") % newc)
- game.quad[scratch.x][scratch.y] = IHDOT
- game.quad[newc.x][newc.y] = iquad
- game.ks[ll] = newc
- game.kdist[ll] = game.kavgd[ll] = distance(game.sector, newc)
- skip(1)
- if top == top2:
- break
- bot = top + 1
- top = top2
- if kount==0:
- return
-
+ game.quad[neighbor.x][neighbor.y] = IHDOT
+ kount += 1
+ elif iquad in (IHP, IHW): # Destroy planet
+ game.state.galaxy[game.quadrant.x][game.quadrant.y].planet = None
+ if iquad == IHP:
+ game.state.nplankl += 1
+ else:
+ game.state.worldkl += 1
+ crmena(True, iquad, "sector", neighbor)
+ prout(_(" destroyed."))
+ game.iplnet.pclass = "destroyed"
+ game.iplnet = None
+ game.plnet.invalidate()
+ if game.landed:
+ finish(FPNOVA)
+ return
+ game.quad[neighbor.x][neighbor.y] = IHDOT
+ elif iquad == IHB: # Destroy base
+ game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase = False
+ game.state.baseq = filter(lambda x: x!= game.quadrant, game.state.baseq)
+ game.base.invalidate()
+ game.state.basekl += 1
+ newcnd()
+ crmena(True, IHB, "sector", neighbor)
+ prout(_(" destroyed."))
+ game.quad[neighbor.x][neighbor.y] = IHDOT
+ elif iquad in (IHE, IHF): # Buffet ship
+ prout(_("***Starship buffeted by nova."))
+ if game.shldup:
+ if game.shield >= 2000.0:
+ game.shield -= 2000.0
+ else:
+ diff = 2000.0 - game.shield
+ game.energy -= diff
+ game.shield = 0.0
+ game.shldup = False
+ prout(_("***Shields knocked out."))
+ game.damage[DSHIELD] += 0.005*game.damfac*randreal()*diff
+ else:
+ game.energy -= 2000.0
+ if game.energy <= 0:
+ finish(FNOVA)
+ return
+ # add in course nova contributes to kicking starship
+ bump += (game.sector-hits[mm]).sgn()
+ elif iquad == IHK: # kill klingon
+ deadkl(neighbor, iquad, neighbor)
+ elif iquad in (IHC,IHS,IHR): # Damage/destroy big enemies
+ for ll in range(len(game.enemies)):
+ if game.enemies[ll].kloc == neighbor:
+ break
+ game.enemies[ll].kpower -= 800.0 # If firepower is lost, die
+ if game.enemies[ll].kpower <= 0.0:
+ deadkl(neighbor, iquad, neighbor)
+ break
+ newc = neighbor + neighbor - hits[mm]
+ crmena(True, iquad, "sector", neighbor)
+ proutn(_(" damaged"))
+ if not VALID_SECTOR(newc.x, newc.y):
+ # can't leave quadrant
+ skip(1)
+ break
+ iquad1 = game.quad[newc.x][newc.y]
+ if iquad1 == IHBLANK:
+ proutn(_(", blasted into "))
+ crmena(False, IHBLANK, "sector", newc)
+ skip(1)
+ deadkl(neighbor, iquad, newc)
+ break
+ if iquad1 != IHDOT:
+ # can't move into something else
+ skip(1)
+ break
+ proutn(_(", buffeted to Sector %s") % newc)
+ game.quad[neighbor.x][neighbor.y] = IHDOT
+ game.quad[newc.x][newc.y] = iquad
+ game.enemies[ll].move(newc)