static struct panel *get_panel_midleft(void) { struct panel *p = panel_allocate(9); panel_line(p, max_color(p_ptr->lev, p_ptr->max_lev), "Level", "%d", p_ptr->lev); panel_line(p, max_color(p_ptr->exp, p_ptr->max_exp), "Cur Exp", "%d", p_ptr->exp); panel_line(p, TERM_L_GREEN, "Max Exp", "%d", p_ptr->max_exp); panel_line(p, TERM_L_GREEN, "Adv Exp", "%s", show_adv_exp()); panel_space(p); panel_line(p, TERM_L_GREEN, "Gold", "%d", p_ptr->au); panel_line(p, TERM_L_GREEN, "Burden", "%.1f lbs", p_ptr->total_weight / 10.0F); panel_line(p, TERM_L_GREEN, "Speed", "%s", show_speed()); panel_line(p, TERM_L_GREEN, "Max Depth", "%s", show_depth()); return p; }
static struct panel *get_panel_midleft(void) { struct panel *p = panel_allocate(9); int diff = weight_remaining(player); byte attr = diff < 0 ? COLOUR_L_RED : COLOUR_L_GREEN; panel_line(p, max_color(player->lev, player->max_lev), "Level", "%d", player->lev); panel_line(p, max_color(player->exp, player->max_exp), "Cur Exp", "%d", player->exp); panel_line(p, COLOUR_L_GREEN, "Max Exp", "%d", player->max_exp); panel_line(p, COLOUR_L_GREEN, "Adv Exp", "%s", show_adv_exp()); panel_space(p); panel_line(p, COLOUR_L_GREEN, "Gold", "%d", player->au); panel_line(p, attr, "Burden", "%.1f lb", player->upkeep->total_weight / 10.0F); panel_line(p, attr, "Overweight", "%d.%d lb", -diff / 10, abs(diff) % 10); panel_line(p, COLOUR_L_GREEN, "Max Depth", "%s", show_depth()); return p; }
void backwards(int * trace, int * max_used_color, int * vertex_max_color, int * current_vertex, int * satur_degree, Graph * graph, tuple * base, int * popularity, int * coloring, int * depth, int upper_bound, int lower_bound) { // Se determina la posición en la traza donde se encuentra // el vértice desde el cual se hace backtracking int vertex_position = lin_search(trace, *current_vertex, *depth); // Se averigua si el vértice de donde se parte // el backtracking es la raiz if (vertex_position == 0) { int vertex_color = graph[trace[vertex_position]].color; update_all(trace, graph, base, popularity, *depth, vertex_position, satur_degree); // Quitamos su color del FC graph[trace[vertex_position]].FC[vertex_color] = 0; // Se determina el máximo color utilizado hasta ahora max_color(popularity, max_used_color, upper_bound); if (valid_FC(graph, trace[vertex_position],lower_bound+1)) { *current_vertex = trace[vertex_position]; *vertex_max_color = 0; return; } else { // Se ha llegado a la raiz y no hay mas colores // posibles que introducir *current_vertex = -1; return; } } else { tuple_list * candidates = NULL; if (vertex_position == -1) { // Significa que el vértice donde quedó forward // tuvo FC vació, por lo tanto no se encontró en // la traza. Se llama directamente label candidates = label(graph, *depth + 1, *max_used_color, trace, *current_vertex); vertex_position = *depth + 1; } else { // Se logró una coloración completa. Por lo tanto: // Se decolorean todos los vértices subiendo en el // árbol hasta llegar al vértice de mínimo rango // con el mayor color usado en la coloración parcial actual update_all(trace, graph, base, popularity, *depth, vertex_position, satur_degree); // Se procede a hacer el etiquetado partiendo del vértice // con coloración más alta y de rango mínimo. O partiendo // del vértice cuyo FC se hizo vacío candidates = label(graph, vertex_position, *max_used_color, trace, *current_vertex); } // Se verifica que la lista de candidatos del label // sea distinta de Nula. En caso contrario no hay más // backtracking que hacer y se consiguió una coloración while (candidates != NULL) { int vertex_color = graph[candidates->vertex].color; // Se decolorean todos los vértices que están a partir // de una posición anterior desde donde se hizo labeling // hasta el vértice de rango máximo entre todos los // etiquetados update_all(trace, graph, base, popularity, vertex_position - 1, candidates->position, satur_degree); // Se elimina de su FC el color que tiene actualmente graph[candidates->vertex].FC[vertex_color] = 0; // Se determina el máximo color utilizado hasta ahora max_color(popularity, max_used_color, upper_bound); // Se verifica que el vértice de máximo rango etiquetado // no tenga un FC vacío. Al ser su FC no vació se hace // retornar el algoritmo if (valid_FC(graph, candidates->vertex, *max_used_color)) { // Se determina la posición en la traza // del vértice de mínimo rango que tiene // el color máximo utilizado det_vertex_max_color(graph, trace,*max_used_color, vertex_max_color, candidates->position); // Se indica la posición en la traza del vértice // del cual se parte para hacer forward. *current_vertex = candidates->vertex; *depth = candidates->position; free_tuple_list(candidates); return; } else { tuple_list * tmp = candidates; candidates = candidates->next; tmp->next = NULL; free_tuple_list(tmp); } } } // La lista CP está vacía por lo tanto se retorna el // algoritmo con current_vertex siendo cero. *current_vertex = -1; return; }
static int get_panel(int oid, data_panel *panel, size_t size) { int ret = (s32b) size; switch(oid) { case 1: { int i = 0; assert( size >= (u32b) boundaries[1].page_rows); ret = boundaries[1].page_rows; P_I(TERM_L_BLUE, "Name", "%y", s2u(op_ptr->full_name), END ); P_I(TERM_L_BLUE, "Sex", "%y", s2u(sp_ptr->title), END ); P_I(TERM_L_BLUE, "Race", "%y", s2u(rp_ptr->name), END ); P_I(TERM_L_BLUE, "Class", "%y", s2u(cp_ptr->name), END ); P_I(TERM_L_BLUE, "Title", "%y", s2u(show_title()), END ); P_I(TERM_L_BLUE, "HP", "%y/%y", i2u(p_ptr->chp), i2u(p_ptr->mhp) ); P_I(TERM_L_BLUE, "SP", "%y/%y", i2u(p_ptr->csp), i2u(p_ptr->msp) ); P_I(TERM_L_BLUE, "Level", "%y", i2u(p_ptr->lev), END ); assert(i == boundaries[1].page_rows); return ret; } case 2: { int i = 0; assert( ret >= boundaries[2].page_rows); ret = boundaries[2].page_rows; P_I(max_color(p_ptr->lev, p_ptr->max_lev), "Level", "%y", i2u(p_ptr->lev), END ); P_I(max_color(p_ptr->exp, p_ptr->max_exp), "Cur Exp", "%y", i2u(p_ptr->exp), END ); P_I(TERM_L_GREEN, "Max Exp", "%y", i2u(p_ptr->max_exp), END ); P_I(TERM_L_GREEN, "Adv Exp", "%y", s2u(show_adv_exp()), END ); P_I(TERM_L_GREEN, "MaxDepth", "%y", s2u(show_depth()), END ); P_I(TERM_L_GREEN, "Game Turns", "%y", i2u(turn), END ); P_I(TERM_L_GREEN, "Standard Turns","%y", i2u(p_ptr->total_energy / 100), END ); P_I(TERM_L_GREEN, "Resting Turns","%y", i2u(p_ptr->resting_turn), END ); P_I(TERM_L_GREEN, "Gold", "%y", i2u(p_ptr->au), END ); assert(i == boundaries[2].page_rows); return ret; } case 3: { int i = 0; assert(ret >= boundaries[3].page_rows); ret = boundaries[3].page_rows; P_I(TERM_L_BLUE, "Armor", "[%y,%+y]", i2u(p_ptr->state.dis_ac), i2u(p_ptr->state.dis_to_a) ); P_I(TERM_L_BLUE, "Fight", "(%+y,%+y)", i2u(p_ptr->state.dis_to_h), i2u(p_ptr->state.dis_to_d) ); P_I(TERM_L_BLUE, "Melee", "%y", s2u(show_melee_weapon(&p_ptr->inventory[INVEN_WIELD])), END ); P_I(TERM_L_BLUE, "Shoot", "%y", s2u(show_missile_weapon(&p_ptr->inventory[INVEN_BOW])), END ); P_I(TERM_L_BLUE, "Blows", "%y.%y/turn", i2u(p_ptr->state.num_blow / 100), i2u((p_ptr->state.num_blow / 10) % 10) ); P_I(TERM_L_BLUE, "Shots", "%y/turn", i2u(p_ptr->state.num_fire), END ); P_I(TERM_L_BLUE, "Infra", "%y ft", i2u(p_ptr->state.see_infra * 10), END ); P_I(TERM_L_BLUE, "Speed", "%y", s2u(show_speed()), END ); P_I(TERM_L_BLUE, "Burden","%.1y lbs", f2u(p_ptr->total_weight/10.0), END ); assert(i == boundaries[3].page_rows); return ret; } case 4: { static struct { const char *name; int skill; int div; } skills[] = { { "Saving Throw", SKILL_SAVE, 6 }, { "Stealth", SKILL_STEALTH, 1 }, { "Fighting", SKILL_TO_HIT_MELEE, 12 }, { "Shooting", SKILL_TO_HIT_BOW, 12 }, { "Disarming", SKILL_DISARM, 8 }, { "Magic Device", SKILL_DEVICE, 6 }, { "Perception", SKILL_SEARCH_FREQUENCY, 6 }, { "Searching", SKILL_SEARCH, 6 } }; int i; assert(N_ELEMENTS(skills) == boundaries[4].page_rows); ret = N_ELEMENTS(skills); if ((u32b) ret > size) ret = size; for (i = 0; i < ret; i++) { s16b skill = p_ptr->state.skills[skills[i].skill]; panel[i].color = TERM_L_BLUE; panel[i].label = skills[i].name; if (skills[i].skill == SKILL_SAVE || skills[i].skill == SKILL_SEARCH) { if (skill < 0) skill = 0; if (skill > 100) skill = 100; panel[i].fmt = "%y%%"; panel[i].value[0] = i2u(skill); panel[i].color = colour_table[skill / 10]; } else if (skills[i].skill == SKILL_DEVICE) { panel[i].fmt = "%y"; panel[i].value[0] = i2u(skill); panel[i].color = colour_table[skill / 13]; } else if (skills[i].skill == SKILL_SEARCH_FREQUENCY) { if (skill <= 0) skill = 1; if (skill >= 50) { panel[i].fmt = "1 in 1"; panel[i].color = colour_table[10]; } else { /* convert to % chance of searching */ skill = 50 - skill; panel[i].fmt = "1 in %y"; panel[i].value[0] = i2u(skill); panel[i].color = colour_table[(100 - skill*2) / 10]; } } else if (skills[i].skill == SKILL_DISARM) { /* assume disarming a dungeon trap */ skill -= 5; if (skill > 100) skill = 100; if (skill < 2) skill = 2; panel[i].fmt = "%y%%"; panel[i].value[0] = i2u(skill); panel[i].color = colour_table[skill / 10]; } else { panel[i].fmt = "%y"; panel[i].value[0] = s2u(likert(skill, skills[i].div, &panel[i].color)); } } return ret; } case 5: { int i = 0; assert(ret >= boundaries[5].page_rows); ret = boundaries[5].page_rows; P_I(TERM_L_BLUE, "Age", "%y", i2u(p_ptr->age), END ); P_I(TERM_L_BLUE, "Height", "%y", i2u(p_ptr->ht), END ); P_I(TERM_L_BLUE, "Weight", "%y", i2u(p_ptr->wt), END ); P_I(TERM_L_BLUE, "Social", "%y", s2u(show_status()), END ); P_I(TERM_L_BLUE, "Maximize", "%y", c2u(OPT(birth_maximize) ? 'Y' : 'N'), END); #if 0 /* Preserve mode deleted */ P_I(TERM_L_BLUE, "Preserve", "%y", c2u(birth_preserve ? 'Y' : 'N'), END); #endif assert(i == boundaries[5].page_rows); return ret; } } /* hopefully not reached */ return 0; }