rendered paste bodyCTCP ^*:ENABLED:{ haltdef | ctcpreply ENABLED $Nick yes }
dialog ttt {
title "Tic TacToe"
size -1 -1 124 134
option dbu
button "", 1, 5 25 37 31
button "", 2, 42 25 37 31
button "", 3, 79 25 37 31
button "", 4, 5 56 37 31
button "", 5, 42 56 37 31
button "", 6, 79 56 37 31
button "", 7, 5 87 37 31
button "", 8, 42 87 37 31
button "", 9, 79 87 37 31
text "Challenger:", 10, 5 5 29 8
text "", 11, 5 13 56 8
button "Forfeit", 12, 79 8 37 12
text "Turn:", 13, 38 122 16 8
text "", 14, 54 122 44 8
text "", 15, 33 5 37 8
}
on 1:dialog:ttt:sclick:12: {
msg TicTacToeBot forfeit
dialog -x ttt ttt
}
on 1:dialog:ttt:close:0: {
msg TicTacToeBot forfeit
}
on 1:dialog:ttt:sclick:*: {
if ($did == 1) {
msg TicTacToeBot move 1
}
if ($did == 2) {
msg TicTacToeBot move 2
}
if ($did == 3) {
msg TicTacToeBot move 3
}
if ($did == 4) {
msg TicTacToeBot move 4
}
if ($did == 5) {
msg TicTacToeBot move 5
}
if ($did == 6) {
msg TicTacToeBot move 6
}
if ($did == 7) {
msg TicTacToeBot move 7
}
if ($did == 8) {
msg TicTacToeBot move 8
}
if ($did == 9) {
msg TicTacToeBot move 9
}
}
on *:TEXT:*:#tictactoe: {
if ($nick == TicTacToeBot) {
if ($1 == Game) && ($4 == Accepted) {
if ($6 == $me) {
set %me.playing $2
dialog -m ttt ttt
did -a ttt 15 $12
}
elseif ($12 == $me) {
set %me.playing $2
dialog -m ttt ttt
did -a ttt 15 $6
}
}
else if ($1 == Game) && ($4 != Accepted) {
if ($2 == %me.playing) {
if ($5 == moves) {
if ($4 = $me) {
did -b ttt $7
did -a ttt $7 X
did -ra ttt 14 His Turn
did -ra ttt 11 You move to $7
}
else {
did -b ttt $7
did -a ttt $7 O
did -ra ttt 14 Your Turn
did -ra ttt 11 He Moved to $7
}
}
else if ($6 == go) {
if ($4 = $me) {
did -ra ttt 14 Your Turn
}
else {
did -ra ttt 14 His Turn.
}
}
else if ($4 == End) {
unset %me.playing
if ($dialog(ttt) == ttt) { .dialog -x ttt }
}
}
}
}
}