Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 3.58 KB | None | 0 0
  1. ;; there are 4 parts
  2.  
  3. ;; Part one, starting the game
  4.  
  5. on *:TEXT:!rps:#*:{
  6.   if ( !%rps.playerone ) {
  7.     /msg $chan Type !joinRPS to join in the fun :)
  8.     /set %rps.playerone $nick
  9.     /set %rps.chan $chan
  10.     /halt
  11.   }
  12.   /msg $chan There is already a game being played. Try agin in a bit.
  13. }
  14.  
  15.  
  16. ;; Part two player #2 joining the game
  17. ;;   also messages players on how to make a selection
  18.  
  19. on *:TEXT:!joinrps:#*:{
  20.   if ( !%rps.playerone ) { /msg $chan Type !rps to start a new game. | halt }
  21.   if ($nick == %rps.playerone ) { /msg $chan So... you like playing with yourself, do you? Very naughty ;) Type !rpsbot for that ;) | /unset %rps.* | /halt }
  22.   /set %rps.playertwo $nick
  23.   /notice %rps.playerone Type /msg PsiBot !rpschoice <rock, paper, scissors>
  24.   /notice %rps.playertwo Type /msg PsiBot !rpschoice <rock, paper, scissors>
  25. }
  26.  
  27. ;; Part three receiving the players choices and evaluating them
  28. ;;   also messages the outcome and ends the game
  29.  
  30. on *:TEXT:!rpschoice*:?:{
  31.   if ( !%rps.playerone ) { /msg $nick Type !rps to start a new game. | halt }
  32.   if ( !%rps.playertwo ) { /msg $nick So... you like playing with yourself, do you? Very naughty ;) Type !rpsbot for that  ;) | /unset %rps.* | /halt }
  33.   if ( !$2 ) { /msg $nick You need to make a selection | halt }
  34.   /set %rps.choice none
  35.   if ( $2 == rock ) /set %rps.choice Rock
  36.   if ( $2 == paper ) /set %rps.choice Paper
  37.   if ( $2 == scissors ) /set %rps.choice Scissors
  38.   if ( %rps.choice == none ) { /unset %rps.choice | /msg $nick Please make a propper selection | /halt }
  39.   if ( $nick != %rps.playerone ) {
  40.     if ( $nick != %rps.playertwo ) {
  41.       /unset %rps.choice
  42.       /msg $nick Sorry, you aren't in this game, try again next time
  43.      /halt
  44.    }
  45.  }
  46.  if ( %rps.playerone == $nick ) {
  47.    /set %rps.onechoice %rps.choice
  48.    if ( !%rps.twochoice ) { /unset %rps.choice | /msg %rps.chan Waiting on %rps.playertwo to take thier turn. | /halt }
  49.  }
  50.  if ( %rps.playertwo == $nick ) {
  51.    /set %rps.twochoice %rps.choice
  52.    if ( !%rps.onechoice ) { /unset %rps.choice | /msg %rps.chan Waiting on %rps.playerone to take thier turn. | /halt }
  53.  }
  54.  if ( %rps.onechoice == Rock ) {
  55.    if ( %rps.twochoice == Rock )  /msg %rps.chan %rps.playerone and %rps.playertwo both picked Rock. It is a TIE!
  56.    if ( %rps.twochoice == Paper )  /msg %rps.chan %rps.playerone picked Rock and %rps.playertwo picked Paper. %rps.playertwo WINS!
  57.    if ( %rps.twochoice == Scissors ) /msg %rps.chan %rps.playerone picked Rock and %rps.playertwo picked Scissors. %rps.playerone WINS!
  58.  }
  59.  if ( %rps.onechoice == Paper ) {  
  60.    if ( %rps.twochoice == Rock ) /msg %rps.chan %rps.playerone picked Paper and %rps.playertwo picked Rock. %rps.playerone WINS!
  61.    if ( %rps.twochoice == Paper ) /msg %rps.chan %rps.playerone and %rps.playertwo both picked Psper. It is a TIE!
  62.    if ( %rps.twochoice == Scissors ) /msg %rps.chan %rps.playerone picked Paper and %rps.playertwo picked Scissors. %rps.playertwo WINS!
  63.  }
  64.  if ( %rps.onechoice == Scissors ) {
  65.    if ( %rps.twochoice == Rock )  /msg %rps.chan %rps.playerone picked Scissors and %rps.playertwo picked Rock. %rps.playertwo WINS!
  66.    if ( %rps.twochoice == Paper )  /msg %rps.chan %rps.playerone picked Scissors and %rps.playertwo picked Paper. %rps.playerone WINS!
  67.    if ( %rps.twochoice == Scissors ) /msg %rps.chan %rps.playerone and %rps.playertwo both picked Scissors. It is a TIE!
  68.  }
  69.  /unset %rps.*
  70. }
  71.  
  72. ;;Part four: terminating the game
  73. ;; if one of the participants leaves, this option allows for the game to be terminated
  74.  
  75. on *:TEXT:!rpskill:#*:{ /unset %rps.* | /msg $chan done }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement