Skip to content

Instantly share code, notes, and snippets.

@shipof123
Created May 1, 2020 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shipof123/62f6327390eec81528c153ab668e2b28 to your computer and use it in GitHub Desktop.
Save shipof123/62f6327390eec81528c153ab668e2b28 to your computer and use it in GitHub Desktop.
char* process_cards(char deck[162]) {
char new_deck[54];
bool _JA = false;
bool _JB = false;
for (unsigned char i = 0, j = 0; i < 164; j++) {
switch(deck[i]) {
case 'J':
switch (deck[(i*3)+1]) {
case 'A':
JA_pos = j;
_JA = true;
new_deck[j] = JA;
break;
case 'B':
JB_pos = j;
_JA = true;
new_deck[j] = JB;
break;
}
i += 2;
break;
default:
new_deck[j] = (deck[i] == 'C')?
_CLV
: (deck[i] == 'D')? _DMD
: (deck[i] == 'H')? _HRT : _SPD;
new_deck[j] += (deck[i+1] == 0x31)? 10
: (deck[i+1] == 'J')? 11
: (deck[i+1] == 'Q')? 12
: (deck[i+1] =='K')? 13
: (deck[i+1] == 'A')? 1
: (deck[i+1] - 0x30);
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment