def get_life_member_stats(entity): stats = get_alpha_surface(RESOURCE_HUD_BASE.get_width(), RESOURCE_HUD_BASE.get_height()) name = get_text_surface(entity.combatant.name, fontsize=12, color=WHITE) level = get_text_surface(str(entity.combatant.level.current_level), fontsize=12, color=WHITE) hp = get_surface(HP) mp = get_surface(MP) tp = get_surface(TP) vp = get_surface(VP) percent_hp = entity.combatant.attributes.current_hp / entity.combatant.max_hp percent_mp = entity.combatant.attributes.current_mp / entity.combatant.max_mp percent_tp = entity.combatant.attributes.current_tp / entity.combatant.max_tp percent_vp = entity.combatant.attributes.current_vp / entity.combatant.max_vp stats.blit(name, (95, 0)) stats.blit(level, (65, 60)) stats.blit(scale(hp, (int(hp.get_width() * percent_hp), hp.get_height())), (86, 22)) stats.blit(scale(mp, (int(mp.get_width() * percent_mp), mp.get_height())), (86, 34)) stats.blit(scale(tp, (int(tp.get_width() * percent_tp), tp.get_height())), (86, 46)) stats.blit(scale(vp, (int(vp.get_width() * percent_vp), vp.get_height())), (86, 58)) return stats
def display_saving_throws(player): gap = 25 c = player.combatant save_l = [ c.savethrow_injury, c.savethrow_tenacity, c.savethrow_composure, c.savethrow_cognition, c.savethrow_breath, c.savethrow_corruption ] save_r = [ c.savethrow_illness, c.savethrow_apathy, c.savethrow_pain, c.savethrow_force, c.savethrow_reflex, c.savethrow_will ] display = get_alpha_surface(100, gap * len(save_r)) for ind, stat in enumerate(save_l): align_and_blit(display, get_text_surface(str(stat), 16, WHITE, 'source_sans_pro'), x_ratio=0.1, y_ratio=.0833 + (0.1666 * ind)) for ind, stat in enumerate(save_r): align_and_blit(display, get_text_surface(str(stat), 16, WHITE, 'source_sans_pro'), x_ratio=0.9, y_ratio=.0833 + (0.1666 * ind)) return display
def get_title_text(): text = get_text_surface('WUNCEMOOR', fontsize=150, style='lunchds') subtext = get_text_surface('THE ETERNAL DREAM', fontsize=60, style='lunchds') return text, subtext
def display_mass_capacities(party, surf): total_used = party.inventory.mass player_capa = get_text_surface(str(round(party.p1.used_carry_capacity, 2)) + ' / ' + str(round(party.p1.max_carry_capacity, 2)) + ' kg.', color=WHITE) surf.blit(player_capa, (140, 400)) mass_capa = get_text_surface(str(round(total_used, 2)) + ' / ' + str(round(party.inventory.max_carry_capacity, 2)) + ' kg.', color=WHITE) surf.blit(mass_capa, (358, surf.get_height()-50))
def get_life_party_travel_settings(party): window = get_alpha_surface(248, 186) setting_titles = ['Formation', 'Move Speed', 'Rations'] settings = [party.formation, party.move_speed, party.rations] for i in range(3): settings_frame = get_surface(PARTY_SETTINGS_FRAME) setting_title = get_text_surface(setting_titles[i], color=WHITE) align_and_blit(settings_frame, setting_title, y_ratio=0.24) setting = get_text_surface(settings[i], fontsize=16) align_and_blit(settings_frame, setting, y_ratio=0.68) window.blit(settings_frame, (0, i * settings_frame.get_height())) return window
def split_money(value: int, fontsize: int = 12, color: tuple = WHITE): val_str = str(value) if value >= 10000: gold = get_text_surface(val_str[0], fontsize=fontsize, color=color) silver = get_text_surface(cut_leading_zero(val_str[1:3]), fontsize=fontsize, color=color) copper = get_text_surface(cut_leading_zero(val_str[3:]), fontsize=fontsize, color=color) elif value >= 1000: gold = None silver = get_text_surface(val_str[0:2], fontsize=fontsize, color=color) copper = get_text_surface(cut_leading_zero(val_str[2:]), fontsize=fontsize, color=color) elif value >= 100: gold = None silver = get_text_surface(val_str[0], fontsize=fontsize, color=color) copper = get_text_surface(cut_leading_zero(val_str[1:]), fontsize=fontsize, color=color) else: gold = None silver = None copper = get_text_surface(val_str, fontsize=fontsize, color=color) return gold, silver, copper
def character_screen(self): char_sheet = get_surface(CHARACTER_SHEET_BASE) player = self.game.model.party.p1 # level = get_level_icon(player) # age = get_age_icon(player) # species = None # sex = None xp = display_xp_fill(player) resources = display_resources(player) primaries = display_primary_stats(player) secondaries = display_secondary_stats(player) attributes = display_attributes(player) saves = display_saving_throws(player) p_name = get_text_surface(player.name, fontsize=25, color=WHITE, style='source_sans_pro') align_and_blit(char_sheet, p_name, x_ratio=0.23, y_ratio=0.25) align_and_blit(char_sheet, player.images.portrait, x_ratio=0.23) # surf.blit(level, (35, 110)) # surf.blit(age, (35, 110 + level.get_height())) # surf.blit(species, (39, 110 + level.get_height() + age.get_height() + 10)) # surf.blit(sex, (39, 110 + level.get_height() + age.get_height() + species.get_height() + 20)) # surf.blit(xp, ((surf.get_width() / 4) - (xp.get_width() / 2), 420)) align_and_blit(char_sheet, resources, x_ratio=0.23, y_ratio=0.9) align_and_blit(char_sheet, xp, x_ratio=0.224, y_ratio=0.948) char_sheet.blit(primaries, (405, 175)) char_sheet.blit(secondaries, (475, 387)) char_sheet.blit(attributes, (675, 145)) char_sheet.blit(saves, (605, 386)) align_and_blit(self.screen, char_sheet)
def glyph_dimensions(): pygame.init() keys = STRING_TO_FONT_STYLE_DICT.keys() with open('script_outputs/glyph_dimensions.py', 'w') as opened_file: opened_file.write('glyph_dim_dict = {\n') for unicode in [x for x in range(32, 127)]: for fontsize in range(3, 72): for fontstyle in keys: glyph = chr(unicode) surf = get_text_surface(glyph) if unicode == 39: # Must use double quotes to store single quote opened_file.write(' ("' + glyph + '", ' + str(fontsize) + ", '" + fontstyle + "'): (" + str(surf.get_width()) + ", " + str(surf.get_height()) + "),\n") elif unicode == 92: # Must use double slash to deal with special backslashes opened_file.write(" ('" + glyph + glyph + "', " + str(fontsize) + ", '" + fontstyle + "'): (" + str(surf.get_width()) + ", " + str(surf.get_height()) + "),\n") else: opened_file.write(" ('" + glyph + "', " + str(fontsize) + ", '" + fontstyle + "'): (" + str(surf.get_width()) + ", " + str(surf.get_height()) + "),\n") opened_file.write('}\n')
def dialogue_screen(self): display = get_surface(DIALOGUE_BG) surf = get_alpha_surface(display.get_width(), int(display.get_height() * 1.5)) partner = self.handler.partner partner_name = get_text_surface(partner.name.capitalize(), fontsize=24, color=WHITE) display.blit( partner_name, (int(display.get_width() * 0.1), int(display.get_height() * 0.05))) align_and_blit(surf, partner.images.portrait, y_ratio=0.12) dialogue = self.handler.partner.converser.dialogue current_node = dialogue.graph_dict.get(dialogue.conversation) words = get_wrapped_text_surface(current_node.words, width=int(display.get_width() * 0.95), fontsize=18, color=WHITE) display.blit( words, (int(display.get_width() * 0.025), int(display.get_height() * 0.05 + partner_name.get_height()))) options = get_dialogue_options(self) display.blit( options, (int(display.get_width() * 0.025), int(display.get_height() * 0.505))) surf.blit(display, (surf.get_width() - display.get_width(), surf.get_height() - display.get_height())) align_and_blit(self.screen, surf, y_ratio=0.65)
def get_entry_details(entry): surf = get_alpha_surface(367, 400) align_and_blit(surf, get_text_surface(entry.title, 22, BLACK), y_ratio=0.1) y_off = 80 for i in entry.plot: sc = get_story_chunk(i) surf.blit(sc, (30, y_off)) y_off += sc.get_height() + 30 return surf
def get_option_image(self, index): w, h = self.specs.button_bg.get_width( ), self.specs.button_bg.get_height() surf = get_alpha_surface(w, h) text = get_text_surface(self.data[index], self.specs.font_size, self.specs.font_color, self.specs.font_style) surf.blit(self.specs.button_bg, (0, 0)) align_and_blit(surf, text) return surf
def display_entity_list(entities, subinv): y = 0 for entity in entities: sprite = entity.images.sprite text = get_text_surface(entity.name, fontsize=24, color=WHITE) item = get_alpha_surface(SUBINVENTORY_OPTION_WIDTH, SUBINVENTORY_OPTION_HEIGHT) align_and_blit(item, sprite, x_ratio=0.15) item.blit(text, (int(item.get_width() * 0.35), int(0.5 * (item.get_height() - text.get_height())))) draw.line(item, DARK_GREY, (0, SUBINVENTORY_OPTION_HEIGHT - 1), (int(SUBINVENTORY_OPTION_WIDTH), SUBINVENTORY_OPTION_HEIGHT - 1)) subinv.blit(item, (0, y * SUBINVENTORY_OPTION_HEIGHT)) y += 1
def shop_screen(self): surf = get_surface(SHOP_MENU) if self.handler.state is ShopStates.BASE: options_img = INVENTORY_ICONS[self.game.options.current.choice] party_subinv, shop_subinv = self.handler.get_subinventories( self.game.options.current.choice) elif self.handler.state in (ShopStates.BUYING, ShopStates.SELLING, ShopStates.TRANSACTING): options_img = INVENTORY_ICONS[self.handler.sub_index] party_subinv, shop_subinv = self.handler.get_subinventories( self.handler.sub_index) else: ind = self.handler.menu_type.options.choice options_img = INVENTORY_ICONS[ind] surf.blit(INDICATOR_H, (410, 130 + (32 * self.game.options.current.choice))) subinventory = self.handler.menu_type.get_sub() ps, ss = display_partysub(party_subinv), display_shopsub(shop_subinv) sk_name = get_text_surface(self.handler.shopkeeper.name.capitalize(), fontsize=18) sk_money = split_money(self.handler.shopkeeper.shopkeeper.inventory.money, color=WHITE) party_money = split_money(self.game.party.inventory.money, color=WHITE) td_text = get_text_surface('Transaction Details', fontsize=14, color=WHITE) align_and_blit(surf, options_img, x_ratio=0.17, y_ratio=0.16) align_and_blit(surf, options_img, x_ratio=0.5, y_ratio=0.16) align_and_blit(surf, options_img, x_ratio=0.83, y_ratio=0.16) align_and_blit(surf, sk_name, x_ratio=0.1, y_ratio=0.05, x_adjust=6, y_adjust=2) align_and_blit(surf, td_text, x_ratio=0.5, y_ratio=0.11) align_and_blit(surf, sk_money, x_ratio=0, y_ratio=0.11, x_adjust=60) align_and_blit(surf, party_money, x_ratio=0, y_ratio=0.11, x_adjust=622) align_and_blit(surf, ps, x_ratio=0.83, y_ratio=0.27) align_and_blit(surf, ss, x_ratio=0.17, y_ratio=0.27) align_and_blit(self.screen, surf)
def get_story_chunk(chunk): width = 300 titlesize = 18 fontsize = 14 lines = get_wrapped_text(chunk.info, width, fontsize, color=BLACK) surf = get_alpha_surface(width, titlesize + (fontsize * 1.2) * len(lines)) surf.blit(get_text_surface(chunk.title, titlesize, WHITE), (0, 0)) y = 20 for line in lines: surf.blit(line, (0, y)) y += fontsize return surf
def display_attributes(player): gap = 19 a = player.combatant.attributes atts = [ a.strength, a.instinct, a.coordination, a.endurance, a.arcana, a.improvisation, a.wisdom, a.finesse, a.charisma, a.devotion ] display = get_alpha_surface(28, gap * len(atts)) for ind, stat in enumerate(atts): align_and_blit(display, get_text_surface(str(stat), 16, WHITE, 'source_sans_pro'), y_ratio=.05 + (0.1 * ind)) return display
def display_loot(reward): window = get_alpha_surface(1280, 300) y1 = 0 for item in reward.loot.items: window.blit(item.images.sprite, (120, 40 + (100 * y1))) text = get_text_surface(item.name, fontsize=20, color=BLACK) window.blit(text, (210, 70 + (100 * y1))) y1 += 1 y2 = 0 bonus_y = 640 for item in reward.loot.claimed: window.blit(item.images.sprite, (120 + bonus_y, 40 + (100 * y2))) text = get_text_surface(item.name, fontsize=20, color=BLACK) window.blit(text, (210 + bonus_y, 40 + (100 * y2))) y2 += 1 choice = reward.owner.options.current.choice if reward.state == RewardStates.SIFTING: window.blit(POINTER_RIGHT, (80, 60 + (choice * 100))) elif reward.state == RewardStates.DEPOSITING: window.blit(POINTER_RIGHT, (80 + bonus_y, 60 + choice * 100)) return window
def display_secondary_stats(player): gap = 19 c = player.combatant stats = [ c.initiative, c.speed, c.accuracy, c.dodge, c.critical_strike, c.critical_damage, c.teamwork, c.presence ] display = get_alpha_surface(38, gap * len(stats)) for ind, stat in enumerate(stats): align_and_blit(display, get_text_surface(str(stat), 16, WHITE, 'source_sans_pro'), y_ratio=.0625 + (0.125 * ind)) return display
def display_shopsub(subinventory): option_height = 32 surf = get_alpha_surface(200, len(subinventory) * option_height) y = 0 for entity in subinventory: mini = entity.images.port_mini text = get_text_surface(entity.name, fontsize=16) value = split_money(entity.item.value) window = get_alpha_surface(200, option_height) window.blit(mini, (0, 0)) window.blit(text, (35, 12)) window.blit(value, (200 - value.get_width(), 12)) surf.blit(window, (0, y * option_height)) y += 1 return surf
def display_xp_fill(player): fill = get_surface(XP_FILL) l = player.combatant.level display = get_alpha_surface(fill.get_width(), fill.get_height()) align_and_blit( display, scale(fill, (int(fill.get_width() * l.percentage_leveled / 100), fill.get_height()))) xp_text = get_text_surface('XP: ' + str(l.current_xp) + ' / ' + str(l.experience_to_next_level) + ' ( ' + str(int(l.percentage_leveled)) + '% )', fontsize=8, color=WHITE) align_and_blit(display, xp_text) return display
def journal_options_display(subjournal, option): obj = JOURNAL_OBJS.get('selected_quest') surf = get_alpha_surface(obj.get_width(), obj.get_height() * len(subjournal)) y = 0 for i in subjournal: if y is option: color = YELLOW_SELECT bg = get_surface(obj) else: color = GREY bg = get_alpha_surface(obj.get_width(), obj.get_height()) text = get_text_surface(i.title, 18, color, 'source_sans_pro') align_and_blit(bg, text) surf.blit(bg, (0, 0 + (y * obj.get_height()))) return surf
def display_resources(player): display = get_alpha_surface(260, 36) ratio_dict = { 'HP': (0.25, 0.25), 'MP': (0.25, 0.75), 'TP': (0.75, 0.25), 'VP': (0.75, 0.75) } for resource in ('HP', 'MP', 'TP', 'VP'): percent, now_val, max_val, font_color = get_resource_vals( player, resource) ratio = ratio_dict.get(resource) x_ratio, y_ratio = ratio text = get_text_surface( str(now_val) + ' / ' + str(max_val), 16, font_color, ) align_and_blit(display, text, x_ratio, y_ratio) return display
def display_time(clock, hour, bg_color): if hour < 12: xm = 'AM' else: xm = 'PM' if hour == 0: hr = '12' elif hour < 10: hr = '0' + str(hour) elif hour < 13: hr = str(hour) elif hour < 22: hr = '0' + str(hour - 12) else: hr = str(hour - 12) tod = get_text_surface(hr + ' : 00 ' + xm, fontsize=20, color=get_negative_color(bg_color)) align_and_blit(clock, tod, y_ratio=0, y_adjust=38)
def display_month(surf, month): dict = { 1: 'January', 2: 'February', 3: 'March', 4: 'April', 5: 'May', 6: 'June', 7: 'july', 8: 'August', 9: 'September', 10: 'October', 11: 'November', 12: 'December', } month = get_text_surface(dict.get(month), fontsize=32, color=BLACK) align_and_blit(surf, month, x_ratio=0.5, y_ratio=0, x_adjust=0, y_adjust=20)
def get_option_image(self, index): text = get_text_surface(self.data[index], self.specs.font_size, self.specs.font_color, self.specs.font_style) return text
def display_name_and_portrait(player, surf): p_name = get_text_surface(player.name, fontsize=25, color=WHITE, style='source_sans_pro') align_and_blit(surf, p_name, x_ratio=0.23, y_ratio=0.25) align_and_blit(surf, player.images.portrait, x_ratio=0.23)
def display_resources_gain(loot): surf = get_alpha_surface(100, 100) text = get_text_surface('XP: ' + str(loot.xp), 20, BLACK) surf.blit(text, (0, 0)) return surf
def display_primary_stats(player): ts = 19 display = get_alpha_surface(92, ts * 8) align_and_blit(display, get_text_surface( str(player.combatant.power_slash), 16, WHITE, ), x_ratio=0.20, y_ratio=.0625) align_and_blit(display, get_text_surface(str(player.combatant.resist_slash), 16, WHITE, 'source_sans_pro'), x_ratio=0.80, y_ratio=.0625) align_and_blit(display, get_text_surface(str(player.combatant.power_pierce), 16, WHITE, 'source_sans_pro'), x_ratio=0.20, y_ratio=.1875) align_and_blit(display, get_text_surface(str(player.combatant.resist_pierce), 16, WHITE, 'source_sans_pro'), x_ratio=0.80, y_ratio=.1875) align_and_blit(display, get_text_surface(str(player.combatant.power_blunt), 16, WHITE, 'source_sans_pro'), x_ratio=0.20, y_ratio=.3125) align_and_blit(display, get_text_surface(str(player.combatant.resist_blunt), 16, WHITE, 'source_sans_pro'), x_ratio=0.80, y_ratio=.3125) align_and_blit(display, get_text_surface(str(player.combatant.power_heat), 16, WHITE, 'source_sans_pro'), x_ratio=0.20, y_ratio=.4375) align_and_blit(display, get_text_surface(str(player.combatant.resist_heat), 16, WHITE, 'source_sans_pro'), x_ratio=0.80, y_ratio=.4375) align_and_blit(display, get_text_surface(str(player.combatant.power_cold), 16, WHITE, 'source_sans_pro'), x_ratio=0.20, y_ratio=.5625) align_and_blit(display, get_text_surface(str(player.combatant.resist_cold), 16, WHITE, 'source_sans_pro'), x_ratio=0.80, y_ratio=.5625) align_and_blit(display, get_text_surface(str(player.combatant.power_acid), 16, WHITE, 'source_sans_pro'), x_ratio=0.20, y_ratio=.6875) align_and_blit(display, get_text_surface(str(player.combatant.resist_acid), 16, WHITE, 'source_sans_pro'), x_ratio=0.80, y_ratio=.6875) align_and_blit(display, get_text_surface(str(player.combatant.power_current), 16, WHITE, 'source_sans_pro'), x_ratio=0.20, y_ratio=.8125) align_and_blit(display, get_text_surface(str(player.combatant.resist_current), 16, WHITE, 'source_sans_pro'), x_ratio=0.80, y_ratio=.8125) align_and_blit(display, get_text_surface(str(player.combatant.power_aether), 16, WHITE, 'source_sans_pro'), x_ratio=0.20, y_ratio=.9375) align_and_blit(display, get_text_surface(str(player.combatant.resist_aether), 16, WHITE, 'source_sans_pro'), x_ratio=0.80, y_ratio=.9375) return display