All pastes #2077332 Raw Edit

c5test

public text v1 · immutable
#2077332 ·published 2011-06-09 17:08 UTC
rendered paste body
  on *:TEXT:*:#c5test: {
    if ($1 == !c5join) && ($numtok($hget(Cop5,Players),32) < 5) && (!$istok($hget(Cop5,Players),$nick,32)) {
      hadd -m Cop5 Players $hget(Cop5,Players) $nick
      mode #c5test +v $nick
      msg #c5test $nick has joined c5.
    }
    if ($1 == !c5quit) && ($istok($hget(Cop5,Players),$nick,32)) && (!%c5act) {
      hadd -m Cop5 Players $remove($hget(Cop5,Players),$nick)
      mode #c5test -v $nick
      msg #c5test $nick has quit c5.
    }
    if ($1 == !c5reset) { endgame }
    if ($1 == !c5players) { msg #c5test Current/Living players: $hget(Cop5,Players) }
    if ($numtok($hget(Cop5,Players),32) == 5) && (!%c5act) {
      set %c5act 1
      mode #c5test +m
      hadd -m Cop5 Roles Wolf Sane Insane Paranoid Naive
      roles
    }
    if (%c5act) {
      if ($1 == vote) && ($istok($hget(Cop5,Players),$nick,32)) && (!$istok($hget(Cop5,Voted),$nick,32)) && (%c5 == Day) {
        if ($istok($hget(Cop5,Players),$2,32)) || ($2 == NoLynch) {
          hinc -m Votes $2
          hinc -m Cop5 Votes
          hadd -m Cop5 Voted $hget(Cop5,Voted) $nick
          msg #c5test $nick has voted for $2
          if ($hget(Cop5,Votes) == $hget(C5,0).item) {
            votes
          }
        }
      }
    }
  }
  on *:TEXT:*:?: {
    if ($istok($hget(Cop5,Players),$nick,32)) {
      if ($hget(C5,$nick) == Wolf) && ($istok(Night1 Night2,%c5,32)) {
        if ($1 == kill) && ($istok($hget(Cop5,Players),$2,32)) {
          if ($2 == $nick) { msg $nick You cannot kill yourself. | halt }
          hadd -m Actions Wolf $2
        }
      }
      Else {
        if ($1 == inspect) && ($istok($hget(Cop5,Players),$2,32)) && ($istok(Night0 Night1 Night2,%c5,32)) {
          if ($2 == $nick) { msg $nick You cannot inspect yourself. | halt }
          var %p1 $hget(C5,$nick)
          var %p2 $hget(C5,$2)
          if (%p1 == Paranoid) { var %r BAD. }
          if (%p1 == Naive) { var %r GOOD. }
          if (%p1 == Sane) {
            if (%p2 == Wolf) { var %r BAD. }
            else { var %r GOOD. }
          }
          if (%p1 == Insane) {
            if (%p2 == Wolf) { var %r GOOD. }
            else { var %r BAD. }
          }
          hadd -m Actions %p1 $2 is %r
        }
        if (%c5 == Night0) && ($hget(Actions,0).item == 4) {
          actions
        }
      }
      if ($hget(Actions,0).item == $hget(C5,0).item) {
        actions
      }
    }
  }
  alias roles {
    var %x $hget(Cop5,Roles)
    var %y $hget(Cop5,Players)
    while (%x) {
      var %r $random(%x)
      var %p $random(%y)
      hadd -m C5 %p %r
      if (%r == Wolf) {
        msg %p You are the wolf. You can kill after night 0. Message me with 'kill nick' after N0.
      }
      var %x $remtok(%x,%r,1,32)
      var %y $remtok(%y,%p,1,32)
    }
    msg #c5test Roles are out. If you didn't receive a PM then you are an inspector. Message me with 'inspect nick'.
    set %c5 Night0
    msg #c5test It is now %c5 $+ .
  }
  alias actions {
    if (%c5 != Night0) {
      var %x $hget(Actions,Wolf)
      var %y $hget(C5,%x)
      hadd -m Cop5 Players $remtok($hget(Cop5,Players),%x,32)
      hadd -m Cop5 Roles $remtok($hget(Cop5,Roles),%y,32)
      hdel C5 %x
      hdel Actions %y
      msg $hfind(C5,Wolf).data %x has been killed. 10 seconds until inspection PMs are sent out.
      set %c5death %x
    }
    timer 1 10 actionpms
  }
  alias actionpms {
    var %x 1
    while (%x <= $hget(C5,0).item) {
      if ($hget(C5,%x).data != Wolf) {
        msg $hget(C5,%x).item $hget(Actions,$hget(C5,%x).data)
      }
      inc %x
    }
    hdel -w Actions *
    if (%c5 == Night0) { set %c5next Night1 }
    elseif (%c5 == Night1) { set %c5next Night2 }
    set %c5 Day
    msg #c5test PMs are out. Day start. Type 'vote nick' to lynch someone or 'vote NoLynch' to skip the day's lynch. You only get to vote once, so think about it.
    if (%c5death) { msg #c5test $+(,%c5death,) has died. Players still alive are: $hget(Cop5,Players) | mode #c5test -v %c5death }
  }
  alias votes {
    var %x 1
    while (%x <= $hget(Votes,0).item) {
      var %y $hget(Votes,%x).data
      if (!%z) { var %z %y }
      elseif (%y > %z) { var %z %y }
      elseif (%y == %z) { var %a %z }
      inc %x
    }
    if (%z == %a) {
      msg #c5test Tie. No one will be lynched.
    }
    else {
      var %q $hfind(Votes,%z).data
      if (%q == NoLynch) {
        msg #c5test No one will be lynched.
      }
      else {
        var %x %q
        var %y $hget(C5,%x)
        hadd -m Cop5 Players $remtok($hget(Cop5,Players),%x,32)
        hadd -m Cop5 Roles $remtok($hget(Cop5,Roles),%y,32)
        hdel C5 %x
        if (%y == Wolf) { msg #c5test The wolf has been lynched, congratulations inspectors! | mode #c5test -v %y | endgame | halt }
        Else { msg #c5test $+(,%x,)has been lynched. | mode #c5test -v %x }
      }
    }
    hdel -w Votes *
    hdel Cop5 Votes
    hdel Cop5 Voted
    set %c5 %c5next
    if ($hget(C5,0).item == 2) || ($hget(C5,0).item == 3) {
      if (%c5 == Night2) { msg #c5test AWOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO! Congratulations Werewolf! | endgame | halt }
    }
    msg #c5test It is now %c5 $+ .
  }
  alias endgame {
    mode #c5test $+(-,$str(v,$numtok($hget(Cop5,Players),32))) $hget(Cop5,Players)
    mode #c5test -m
    hfree Actions
    hfree C5
    hfree Cop5
    hfree Votes
    unset %c5 %c5next %c5act %c5death
  }
  alias random { return $gettok($$1-,$r(1,$0),32) }
}