def show_planets(self): si_txt = Data_CONST.get_text_list('PLANET_SIZES') ty_txt = Data_CONST.get_text_list('PLANET_TYPES') mi_txt = Data_CONST.get_text_list('PLANET_MINERALS') te_txt = Data_CONST.get_text_list('PLANET_TERRAINS') print print( "+-----------+-----------------+----------+--------+---------------+------------+----------+------+---------+" ) print( "| planet_id | star | position | size | type | minerals | terrain | food | max pop |" ) print( "+-----------+-----------------+----------+--------+---------------+------------+----------+------+---------+" ) for i, p in self.d_planets.items(): print( "| %9i | %15s | %8i | %6s | %13s | %10s | %8s | %4i | %7i |" % (i, self.d_stars[p.i_star_id].s_name, p.i_position, si_txt[p.i_size], ty_txt[p.i_type], mi_txt[p.i_minerals], te_txt[p.i_terrain], p.i_foodbase, p.i_max_population)) print( "+-----------+-----------------+----------+--------+---------------+------------+----------+------+---------+" ) print
def show_stars(self): s_txt = Data_CONST.get_text_list('STAR_SIZES') c_txt = Data_CONST.get_text_list('STAR_CLASSES') print print("+---------+-----------------+------------+------------+--------+-------+-------+-------+-------+-------+") print("| star_id | name | coords | class | size | obj 1 | obj 2 | obj 3 | obj 4 | obj 5 |") print("+---------+-----------------+------------+------------+--------+-------+-------+-------+-------+-------+") for i, s in self.d_stars.items(): obj = s.v_object_ids print("| %7i | %15s | %4i, %4i | %10s | %6s | %5i | %5i | %5i | %5i | %5i |" % (i, s.s_name, s.i_x, s.i_y, c_txt[s.i_class], s_txt[s.i_size], obj[0], obj[1], obj[2], obj[3], obj[4])) print("+---------+-----------------+------------+------------+--------+-------+-------+-------+-------+-------+")
def show_planets(self): si_txt = Data_CONST.get_text_list('PLANET_SIZES') ty_txt = Data_CONST.get_text_list('PLANET_TYPES') mi_txt = Data_CONST.get_text_list('PLANET_MINERALS') te_txt = Data_CONST.get_text_list('PLANET_TERRAINS') print print("+-----------+-----------------+----------+--------+---------------+------------+----------+------+---------+") print("| planet_id | star | position | size | type | minerals | terrain | food | max pop |") print("+-----------+-----------------+----------+--------+---------------+------------+----------+------+---------+") for i, p in self.d_planets.items(): print("| %9i | %15s | %8i | %6s | %13s | %10s | %8s | %4i | %7i |" % (i, self.d_stars[p.i_star_id].s_name, p.i_position, si_txt[p.i_size], ty_txt[p.i_type], mi_txt[p.i_minerals], te_txt[p.i_terrain], p.i_foodbase, p.i_max_population)) print("+-----------+-----------------+----------+--------+---------------+------------+----------+------+---------+") print
def show_ships(self): print print("+---------+------------------+-----------------+----------+------------+----------------------------+-------+-------+") print("| ship_id | name | owner | status | coords | destination | speed | turns |") print("+---------+------------------+-----------------+----------+------------+----------------------------+-------+-------+") for i, s in self.d_ships.items(): if s.exists(): i_dest_id = s.i_dest_star_id o_dest_star = self.d_stars[i_dest_id] s_dest_name = o_dest_star.s_name i_dest_x, i_dest_y = o_dest_star.get_coords() o_owner = self.d_players[s.i_owner_id] print("| %7i | %16s | %15s | %8s | %4i, %4i | [%3i, %3i] %15s | %5i | %5i |" % (i, s.s_name, o_owner.s_race_name, s.get_status_text(), s.i_x, s.i_y, i_dest_x, i_dest_y, s_dest_name, s.i_travelling_speed, s.i_turns_left)) print("+---------+------------------+-----------------+----------+------------+----------------------------+-------+-------+") print sp_txt = Data_CONST.get_text_list('SHIP_SPECIALS') for i, s in self.d_ships.items(): d_design = s.d_design print(" === ship_id # %i ===" % i) for i_dev_id in d_design['special_devices']: txt = sp_txt[i_dev_id] if (i_dev_id < sp_txt.__len__()) else '<out-of-range>' print(" special device: %2i ... %s" % (i_dev_id, txt)) print
def show_stars(self): s_txt = Data_CONST.get_text_list('STAR_SIZES') c_txt = Data_CONST.get_text_list('STAR_CLASSES') print print( "+---------+-----------------+------------+------------+--------+-------+-------+-------+-------+-------+" ) print( "| star_id | name | coords | class | size | obj 1 | obj 2 | obj 3 | obj 4 | obj 5 |" ) print( "+---------+-----------------+------------+------------+--------+-------+-------+-------+-------+-------+" ) for i, s in self.d_stars.items(): obj = s.v_object_ids print( "| %7i | %15s | %4i, %4i | %10s | %6s | %5i | %5i | %5i | %5i | %5i |" % (i, s.s_name, s.i_x, s.i_y, c_txt[s.i_class], s_txt[s.i_size], obj[0], obj[1], obj[2], obj[3], obj[4])) print( "+---------+-----------------+------------+------------+--------+-------+-------+-------+-------+-------+" )
def draw(self): self.fill((0, 0, 0)) self.blit_image((0, 0), 'info_screen', 'panel'), self.blit_image((21, 50), 'info_screen', 'button', 'history_graph', 'off'), self.blit_image((21, 77), 'info_screen', 'button', 'tech_review', 'off'), self.blit_image((21, 102),'info_screen', 'button', 'race_statistics', 'off'), self.blit_image((21, 128),'info_screen', 'button', 'turn_summary', 'off'), self.blit_image((21, 154),'info_screen', 'button', 'reference', 'off'), # grid behind self.blit_image((433, 115), 'app_pic', 0) # app image self.blit_image((433, 115), 'app_pic', 155) tech_carets = [] if self.__tech_review == "achievements": v_known_techs = self.get_me().v_known_techs # New Construction Types items = [] for tech_id in [K_TECH_PLANET_CONSTRUCTION, K_TECH_TITAN_CONTRUCTION, K_TECH_TRANSPORT, K_TECH_OUTPOST_SHIP, K_TECH_FREIGHTERS, K_TECH_COLONY_SHIP, K_TECH_COLONY_BASE]: if tech_id in v_known_techs: items.append(tech_id) if len(items): tech_carets.append({'title': "New Construction Types", 'items': items}) # Spies items = [] for tech_id in [K_TECH_TELEPATHIC_TRAINING, K_TECH_NEURAL_SCANNER, K_TECH_SPY_NETWORK]: if tech_id in v_known_techs: items.append(tech_id) if len(items): tech_carets.append({'title': "Spies", 'items': items}) y = 64 for caret in tech_carets: if len(caret['items']): self.write_text(K_FONT4, K_PALETTE_TECH, 223, y, caret['title'], 2) y += 16 for item in caret['items']: text = Data_CONST.get_text_list('TECH_LIST')[item]['name'] self.write_text(K_FONT3, K_PALETTE_TECH, 233, y, text, 2) y += 13 y += 6
def show_ships(self): print print( "+---------+------------------+-----------------+----------+------------+----------------------------+-------+-------+" ) print( "| ship_id | name | owner | status | coords | destination | speed | turns |" ) print( "+---------+------------------+-----------------+----------+------------+----------------------------+-------+-------+" ) for i, s in self.d_ships.items(): if s.exists(): i_dest_id = s.i_dest_star_id o_dest_star = self.d_stars[i_dest_id] s_dest_name = o_dest_star.s_name i_dest_x, i_dest_y = o_dest_star.get_coords() o_owner = self.d_players[s.i_owner_id] print( "| %7i | %16s | %15s | %8s | %4i, %4i | [%3i, %3i] %15s | %5i | %5i |" % (i, s.s_name, o_owner.s_race_name, s.get_status_text(), s.i_x, s.i_y, i_dest_x, i_dest_y, s_dest_name, s.i_travelling_speed, s.i_turns_left)) print( "+---------+------------------+-----------------+----------+------------+----------------------------+-------+-------+" ) print sp_txt = Data_CONST.get_text_list('SHIP_SPECIALS') for i, s in self.d_ships.items(): d_design = s.d_design print(" === ship_id # %i ===" % i) for i_dev_id in d_design['special_devices']: txt = sp_txt[i_dev_id] if ( i_dev_id < sp_txt.__len__()) else '<out-of-range>' print(" special device: %2i ... %s" % (i_dev_id, txt)) print
def draw(self): PLAYERS = self.list_players() PLANETS = self.list_planets() star = self.o_star planet = self.o_planet colony = self.o_colony colony_id = colony.i_id self.blit(self.get_image('background', 'starfield'), (0, 0)) self.blit(self.get_planet_background(planet.i_terrain, planet.i_picture), (0, 0)) self.blit(self.get_image('colony_screen', 'panel'), (0, 0)) self.reset_triggers_list() self.add_trigger({'action': "screen", 'screen': "colony_production", 'colony_id': colony_id, 'rect': pygame.Rect((519, 123), ( 61, 22))}) ICON_AND_Y_OFFSET = { K_FARMER: (1,62), K_WORKER: (3,92), K_SCIENTIST: (5,122) } for i in range(K_MAX_STAR_OBJECTS): object_id = star.v_object_ids[i] if object_id != 0xFFFF: object = PLANETS[object_id] print "type: %i" % object.i_type if object.is_asteroid_belt(): x = 6 y = 22 + (24 * i) self.blit(self.get_image('colony_screen', 'asteroids_scheme'), (x, y)) self.write_text(K_FONT2, K_PALETTE_SCHEMES_FONT, x + 29, y + 9, "Asteroids") if object.is_gas_giant(): x = 11 y = 27 + (24 * i) self.blit(self.get_image('colony_screen', 'gasgiant_scheme'), (x, y)) write_text(K_FONT2, K_PALETTE_SCHEMES_FONT, x + 24, y + 4, "Gas Giant -") write_text(K_FONT2, K_PALETTE_SCHEMES_FONT, x + 24, y + 15, "uninhabitable") elif object.is_planet(): terrain = object.i_terrain size = object.i_size x = 10 + [6, 4, 3, 1, 0][size] y = 26 + (24 * i) + [6, 4, 2, 1, 0][size] self.blit(self.get_image('planet_scheme', terrain, size), (x, y)) self.blit(self.get_image('colony_screen', 'scheme_arrow'), (6, 31 + (24 * i))) title_text = "%s of %s" % (Data_CONST.get_text_list('COLONY_ASSIGNMENT')[colony.i_assignment], colony.s_name) title_surface = self.render(K_FONT5, K_PALETTE_TITLE, title_text, 2) (tw, th) = title_surface.get_size() self.blit(title_surface, (320 - (tw / 2), 1)) # total_population = (1000 * colony['population']) + colony['pop_raised'] # print # print " Colony: %s" % colony.name # print " Population: %i (+%i)" % (total_population, colony['pop_grow']) # print " Industry: %i" % colony.industry() # print " Research: %i" % colony.research() # print " Food (result):%i (%i)" % (colony.food(), colony.food() - colony.population) # print " Colonists:" player_government_id = PLAYERS[colony.i_owner_id].get_racepick_item('goverment') self.blit(self.get_image('government', 'icon', player_government_id), (310, 32)) # TODO: implement negative morale self.repeat_draw(340, 35, self.get_image('morale_icon', 'good'), colony.i_morale // 10, 30, 7, 155) x = 10 + self.repeat_draw(128, 64, self.get_image('production_10food'), colony.i_food // 10, 20, 6, 98) self.repeat_draw(x, 64, self.get_image('production_1food'), colony.i_food % 10, 20, 6, 98) # industry icons number = (colony.i_industry // 10) + (colony.i_industry % 10) xx = min(int(round(160 / max(1, number))), 20) x = self.repeat_draw(128, 94, self.get_image('production_10industry'), colony.i_industry // 10, xx, 99, 162) self.repeat_draw(x, 94, self.get_image('production_1industry'), colony.i_industry % 10, xx, 99, 162) # research icons number = (colony.i_research // 10) + (colony.i_research % 10) xx = min(int(round(160 / max(1, number))), 20) #print "### colony_screen::draw ... research icons ... number = %i, xx = %i" % (number, xx) x = self.repeat_draw(128, 124,self.get_image('production_10research'), colony.i_research // 10, xx, 99, 162) self.repeat_draw(x, 124, self.get_image('production_1research'), colony.i_research % 10, xx, 99, 162) for t in (K_FARMER, K_WORKER, K_SCIENTIST): c = len(colony.d_colonists[t]) xx = 30 if c < 7 else 190/c icon, y = ICON_AND_Y_OFFSET[t] for i in range(c): colonist = colony.d_colonists[t][i] race = colonist['race'] picture = PLAYERS[race].i_picture x = 310 + xx * i self.blit(self.get_image('race_icon', picture, icon), (x, y)) if i == (c - 1): xx = 28 # enlarge the Rect of last icon (no other icon is drawn over it...) self.add_trigger({'action': "pick-colonist:%.2x:%i" % (t, (c - i)), 'rect': pygame.Rect((x, y), (xx, 28))}) x = 0 for i in range(colony.i_num_marines): self.blit_image((x, 450), 'race_icon', picture, 0x07) x += 30 # TODO: count in all races not just owner! total_population = (1000 * colony.total_population()) + sum(colony.v_pop_raised) pop_text = "Pop %i,%.3i k (+%i)" % ((total_population // 1000), (total_population % 1000), sum(colony.v_pop_grow)) population = self.render(K_FONT3, K_PALETTE_POPULATION, pop_text, 2) (tw, th) = population.get_size() self.blit(population, (529, 3))
def draw(self): PLAYERS = self.list_players() PLANETS = self.list_planets() star = self.o_star planet = self.o_planet colony = self.o_colony colony_id = colony.i_id actual_pop = (1000 * colony.i_population) + sum(colony.v_pop_raised) print print " Colony: %s" % colony.s_name print " Population: %i (+%i)" % (actual_pop, sum(colony.v_pop_grow)) print " Food (result): %i (%i)" % (colony.i_food, colony.i_food - actual_pop) print " Industry: %i" % colony.i_industry print " Research: %i" % colony.i_research self.reset_triggers_list() self.add_trigger({'action': "screen", 'screen': "colony_production", 'colony_id': colony_id, 'rect': pygame.Rect((519, 123), ( 61, 22))}) # Background and starfield self.blit(self.get_image('background', 'starfield'), (0, 0)) self.blit(self.get_planet_background(planet.i_terrain, planet.i_picture), (0, 0)) self.blit(self.get_image('colony_screen', 'panel'), (0, 0)) # Solar system objects list for i in range(K_MAX_STAR_OBJECTS): self.blit(self.get_image('colony_screen', 'scheme_arrow'), (6, 31 + (24 * i))) object_id = star.v_object_ids[i] if object_id != 0xFFFF: o_object = PLANETS[object_id] if o_object.is_asteroid_belt(): x = 6 y = 22 + (24 * i) self.blit(self.get_image('colony_screen', 'asteroids_scheme'), (x, y)) self.write_text(K_FONT2, K_PALETTE_SCHEMES_FONT, 40, y + 5, "Asteroids") if o_object.is_gas_giant(): x = 11 y = 27 + (24 * i) self.blit(self.get_image('colony_screen', 'gasgiant_scheme'), (x, y)) self.write_text(K_FONT2, K_PALETTE_SCHEMES_FONT, 40, y + 5, "Gas Giant") elif o_object.is_planet(): x = 10 + [6, 4, 3, 1, 0][o_object.i_size] y = 26 + (24 * i) + [6, 4, 2, 1, 0][o_object.i_size] self.blit(self.get_image('planet_scheme', o_object.i_terrain, o_object.i_size), (x, y)) self.write_text(K_FONT2, K_PALETTE_SCHEMES_FONT, 40, y + 5, o_object.s_name) ##JWL: TODO Also need triggers to switch view to this planet if it has a colony # Screen title / Population summary title_text = "%s of %s" % (Data_CONST.get_text_list('COLONY_ASSIGNMENT')[colony.i_assignment], colony.s_name) title_surface = self.render(K_FONT5, K_PALETTE_TITLE, title_text, 2) (tw, th) = title_surface.get_size() self.blit(title_surface, (320 - (tw / 2), 1)) pop_text = "Pop %i,%.3i k (%+i k)" % ((actual_pop // 1000), (actual_pop % 1000), sum(colony.v_pop_grow)) population = self.render(K_FONT3, K_PALETTE_POPULATION, pop_text, 2) (tw, th) = population.get_size() self.blit(population, (520, 3)) # government/morale icons player_government_id = PLAYERS[colony.i_owner_id].get_racepick_item('goverment') self.blit(self.get_image('government', 'icon', player_government_id), (310, 32)) s_morale_type = 'good' if colony.i_morale > 100.0 else 'bad' i_morale_num = abs(colony.i_morale - 100.0) // 10 self.repeat_draw(340, 35, self.get_image('morale_icon', s_morale_type), i_morale_num, 30, 7, 155) # Food icons #xx = 10 number = (colony.i_food // 10) + (colony.i_food % 10) xx = min(int(round(160 / max(1, number))), 20) x = self.repeat_draw(128, 64, self.get_image('production_10food'), colony.i_food // 10, xx, 99, 162) #6, 98) x = self.repeat_draw(x, 64, self.get_image('production_1food'), colony.i_food % 10, xx, 99, 162) #6, 98) # TODO missing (red outline) food # Industry icons number = (colony.i_industry // 10) + (colony.i_industry % 10) xx = min(int(round(160 / max(1, number))), 20) x = self.repeat_draw(128, 94, self.get_image('production_10industry'), colony.i_industry // 10, xx, 99, 162) x = self.repeat_draw(x, 94, self.get_image('production_1industry'), colony.i_industry % 10, xx, 99, 162) # Research icons number = (colony.i_research // 10) + (colony.i_research % 10) xx = min(int(round(160 / max(1, number))), 20) x = self.repeat_draw(128, 124, self.get_image('production_10research'), colony.i_research // 10, xx, 99, 162) x = self.repeat_draw(x, 124, self.get_image('production_1research'), colony.i_research % 10, xx, 99, 162) # Colonist icons ICON_AND_Y_OFFSET = { K_FARMER: (1,62), K_WORKER: (3,92), K_SCIENTIST: (5,122) } for t in (K_FARMER, K_WORKER, K_SCIENTIST): c = len(colony.d_colonists[t]) xx = 30 if c < 7 else 190/c # Adjust for normal versus overlapped colonist icons icon, y = ICON_AND_Y_OFFSET[t] for i in range(c): colonist = colony.d_colonists[t][i] picture = PLAYERS[colonist.race].i_picture x = 310 + xx * i self.blit(self.get_image('race_icon', picture, icon), (x, y)) if i == (c - 1): xx = 28 # enlarge the Rect of last icon (no other icon is drawn over it...) self.add_trigger({'action': "pick-colonist:0x%.2x:%i" % (t, i), 'rect': pygame.Rect((x, y), (xx, 28))}) # Marines / Armors / Mechs x = 0 for i in range(colony.i_num_marines): self.blit_image((x, 450), 'race_icon', picture, 0x07) x += 30
def get_status_text(self): return Data_CONST.get_text_list('SHIP_STATUS')[self.i_status]
def draw(self): PLAYERS = self.list_players() PLANETS = self.list_planets() star = self.o_star planet = self.o_planet colony = self.o_colony colony_id = colony.i_id self.blit(self.get_image('background', 'starfield'), (0, 0)) self.blit( self.get_planet_background(planet.i_terrain, planet.i_picture), (0, 0)) self.blit(self.get_image('colony_screen', 'panel'), (0, 0)) self.reset_triggers_list() self.add_trigger({ 'action': "screen", 'screen': "colony_production", 'colony_id': colony_id, 'rect': pygame.Rect((519, 123), (61, 22)) }) ICON_AND_Y_OFFSET = { K_FARMER: (1, 62), K_WORKER: (3, 92), K_SCIENTIST: (5, 122) } for i in range(K_MAX_STAR_OBJECTS): object_id = star.v_object_ids[i] if object_id != 0xFFFF: object = PLANETS[object_id] print "type: %i" % object.i_type if object.is_asteroid_belt(): x = 6 y = 22 + (24 * i) self.blit( self.get_image('colony_screen', 'asteroids_scheme'), (x, y)) self.write_text(K_FONT2, K_PALETTE_SCHEMES_FONT, x + 29, y + 9, "Asteroids") if object.is_gas_giant(): x = 11 y = 27 + (24 * i) self.blit( self.get_image('colony_screen', 'gasgiant_scheme'), (x, y)) write_text(K_FONT2, K_PALETTE_SCHEMES_FONT, x + 24, y + 4, "Gas Giant -") write_text(K_FONT2, K_PALETTE_SCHEMES_FONT, x + 24, y + 15, "uninhabitable") elif object.is_planet(): terrain = object.i_terrain size = object.i_size x = 10 + [6, 4, 3, 1, 0][size] y = 26 + (24 * i) + [6, 4, 2, 1, 0][size] self.blit(self.get_image('planet_scheme', terrain, size), (x, y)) self.blit(self.get_image('colony_screen', 'scheme_arrow'), (6, 31 + (24 * i))) title_text = "%s of %s" % (Data_CONST.get_text_list( 'COLONY_ASSIGNMENT')[colony.i_assignment], colony.s_name) title_surface = self.render(K_FONT5, K_PALETTE_TITLE, title_text, 2) (tw, th) = title_surface.get_size() self.blit(title_surface, (320 - (tw / 2), 1)) # total_population = (1000 * colony['population']) + colony['pop_raised'] # print # print " Colony: %s" % colony.name # print " Population: %i (+%i)" % (total_population, colony['pop_grow']) # print " Industry: %i" % colony.industry() # print " Research: %i" % colony.research() # print " Food (result):%i (%i)" % (colony.food(), colony.food() - colony.population) # print " Colonists:" player_government_id = PLAYERS[colony.i_owner_id].get_racepick_item( 'goverment') self.blit(self.get_image('government', 'icon', player_government_id), (310, 32)) # TODO: implement negative morale self.repeat_draw(340, 35, self.get_image('morale_icon', 'good'), colony.i_morale // 10, 30, 7, 155) x = 10 + self.repeat_draw(128, 64, self.get_image('production_10food'), colony.i_food // 10, 20, 6, 98) self.repeat_draw(x, 64, self.get_image('production_1food'), colony.i_food % 10, 20, 6, 98) # industry icons number = (colony.i_industry // 10) + (colony.i_industry % 10) xx = min(int(round(160 / max(1, number))), 20) x = self.repeat_draw(128, 94, self.get_image('production_10industry'), colony.i_industry // 10, xx, 99, 162) self.repeat_draw(x, 94, self.get_image('production_1industry'), colony.i_industry % 10, xx, 99, 162) # research icons number = (colony.i_research // 10) + (colony.i_research % 10) xx = min(int(round(160 / max(1, number))), 20) #print "### colony_screen::draw ... research icons ... number = %i, xx = %i" % (number, xx) x = self.repeat_draw(128, 124, self.get_image('production_10research'), colony.i_research // 10, xx, 99, 162) self.repeat_draw(x, 124, self.get_image('production_1research'), colony.i_research % 10, xx, 99, 162) for t in (K_FARMER, K_WORKER, K_SCIENTIST): c = len(colony.d_colonists[t]) xx = 30 if c < 7 else 190 / c icon, y = ICON_AND_Y_OFFSET[t] for i in range(c): colonist = colony.d_colonists[t][i] race = colonist['race'] picture = PLAYERS[race].i_picture x = 310 + xx * i self.blit(self.get_image('race_icon', picture, icon), (x, y)) if i == (c - 1): xx = 28 # enlarge the Rect of last icon (no other icon is drawn over it...) self.add_trigger({ 'action': "pick-colonist:%.2x:%i" % (t, (c - i)), 'rect': pygame.Rect((x, y), (xx, 28)) }) x = 0 for i in range(colony.i_num_marines): self.blit_image((x, 450), 'race_icon', picture, 0x07) x += 30 # TODO: count in all races not just owner! total_population = (1000 * colony.total_population()) + sum( colony.v_pop_raised) pop_text = "Pop %i,%.3i k (+%i)" % ( (total_population // 1000), (total_population % 1000), sum(colony.v_pop_grow)) population = self.render(K_FONT3, K_PALETTE_POPULATION, pop_text, 2) (tw, th) = population.get_size() self.blit(population, (529, 3))
def get_status_text(self): return Data_CONST.get_text_list('SHIP_STATUS')[self.i_status]