Created
June 15, 2014 05:18
-
-
Save dheaney/764e9b22f36306d3a3ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| from __future__ import unicode_literals | |
| import os, sys | |
| import curses | |
| import outbreak | |
| from emoji import emoji | |
| def get_bool_input(message): | |
| while True: | |
| sys.stdout.write(message + " [y/n]:") | |
| response = raw_input() | |
| if response is "y" or response is "n": break | |
| else: print "Invalid input" | |
| return { | |
| "y" : True, | |
| "n" : False | |
| }[response] | |
| def infection_string(n): | |
| if not n: | |
| return " " | |
| return " " + str(n) + " " | |
| game = outbreak.Game(3,0) | |
| screen = curses.initscr() | |
| screen.keypad(1) | |
| #screen.border(0) | |
| curses.noecho() | |
| curses.cbreak() | |
| curses.start_color() | |
| curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE) #blue | |
| curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_YELLOW) #yellow | |
| curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_BLACK) #black | |
| curses.init_pair(4, curses.COLOR_WHITE, curses.COLOR_RED) #red | |
| curses.init_pair(5, curses.COLOR_BLACK, curses.COLOR_WHITE) | |
| screen.bkgd(0, curses.color_pair(5)) | |
| color = { | |
| "blue": curses.color_pair(1), | |
| "yellow": curses.color_pair(2), | |
| "black": curses.color_pair(3), | |
| "red": curses.color_pair(4), | |
| } | |
| def update_right_col(): | |
| screen.addstr(4,100, "Cures: " + str([x for x in outbreak.Infection.cures if outbreak.Infection.cures[x] is True]).strip('[').strip(']'), curses.A_NORMAL) | |
| screen.addstr(5,100, "Eradications: " + str([x for x in outbreak.Infection.eradications if outbreak.Infection.eradications[x] is True]).strip('[').strip(']'), curses.A_NORMAL) | |
| screen.addstr(6,100, "Player Cards Remaining: " + str(len(game.player_card_pile.draw_pile))) | |
| screen.addstr(7,100, "Outbreaks: " + str(outbreak.City.outbreak_count), curses.A_NORMAL) | |
| screen.addstr(8,100, "Infection Rate: " + str(game.infection_rate), curses.A_NORMAL) | |
| screen.addstr(10,100, "City", curses.A_BOLD) | |
| screen.addstr(10,130, "Cubes", curses.A_BOLD) | |
| screen.addstr(10,150, "RS", curses.A_BOLD) | |
| i = 11 | |
| for c in sorted(sorted(set(game.cities)), key=lambda n: game.cities[n].color): | |
| city = game.cities[c] | |
| screen.addstr(i, 100, city.name, color[city.color]) | |
| screen.addstr(i, 130, infection_string(city.infections('black')), color['black']) #, color['black']) | |
| screen.addstr(i, 135, infection_string(city.infections('blue')), color['blue']) #, color['blue']) | |
| screen.addstr(i, 140, infection_string(city.infections('red')), color['red']) #, color['red']) | |
| screen.addstr(i, 145, infection_string(city.infections('yellow')), color['yellow']) #, color['yellow']) | |
| screen.addstr(i, 150, ("True" if city.has_research_station else ""), curses.A_NORMAL) | |
| i += 1 | |
| screen.addstr(4,130, "Player Locations:", curses.A_NORMAL) | |
| i = 5 | |
| for player in game.players: | |
| screen.addstr(i,135, "The " + player.name + " is in " + player.city.name, curses.A_NORMAL) | |
| i += 1 | |
| screen.refresh() | |
| def update_left_col(): | |
| screen.addstr(2,2, "Outbreak", curses.A_STANDOUT) | |
| screen.addstr(4,2, "The " + game.current_player.name + " has " + str(game.current_player.actions_remaining) + " actions remaining.", curses.A_NORMAL) | |
| screen.addstr(6,2, "Cards:", curses.A_NORMAL) | |
| i = 7 | |
| for card in game.current_player.cards: | |
| try: | |
| text = card.city | |
| except: | |
| text = card.description | |
| screen.addstr(i,7, text, color[card.color]) | |
| i += 1 | |
| screen.refresh() | |
| while True: | |
| try: | |
| update_right_col() | |
| update_left_col() | |
| screen.getch() | |
| except KeyboardInterrupt: | |
| curses.endwin() | |
| os.system('clear') | |
| #from collections import Counter | |
| #l = [x.__class__ for x in game.player_card_pile.draw_pile] | |
| #print Counter(l) | |
| sys.exit(0) | |
| curses.endwin() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment