RPS

By ChrisP on Dec 20, 2010

A simple game that will entertain some.

on *:TEXT:!rps:#: {
  if (%rps == on) {
    msg $chan RPS is already on.
  }
  else {
    msg $chan $nick has started rock, paper, scissors! Type !join to join.
    set %player1 $nick
    set %player1taken yes
    set %rps on
    set %chan $chan
  }
}

on *:TEXT:!join:#: {
  if (%rps == on) && (%player2taken == yes) {
    msg %chan You can not join. Someone is already playing.
  }
  elseif ($nick == %player1) {
    msg $chan You can not play against yourself!
  }
  elseif (%rps == on) {
    msg %chan $nick has joined the game!
    set %player2 $nick
    set %player2taken yes
    rpsjoin
  }
  elseif (%rps == off) {
    msg $chan RPS is off. To turn on RPS, type !rps
  }
}

on *:TEXT:!stop:#: {
  if (%rps == on) {
    if ($nick == %player1 || $nick == %player2) {
      msg %chan $nick has stopped the RPS Game.
      set %rps off
      unset %player1
      unset %player2
      unset %player1taken
      unset %player2taken
      rpsoff
    }
  }
}

on *:TEXT:*:#: {
  if (%rpson == on) {
    if ($nick == %player1) {
      if ($1 == !rock) { set %player1object rock }
      if ($1 == !paper) { set %player1object paper }
      if ($1 == !scissors) { set %player1object scissors }
    }
    if ($nick == %player2) {
      if ($1 == ~rock) { set %player2object rock }
      if ($1 == ~paper) { set %player2object paper }
      if ($1 == ~scissors) { set %player2object scissors }
    }
  }
}

alias rpsjoin {
  if (%rps == on) {
    msg %chan You have 5 seconds to put in your answer!
    msg %chan %player1 use !rock, !paper, and !scissors
    msg %chan %player2 use ~rock, ~paper, and ~scissors
    set %rpson on
    rps
  }
}

alias rps {
  if (%rpson == on) {
    timerrps1 1 5 msg %chan 4Rock
    timerrps2 1 6 msg %chan 3Paper
    timerrps3 1 7 msg %chan 12Scissors
    timerrps4 1 8 msg %chan 10Shoot!
    timerrps5 1 13 rpsblank
  }
}
alias rpsoff {
  timerrps* off
}

alias rpsblank {
  if (%player1object == $null || %player2object == $null) {
    msg %chan Someone didn't put their answer in!
  }
  else { 
    rpscheck
  }
}

alias rpsstop {
  unset %player1
  unset %player2
  unset %player1taken
  unset %player2taken
  unset %player1object
  unset %player2object
  set %rps off
  set %rpson off
}

alias rpscheck {
  if (%player1object == rock) && (%player2object == rock) {
    msg %chan It is a tie!
  }
  if (%player1object == paper) && (%player2object == paper) {
    msg %chan It is a tie!
  }
  if (%player1object == scissors) && (%player2object == scissors) {
    msg %chan It is a tie!
  }
  if (%player1object == rock) && (%player2object == scissors) {
    msg %chan %player1 won!
  }
  if (%player1object == rock) && (%player2object == paper) {
    msg %chan %player2 won!
  }
  if (%player1object == paper) && (%player2object == rock) {
    msg %chan %player1 won!
  }
  if (%player1object == paper) && (%player2object == scissors) {
    msg %chan %player2 won!
  }
  if (%player1object == scissors) && (%player2object == paper) {
    msg %chan %player1 won!
  }
  if (%player1object == scissors) && (%player2object rock) {
    msg %chan %player2 won!
  }
  rpsstop
}

Comments

Sign in to comment.
Jethro   -  Dec 23, 2010

Burrito, I will suggest that you set up the dynamic variable as such:

$+(%,var,.,$chan,.,$network,.,$cid)

The reason being if you're on another network with the same channel name, the var will mistake it for the current channel on the other network.

 Respond  
Burrito   -  Dec 23, 2010

You should use variables such as %var $+ $chan and so on to make it work in multiple channels.

 Respond  
cupcake   -  Dec 20, 2010

yeah, what Tidum said ...LoL

 Respond  
Tidum   -  Dec 20, 2010

It's an images from his topic script.

 Respond  
Jethro   -  Dec 20, 2010

Can anyone read Chris's avatar? All I see is a smear of string.

 Respond  
Tidum   -  Dec 20, 2010
  if (%rps == on) && (%player2taken == yes) {

Could just be:

  if (%rps == on) && (%player2) {

As you're just checking if the variable is set.

 Respond  
Jethro   -  Dec 20, 2010

Use one text event with if the elseif for each routine. No need to go the extra mile for several bits of text event.

/unset %1var %2var %3var etc...

This way you don't have to reiterate the /unset every time.

 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.