tic-tac-toe game

By kerstt on Aug 20, 2007

simple tic-tac-toe game, right click -> tictactoe to start

alias -l tictactoe {
  window -c @tic-tac-toe
  window -pk0 @tic-tac-toe
  set %ticturn $replace($r(1,2),1,x,2,o)
  titlebar @tic-tac-toe its the turn of $iif(%ticturn == x,CYAN (11),ORANGE (O7))
  drawreplace @tic-tac-toe 00 01
  drawline @tic-tac-toe 0 10 250 0 250 600
  drawline @tic-tac-toe 0 10 500 0 500 600
  drawline @tic-tac-toe 0 10 0 135 800 135
  drawline @tic-tac-toe 0 10 0 280 800 280
}
menu * {
  .tictactoe: tictactoe
}
menu @tic-tac-toe {
  mouse:{
    if (!%winner) {
      if ($mouse.x isnum 0-250) && ($mouse.y isnum 0-135) && (!%tic1) { drawreplace @tic-tac-toe 04 01
        drawdot @tic-tac-toe 4 50 120 62
      }
      if ($mouse.x isnum 0-250) && ($mouse.y isnum 136-280) && (!%tic2) { drawreplace @tic-tac-toe 04 01
        drawdot @tic-tac-toe 4 50 120 220
      }
      if ($mouse.x isnum 0-250) && ($mouse.y isnum 280-400) && (!%tic3) { drawreplace @tic-tac-toe 04 01
        drawdot @tic-tac-toe 4 50 120 360
      }
      if ($mouse.x isnum 250-500) && ($mouse.y isnum 0-135) && (!%tic4) { drawreplace @tic-tac-toe 04 01
        drawdot @tic-tac-toe 4 50 370 62
      }
      if ($mouse.x isnum 250-500) && ($mouse.y isnum 136-280) && (!%tic5) { drawreplace @tic-tac-toe 04 01
        drawdot @tic-tac-toe 4 50 370 220
      }
      if ($mouse.x isnum 250-500) && ($mouse.y isnum 280-400) && (!%tic6) { drawreplace @tic-tac-toe 04 01
        drawdot @tic-tac-toe 4 50 370 360
      }
      if ($mouse.x isnum 500-750) && ($mouse.y isnum 0-135) && (!%tic7) { drawreplace @tic-tac-toe 04 01
        drawdot @tic-tac-toe 4 50 600 62
      }
      if ($mouse.x isnum 500-750) && ($mouse.y isnum 136-280) && (!%tic8) { drawreplace @tic-tac-toe 04 01
        drawdot @tic-tac-toe 4 50 600 220
      }
      if ($mouse.x isnum 500-750) && ($mouse.y isnum 280-400) && (!%tic9) { drawreplace @tic-tac-toe 04 01
        drawdot @tic-tac-toe 4 50 600 360
      }
    }
  }
  sclick:{
    if (!%winner) {
      titlebar @tic-tac-toe its the turn of $iif(%ticturn == x,ORANGE (O7),CYAN (11))
      if ($mouse.x isnum 0-250) && ($mouse.y isnum 0-135) && (!%tic1) { drawreplace @tic-tac-toe 04 01
        if (%ticturn == x) { drawdot @tic-tac-toe 11 50 120 62
          set %tic1 x 
          set %ticturn o
          checkwin
        halt }
        if (%ticturn == o) { drawdot @tic-tac-toe 07 50 120 62 
          set %tic1 o
          set %ticturn x
          checkwin
        halt }
      }
      if ($mouse.x isnum 0-250) && ($mouse.y isnum 136-280) && (!%tic2) { drawreplace @tic-tac-toe 04 01
        if (%ticturn == x) { drawdot @tic-tac-toe 11 50 120 220
          set %tic2 x 
          set %ticturn o
          checkwin
        halt }
        if (%ticturn == o) { drawdot @tic-tac-toe 07 50 120 220
          set %tic2 o
          set %ticturn x
          checkwin
        halt }
      }
      if ($mouse.x isnum 0-250) && ($mouse.y isnum 280-400) && (!%tic3) { drawreplace @tic-tac-toe 04 01
        if (%ticturn == x) { drawdot @tic-tac-toe 11 50 120 360
          set %tic3 x 
          set %ticturn o
          checkwin
        halt }
        if (%ticturn == o) { drawdot @tic-tac-toe 07 50 120 360
          set %tic3 o
          set %ticturn x
          checkwin
        halt }
      }
      if ($mouse.x isnum 250-500) && ($mouse.y isnum 0-135) && (!%tic4) { drawreplace @tic-tac-toe 04 01
        if (%ticturn == x) { drawdot @tic-tac-toe 11 50 370 62
          set %tic4 x 
          set %ticturn o
          checkwin
        halt }
        if (%ticturn == o) { drawdot @tic-tac-toe 07 50 370 62 
          set %tic4 o
          set %ticturn x
          checkwin
        halt }
      }
      if ($mouse.x isnum 250-500) && ($mouse.y isnum 136-280) && (!%tic5) { drawreplace @tic-tac-toe 04 01
        if (%ticturn == x) { drawdot @tic-tac-toe 11 50 370 220
          set %tic5 x 
          set %ticturn o
          checkwin
        halt }
        if (%ticturn == o) { drawdot @tic-tac-toe 07 50 370 220 
          set %tic5 o
          set %ticturn x
          checkwin
        halt }
      }
      if ($mouse.x isnum 250-500) && ($mouse.y isnum 280-400) && (!%tic6) { drawreplace @tic-tac-toe 04 01
        if (%ticturn == x) { drawdot @tic-tac-toe 11 50 370 360
          set %tic6 x 
          set %ticturn o
          checkwin
        halt }
        if (%ticturn == o) { drawdot @tic-tac-toe 07 50 370 360
          set %tic6 o
          set %ticturn x
          checkwin
        halt }
      }
      if ($mouse.x isnum 500-750) && ($mouse.y isnum 0-135) && (!%tic7) { drawreplace @tic-tac-toe 04 01
        if (%ticturn == x) { drawdot @tic-tac-toe 11 50 120 62
          set %tic7 x 
          set %ticturn o
          checkwin
        halt }
        if (%ticturn == o) { drawdot @tic-tac-toe 07 50 600 62 
          set %tic7 o
          set %ticturn x
          checkwin
        halt }
      }
      if ($mouse.x isnum 500-750) && ($mouse.y isnum 136-280) && (!%tic8) { drawreplace @tic-tac-toe 04 01
        if (%ticturn == x) { drawdot @tic-tac-toe 11 50 600 220
          set %tic8 x 
          set %ticturn o
          checkwin
        halt }
        if (%ticturn == o) { drawdot @tic-tac-toe 07 50 600 220 
          set %tic8 o
          set %ticturn x
          checkwin
        halt }
      }
      if ($mouse.x isnum 500-750) && ($mouse.y isnum 280-400) && (!%tic9) { drawreplace @tic-tac-toe 04 01
        if (%ticturn == x) { drawdot @tic-tac-toe 11 50 600 360
          set %tic9 x 
          set %ticturn o
          checkwin
        halt }
        if (%ticturn == o) { drawdot @tic-tac-toe 07 50 600 360 
          set %tic9 o
          set %ticturn x
          checkwin
        halt }
      }
    }
    else { tictactoe 
    unset %winner }
  }
}
alias -l checkwin {
  if (%tic1 %tic2 %tic3 == x x x) { set %winner $replace($v2,x x x,cyan has won,o o o,orange has won) | drawtext @tic-tac-toe 4 300 200 %winner | unset %tic* }
  if (%tic1 %tic2 %tic3 == o o o) { set %winner $replace($v2,x x x,cyan has won,o o o,orange has won) | drawtext @tic-tac-toe 4 300 200 %winner | unset %tic* }
  if (%tic4 %tic5 %tic6 == x x x) { set %winner $replace($v2,x x x,cyan has won,o o o,orange has won) | drawtext @tic-tac-toe 4 300 200 %winner | unset %tic* }
  if (%tic4 %tic5 %tic6 == o o o) { set %winner $replace($v2,x x x,cyan has won,o o o,orange has won) | drawtext @tic-tac-toe 4 300 200 %winner | unset %tic* }
  if (%tic7 %tic8 %tic9 == x x x) { set %winner $replace($v2,x x x,cyan has won,o o o,orange has won) | drawtext @tic-tac-toe 4 300 200 %winner | unset %tic* }
  if (%tic7 %tic8 %tic9 == o o o) { set %winner $replace($v2,x x x,cyan has won,o o o,orange has won) | drawtext @tic-tac-toe 4 300 200 %winner | unset %tic* }
  if (%tic1 %tic4 %tic7 == x x x) { set %winner $replace($v2,x x x,cyan has won,o o o,orange has won) | drawtext @tic-tac-toe 4 300 200 %winner | unset %tic* }
  if (%tic1 %tic4 %tic7 == o o o) { set %winner $replace($v2,x x x,cyan has won,o o o,orange has won) | drawtext @tic-tac-toe 4 300 200 %winner | unset %tic* }
  if (%tic2 %tic5 %tic8 == x x x) { set %winner $replace($v2,x x x,cyan has won,o o o,orange has won) | drawtext @tic-tac-toe 4 300 200 %winner | unset %tic* }
  if (%tic2 %tic5 %tic8 == o o o) { set %winner $replace($v2,x x x,cyan has won,o o o,orange has won) | drawtext @tic-tac-toe 4 300 200 %winner | unset %tic* }
  if (%tic3 %tic6 %tic9 == x x x) { set %winner $replace($v2,x x x,cyan has won,o o o,orange has won) | drawtext @tic-tac-toe 4 300 200 %winner | unset %tic* }
  if (%tic3 %tic6 %tic9 == o o o) { set %winner $replace($v2,x x x,cyan has won,o o o,orange has won) | drawtext @tic-tac-toe 4 300 200 %winner | unset %tic* }
  if (%tic1 %tic5 %tic9 == x x x) { set %winner $replace($v2,x x x,cyan has won,o o o,orange has won) | drawtext @tic-tac-toe 4 300 200 %winner | unset %tic* }
  if (%tic1 %tic5 %tic9 == o o o) { set %winner $replace($v2,x x x,cyan has won,o o o,orange has won) | drawtext @tic-tac-toe 4 300 200 %winner | unset %tic* }
  if (%tic3 %tic5 %tic7 == x x x) { set %winner $replace($v2,x x x,cyan has won,o o o,orange has won) | drawtext @tic-tac-toe 4 300 200 %winner | unset %tic* }
  if (%tic3 %tic5 %tic7 == o o o) { set %winner $replace($v2,x x x,cyan has won,o o o,orange has won) | drawtext @tic-tac-toe 4 300 200 %winner | unset %tic* }
  if (%tic1) && (%tic2) && (%tic3) && (%tic4) && (%tic5) && (%tic6) && (%tic7) && (%tic8) && (%tic9) { set %winner Tie | drawtext @tic-tac-toe 4 300 200 %winner | unset %tic* }
}
on *:close:@tic-tac-toe: unset %tic* | unset %winner

Comments

Sign in to comment.
BlueThen   -  Aug 20, 2008

Looks nice, but definately not worthy as a 10/10 script. :P

 Respond  
jakobLUVSpizza   -  Aug 20, 2008

thats not even a tic tac toe board... :/

 Respond  
kerstt   -  Aug 23, 2007

then they just have to rightclick ;)

 Respond  
Callison1   -  Aug 21, 2007

The idea of submitting snippets to hawkee is not only so that scripters who know how to change things can use them, they are also for non-scripters, they would not know how to change the local alias.

 Respond  
kerstt   -  Aug 21, 2007

if they want to typ /tictactoe so hard they can remove the local lol, also the window is sizeable so you can make it the right size.

 Respond  
Olliegod   -  Aug 20, 2007

Why would anyone play tic tac toe versus themselves? Also the window should be made a desktop window because if the main mirc window isnt the right size it looks very odd. I\'m not sure why the tictactoe alias is local too, because if someone wants to type /tictactoe to start the game, why not let them?

 Respond  
Godzilla   -  Aug 20, 2007

Nice, well done on the script, looks nice, hehe ^^

 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.