@@ -69,13 +69,16 @@ void __attribute__((section(".entry"))) start(uint16_t bootDrive)
69
69
for (;;);
70
70
}
71
71
72
- // look at all these if statements. very disgusting
72
+ // user input function. This could rank in my top 10 ugliest pieces of code to date. I'm
73
+ // sure as hell not fixing it lmao
73
74
74
75
void user_input (char * input ) {
75
76
int len = strlen (input );
76
77
char buffer [len + 1 ];
77
78
static char rizz [6 ];
78
79
static char dice [6 ];
80
+ static char umoney [6 ];
81
+ static char kmoney [6 ];
79
82
if (strcmp (rizz ,"True" ) == 0 ) {
80
83
int score = rizzScore (input );
81
84
printf ("\n" );
@@ -89,6 +92,29 @@ void user_input(char *input) {
89
92
printf (" he said in his native language\n" );
90
93
memcpy (rizz ,"False" ,strlen ("False" )+ 1 );
91
94
printf ("> " );
95
+ } else if (strcmp (dice ,"True" ) == 0 ) {
96
+ if (strcmp (input ,"exit" ) != 0 ) {
97
+ int score = convert (umoney );
98
+ int bscore = convert (kmoney );
99
+ int mroll = randint (6 ,1 ) + randint (6 ,1 );
100
+ int kroll = randint (6 ,1 ) + randint (6 ,1 );
101
+ if (mroll >= kroll ) {
102
+ score = score + convert (input );
103
+ bscore = bscore - convert (input );
104
+ } else {
105
+ score = score - convert (input );
106
+ bscore = bscore + convert (input );
107
+ }
108
+ memcpy (umoney ,itoa (score ,10 ),6 );
109
+ memcpy (kmoney ,itoa (bscore ,10 ),6 );
110
+ printf ("your roll: %d, klaud roll: %d\n" ,mroll ,kroll );
111
+ printf ("your money: %s, klaud money: %s\n" ,umoney ,kmoney );
112
+ printf ("Type 'exit' to leave the game\nPlace bet>" );
113
+ } else {
114
+ memcpy (dice ,"False" ,strlen ("False" )+ 1 );
115
+ clrscr ();
116
+ printf ("> " );
117
+ }
92
118
} else if (strlen (input ) <= 4 ) {
93
119
printf ("Every command starts with klaud, try again" );
94
120
printf ("\n> " );
@@ -168,12 +194,23 @@ void user_input(char *input) {
168
194
"Chewbacca was the person who convinced Klaud to join the Resistance"
169
195
};
170
196
int arrMax = * (& factList + 1 ) - factList ;
171
- int randNum = rand ( 32 )%(( arrMax + 1 ) - 0 ) + 0 ;
197
+ int randNum = randint ( arrMax , 0 ) ;
172
198
if (randNum == 12 ) {randNum = 11 ;} // im not sure why this works but oh well
173
199
printf ("%s\n> " ,factList [randNum ]);
174
200
} else if (strcmp (slice_str (input ,buffer ,0 ,9 ),"klaud plot" )== 0 ) {
175
201
graph (slice_str (input ,buffer ,11 ,len ),22 );
176
202
printf ("> " );
203
+ } else if (strcmp (slice_str (input ,buffer ,0 ,9 ),"klaud echo" )== 0 ) {
204
+ printf ("'%s' Klaud said in his native language" ,slice_str (input ,buffer ,11 ,len ));
205
+ printf ("\n> " );
206
+ } else if (strcmp (slice_str (input ,buffer ,0 ,9 ),"klaud dice" )== 0 ) {
207
+ memcpy (dice ,"True" ,strlen ("True" )+ 1 );
208
+ memcpy (umoney ,"500" ,strlen ("500" )+ 1 );
209
+ memcpy (kmoney ,"500" ,strlen ("500" )+ 1 );
210
+ clrscr ();
211
+ klaud_ascii ();
212
+ printf ("your money:%s, klaud money: %s" ,umoney ,kmoney );
213
+ printf ("\nPlace bet>" );
177
214
} else {
178
215
printf ("You said: %s, which is not a certified Klaud command. Use the klaud --help command." ,input );
179
216
printf ("\n> " );
0 commit comments