/* * Copyright (C) 2002-2007 The Warp Rogue Team * Part of the Warp Rogue Project * * This software is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License. * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY. * * See the license.txt file for more details. */ /* * Module Name: Honour * Description: Certificate of Honour */ #define Uses_Ui #define Uses_Grammar #define Uses_Character #define Uses_Npc #define Uses_Career #define Uses_Stats #define Uses_Perks #define Uses_Psychic #define Uses_Inventory #define Uses_DataFile #define Uses_Util #define Uses_Quest #include "mheader.h" #include "honour.h" static void certificate_print(void); static void print_basics(FILE *, const CHARACTER *); static void print_stats(FILE *, const CHARACTER *); static void print_perks(FILE *, const CHARACTER *); static void print_psy_powers(FILE *, const CHARACTER *); static void print_inventory(FILE *, const CHARACTER *); static void print_quests(FILE *); static void print_body_count(FILE *); /* * the certificate of honour screen */ void certificate_screen(void) { certificate_print(); command_bar_set(1, CM_EXIT); render_certificate_screen(); update_screen(); command_bar_get_command(); } /* * prints the certificate of honour */ static void certificate_print(void) { FILE *out_file; const CHARACTER *character; character = player_character(); set_data_path(DIR_USER_DATA, FILE_CERTIFICATE); out_file = open_file(data_path(), "w"); fprintf(out_file, " -== Certificate of Honour ==-\n\n"); print_basics(out_file, character); print_stats(out_file, character); print_perks(out_file, character); print_psy_powers(out_file, character); print_inventory(out_file, character); print_quests(out_file); print_body_count(out_file); fprintf(out_file, "\n\n"); close_file(out_file); } /* * prints the basics */ static void print_basics(FILE *out_file, const CHARACTER *character) { fprintf(out_file, "Name : %s\n", character->name); fprintf(out_file, "Career : "); if (character->career == CAREER_NIL) { fprintf(out_file, "-\n"); } else { fprintf(out_file, "%s\n", get_career_pointer(character->career)->name ); } fprintf(out_file, "Power Rating : %d\n\n", character_power_rating(character) ); } /* * prints the stats */ static void print_stats(FILE *out_file, const CHARACTER *character) { STAT stat; for (stat = 0; stat < MAX_STATS; stat++) { fprintf(out_file, "%-13s: %d\n", stat_long_name(stat), character->stat[stat].current ); } } /* * prints the perks */ static void print_perks(FILE *out_file, const CHARACTER *character) { PERK perk; fprintf(out_file, "\n[Perks]\n"); for (perk = 0; perk < MAX_PERKS; perk++) { if (character->perk[perk]) { fprintf(out_file, "%s\n", perk_name(perk)); } } } /* * prints the psychic powers */ static void print_psy_powers(FILE *out_file, const CHARACTER *character) { PSY_POWER psy_power; fprintf(out_file, "\n[Psychic Powers]\n"); for (psy_power = 0; psy_power < MAX_PSY_POWERS; psy_power++) { if (!character->psy_power[psy_power]) continue; fprintf(out_file, "%s\n", psy_power_name(psy_power)); } } /* * prints the inventory */ static void print_inventory(FILE *out_file, const CHARACTER *character) { LIST_NODE *node; fprintf(out_file, "\n[Inventory]\n"); for (node = character->inventory->head; node != NULL; node = node->next) { inventory_object_print(character, (OBJECT *)node->data, out_file ); } } /* * prints the quests */ static void print_quests(FILE *out_file) { LIST_NODE *node; fprintf(out_file, "\n[Quests]\n"); for (node = quest_list()->head; node != NULL; node = node->next) { QUEST *quest; quest = (QUEST *)node->data; if (!quest->given) continue; fprintf(out_file, "%-32s %16s\n", quest->name, quest->status); } } /* * prints the body count */ static void print_body_count(FILE *out_file) { NPC_INDEX npc_index; NPC_INDEX npc_index_max; fprintf(out_file, "\n[Body Count]\n"); npc_index_max = npc_box_size() - 1; for (npc_index = 0; npc_index <= npc_index_max; npc_index++) { const NPC_COUNTER *counter; const char *name_string; counter = npc_counter(npc_index); if (counter->n_killed == 0) continue; name_string = npc_index_to_name(npc_index); if (counter->n_killed > 1) { name_string = plural_form(name_string); } if (!npc_is_unique(npc_index)) { fprintf(out_file, "%d ", counter->n_killed); } fprintf(out_file, "%s\n", name_string); } }