def main(screen):
screen.clear()
screen.keypad(True)
curses.curs_set(False)
width = curses.COLS
height = curses.LINES
if(height < 20 or width < 50):
raise RuntimeError("This terminal is too damn small!")
if not (curses.has_colors()):
raise RuntimeError("This terminal does not support colors!")
if not (curses.can_change_color()):
raise RuntimeError("This terminal does not support changing color definitions!")
conf = configs.nice_conf
menu.confmenu(conf, screen)
screen.nodelay(True)
screen.clear()
screen.refresh()
mainwin = curses.newwin(height-7, width, 0, 0)
statuswin = curses.newwin(7, width, height-7, 0)
while(1):
world = World(mainwin, conf)
activeplayer = 0
n_turns = 1
for p in itertools.cycle(world.players):
if(p.isdead):
continue
world.wind = randint(max(-conf['wind_max'], world.wind-conf['wind_change']),
min( conf['wind_max'], world.wind+conf['wind_change']))
p.isactive = True
p.active_shots = 0
while ((p.isactive or p.active_shots > 0) and not len([p for p in world.players if not p.isdead]) <= 1 ):
gamestep(screen, mainwin, statuswin, p, world, conf, n_turns)
if (len([p for p in world.players if not p.isdead]) == 1):
gameover(screen, [p for p in world.players if not p.isdead][0])
break
if (len([p for p in world.players if not p.isdead]) == 0):
gameover(screen, None)
break
n_turns += 1
评论列表
文章目录