diff options
-rw-r--r-- | 7w.h | 25 | ||||
-rw-r--r-- | cards.c | 24 | ||||
-rw-r--r-- | color.c | 15 | ||||
-rw-r--r-- | io.c | 32 | ||||
-rw-r--r-- | main.c | 4 |
5 files changed, 87 insertions, 13 deletions
@@ -1,10 +1,7 @@ #define NUMRESOURCES 8 #define WOOD 0 -#define COLORWOOD 32 #define STONE 1 -#define COLORSTONE 0 #define CLAY 2 -#define COLORCLAY #define ORE 3 #define CLOTH 4 #define GLASS 5 @@ -31,3 +28,25 @@ #define UP 2 #define DOWN 3 #define ENTER 4 + +#define COLORWOOD 32 +#define COLORSTONE 0 +#define COLORCLAY 31 +#define COLORORE 0 +#define COLORCLOTH 35 +#define COLORGLASS 36 +#define COLORPAPER 33 +#define COLORGOLD 33 +#define COLORCOMPASS 0 +#define COLORGEAR 0 +#define COLORTABLET 31 +#define COLORSHIELD 31 +#define COLORVP 34 + +#define COLORRESOURCE 36 +#define COLORINDUSTRY 0 +#define COLORSTRUCTURE 34 +#define COLORCOMMERCIAL 33 +#define COLORMILITARY 31 +#define COLORSCIENTIFIC 32 +#define COLORGUILD 35 @@ -71,7 +71,7 @@ void cards_updatecoupons() void cards_setname(int era, int card, char *name, int type) { int i; - for(i = 0; (cards[era][card][i+1+NUMRESOURCES+NUMPRODUCTS+4] = name[i]) != '\0'; i++); + for(i = 0; (cards[era][card][i+1+NUMRESOURCES+NUMPRODUCTS+8] = name[i]) != '\0'; i++); cards_settype(era, card, type); } @@ -79,10 +79,30 @@ char* cards_getname(int era, int card) { char *ret = get_chararray(26); int i; - for(i = 0; (ret[i] = cards[era][card][i+1+NUMRESOURCES+NUMPRODUCTS+4]) != '\0'; i++); + for(i = 0; (ret[i] = cards[era][card][i+1+NUMRESOURCES+NUMPRODUCTS+8]) != '\0'; i++); return ret; } +char* getname(int res) +{ + switch(res) { + case WOOD: return "wood"; + case STONE: return "stone"; + case CLAY: return "clay"; + case ORE: return "ore"; + case CLOTH: return "cloth"; + case GLASS: return "glass"; + case PAPER: return "paper"; + case GOLD: return "gold"; + case COMPASS: return "compass"; + case GEAR: return "gear"; + case TABLET: return "tablet"; + case SHIELD: return "shield"; + case VP: return "vp"; + default: return "error"; + } +} + void cards_init() { //Era 1 @@ -0,0 +1,15 @@ +#include "7w.h" + +int gettypecolor(int type) +{ + switch(type) { + case RESOURCE: return COLORRESOURCE; + case INDUSTRY: return COLORINDUSTRY; + case STRUCTURE: return COLORSTRUCTURE; + case COMMERCIAL: return COLORCOMMERCIAL; + case MILITARY: return COLORMILITARY; + case SCIENTIFIC: return COLORSCIENTIFIC; + case GUILD: return COLORGUILD; + default: return 0; + } +} @@ -6,6 +6,8 @@ char* cards_getname(int era, int card); int* cards_getcost(int era, int card); int cards_gettype(int era, int card); int* cards_getproduction(int era, int card); +char* getname(int res); +int gettypecolor(int type); void io_init() { @@ -19,6 +21,8 @@ void io_init() use_default_colors(); //This may seem slightly conveluted, but it's the curses way. + init_pair(0, A_NORMAL, -1); + init_pair(30, COLOR_BLACK, -1); init_pair(31, COLOR_RED, -1); init_pair(32, COLOR_GREEN, -1); init_pair(33, COLOR_YELLOW, -1); @@ -57,12 +61,26 @@ int c; void io_printcard(int x, int y, int era, int card) { - mvprintw(y++, x, " ______________________"); - mvprintw(y++, x, "| %20s |", cards_getname(era, card)); - mvprintw(y++, x, "|Cost: Produces: |"); + mvprintw(y++, x, "################################"); + mvprintw(y++, x, "# "); + attron(COLOR_PAIR(gettypecolor(cards_gettype(era, card)))); + printw("%-28s", cards_getname(era, card)); + attrset(A_NORMAL); + printw(" #"); + mvprintw(y++, x, "# Cost (and): | Products (or): #"); int *costs = cards_getcost(era, card); - int i; - for(i = 0; i < NUMRESOURCES; i++) - - mvprintw(y++, x, "|______________________|"); + int *products = cards_getproduction(era, card); + int i, j; + i = j = -1; + while(i < NUMRESOURCES || j < NUMPRODUCTS) { + while(i < NUMRESOURCES && costs[++i] == 0); + while(j < NUMPRODUCTS && products[++j] == 0); + if(i == NUMRESOURCES && j == NUMPRODUCTS) break; + mvprintw(y++, x, "# "); + if(i < NUMRESOURCES) printw(" %d %-9s| ", costs[i], getname(i)); + else printw(" | "); + if(j < NUMPRODUCTS) printw(" %d %-11s #", products[j], getname(j)); + else printw(" #"); + } + mvprintw(y++, x, "################################"); } @@ -16,7 +16,9 @@ main() io_init(); cards_init(); io_printcard(0, 0, 0, 0); - io_printcard(0, 10, 0, 1); + io_printcard(0, 4, 2, 14); + io_printcard(0, 10, 2, 3); + io_printcard(31, 0, 1, 12); io_getkey(); halt(); } |