Skip to content
Snippets Groups Projects
Commit 8d658f8d authored by Jake Feddersen's avatar Jake Feddersen
Browse files

Fix some bugs

parent 3198d513
No related branches found
No related tags found
No related merge requests found
......@@ -242,7 +242,7 @@ position monster::monster_move(dungeon &d) {
return pos;
}
player_character::player_character(uint8_t x, uint8_t y) : character(10, '@', 1000) {
player_character::player_character(uint8_t x, uint8_t y) : character(10, '@', 100) {
pos.x = x;
pos.y = y;
......@@ -506,11 +506,11 @@ item *player_character::take_off() {
}
item *player_character::drop_item() {
int slot = print_inventory("Select an item to equip, or ESC to cancel:");
int slot = print_inventory("Select an item to drop, or ESC to cancel:");
if (!(slot >= '0' && slot <= '9')) return 0;
item *item_to_drop = equipment[slot-'0'];
equipment[slot-'0'] = 0;
item *item_to_drop = inventory[slot-'0'];
inventory[slot-'0'] = 0;
return item_to_drop;
}
......
......@@ -7,19 +7,19 @@
#include "util.h"
int randrange(int min, int max) {
int range = max - min + 1;
return (rand() % range) + min;
int range = max - min + 1;
return (rand() % range) + min;
}
int randchance(double prob) {
int resolution = RAND_MAX;
return (rand() % resolution) < (prob * resolution);
int resolution = RAND_MAX;
return (rand() % resolution) < (prob * resolution);
}
int sign(int x) {
if (x > 0) return 1;
if (x < 0) return -1;
return 0;
if (x > 0) return 1;
if (x < 0) return -1;
return 0;
}
void parse_args(int argc, char *argv[], args *args) {
......@@ -34,11 +34,11 @@ void parse_args(int argc, char *argv[], args *args) {
int valid = 1;
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--save")) {
args->save = 1;
} else if (!strcmp(argv[i], "--load")) {
args->load = 1;
} else if (!strncmp(argv[i], "--seed=", 7)) {
if (!strcmp(argv[i], "--save")) {
args->save = 1;
} else if (!strcmp(argv[i], "--load")) {
args->load = 1;
} else if (!strncmp(argv[i], "--seed=", 7)) {
if (strlen(argv[i]) > 7) {
args->seed = atoi(argv[i] + 7);
} else {
......@@ -62,18 +62,18 @@ void parse_args(int argc, char *argv[], args *args) {
fprintf(stderr, " --load: \tInstead of generating a random dungeon, loads the saved dungeon\n\t\tfile from ~/.rlg327/dungeon\n");
fprintf(stderr, " --save: \tSaves the dungeon to ~/.rlg327/dungeon\n");
fprintf(stderr, " --seed: \tSeeds the random number generator to the given value. If not\n\t\tspecified, time(NULL) is used as the seed\n");
fprintf(stderr, " --nummon:\tSets the number of monsters to generate in the dungeon. If not\n\t\tspecified, the default is 7. Automatically capped at the number\n\t\tof empty spaces in the dungeon.\n\t\tIf nummon is 0, the game never ends and the PC wanders the\n\t\tdungeon endlessly.\n");
fprintf(stderr, " --nummon:\tSets the number of monsters to generate in the dungeon. If not\n\t\tspecified, the default is 7. Automatically capped at the number\n\t\tof empty spaces in the dungeon.\n");
fprintf(stderr, " -h: \tPrints this help information and exits\n");
exit(1);
}
}
int position::operator==(const position &p) {
return (x == p.x && y == p.y);
return (x == p.x && y == p.y);
}
position &position::operator=(const position &p) {
x = p.x;
y = p.y;
return *this;
x = p.x;
y = p.y;
return *this;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment