Sephiroth
http://sephiroth.scifi-action.de/board/

Simple German Wordgame
http://sephiroth.scifi-action.de/board/viewtopic.php?f=4&t=18
Seite 1 von 1

Autor:  Sephiroth [ 18. März 2008 00:13 ]
Betreff des Beitrags:  Simple German Wordgame

;;
;; Add a user with Userlevel 'wordgame' to your Userlist (Administrator)
;; !addbot <botnick> - Adds a bot (won't be selected on new round)
;; !delbot <botnick> - Removes a bot
;; !viewbot - shows all botnicks
;; !reset - resets a game (same as new round! and only if game is running)
;; !start - starts a game in the active channel
;; !stop - stops the game in the active channel
;; !resetdatabase - removes all word entrys in the word database
;;
;; 30 mins of work *g*
;;
;; only nicks with idletime < 5 mins will be selected
;; if no one is awailable game will stop
;;
on *:text:*:#:{
  if ($level($ial($nick)) == 5) {
    if (%wordgame.active == #) {
      if ($1 == !addbot) { set %botnicks $addtok(%botnicks,$$2,32) | .notice $nick Botnicks: %botnicks }
      if ($1 == !delbot) { set %botnicks $remtok(%botnicks,$$2,1,32) | .notice $nick Botnicks: %botnicks }
      if ($1 == !viewbot) { .notice $nick Botnicks: %botnicks }
      if ($1 == !reset) { wordgame reset # }
    }
    if ($1 == !resetdatabase) {
      write -c words.txt
      .notice $nick Done!
    }
    if ($1 == !start) {
      if (%wordgame.active) { wordgame off $ifmatch }
      wordgame on #
    }
    if ($1 == !stop) { wordgame off # }
    if ($1 == !help) { .notice $nick Wordgame Admin Commands: !addbot <nick> - !delbot <nick> - !viewbot - !reset - !start - !stop - !resetdatabase (use this command with care!) }
  }
  if (%wordgame.active == #) {
    tokenize 32 $1 $strip($norm($2)) $3-
    if ($nick == %wordgame.activenick) {
      if ($istok(!wort !word ! $+(!,$nick),$1,32)) {
        set %wordgame.setautooff 0
        if ($len($2) > 2) {
          if ($right(%wordgame.lastword,1) == $left($2,1)) {
            set %wordgame.lastword $2
            setnick #
            if ($read(words.txt,wn,$2 *)) {
              var %n = $ifmatch,%l = $readn
              write -dl $+ $readn words.txt
              write words.txt $2 $calc($gettok(%n,2,32) +1) $gettok(%n,3,32) $nick
              %n = $2 $calc($gettok(%n,2,32) +1) $gettok(%n,3,32) $gettok(%n,4,32)
            }
            else { write words.txt $2 1 $nick | var %n = $2 1 $nick }
            var %z = $gettok(%n,2,32)
            msg # $logo  $+ $nick $+  hat ein Wort gefunden $+(',$2,') - $iif(%z == 1,dieses Wort wurde bisher noch nicht verwendet $+ $chr(44) oh du bist so gut!,dieses Wort wurde bereits  $+ $gettok(%n,2,32) $+  mal benutzt $+ $chr(44) als erstes hat dies  $+ $gettok(%n,3,32) $+  benutzt und zuletzt wurde es von  $+ $iif($gettok(%n,4,32),$ifmatch,$gettok(%n,3,32)) $+  benutzt. ) ;)
            msg # $logo Die Datenbank umfasst nun  $+ $lines(words.txt) $+  Wörter mit einer Dateigrösse von  $+ $bytes($file(words.txt).size).suf $+ 
            msg # $logo Nun ist  $+ %wordgame.activenick $+  an der Reihe ein Wort zu finden das mit $+(',$upper($right($2,1)),') beginnt. (Trigger: ! $+ %wordgame.activenick <wort>)
            .timerresetwordgame -o 1 30 wordgame reset #
            .timerremember -o 1 20 msg # $logo  $+ %wordgame.activenick $+  du hast noch 10 Sekunden!
          }
          else { msg # $logo Das Wort stimmt nicht mit dem letzten Buchstaben des vorrangeganenen Wortes überein. }
        }
        else { msg # $logo Das Wort ist nicht lang genug. }
      }
    }
  }
}
on *:disconnect:{
  unset %wordgame.*
  .timerresetwordgame off
  .timerremember off
}
alias wordgame {
  if ($1 == on) {
    if ($2 ischan) {
      set %wordgame.active $2
      set %wordgame.lastword $rand(a,z)
      setnick $2
      msg $2 $logo  $+ %wordgame.activenick $+  muss nun ein Wort finden das mit $+(',$upper(%wordgame.lastword),') beginnt. (Trigger: ! $+ %wordgame.activenick <wort>) - Sonderzeichen werden nicht gewertet!
      .timerresetwordgame -o 1 30 wordgame reset $2
    }
  }
  elseif ($1 == off) {
    msg %wordgame.active $logo Spiel deaktiviert. Schreibe !start um es zu reaktivieren.
    unset %wordgame.*
    .timerresetwordgame off
    .timerremember off
  }
  elseif ($1 == reset) {
    msg $2 $logo  $+ %wordgame.activenick $+  (Idle: $+  $duration($nick($2,%wordgame.activenick).idle) $+ ) hat es leider nicht geschafft, ein tolles Wort in 30 Sekunden zu finden. Was für ein Versager aber auch! - Wie dem auch sei, neues Spiel, neues Glück!
    set %wordgame.lastword $rand(a,z)
    setnick $2
    if (%wordgame.setautooff == 6) { .timer 1 1 wordgame off }
    inc %wordgame.setautooff
    .timerresetwordgame -o 1 30 wordgame reset $2
    .timerremember -o 1 20 msg $2 $logo  $+ %wordgame.activenick $+  du hast noch 10 Sekunden!
    msg $2 $logo  $+ %wordgame.activenick $+  muss nun ein Wort finden das mit $+(',$upper(%wordgame.lastword),') beginnt. (Trigger: ! $+ %wordgame.activenick <wort>)
  }
}
alias -l logo { return -12W7ord12G7ame- }
alias setnick {
  :start
  var %x = $nick($1,%wordgame.activenick),%i = $nick($1,0),%y = 0,%f
  %f = $calc(%x + 1)
  if (%f > %i) { %f = $calc(%f - %i) }
  set %wordgame.activenick $nick($1,%f)
  if ($istok($botnicks,%wordgame.activenick,32)) { goto start }
  if ($nick($1,%wordgame.activenick).idle > 300) { goto start }
}
alias botnicks return $me %botnicks
alias norm {
  var %x = 32,%y = 255,%w = $1
  while (%x < %y) {
    inc %x | %c = $chr(%x)
    if (%c !isalnum && !$istok(ä ö ü - _,%c,32)) { %w = $remove(%w,$chr(%x)) }
  }
  return $strip(%w)
}
alias randomnick return $nick($1,$r(1,$nick($1,0)))

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/