Skip to content
Snippets Groups Projects
Commit aa138fd4 authored by deuce's avatar deuce
Browse files

Create armour struct/array with "separate" cost..

parent 66f1d13d
No related branches found
No related tags found
No related merge requests found
...@@ -98,7 +98,12 @@ struct weapon { ...@@ -98,7 +98,12 @@ struct weapon {
char name[31]; char name[31];
WORD attack; WORD attack;
WORD power; WORD power;
DWORD cost; DWORD cost;
};
struct armour {
char name[31];
DWORD cost;
}; };
struct playertype player[31]; struct playertype player[31];
...@@ -110,7 +115,7 @@ const char dots[] = "..............................................."; ...@@ -110,7 +115,7 @@ const char dots[] = "...............................................";
/* In these arrays, 0 isn't actually used */ /* In these arrays, 0 isn't actually used */
QWORD required[29]; /* Experience required for each level */ QWORD required[29]; /* Experience required for each level */
struct weapon weapon[26]; struct weapon weapon[26];
char sname[26][31]; /* Array of shield names */ struct armour armour[26];
char temp[81]; char temp[81];
FILE *infile; /* Current input file */ FILE *infile; /* Current input file */
DWORD player_num; /* Current Player Number */ DWORD player_num; /* Current Player Number */
...@@ -631,7 +636,7 @@ statshow(void) ...@@ -631,7 +636,7 @@ statshow(void)
od_printf("Battles: %u Retreats: %u Fights: %u Hps: %u(%u)\r\n", user.battles, user.flights, user.fights, user.hps - user.damage, user.hps); od_printf("Battles: %u Retreats: %u Fights: %u Hps: %u(%u)\r\n", user.battles, user.flights, user.fights, user.hps - user.damage, user.hps);
nl(); nl();
od_set_color(L_CYAN, D_BLACK); od_set_color(L_CYAN, D_BLACK);
od_printf("Weapon: %s Armor: %s\r\n", weapon[user.weapon].name, sname[user.armour]); od_printf("Weapon: %s Armor: %s\r\n", weapon[user.weapon].name, armour[user.armour].name);
} }
BOOL BOOL
incre(void) incre(void)
...@@ -1146,7 +1151,7 @@ weaponlist(void) ...@@ -1146,7 +1151,7 @@ weaponlist(void)
od_disp_str("(-------------------------------------------------------------------------)\r\n"); od_disp_str("(-------------------------------------------------------------------------)\r\n");
od_set_color(L_YELLOW, D_BLACK); od_set_color(L_YELLOW, D_BLACK);
for (i = 1; i <= 25; i++) for (i = 1; i <= 25; i++)
od_printf(" %2d> %-25.25s %-25.25s %9u\r\n", i, weapon[i].name, sname[i], weapon[i].cost); od_printf(" %2d> %-25.25s %-25.25s %9u\r\n", i, weapon[i].name, armour[i].name, weapon[i].cost);
} }
void void
...@@ -1205,11 +1210,11 @@ weaponshop(void) ...@@ -1205,11 +1210,11 @@ weaponshop(void)
od_disp_str("Are you sure you want buy it? "); od_disp_str("Are you sure you want buy it? ");
if (od_get_answer("YN") == 'Y') { if (od_get_answer("YN") == 'Y') {
od_disp_str("Yes\r\n"); od_disp_str("Yes\r\n");
user.gold -= weapon[buy].cost; user.gold -= armour[buy].cost;
user.armour = buy; user.armour = buy;
nl(); nl();
od_set_color(D_MAGENTA, D_BLACK); od_set_color(D_MAGENTA, D_BLACK);
od_printf("You've bought a %s\r\n", sname[buy]); od_printf("You've bought a %s\r\n", armour[buy].name);
} else } else
od_disp_str("No\r\n"); od_disp_str("No\r\n");
break; break;
...@@ -1242,7 +1247,7 @@ weaponshop(void) ...@@ -1242,7 +1247,7 @@ weaponshop(void)
break; break;
case 'A': case 'A':
od_disp_str("Armour\r\n"); od_disp_str("Armour\r\n");
buyprice = user.charisma * weapon[user.armour].cost / 20; buyprice = user.charisma * armour[user.armour].cost / 20;
nl(); nl();
od_printf("I will purchase it for %u, okay? ", buyprice); od_printf("I will purchase it for %u, okay? ", buyprice);
if (od_get_answer("YN") == 'Y') { if (od_get_answer("YN") == 'Y') {
...@@ -1301,7 +1306,7 @@ spy(void) ...@@ -1301,7 +1306,7 @@ spy(void)
nl(); nl();
od_set_color(D_MAGENTA, D_BLACK); od_set_color(D_MAGENTA, D_BLACK);
od_printf("Weapon : %s\r\n", weapon[player[a].weapon].name); od_printf("Weapon : %s\r\n", weapon[player[a].weapon].name);
od_printf("Armour : %s\r\n", sname[player[a].armour]); od_printf("Armour : %s\r\n", armour[player[a].armour].name);
nl(); nl();
od_set_color(L_YELLOW, D_BLACK); od_set_color(L_YELLOW, D_BLACK);
od_printf("Steel (in hand): %" QWORDFORMAT "\r\n", player[a].gold); od_printf("Steel (in hand): %" QWORDFORMAT "\r\n", player[a].gold);
...@@ -1616,11 +1621,12 @@ main(int argc, char **argv) ...@@ -1616,11 +1621,12 @@ main(int argc, char **argv)
infile = fopen("data/armor.lan", "rb"); infile = fopen("data/armor.lan", "rb");
od_set_color(L_BLUE, D_BLACK); od_set_color(L_BLUE, D_BLACK);
for (i = 1; i <= 25; i++) for (i = 1; i <= 25; i++)
readline(sname[i], sizeof(sname[i])); readline(armour[i].name, sizeof(armour[i].name));
fclose(infile); fclose(infile);
infile = fopen("data/prices.lan", "rb"); infile = fopen("data/prices.lan", "rb");
for (i = 1; i <= 25; i++) { for (i = 1; i <= 25; i++) {
weapon[i].cost = readnumb(100000000); weapon[i].cost = readnumb(100000000);
armour[i].cost = weapon[i].cost;
endofline(); endofline();
} }
fclose(infile); fclose(infile);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment