Zmodem commented on a Page, !21 Cards bot Game  -  Aug 25, 2008

Shoot me now, but here is a quick, sort-of English re-write. This code is too messy, I didn't bother cleaning it up, but here it is with a more English pazazz!

;##############################################
;## !21 cards game ############################
;######################### by rhasttaff  ######
;##############################################
on *:text:!21:#: {
  if (%21jog !== on) {
    set %21jog on
    set %21jogador-1 $nick
    /msg $chan This Game Requires 2 Players. Someone needs to type !21 to play against you within 60 seconds.
    .timer_encerra-21 1 62 /encerra-21 $chan
    set %21para-jog-1 off
    halt
  }
  if (%21jog == on) && (!%21jogador-2) {
    /timer_21-um-so off
    set %21jogador-2 $nick
    /notice %21jogador-1 This is the 21 Cards game! Whomever gets their cards to equal the number: 21 wins the game! 
    /notice %21jogador-2 This is the 21 Cards game! Whomever gets their cards to equal the number: 21 wins the game!
    /msg $chan Game Started!! 9-14=[12 %21jogador-1 14]=9- 7& 9-14=[2 %21jogador-2 14]=9-
    /msg $chan Player: 9-14=[12 %21jogador-1 14]=9- it is now your turn! type 4!card $+ . You have 60 seconds to play...
    set %21jogada-jog 1
    set %21para-jog-2 off
    .timer_encerra-21 1 62 /encerra-21 $chan
  }
}
on *:text:!card:#: {
  if (%21jogada-jog == 1) && ($nick == %21jogador-1) {
    set %carta-jog-1 $rand(1,13)
    if (!%cartas-valor-jog-1) {
      set %cartas-valor-jog-1 %carta-jog-1
      set %cartas-jog-1 $passa-carta(%carta-jog-1)
      set %21jogada-jog 2
      /notice $nick Your cards: %cartas-jog-1
      /notice $nick Your total: %cartas-valor-jog-1
      /calcula-proxima-oupara %cartas-valor-jog-1 %21jogador-1 $chan
    }
    else {
      set %21jogada-jog 2
      set %cartas-valor-jog-1 $calc(%cartas-valor-jog-1 + %carta-jog-1)
      set %cartas-jog-1 %cartas-jog-1 $passa-carta(%carta-jog-1)
      /notice $nick Your cards: %cartas-jog-1
      /notice $nick Your total: %cartas-valor-jog-1
      /calcula-proxima-oupara %cartas-valor-jog-1 %21jogador-1 $chan
    }
  }
  if (%21jogada-jog == 2)  && ($nick == %21jogador-2) {
    set %carta-jog-2 $rand(1,13)
    if (!%cartas-valor-jog-2) {
      set %cartas-valor-jog-2 %carta-jog-2
      set %cartas-jog-2 $passa-carta(%carta-jog-2)
      set %21jogada-jog 1
      /notice $nick Your cards: %cartas-jog-2
      /notice $nick Your total: %cartas-valor-jog-2
      /calcula-proxima-oupara %cartas-valor-jog-2 %21jogador-2 $chan
    }
    else {
      set %21jogada-jog 1
      set %cartas-valor-jog-2 $calc(%cartas-valor-jog-2 + %carta-jog-2)
      set %cartas-jog-2 %cartas-jog-2 $passa-carta(%carta-jog-2)
      /notice $nick Your cards: %cartas-jog-2
      /notice $nick Your total: %cartas-valor-jog-2
      /calcula-proxima-oupara %cartas-valor-jog-2 %21jogador-2 $chan
    }
  }
}
alias encerra-21 {
  if (%21jog == on) {
    quem-ganha-21 $1
  }
  else {
    acaba-21
  }
}
alias calcula-proxima-oupara {
  if ($1 > 21) && ($2 == %21jogador-1)  { /msg $3 12[4 BOOOOOOOOOOMMMM!!!!12] 9-14=[12 $2 14]=9- Explodes with the cards  %cartas-jog-1  Totaling:4 %cartas-valor-jog-1 |  /timer_encerra-21 off | /msg $3 Winner  9-14=[2 %21jogador-2 14]=9- with the Cards %cartas-jog-2 Totalizing:4 %cartas-valor-jog-2  | /acaba-21 | halt }
  if ($1 == 21) && ($2 == %21jogador-1)  { /msg $3 Winner: 9-14=[12 %21jogador-1 14]=9- with the cards %cartas-jog-1 Totaling:4 %cartas-valor-jog-1 |  /timer_encerra-21 off | /acaba-21 | halt }
  if ($1 < 21) && ($2 == %21jogador-1) {
    if (%21para-jog-2 !== on) { /msg $3 9-14=[2 %21jogador-2 14]=9- Your Turn! Type 4 !card  for one more card or type 4 !compare  To compare the cards and end the game! You have 60 seconds... }
    if (%21para-jog-2 == on) { set %21jogada-jog 1 | /msg $3 9-14=[12 %21jogador-1 14]=9- You rule! Type 4 !card  for one more card or type 4 !compare  To compare the cards and end the game! You have 60 seconds...  |  .timer_encerra-21 1 62 /encerra-21 $3 | halt }
  }
  if ($1 > 21) && ($2 == %21jogador-2) { /msg $3 12[4 BOOOOOOOOOOMMMM!!!!12] 9-14=[2 $2 14]=9- Explodes with the cards %cartas-jog-2 Totaling:4 %cartas-valor-jog-2 | /msg $3 Winner 9-14=[12 %21jogador-1 14]=9- with the Cards %cartas-jog-1 Totaling:4 %cartas-valor-jog-1  |  /timer_encerra-21 off | /acaba-21 | halt }
  if ($1 == 21) && ($2 == %21jogador-2) { /msg $3 Winner 9-14=[2 %21jogador-2 14]=9- with the cards  %cartas-jog-2 Totaling:4 %cartas-valor-jog-2  |   /timer_encerra-21 off | /acaba-21 | halt }
  if ($1 < 21) && ($2 == %21jogador-2) {
    if (%21para-jog-1 !== on) { /msg $3 9-14=[12 %21jogador-1 14]=9- Your Turn! Type 4 !card  for one more card or type 4 !compare  To compare the cards and end the game! You have 60 seconds... | halt }
    if (%21para-jog-1 == on)  { set %21jogada-jog 2 | /msg $3  9-14=[2 %21jogador-2 14]=9- You rule! Type 4 !card  for one more card or type 4 !compare  To compare the cards and end the game! You have 60 seconds...  |  .timer_encerra-21 1 62 /encerra-21 $3 | halt }
  }
}
alias acaba-21 {
  set %21jog off
  unset %21jogador-1 %21jogador-2 %cartas-valor-jog-1 %cartas-jog-1 %cartas-valor-jog-2 %cartas-jog-2
}
on *:text:!compare:#: {
  if (%21jogada-jog == 1) {
    if ($nick == %21jogador-1) && (%21para-jog-2 !== on) { /set %21para-jog-1 on | set %21jogada-jog 2 | /msg $chan   9-14=[2 %21jogador-2 14]=9-  You rule! Type 4 !card  for one more card or type 4 !compare  To compare the cards and end the game! You have 60 seconds... |  .timer_encerra-21 1 62 /encerra-21 $chan }
    if ($nick == %21jogador-1) && (%21para-jog-2 == on) { /quem-ganha-21 $chan |  /timer_encerra-21 off }
  }
  if (%21jogada-jog == 2) {
    if ($nick == %21jogador-2) && (%21para-jog-1 !== on) { /set %21para-jog-2 on | set %21jogada-jog 1 | /msg $chan   9-14=[12 %21jogador-1 14]=9- You rule! Type 4 !card  for one more card or type 4 !compare  To compare the cards and end the game! You have 60 seconds... |  .timer_encerra-21 1 62 /encerra-21 $chan }
    if ($nick == %21jogador-2) && (%21para-jog-1 == on) { /quem-ganha-21 $chan |  /timer_encerra-21 off }
  }
}
alias quem-ganha-21 {
  set %21total-jog-1 $calc(21 - %cartas-valor-jog-1)
  set %21total-jog-2 $calc(21 - %cartas-valor-jog-2)
  if (%21total-jog-1 < %21total-jog-2) {  /timer_encerra-21 off | /msg $1 Winner 9-14=[12 %21jogador-1 14]=9- with the Cards %cartas-jog-1 Totaling:4 %cartas-valor-jog-1 | /msg $1 Against the Cards: %cartas-jog-2 Of 9-14=[2 %21jogador-2 14]=9- Totaling:4 %cartas-valor-jog-2 | /acaba-21 | halt }
  if (%21total-jog-1 > %21total-jog-2) {  .timer_encerra-21 off | /msg $1 Winner  9-14=[2 %21jogador-2 14]=9- with the Cards %cartas-jog-2 Totaling:4 %cartas-valor-jog-2  | /msg $1 Against the Cards: %cartas-jog-1 Of 9-14=[2 %21jogador-1 14]=9- Totaling:4 %cartas-valor-jog-1  | /acaba-21 | halt }
  if (%21total-jog-1 == %21total-jog-2) {  .timer_encerra-21 off | /msg $1 This Game have no winner! | /acaba-21 | halt } 
}
alias passa-carta {
  set %21cor  $rand(1,2)
  if (%21cor == 1) { set %21cort 1 }
  if (%21cor == 2) { set %21cort 4 }
  if ($1 == 1) { return  $+ %21cort $+ ,0 $+ [A] }
  if ($1 == 2) { return  $+ %21cort $+ ,0 $+ [2] }
  if ($1 == 3) { return  $+ %21cort $+ ,0 $+ [3] }
  if ($1 == 4) { return  $+ %21cort $+ ,0 $+ [4] }
  if ($1 == 5) { return  $+ %21cort $+ ,0 $+ [5] }
  if ($1 == 6) { return  $+ %21cort $+ ,0 $+ [6] }
  if ($1 == 7) { return  $+ %21cort $+ ,0 $+ [7] }
  if ($1 == 8) { return  $+ %21cort $+ ,0 $+ [8] }
  if ($1 == 9) { return  $+ %21cort $+ ,0 $+ [9] }
  if ($1 == 10) { return  $+ %21cort $+ ,0 $+ [10] }
  if ($1 == 11) { return  $+ %21cort $+ ,0 $+ [J] }
  if ($1 == 12) { return  $+ %21cort $+ ,0 $+ [Q] }
  if ($1 == 13) { return  $+ %21cort $+ ,0 $+ [K] }
}

Why the Ace only equals 1 is beyond me; it makes as much sense as the J/Q/K = 11/12 & 13 respectively. It is mind-boggling pain! :-) This whole deal is crazy! If you were looking for a Black Jack alias, why didn't you make the Ace = 1 & 11 and the J/Q/K = 10? Writing the Ace to take both values inherently when needed is a trick in itself because how Black Jack works is if the Ace being 11 puts you over 21, the Ace is considered a 1 instead. However, it's vise-versa during fair-play within the 21 boundary. Ace is always 11, assuming it gets you at or around 21.

Whew, that was a mouthful. I hope I've been clear, I don't speak Spanish.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.