36Box

By eqrunner on Feb 02, 2010

A pick a box and get points game that was created for a fellow forum user.

You pick a number and get points based on what is in the box.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 36box ;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;; by eqrunner ;;

/*
!pick ##   = nick picks a number
!36box start  =  starts a game (picks numbers)
!36box clear  =  clears everything
!36box remain =  show remaining boxes
!36box scores =  shows the scores for each nick
*/

ON *:START: {
  hmake 36box 50
  if ($isfile(36box.dat)) { hload 36box 36box.dat }
  hmake 36box_nick 36
  if ($isfile(36box_nick.dat)) { hload 36box_nick 36box_nick.dat }
}
ON *:EXIT: {
  if ($hget(36box)) { hsave -o 36box 36box.dat }
  if ($hget(36box_nick)) { hsave -o 36box_nick 36box_nick.dat }
}

on $*:text:/^[!](36box|pick)/Si:#: {

  if ($1 == !36box) {
    if ($2 == start) {
      var %i = 1
      while (%i <= 36) {
        var %num $rand(1,100)
        hadd 36box $+(box_,%i) %num
        inc %i
      }
      msg $chan 36box STARTED
    }
    if ($2 == clear) {
      hfree 36box
      hfree 36box_nick
      hmake 36box 36
      hmake 36box_nick
      msg $chan 36box CLEARED
    }
    if ($2 == remain) {
      var %i = 1
      while (%i <= 36) {
        var %box_i $($+(box_,%i))
        if ($hfind(36box,%box_i) != $null) {
          set %box_i $remove(%box_i,box_)
          set %box_remain $addtok(%box_remain,%box_i,32)) 
        }
        inc %i
      }
      msg $chan Boxes remaining: %box_remain
    }
    if ($2 == scores) {
      var %i = 1
      while ( $hget(36box_nick,%i).item ) {
        var %item = $ifmatch
        var %data = $hget(36box_nick,%i).data
        tokenize 32 %data
        set %box_scores $addtok(%box_scores,$($+(%item,$chr(58),$1)),32)
        inc %i
      }
      msg $chan Scores: %box_scores
    }
  }

  if ($1 == !pick) {
    var %box_i $($+(box_,$2))
    if ($hfind(36box,%box_i) == $null) {
      msg $chan That box has already been picked.
      var %i = 1
      while (%i <= 36) {
        var %box_i $($+(box_,%i))
        if ($hfind(36box,%box_i) != $null) {
          set %box_i $remove(%box_i,box_)
          set %box_remain $addtok(%box_remain,%box_i,32)) 
        }
        inc %i
      }
      msg $chan Boxes remaining: %box_remain
    }
    if ($hfind(36box,%box_i) != $null) {
      if ($hfind(36box_nick,$nick) != $null) {
        tokenize 32 $hget(36box_nick,$nick)
        msg $chan You already picked Box $remove($2,box_) and won $1 
      }
      if ($hfind(36box_nick,$nick) == $null) {
        hadd -u60 36box_nick $nick $hget(36box,%box_i) %box_i
        msg $chan You won $hget(36box,%box_i) point(s)
        hdel 36box $+(box_,$2)
      }
    }
  }
  unset %box_*
  ;echo -s end of boxparty
}

Comments

Sign in to comment.
Bad_Girl   -  Feb 02, 2010

in this game don't appears this message
Boxes remaining:........
and the player could lose points also
kiss

 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.