summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/screen.c45
-rw-r--r--src/screen.h27
2 files changed, 60 insertions, 12 deletions
diff --git a/src/screen.c b/src/screen.c
index fa5bb28..5fe2822 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -175,6 +175,9 @@ static int docolors(void) {
175 init_rgb_color(CC_WHITE, 255, 255, 255); 175 init_rgb_color(CC_WHITE, 255, 255, 255);
176 init_rgb_color(CC_BLACK, 0, 0, 0); 176 init_rgb_color(CC_BLACK, 0, 0, 0);
177 177
178 init_rgb_color(CC_WINNING, 232, 185, 35);
179
180
178 init_pair(CCP_TESTING, CC_RED, CC_WHITE); 181 init_pair(CCP_TESTING, CC_RED, CC_WHITE);
179 init_pair(CCP_BANNER, CC_WHITE, CURSES_BLUE); 182 init_pair(CCP_BANNER, CC_WHITE, CURSES_BLUE);
180 183
@@ -186,6 +189,9 @@ static int docolors(void) {
186 init_pair(CCP_PURPLE, CC_WHITE, CC_PURPLE); 189 init_pair(CCP_PURPLE, CC_WHITE, CC_PURPLE);
187 init_pair(CCP_MAGENTA, CC_WHITE, CC_MAGENTA); 190 init_pair(CCP_MAGENTA, CC_WHITE, CC_MAGENTA);
188 init_pair(CCP_WHITE, CC_BLACK, CC_WHITE); 191 init_pair(CCP_WHITE, CC_BLACK, CC_WHITE);
192
193 init_pair(CCP_WINNING1, CC_WHITE, CC_WINNING);
194 init_pair(CCP_WINNING2, CC_WINNING, CC_WHITE);
189 } else { 195 } else {
190 endwin(); 196 endwin();
191 error(1, ENOTSUP, "[VX-GAMBLEGROUND] Colors are not supported on your terminal"); 197 error(1, ENOTSUP, "[VX-GAMBLEGROUND] Colors are not supported on your terminal");
@@ -449,10 +455,16 @@ int spin(void *params) {
449 /* Previous solution fucked it by changing the actual color when it's supposed to be the default color to revert back to 455 /* Previous solution fucked it by changing the actual color when it's supposed to be the default color to revert back to
450 // This works better, but is also more ugly. So be it */ 456 // This works better, but is also more ugly. So be it */
451 wbkgd(p->slots->subslot[subs], COLOR_PAIR(rangemod(CCP_CURSES_DEFAULT, i + CCP_RED, CCP_RED, CCP_WHITE))); 457 wbkgd(p->slots->subslot[subs], COLOR_PAIR(rangemod(CCP_CURSES_DEFAULT, i + CCP_RED, CCP_RED, CCP_WHITE)));
452 458
459 #ifndef TESTING
453 p->slots->slotchar[subs][2] = p->slots->slotchar[subs][1]; 460 p->slots->slotchar[subs][2] = p->slots->slotchar[subs][1];
454 p->slots->slotchar[subs][1] = p->slots->slotchar[subs][0]; 461 p->slots->slotchar[subs][1] = p->slots->slotchar[subs][0];
455 p->slots->slotchar[subs][0] = randombytes_uniform('~' - '!' + 1) + '!'; 462 p->slots->slotchar[subs][0] = randombytes_uniform('~' - '!' + 1) + '!';
463 #endif
464
465 #ifdef TESTING
466 p->slots->slotchar[subs][1] = '7';
467 #endif
456 468
457 // Update characters & draw them 469 // Update characters & draw them
458 int my, mx; 470 int my, mx;
@@ -468,6 +480,37 @@ int spin(void *params) {
468 nanosleep(&sleeper, NULL); 480 nanosleep(&sleeper, NULL);
469 } 481 }
470 482
483 // Check to see if user has won a jackpot
484 int winning = 0;
485 for(size_t i = 0; i < STATIC_ARRSIZE(p->slots->subslot); i++) {
486 if(p->slots->slotchar[i][1] == '7')
487 winning++;
488 }
489 if(winning == 3) {
490 // Do winning anim
491 mvaddch(0, 0, 'J');
492 for(int i = 0, color = CCP_WINNING1;; i++, color = rangemod(color, 1, CCP_WINNING1, CCP_WINNING2)) {
493 // wbkgd(p->bannerwin, COLOR_PAIR(color));
494 // wbkgd(p->menuholder, COLOR_PAIR(color));
495
496 // wbkgd(p->slots->slotwin, COLOR_PAIR(rangemod(color, 1, CCP_WINNING1, CCP_WINNING2)));
497 // for(size_t j = 0; j < STATIC_ARRSIZE(p->slots->subslot); j++) {
498 // wbkgd(p->slots->subslot[j], COLOR_PAIR(rangemod(color, j + 1, CCP_WINNING1, CCP_WINNING2)));
499 // wnoutrefresh(p->slots->subslot[j]);
500 // }
501
502 // wnoutrefresh(p->bannerwin);
503 // wnoutrefresh(p->menuholder);
504 // wnoutrefresh(p->slots->slotwin);
505
506 bkgd(COLOR_PAIR(color));
507 addch("JACKPOT"[rangemod(i, 1, 0, 6)]);
508
509 refresh();
510 nanosleep(&sleeper, NULL);
511 }
512 }
513
471 // Revert colors back to normal 514 // Revert colors back to normal
472 wbkgd(p->bannerwin, COLOR_PAIR(CCP_BANNER)); 515 wbkgd(p->bannerwin, COLOR_PAIR(CCP_BANNER));
473 wnoutrefresh(p->bannerwin); 516 wnoutrefresh(p->bannerwin);
diff --git a/src/screen.h b/src/screen.h
index 22211b4..25cd8fa 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -41,6 +41,8 @@ enum custom_colors {
41 CC_WHITE, // RGB: 255, 255, 255 41 CC_WHITE, // RGB: 255, 255, 255
42 CC_BLACK, // RGB: 0, 0, 0 42 CC_BLACK, // RGB: 0, 0, 0
43 43
44 CC_WINNING, // RGB: 232, 185, 35
45
44 // This isn't actually a color, even if you try to use it as one 46 // This isn't actually a color, even if you try to use it as one
45 CC_TOOBIG 47 CC_TOOBIG
46}; 48};
@@ -50,17 +52,20 @@ enum customcolor_pairs {
50 52
51 CCP_CURSES_DEFAULT = 0, 53 CCP_CURSES_DEFAULT = 0,
52 54
53 CCP_TESTING, 55 CCP_TESTING, // Text: White, BG: Red
54 CCP_BANNER, 56 CCP_BANNER, // Text: White, BG: Curses' Blue
55 57
56 CCP_RED, 58 CCP_RED, // Text: White, BG: Red
57 CCP_ORANGE, 59 CCP_ORANGE, // Text: Black, BG: Orange
58 CCP_YELLOW, 60 CCP_YELLOW, // Text: Black, BG: Yellow
59 CCP_GREEN, 61 CCP_GREEN, // Text: Black, BG: Green
60 CCP_BLUE, 62 CCP_BLUE, // Text: White, BG: Blue
61 CCP_PURPLE, 63 CCP_PURPLE, // Text: White, BG: Purple
62 CCP_MAGENTA, 64 CCP_MAGENTA, // Text: White, BG: Magenta
63 CCP_WHITE, 65 CCP_WHITE, // Text: Black, BG: White
66
67 CCP_WINNING1, // Text: White, BG: Gold
68 CCP_WINNING2, // Text: Gold, BG: White
64 69
65 CCP_TOOBIG 70 CCP_TOOBIG
66}; 71};