Rock paper scissors

By asakura on Jul 29, 2008

i dont know if this is really useful to be honest i was just bored lol

menu * {
  .rps:dialog -m rps rps
}
dialog rps {
  title "Rock Paper Scissors"
  size -1 -1 250 165
  option pixels
  box "Settings", 1, 5 5 240 155
  button "Rock" 10, 75 25 100 20
  button "Scissors" 11, 75 75 100 20
  button "Paper" 12, 75 50 100 20
  edit "" 16, 15 105 210 20, read autohs
  edit "" 17, 15 130 210 20, read autohs
}
on *:DIALOG:rps:sclick:*:{ 
  if ($did = 10) { set %choice 1 | win }
  if ($did = 11) { set %choice 2 | win }
  if ($did = 12) { set %choice 3 | win }
}
alias win {
  set %rps $rand(1,3)
  if (%rps = 1) { set %rps.game Rock }
  elseif (%rps = 2) { set %rps.game paper }
  elseif (%rps = 3) { set %rps.game scissors } 
  if (%rps.game = rock) && (%choice = 1) { did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game | did -ra $dname 17 we tied! }
  elseif (%rps.game = paper) && (%choice = 3) { did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game | did -ra $dname 17 we tied! }
  elseif (%rps.game = scissors) && (%choice = 2) { did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game | did -ra $dname 17 we tied! }
  elseif (%rps.game = rock) && (%choice = 2) { did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game  | did -ra $dname 17 you lose!
  }
  elseif (%rps.game = paper) && (%choice = 1) { 
    did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game  | did -ra $dname 17 you lose!
  }
  elseif (%rps.game = scissors) && (%choice = 3) { 
    did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game  | did -ra $dname 17 you lose!
  }
  elseif (%rps.game = rock) && (%choice = 3) { 
    did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game | did -ra $dname 17 you win!
  }
  elseif (%rps.game = paper) && (%choice = 2) { 
    did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game | did -ra $dname 17 you win!
  }
  elseif (%rps.game = scissors) && (%choice = 1) { 
  did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game | did -ra $dname 17 you win! }
}

Comments

Sign in to comment.
asakura   -  Jul 29, 2008

i will change it soon... :p when i get time alot of my time goes 2 course work or msn

 Respond  
wizard38   -  Jul 29, 2008

perhaps the game would be more useful in the room and play with time, the players choose paper or scissors rock and wait perhaps a minute and the game chose what it wanted
\" you chose paper and you lose 20 points \"
but it is just a thought

 Respond  
asakura   -  Jul 29, 2008

meh i know but i had like 5 mins to do sumit quick so i just used a part of my old rps script and turned it to a dialog

 Respond  
guest598594   -  Jul 29, 2008

In the dialog, when you choose something, why not set the var as the item chosen instead of a number? That\'ll save you the $replace\'s later on.

And btw, you can call an alias with parameters, so you could skip the var and just do \"win rock\" or \"win scissors\" and then refer to that as $1.

Also,

  set %rps $rand(1,3)
  if (%rps = 1) { set %rps.game Rock }
  elseif (%rps = 2) { set %rps.game paper }
  elseif (%rps = 3) { set %rps.game scissors } 

I\'d use /var, and you could do

  var %rps = $gettok(Rock Paper Scissors,$r(1,3),32)

And in the rest of the win alias, since you repeat one action in every if, all you really have to do is

  did -ra $dname 16 You picked $replace(%choice,1,rock,2,scissors,3,paper) and I chose %rps.game
  if (%rps.game == paper) && (%choice == 1) { did -ra $dname 17 you lose! }
  ;etc.

But as I said earlier, if you set the var as the action instead of a number, you could simply check if (%rps.game == %choice) for ties.

 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.