Soyez le premier à donner votre avis sur cette source.
Vue 8 823 fois - Téléchargée 349 fois
; Jeu de morpion alias morpion { if (!$m(info)) { if (!$1) { var %n = $?="Niveau de 1 à 3 :" + 9 if (%n isnum 10-12) { hadd -m morpion info computer h niv %n morpion.open } } elseif ($1 != $me) { var %p = $$?="Entrer un port" socklisten morpion.listen %p .ctcp $1 morpion $ip %p hadd -m morpion info $1 .timermorpion 1 30 annule.morpion } } } menu nicklist { $iif($$1 != $me,Morpion):morpion $1 } alias -l ia { var %a = $m(possible) while ($regsub(%a,/([0-9])([A-Z])/ig,\2\1,%a)) noop if ($regex(%a,OO([0-9]))) var %case = $regml(1) elseif ($regex(%a,XX([0-9]))) var %case = $regml(1) elseif ($1 == 10) { if ($numtok($m(case),32) isin 8,9) { while (%case !isin $m(case)) var %c = $r(1,5), %case = $gettok(1 3 5 7 9,%c,32) } else var %case = $gettok($m(case),$r(1,$numtok($m(case),32)),32) } elseif ($1 == 11) { if ($numtok($m(case),32) isin 8,9) { while (%case !isin $m(case)) var %c = $r(1,4), %case = $gettok(2 4 6 8,%c,32) } else var %case = $gettok($m(case),$r(1,$numtok($m(case),32)),32) } else { var %n = $numtok($m(case),32) if (%n = 9) { while (%case !isin $m(case)) var %case = $r(1,9) } elseif (%n = 8) { var %c = 1 3 7 9, %n = 4 while (%n) { if (!$istok($gettok(%c,%n,32),$m(case),32)) { var %y = oui dec %n } } if (%y) var %c = $r(1,5), %case $gettok(2 4 6 8 5,%c,32) else var %c = $r(1,4), %case $gettok(1 3 7 9,%c,32) } elseif (%n = 7) { while (%case !isin $m(case)) var %c = $r(1,5), %case = $gettok(2 4 6 8 5,%c,32) } else var %case = $gettok($m(case),$r(1,$numtok($m(case),32)),32) } var %d = 1 while (!$regex($hfind(morpion,%case,%d).data,\.)) inc %d var %x.y = $hfind(morpion,%case,%d).data tokenize 46 %x.y .timer -m 1 800 play.morpion O %case $1- } ctcp *:morpion:*:{ if (!$m(info)) { hadd -m morpion info $cid $nick $2- .timermorpion 1 30 hdel morpion info echo 4 -a Morpion: $nick vous propose un morpion, faites Ctrl+F6 pour jouer halt } } on *:socklisten:morpion.listen:{ if ($timer(morpion)) sockaccept morpion } alias -l annule.morpion { echo 4 -a Morpion: $m(info) n'a pas accepté votre invitation, la partie est annulée sockclose morpion* hdel morpion info } alias cF6 { if ($m(info)) { .timermorpion off tokenize 32 $m(info) scid $1 .ctcpreply $2 morpion sockopen morpion $3- h me $scid($1).me h info $2 h debut oui morpion.open } } on *:ctcpreply:morpion:{ .timermorpion off echo 4 -a Morpion: $nick a accepté votre invitation morpion.open halt } alias -l morpion.open { window -Cdekp @morpion -1 -1 500 500 drawfill -r @morpion 16777215 0 0 0 0 h lignes 10 if ($m(niv)) h me $me h $m(me) 10 h $m(info) 10 h copie 123 456 789 159 357 147 258 369 var %c = 1, %x = 100, %y = 30 while (%c <= 9) { h $+(%x,.,%y) %c if (%c isin 3,6) { var %x = 0 inc %y 100 } inc %x 100 inc %c } morpion.jeu } alias -l morpion.jeu { if ($window(@morpion)) { drawrect -fr @morpion 16777215 1 100 30 300 300 dl 0 5 100 130 400 130 dl 0 5 100 230 400 230 dl 0 5 200 30 200 330 dl 0 5 300 30 300 330 dl 13816530 3 204 30 204 330 dl 13816530 3 304 30 304 330 dl 8355711 3 100 134 400 134 dl 8355711 3 100 234 400 234 h possible $m(copie) h case 1 2 3 4 5 6 7 8 9 if ($m(debut)) { hdel morpion debut hdel morpion tour } else { h debut oui h tour oui } tableau if ($m(niv)) && (!$m(tour)) ia $m(niv) } } alias -l tableau { drawrect -f @morpion 0 1 0 0 500 20 drawtext @morpion $iif($m(tour),4,1) arial 12 5 5 $m(me) $c($m($m(me)) -10) var %a = $m(info) $c($m($m(info)) -10) drawtext @morpion $iif($m(tour),1,4) arial 12 $c(485 - $width(%a,arial,12)) 5 %a } menu @morpion { sclick:sclick.morpion $mouse.x $mouse.y } alias -l sclick.morpion { if ($inrect($1,$2,100,30,300,300) && $m(tour)) { var %x = $c($c($int($c($c($1 -100) /100)) *100) +100) var %y = $c($c($int($c($c($2 -30) /100)) *100) +30) var %c = $m($+(%x,.,%y)) if (%c isin $m(case) && !$timer(wait)) { play.morpion X %c %x %y if ($m(niv)) && ($m(case)) && (!$timer(wait)) ia $m(niv) } } } alias -l play.morpion { h possible $replace($m(possible),$2,$1) h case $remtok($m(case),$2,1,32) var %a = $c($3 +50) $c($4 +50), %s = $1 | %s %a if (!$m(niv)) sockwrite -n morpion bouge $2 %a var %f = $findtok($m(possible),$str(%s,3),1,32) if (%f) { var %g = $gettok($m(copie),%f,32) var %x = $hfind(morpion,$left(%g,1)).data var %y = $hfind(morpion,$right(%g,1)).data tokenize 46 %x %y tic-tac-toe $1- if (!$m(niv)) sockwrite -n morpion tic-tac-toe $1- if (%s == O) hinc morpion computer else hinc morpion $m(me) tableau .timerwait 1 2 morpion.jeu } if (!$m(case)) .timerwait 1 2 morpion.jeu elseif (!%f) { if (!$m(tour)) h tour oui else hdel morpion tour tableau } } alias -l tic-tac-toe dl 8355711 5 $c($1 +50) $c($2 +50) $c($3 +50) $c($4 +50) alias -l o { drawdot @morpion 5 30 $c($1 +4) $c($2 +3) drawdot @morpion 4 30 $1 $2 drawdot @morpion 0 25 $1 $2 } alias -l x { dl 8323072 5 $c($1 -20) $c($2 -25) $c($1 +30) $c($2 +25) dl 8323072 5 $c($1 -20) $c($2 +25) $c($1 +30) $c($2 -25) dl 16515072 5 $c($1 -25) $c($2 -25) $c($1 +25) $c($2 +25) dl 16515072 5 $c($1 -25) $c($2 +25) $c($1 +25) $c($2 -25) } on *:input:@morpion:{ if ($1 == /clear) { drawrect -f @morpion 0 1 0 350 500 90 hdel -w morpion lignes.* h lignes 10 halt } elseif ($left($1,1) != /) { h lignes. $+ $m(lignes) $+([,$time,]) $+(<,$m(me),>) $1- if (!$m(niv)) sockwrite -n morpion msg $gettok($m(lignes. $+ $m(lignes)),2-,32) hinc morpion lignes dialogue } } alias -l dialogue { if ($window(@morpion)) { drawrect -f @morpion 0 1 0 350 500 90 var %a = $m(lignes), %b = 425 while (%a > $c($m(lignes) -5)) { if ($m(lignes. $+ $c(%a -1))) drawtext -p @morpion 1 arial 12 2 %b $v1 dec %b 16 dec %a } } } on *:sockread:morpion:{ sockread %a tokenize 32 %a if ($1 == msg) { h lignes. $+ $m(lignes) $+([,$time,]) $2- hinc morpion lignes dialogue } elseif ($1 == bouge) { h case $remtok($m(case),$2,1,32) | o $3- h tour oui if (!$m(case)) .timerwait 1 2 morpion.jeu else tableau } elseif ($1 == tic-tac-toe) { tic-tac-toe $2- hinc morpion $m(info) .timerwait 1 2 morpion.jeu } elseif ($1 == nick) { h $2 $m($m(info)) h info $2 tableau } } on *:nick:{ if ($window(@morpion) && $m(me) == $nick) { if (!$m(niv)) sockwrite -n morpion nick $newnick h $newnick $m($m(me)) .timer1 0 0 tableau } } on *:close:@morpion:close.morpion on *:sockclose:morpion:{ close.morpion | morpion } alias -l close.morpion { window -c @morpion hfree morpion sockclose morpion* } alias -l c return $calc($1-) alias -l m return $hget(morpion,$1) alias -l h hadd morpion $1- alias -l dl drawline -r @morpion $1-
30 juil. 2008 à 17:14
5 janv. 2007 à 23:42
merci pour le commentaire, au moins j'en aurai eu un :)
21 déc. 2006 à 18:16
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.