Exemplo n.º 1
0
 def __draw_player_ai(self, item):
 ###########################################################################
     print("AI PLAYER STATS:")
     print("  tech level: ", end="")
     cprint(GREEN, item.tech_level())
     print("\n  population: ", end="")
     cprint(BLUE, item.population())
Exemplo n.º 2
0
    def __draw_geology(self, item):
    ###########################################################################
        draw_mode = curr_draw_mode()
        prequire(is_geological(draw_mode), "Bad draw mode ", draw_mode)
        expected_length = self.TILE_TEXT_WIDTH

        # Figure out what string to print and what color it should be
        if (draw_mode == DrawMode.GEOLOGY):
            color, symbol = self._GEOLOGY_MAP[item.__class__]

            to_draw = symbol.center(expected_length)
        elif (draw_mode in [DrawMode.TENSION, DrawMode.MAGMA]):
            value = item.tension() if draw_mode == DrawMode.TENSION \
               else item.magma()
            to_draw = ("%.3f" % value).center(expected_length)

            if (value < .333):
                color = GREEN
            elif (value < .666):
                color = YELLOW
            else:
                color = RED
        else:
            prequire(False, "Should not draw geology in mode: ", draw_mode)

        prequire(len(to_draw) == self.TILE_TEXT_WIDTH,
                 "Symbol '", to_draw, "' is wrong length")

        cprint(color, to_draw)
Exemplo n.º 3
0
    def __draw_atmosphere(self, item):
    ###########################################################################
        draw_mode = curr_draw_mode()

        field = self.__get_field_for_draw_mode(item, draw_mode)
        color = self.__compute_atmos_color(draw_mode, field)
        str_  = str(field).center(self.TILE_TEXT_WIDTH)

        cprint(color, str_)
Exemplo n.º 4
0
    def __draw_time(self, item):
    ###########################################################################
        # Compute color
        if (item.season() == Season.WINTER):
            color = BLUE
        elif (item.season() == Season.SPRING):
            color = GREEN
        elif (item.season() == Season.SUMMER):
            color = RED
        elif (item.season() == Season.FALL):
            color = YELLOW
        else:
            prequire(False, "Unhandled season ", item.season())

        cprint(color, item.season(), ", Year ", item.year())
Exemplo n.º 5
0
 def __draw_player(self, item):
 ###########################################################################
     print("PLAYER STATS:")
     print("  name:", item.name())
     print("  level: ", end="")
     cprint(GREEN, item.level())
     print("\n  mana: ", end="")
     cprint(BLUE, item.mana(), "/", item.max_mana())
     print("\n  exp: ", end="")
     cprint(YELLOW, item.exp(), "/", item.next_level_cost())
Exemplo n.º 6
0
 def ai_wins(self):
     ###########################################################################
     cprint(RED, "UR LUZER. LOL, GET PWNED\n")
     sys.stdout.flush()
Exemplo n.º 7
0
 def human_wins(self):
     ###########################################################################
     cprint(GREEN, "GRATZ, UR WINNAR!\n")
     sys.stdout.flush()
Exemplo n.º 8
0
 def spell_report(self, report):
     ###########################################################################
     cprint(RED, report)
     sys.stdout.flush()
Exemplo n.º 9
0
    def __draw_world_tile(self, item, mode_override=None):
    ###########################################################################
        if (mode_override is None):
            draw_mode = curr_draw_mode()
        else:
            draw_mode = mode_override

        if (draw_mode == DrawMode.LAND):
            self.__draw_land(item)

        elif (draw_mode == DrawMode.CIV):
            if (item.city() is not None):
                cprint(RED, " C: ",
                       str(item.city().rank()).center(self.TILE_TEXT_WIDTH-4))
            elif (item.infra_level() is not None and item.infra_level() > 0):
                cprint(YELLOW, " I: ",
                       str(item.infra_level()).center(self.TILE_TEXT_WIDTH-4))
            else:
                self.__draw_land(item)

        elif (draw_mode == DrawMode.MOISTURE):
            moisture = item.soil_moisture()
            if (moisture is not None):
                if (moisture < 1.0):
                    color = YELLOW
                elif (moisture < get_flooding_threshold()):
                    color = GREEN
                elif (moisture < get_totally_flooded_threshold()):
                    color = BLUE
                else:
                    color = RED
                cprint(color, "%.3f" % moisture)
            else:
                self.__draw_land(item)

        elif (draw_mode == DrawMode.YIELD):
            yield_ = item.yield_()
            if (yield_.food > 0):
                cprint(GREEN, "%.3f" % yield_.food)
            else:
                cprint(RED, "%.3f" % yield_.prod)

        elif (draw_mode == DrawMode.ELEVATION):
            elevation = item.elevation()
            if (elevation is not None):
                if (elevation < 2500):
                    color = GREEN
                elif (elevation < 7000):
                    color = YELLOW
                else:
                    color = WHITE
                cprint(color, ("%d" % elevation).center(self.TILE_TEXT_WIDTH))
            else:
                self.__draw_land(item)

        elif (draw_mode == DrawMode.SNOWPACK):
            snowpack = item.snowpack()
            if (snowpack is not None):
                if (snowpack < 12):
                    color = YELLOW
                elif (snowpack < 40):
                    color = BLUE
                else:
                    color = WHITE
                cprint(color, ("%.1f" % snowpack).center(self.TILE_TEXT_WIDTH))
            else:
                self.__draw_land(item)

        elif (draw_mode == DrawMode.SEASURFACETEMP):
            sea_surface_temp = item.sea_surface_temp()
            if (sea_surface_temp is not None):
                if (sea_surface_temp < 65):
                    color = BLUE
                elif (sea_surface_temp < 80):
                    color = YELLOW
                else:
                    color = RED
                cprint(color, "%.2f" % sea_surface_temp)
            else:
                self.__draw_land(item)

        elif (is_geological(draw_mode)):
            self.draw(item.geology())

        elif (is_atmospheric(draw_mode)):
            self.draw(item.atmosphere())

        else:
            prequire(False, "Unhandled mode: ", draw_mode)
Exemplo n.º 10
0
 def __draw_land(self, item):
 ###########################################################################
     color, symbol = self._TILE_MAP[item.__class__]
     cprint(color, symbol * self.TILE_TEXT_WIDTH)