Advertisement
Guest User

Untitled

a guest
Jul 13th, 2017
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.82 KB | None | 0 0
  1. ####################################################################
  2. #
  3. # Black Scrabble 1.1 TCL
  4. #
  5. #The game offers letters and the users have to make words
  6. #with the letters offered. Minimum 4 letters may be used to
  7. #make words.
  8. #
  9. #Comment :
  10. #
  11. #!scrabble <on> / <off> - activate / disable Scrabble
  12. #!scrabble - start the game
  13. #!scrabble stop - stop the game
  14. #!scrabble reset - reset scores
  15. #!top <general> / <runde> - view tops.
  16. #!won <user> - view user statistics.
  17. #!lettre - show the current letters .
  18. #
  19. #INSTALARE :
  20. #Lang Romain
  21. #Put Scrabble.db in the main directory of the eggdrop ( eggdrop usual )
  22. #and the tcl BlackScrabble.tcl in scripts
  23. #Add in config source scripts/BlackScrabble.tcl
  24. #
  25. # have Fun
  26. #
  27. # BLackShaDoW ProductionS
  28. # WwW.TclScripts.Net
  29. #####################################################################
  30.  
  31. # #################### modif dilettante
  32. # traduction dico français
  33. # modif pour couleur
  34. # les scores sont basés sur le pseudo même si c'est un guest - demande de Cbastien95
  35. # ####################
  36.  
  37.  
  38. #Set here the flags to activate/disable/reset Scrabble
  39.  
  40. set scrabble(flags) "mn|mM"
  41.  
  42. #Set here the limit rounds for the eggdrop to run without someone playing
  43. #After that the game will stop.
  44.  
  45. set scrabble(end_rounds) "4"
  46.  
  47. set monchan "#scrabble"
  48.  
  49. #####################################################################
  50. #
  51. # The End is Near :)
  52. #
  53. #####################################################################
  54.  
  55. bind pub - !scrabble start:scrabble
  56. bind pubm - * preia:cuvant
  57. bind pub - !top top:scrabble
  58. bind pub - !won won:scrabble
  59. bind pub - !lettre arata:litere
  60. bind join - * top:3:join
  61.  
  62. set scrabble(file) "Scrabble.db"
  63. set scrabble(userfile) "Scrabble_stats.db"
  64. setudef flag scrabble
  65.  
  66. if {![file exists $scrabble(userfile)]} {
  67. set file [open $scrabble(userfile) w]
  68. close $file
  69. }
  70.  
  71. if {![file exists $scrabble(file)]} {
  72. set file [open $scrabble(file) w]
  73. close $file
  74. }
  75.  
  76. proc arata:litere {nick host hand chan arg} {
  77. global scrabble
  78.  
  79. if {![channel get $chan scrabble]} {
  80. putquick "NOTICE $nick :Le \00312 Scrabble\003 n'est pas activé, voir un responsable du bot ou du salon ou encore un IRCop, selon."
  81. return 0
  82. }
  83. if {![info exists scrabble($chan:run)] && [channel get $chan scrabble]} {
  84. putquick "PRIVMSG $chan :\00312Tapez !scrabble pour démarrer le jeu"
  85. return 0
  86. }
  87. if {[info exists scrabble(word:$chan)]} {
  88. putquick "PRIVMSG $chan :\00304Les lettres actuelles sont \00309:\003 \00300,12 $scrabble(word:$chan) \003"
  89. }
  90. }
  91.  
  92. proc won:scrabble {nick host hand chan arg} {
  93. global scrabble
  94. set lexten "*|*"
  95. set user [lindex [split $arg] 0]
  96. if {![channel get $chan scrabble]} {
  97. putquick "NOTICE $nick : Le \00312 Scrabble\003 n'est pas activé."
  98. return 0
  99. }
  100. if {[string match $lexten $nick]} {
  101. regsub {\|.*$} $nick {} nick
  102. }
  103. if {$user == ""} { set user $nick }
  104. set file [open $scrabble(userfile) "r"]
  105. set data [read -nonewline $file]
  106. close $file
  107. set words [split $data "\n"]
  108. foreach line $words {
  109. set channel [lindex [split $line] 1]
  110. set get_nick [lindex [split $line] 0]
  111. if {[string match -nocase $chan $channel] && [string match -nocase $get_nick $user]} {
  112. set found_nrg 1
  113. lappend points [join [lindex [split $line] 3]]
  114. lappend rounds [join [lindex [split $line] 4]]
  115. }
  116. }
  117.  
  118. if {[info exists found_nrg]} {
  119. putquick "PRIVMSG $chan :\00312$user\003 \00304a\003 \00304$points\003 \00304points et\003 \00304$rounds\003 \00304manches gagnées.\003"
  120. } else {
  121. putquick "NOTICE $nick :\00304Aucune information touvée\003"
  122. }
  123. }
  124.  
  125. proc top:scrabble {nick host hand chan arg} {
  126. global scrabble
  127. set option [lindex [split $arg] 0]
  128. if {![channel get $chan scrabble]} {
  129. putquick "NOTICE $nick :Le \00312 Scrabble \003 n'est pas activé."
  130. return 0
  131. }
  132.  
  133. if {$option == ""} {
  134. putquick "NOTICE $nick :\00304Use\003 \00312!top <general> / <runde>\003"
  135. return 0
  136. }
  137.  
  138. switch -exact -- $option {
  139. general {
  140. putquick "PRIVMSG $chan :\00314Top du \00300,2 Scrabble \003 General :"
  141. afiseaza:topscrabble $chan "general"
  142. }
  143. runde {
  144. putquick "PRIVMSG $chan :\00314Top du \00300,2 Scrabble \003 Manches :"
  145. afiseaza:topscrabble $chan "runde"
  146. }
  147. default {
  148. putquick "NOTICE $nick :\00304Use\003 \00312!top <general> / <runde>\003"
  149. }
  150.  
  151. }
  152. }
  153.  
  154. proc afiseaza:topscrabble {chan type} {
  155. global scrabble
  156. set counter 0
  157. array set topscr [list]
  158. set file [open $scrabble(userfile) "r"]
  159. set data [read -nonewline $file]
  160. close $file
  161. set words [split $data "\n"]
  162. foreach line $words {
  163. set channel [lindex [split $line] 1]
  164. set nick [lindex [split $line] 0]
  165. if {$type == "general"} { set top_point [lindex [split $line] 3] } else { set top_point [lindex [split $line] 4] }
  166. if {[string match -nocase $channel $chan]} {
  167. if {$top_point != "0"} {
  168. lappend topscr($top_point) $nick
  169. }
  170. }
  171. }
  172.  
  173. foreach t_scr [lsort -integer -decreasing [array names topscr]] {
  174. set counter [expr $counter + 1]
  175. if {$counter < 11} {
  176. lappend the_line \00303- $counter -\00309 : \003\00314[join $topscr($t_scr) ,] \00304$t_scr\ Points\003
  177. }
  178. }
  179.  
  180. if {[info exists the_line]} {
  181. putquick "PRIVMSG $chan :[join $the_line]"
  182. } else {
  183. putquick "PRIVMSG $chan :\00314Aucun joueur inscrit dans le top10\003"
  184. }
  185. }
  186.  
  187. proc start:scrabble {nick host hand chan arg} {
  188. global scrabble
  189. set option [lindex [split $arg] 0]
  190. if {[matchattr $hand $scrabble(flags) $chan]} {
  191. if {[string equal -nocase "reset" $option]} {
  192. set file [open $scrabble(userfile) "r"]
  193. set data [read -nonewline $file]
  194. close $file
  195. set words [split $data "\n"]
  196. foreach line $words {
  197. set channel [lindex [split $line] 1]
  198. if {[string match -nocase $channel $chan]} {
  199. lappend arguments [join $channel]
  200. }
  201. }
  202.  
  203. if {[info exists arguments]} {
  204. resetare:top $chan $arguments
  205. }
  206. putquick "NOTICE $nick :\00304Reseting du top10..\003"
  207. return 0
  208. }
  209. if {[string equal -nocase "on" $option]} {
  210. channel set $chan +scrabble
  211. putquick "PRIVMSG $chan :Le \00304 Scrabble\003 est activé. Pour commencer à jouer tapez \00304!scrabble\003"
  212. return 0
  213. }
  214.  
  215. if {[string equal -nocase "off" $option]} {
  216. channel set $chan -scrabble
  217. scrabble:stop $chan
  218. putquick "PRIVMSG $chan :Le \00312 Scrabble\003 est désactivé."
  219. return 0
  220. }
  221. }
  222.  
  223. if {![channel get $chan scrabble]} {
  224. putquick "NOTICE $nick :Le \00312 Scrabble\003 n'est pas activé."
  225. return 0
  226. }
  227.  
  228. if {[string equal -nocase "version" $option]} {
  229. putquick "PRIVMSG $chan :Version \00300,2 Black Scrabble 1.1 modifiée par dilettante V1.2\003 ."
  230. return 0
  231. }
  232.  
  233. if {[string equal -nocase "stop" $option]} {
  234. if { [matchattr [nick2hand $nick] "o" $chan]} {
  235. putquick "PRIVMSG $chan :\00304Le Scrabble\003 a été stoppé par $nick."
  236. scrabble:stop $chan
  237. } else {
  238. putquick "NOTICE $nick :Vous n'avez pas l'autorisation pour arrêter le Scrabble"
  239. }
  240. return 0
  241. }
  242. if {[info exists scrabble($chan:run)]} {
  243. putquick "NOTICE $nick :\00304Le Scrabble est déjà  en cours d'éxécution.\003"
  244. return 0
  245. }
  246. putquick "PRIVMSG $chan :\00300,2 ¤ Scrabble ¤ \003"
  247. putquick "PRIVMSG $chan :\00304Trouver des mots\00302 français.\00304 Pour connaitre les lettres actuelles tapez\00302 !lettre \00302."
  248. afiseaza:scrabble $chan
  249. set scrabble($chan:run) 1
  250. }
  251.  
  252. proc afiseaza:scrabble {chan} {
  253. global scrabble
  254. if {[info exists scrabble(stop:it:$chan)]} {
  255. unset scrabble(stop:it:$chan)
  256. return 0
  257. }
  258. set file [open $scrabble(file) "r"]
  259. set data [read -nonewline $file]
  260. close $file
  261. set words [split $data "\n"]
  262. set scrabble(current_word:$chan) [lindex $words [rand [llength $words]]]
  263. set scrabble(word:$chan) [scrabble:process $scrabble(current_word:$chan)]
  264. set length_word [string length $scrabble(current_word:$chan)]
  265. switch -exact -- $length_word {
  266. 4 {
  267. set timer_seconds 60
  268. }
  269. 5 {
  270. set timer_seconds 65
  271. }
  272. 6 {
  273. set timer_seconds 75
  274. }
  275. 7 {
  276. set timer_seconds 85
  277. }
  278. 8 {
  279. set timer_seconds 95
  280. }
  281. 9 {
  282. set timer_seconds 100
  283. }
  284. default {
  285. set timer_seconds 120
  286. }
  287. }
  288.  
  289. if {$data == ""} {
  290. putquick "PRIVMSG $chan :There are no words in my database. \00312Scrabble\003 stopped."
  291. scrabble:stop $chan
  292. return 0
  293. }
  294. putquick "PRIVMSG $chan :\00308,4 ATTENTION \003 \0031 mots\00304 Minimum\00314 de\00304 4\00314 lettres\00309 : \00300,2 $scrabble(word:$chan) \003\00309 - \00314Vous avez \00304$timer_seconds secondes \00314pour trouver un \00304Maximum \00314de mots."
  295. utimer $timer_seconds [list again:scrabble $chan]
  296. set scrabble($chan:the_time) $timer_seconds
  297. }
  298.  
  299. proc again:scrabble {chan} {
  300. global scrabble
  301. alege:castigator $chan
  302. verifica:top:3 $chan
  303. reset:for:new $chan
  304. afiseaza:scrabble $chan
  305. }
  306.  
  307. proc verifica:top:3 {chan} {
  308. global scrabble
  309. array set topscr [list]
  310. set counter 0
  311. set file [open $scrabble(userfile) "r"]
  312. set data [read -nonewline $file]
  313. close $file
  314. set words [split $data "\n"]
  315. foreach line $words {
  316. set channel [lindex [split $line] 1]
  317. set host [lindex [split $line] 2]
  318. set top_point [lindex [split $line] 3]
  319. if {[string match -nocase $channel $chan]} {
  320. lappend topscr($top_point) $host
  321. }
  322. }
  323.  
  324. foreach t_scr [lsort -integer -decreasing [array names topscr]] {
  325. set counter [expr $counter + 1]
  326. if {$counter <= 3} {
  327. lappend top_3 [join $topscr($t_scr)]
  328. }
  329. }
  330.  
  331. if {[info exists top_3]} {
  332. set lexten "*|*"
  333. foreach read_host $top_3 {
  334. foreach user [chanlist $chan] {
  335. if {[string match $lexten $user]} {
  336. regsub {\|.*$} $user {} user
  337. }
  338. set get_host "ip$user"
  339. if {[string match -nocase $read_host $get_host]} {
  340. lappend valid_users [join $user]
  341. }
  342. }
  343. }
  344.  
  345. if {[info exists valid_users]} {
  346. foreach user $valid_users {
  347. if {(![isop $user $chan]) && (![isvoice $user $chan])} {
  348. pushmode $chan +v $user
  349. lappend now_voice [join $user]
  350. }
  351. }
  352. }
  353.  
  354. if {[info exists now_voice]} {
  355. if {[llength $now_voice] > 1} {
  356. # puthelp "PRIVMSG $chan :\00304[join $now_voice ", "]\003 \00314reçois un \00304VOICE (+)\003 \00314because there are in \00304Top 3 Scrabble\003 ."
  357. #} else {
  358. # puthelp "PRIVMSG $chan :\00304$now_voice\003 \00314reçois un \00304VOICE (+)\003 \00314because he is in \00304Top 3 Scrabble\003."
  359. }
  360. }
  361. }
  362. }
  363.  
  364. proc top:3:join {nick host hand chan} {
  365. global scrabble
  366. set lexten "*|*"
  367. if {![channel get $chan scrabble]} {
  368. return 0
  369. }
  370. if {[string match $lexten $nick]} {
  371. regsub {\|.*$} $nick {} nick
  372. }
  373. set get_host "ip$nick"
  374. array set topscr [list]
  375. set counter 0
  376. set file [open $scrabble(userfile) "r"]
  377. set data [read -nonewline $file]
  378. close $file
  379. set words [split $data "\n"]
  380. foreach line $words {
  381. set channel [lindex [split $line] 1]
  382. set host [lindex [split $line] 2]
  383. set top_point [lindex [split $line] 3]
  384. if {[string match -nocase $channel $chan]} {
  385. lappend topscr($top_point) $host
  386. }
  387. }
  388.  
  389. foreach t_scr [lsort -integer -decreasing [array names topscr]] {
  390. set counter [expr $counter + 1]
  391. if {$counter <= 3} {
  392. lappend top_3 [join $topscr($t_scr)]
  393. }
  394. }
  395.  
  396. if {[info exists top_3]} {
  397. foreach read_host $top_3 {
  398. if {[string match -nocase $get_host $read_host]} {
  399. set found_reg 1
  400. utimer 3 [list pushmode $chan +v $nick]
  401. }
  402. }
  403.  
  404. if {[info exists found_reg]} {
  405. # utimer 3 [list puthelp "PRIVMSG $chan :\00304$nick\003 \00314reçois un \00304VOICE (+)\003 \00314because he is in \00304Top 3 Scrabble\003 ."]
  406. }
  407. }
  408. }
  409.  
  410. proc alege:castigator {chan} {
  411. global scrabble counter
  412. array set winner [list]
  413. set nicks ""
  414. if {[info exists scrabble($chan:round_players)]} {
  415. foreach m $scrabble($chan:round_players) {
  416. if {[info exists scrabble($m:current_points)]} {
  417. lappend winner($scrabble($m:current_points)) $m
  418. }
  419. }
  420.  
  421. foreach eq [lsort -integer -increasing [array names winner]] {
  422. set max "$eq"
  423. }
  424.  
  425. if {[info exists max]} {
  426. set lexten "*|*"
  427. foreach nick [chanlist $chan] {
  428. if {![isbotnick $nick]} {
  429. if {[string match $lexten $nick]} {
  430. regsub {\|.*$} $nick {} nick
  431. }
  432. set get_host "ip$nick"
  433. foreach hosts $winner($max) {
  434. if {[string match -nocase $get_host $hosts]} {
  435. lappend nicks $nick
  436. }
  437. }
  438. }
  439. }
  440.  
  441. putquick "PRIVMSG $chan :\00314La meilleure réponse était\00309 : \00304$scrabble(current_word:$chan)\003 \00309- \00314 Préparez vous prochain mot dans quelques secondes"
  442. putquick "PRIVMSG $chan :\00304Gagnant de la manche \00314 : \00304[join $nicks ", "]\003 \00314avec \00304$max Points\003"
  443. runda:castigata $chan $winner($max)
  444. }
  445. set scrabble(is:played:$chan) 1
  446. }
  447. putquick "PRIVMSG $chan : "
  448. putquick "PRIVMSG $chan :\00314Top10 du\00304 Scrabble\00309:\003"
  449. afiseaza:topscrabble $chan "general"
  450. putquick "PRIVMSG $chan : "
  451. putquick "PRIVMSG $chan :\00300,2 ¤ Scrabble ¤ \003"
  452. putquick "PRIVMSG $chan :\00304Trouver le maximum de mots\00302 français\00304 dans le temps imparti. Pour connaitre les lettres actuelles tapez\00302 !lettre."
  453. }
  454.  
  455. proc runda:castigata {chan args} {
  456. global scrabble
  457. set file [open $scrabble(userfile) "r"]
  458. set data [read -nonewline $file]
  459. close $file
  460. set words [split $data "\n"]
  461. foreach host $args {
  462. foreach line $words {
  463. set channel [lindex [split $line] 1]
  464. set get_host [lindex [split $line] 2]
  465. if {[string match -nocase $chan $channel] && [string match -nocase $get_host $host]} {
  466. lappend current_hosts [join $get_host]
  467. }
  468. }
  469. }
  470. if {[info exists current_hosts]} {
  471. runda:noua $chan $current_hosts
  472. }
  473. }
  474.  
  475. proc runda:noua {chan hosts} {
  476. global scrabble the_nick
  477. set lexten "*|*"
  478. foreach host $hosts {
  479. if {$host != ""} {
  480. set file [open $scrabble(userfile) "r"]
  481. set data [read -nonewline $file]
  482. close $file
  483. set words [split $data "\n"]
  484. set i [lsearch -glob $words "* $chan $host *"]
  485. if {$i > -1} {
  486. set line [lindex $words $i]
  487. lappend total_general [lindex [split $line] 3]
  488. lappend runda_curenta [lindex [split $line] 4]
  489. set delete [lreplace $words $i $i]
  490. set file [open $scrabble(userfile) "w"]
  491. puts $file [join $delete "\n"]
  492. close $file
  493. }
  494. }
  495. foreach nick [chanlist $chan] {
  496. if {[string match $lexten $nick]} {
  497. regsub {\|.*$} $nick {} nick
  498. }
  499. set get_host "ip$nick"
  500. if {[string match -nocase $get_host $host]} {
  501. set the_nick $nick
  502. }
  503. }
  504. }
  505. set file [open $scrabble(userfile) "r"]
  506. set data [read -nonewline $file]
  507. close $file
  508. if {$data == ""} {
  509. set file [open $scrabble(userfile) "w"]
  510. close $file
  511. }
  512.  
  513. if {[info exists total_general] && [info exists runda_curenta]} {
  514. set file [open $scrabble(userfile) a]
  515. puts $file "$the_nick $chan $host [join $total_general] [expr [join $runda_curenta] + 1]"
  516. close $file
  517. }
  518. }
  519.  
  520. proc reset:for:new {chan} {
  521. global scrabble
  522. if {[info exists scrabble($chan:round_players)]} {
  523. foreach m $scrabble($chan:round_players) {
  524. if {[info exists scrabble($m:current_points)]} {
  525. unset scrabble($m:current_points)
  526. }
  527. }
  528. }
  529.  
  530. if {[info exists scrabble(current_word:$chan)]} {
  531. unset scrabble(current_word:$chan)
  532. }
  533.  
  534. if {[info exists scrabble(word:$chan)]} {
  535. unset scrabble(word:$chan)
  536. }
  537.  
  538. if {[info exists scrabble($chan:the_time)]} {
  539. unset scrabble($chan:the_time)
  540. }
  541.  
  542. if {[info exists scrabble($chan:round_words)]} {
  543. unset scrabble($chan:round_words)
  544. }
  545.  
  546. if {[info exists scrabble($chan:round_players)]} {
  547. unset scrabble($chan:round_players)
  548. }
  549.  
  550. if {![info exists scrabble(is:played:$chan)]} {
  551. if {![info exists scrabble(no:playing:$chan)]} {
  552. set scrabble(no:playing:$chan) 0
  553. }
  554. set scrabble(no:playing:$chan) [expr $scrabble(no:playing:$chan) + 1]
  555. } else {
  556. if {[info exists scrabble(no:playing:$chan)]} {
  557.  
  558. unset scrabble(no:playing:$chan)
  559. }
  560. }
  561.  
  562. if {[info exists scrabble(no:playing:$chan)]} {
  563. if {$scrabble(no:playing:$chan) >= $scrabble(end_rounds)} {
  564. putquick "PRIVMSG $chan :\00312Scrabble\003 arrêté. Pour jouer tapez \00304!scrabble\003 ."
  565. unset scrabble(no:playing:$chan)
  566. if {[info exists scrabble(is:played:$chan)]} {
  567. unset scrabble(is:played:$chan)
  568. }
  569. set scrabble(stop:it:$chan) 1
  570. scrabble:stop $chan
  571. }
  572. }
  573. if {[info exists scrabble(is:played:$chan)]} {
  574. unset scrabble(is:played:$chan)
  575. }
  576. }
  577.  
  578. proc scrabble:process {word} {
  579. global scrabble ranch_chars
  580. set split_word [split $word ""]
  581. set correct_word 0
  582. while {$split_word != ""} {
  583. set char_position [rand [llength $split_word]]
  584. set char [lindex $split_word $char_position]
  585. lappend rand_chars [join $char]
  586. set split_word [lreplace $split_word $char_position $char_position]
  587. }
  588. return $rand_chars
  589. }
  590.  
  591. # modif pour couleur première lettre de couleur différente de la suite
  592.  
  593. proc xystrip {text} {
  594. regsub -all -- "\003(\[0-9\]\[0-9\]?(,\[0-9\]\[0-9\]?)?)?" $text "" text
  595. set text "[string map -nocase [list \002 "" \017 "" \026 "" \037 ""] $text]"
  596. return $text
  597. }
  598.  
  599. proc preia:cuvant {nick host hand chan arg} {
  600. global scrabble
  601. set lexten "*|*"
  602. set orinick $nick
  603. if {![channel get $chan scrabble]} {
  604. return 0
  605. }
  606. set cuvant_dat [join [lindex [split $arg] 0]]
  607. set cuvant_dat [xystrip $cuvant_dat]
  608. set correct_word 0
  609. set the_word 0
  610. if {[string match $lexten $nick]} {
  611. regsub {\|.*$} $nick {} nick
  612. }
  613. set mask "ip$nick"
  614. if {![info exists scrabble($chan:run)] && ![info exists scrabble(word:$chan)]} {
  615. return 0
  616. }
  617.  
  618. if {[string length $cuvant_dat] > 3} {
  619. if {[info exists scrabble($chan:round_words)]} {
  620. if {[lsearch -exact [string tolower $scrabble($chan:round_words)] [string tolower $cuvant_dat]] > -1} {
  621. putquick "PRIVMSG $chan :\00314Désolé \00304$orinick \00314le mot\003 \00304$cuvant_dat\003 \00314a déja été dit..\003"
  622. return 0
  623. }
  624. }
  625. set split_word [string toupper [split $cuvant_dat ""]]
  626. set split_word_one $split_word
  627. set split_current [split $scrabble(current_word:$chan) ""]
  628. set file [open $scrabble(file) "r"]
  629. set data [read -nonewline $file]
  630. close $file
  631. set words [split $data "\n"]
  632. foreach char $split_current {
  633. if {[lsearch -exact $split_word $char] > -1} {
  634. set position [lsearch -exact $split_word $char]
  635. set correct_word [expr $correct_word + 1]
  636. set split_word [lreplace $split_word $position $position]
  637. }
  638. }
  639.  
  640. foreach char $split_word_one {
  641. if {[lsearch -exact $split_current $char] > -1} {
  642. set position [lsearch -exact $split_current $char]
  643. set the_word [expr $the_word + 1]
  644. set split_current [lreplace $split_current $position $position]
  645. }
  646. }
  647.  
  648. if {$correct_word > 3} {
  649. if {([lsearch -glob $words [string toupper $cuvant_dat]] > -1) && ([string length $cuvant_dat] == $correct_word)} {
  650. lappend scrabble($chan:round_words) [join $cuvant_dat]
  651. if {[info exists scrabble($chan:round_players)]} {
  652. if {[lsearch -exact $scrabble($chan:round_players) $mask] < 0} {
  653. lappend scrabble($chan:round_players) [join $mask]
  654. }
  655. } else {
  656. lappend scrabble($chan:round_players) [join $mask]
  657. }
  658.  
  659. if {($split_current == "") && ([string length $cuvant_dat] == [string length $scrabble(current_word:$chan)])} {
  660. set punctaj 500
  661. scrabble:punctaj $nick $chan $mask $punctaj
  662. anunta:punctaj $nick $chan $mask $cuvant_dat $punctaj
  663. return 0
  664. }
  665.  
  666. switch -exact -- $correct_word {
  667. 4 {
  668. set punctaj 30
  669. scrabble:punctaj $nick $chan $mask $punctaj
  670. anunta:punctaj $nick $chan $mask $cuvant_dat $punctaj
  671. }
  672. 5 {
  673. set punctaj 35
  674. scrabble:punctaj $nick $chan $mask $punctaj
  675. anunta:punctaj $nick $chan $mask $cuvant_dat $punctaj
  676. }
  677. 6 {
  678. set punctaj 40
  679. scrabble:punctaj $nick $chan $mask $punctaj
  680. anunta:punctaj $nick $chan $mask $cuvant_dat $punctaj
  681. }
  682. 7 {
  683. set punctaj 50
  684. scrabble:punctaj $nick $chan $mask $punctaj
  685. anunta:punctaj $nick $chan $mask $cuvant_dat $punctaj
  686. }
  687. 8 {
  688. set punctaj 60
  689. scrabble:punctaj $nick $chan $mask $punctaj
  690. anunta:punctaj $nick $chan $mask $cuvant_dat $punctaj
  691. }
  692. 9 {
  693. set punctaj 90
  694. scrabble:punctaj $nick $chan $mask $punctaj
  695. anunta:punctaj $nick $chan $mask $cuvant_dat $punctaj
  696. }
  697. default {
  698. set punctaj 120
  699. scrabble:punctaj $nick $chan $mask $punctaj
  700. anunta:punctaj $nick $chan $mask $cuvant_dat $punctaj
  701. }
  702. }
  703. }
  704. }
  705. }
  706. }
  707.  
  708. proc scrabble:punctaj {nick chan mask punctaj} {
  709. global scrabble
  710. set counter 0
  711. set read_points 0
  712. set read_round 0
  713. set file [open $scrabble(userfile) "r"]
  714. set data [read -nonewline $file]
  715. close $file
  716. set words [split $data "\n"]
  717. foreach line $words {
  718. set counter [expr $counter + 1]
  719. set channel [lindex [split $line] 1]
  720. set usermask [lindex [split $line] 2]
  721. if {[string match -nocase $mask $usermask] && [string match -nocase $channel $chan]} {
  722. set read_points [lindex [split $line] 3]
  723. set read_round [lindex [split $line] 4]
  724. if {$line != ""} {
  725. set counter [expr $counter - 1]
  726. set delete [lreplace $words $counter $counter]
  727. set files [open $scrabble(userfile) "w"]
  728. puts $files [join $delete "\n"]
  729. close $files
  730. }
  731. }
  732. }
  733. set file [open $scrabble(userfile) "r"]
  734. set data [read -nonewline $file]
  735. close $file
  736. if {$data == ""} {
  737. set file [open $scrabble(userfile) "w"]
  738. close $file
  739. }
  740. set file [open $scrabble(userfile) "a"]
  741. puts $file "$nick $chan $mask [expr $read_points + $punctaj] $read_round"
  742. close $file
  743. if {[info exists scrabble($mask:current_points)]} {
  744. set scrabble($mask:current_points) [expr $scrabble($mask:current_points) + $punctaj]
  745. } else {
  746. set scrabble($mask:current_points) 0
  747. set scrabble($mask:current_points) [expr $scrabble($mask:current_points) + $punctaj]
  748. }
  749. }
  750.  
  751. proc anunta:punctaj {nick chan mask cuvant_dat punctaj} {
  752. global scrabble
  753. set file [open $scrabble(userfile) "r"]
  754. set data [read -nonewline $file]
  755. close $file
  756. set words [split $data "\n"]
  757. foreach line $words {
  758. set channel [lindex [split $line] 1]
  759. set usermask [lindex [split $line] 2]
  760. set punctaj_citit [lindex [split $line] 3]
  761. set runde [lindex [split $line ] 4]
  762. if {[string match -nocase $mask $usermask] && [string match -nocase $channel $chan]} {
  763. set exists_user 1
  764. }
  765. }
  766.  
  767. if {[info exists exists_user] && [info exists scrabble($chan:the_time)]} {
  768. putquick "PRIVMSG $chan :\00304$nick\003 \00314avec le mot \00300,2 $cuvant_dat \003 \00314tu obtiens \00304$punctaj points\003 \00314en \00304[expr $scrabble($chan:the_time) - [get:scrabble:time $chan]] secondes.\003 \00314Cette manche \00309: \00304$scrabble($mask:current_points) points\003 \00309- \00314Manches gagnées \00309: \00304$runde \00309- \00314Total points \00309: \00304$punctaj_citit . \00314Faites vite il vous reste \00304[get:scrabble:time $chan] secondes\003"
  769. }
  770. }
  771.  
  772. proc scrabble:stop {chan} {
  773. global scrabble
  774. if {[info exists scrabble($chan:round_players)]} {
  775. foreach m $scrabble($chan:round_players) {
  776. if {[info exists scrabble($m:current_points)]} {
  777. unset scrabble($m:current_points)
  778. }
  779. }
  780. }
  781.  
  782. if {[info exists scrabble($chan:round_players)]} {
  783. unset scrabble($chan:round_players)
  784. }
  785.  
  786. if {[info exists scrabble($chan:run)]} {
  787. unset scrabble($chan:run)
  788. }
  789.  
  790. if {[info exists scrabble($chan:the_time)]} {
  791. unset scrabble($chan:the_time)
  792. }
  793.  
  794. if {[info exists scrabble(current_word:$chan)]} {
  795. unset scrabble(current_word:$chan)
  796. }
  797.  
  798. if {[info exists scrabble(word:$chan)]} {
  799. unset scrabble(word:$chan)
  800. }
  801.  
  802. if {[info exists scrabble($chan:round_words)]} {
  803. unset scrabble($chan:round_words)
  804. }
  805.  
  806. foreach tmr [utimers] {
  807. if {[string match "*again:scrabble*" [join [lindex $tmr 1]]]} {
  808. killutimer [lindex $tmr 2]
  809. }
  810. }
  811. }
  812.  
  813. proc get:scrabble:time {chan} {
  814. global scrabble time_left
  815. foreach tmr [utimers] {
  816. if {[string match "*again:scrabble $chan*" [join [lindex $tmr 1]]]} {
  817. set time_left [lindex $tmr 0]
  818. }
  819. }
  820. return $time_left
  821. }
  822.  
  823. proc resetare:top {chan arguments} {
  824. global scrabble
  825. foreach arg $arguments {
  826. if {$arg != ""} {
  827. set file [open $scrabble(userfile) "r"]
  828. set data [read -nonewline $file]
  829. close $file
  830. set words [split $data "\n"]
  831. set i [lsearch -glob $words "* $arg *"]
  832. if {$i > -1} {
  833. set line [lindex $words $i]
  834. set delete [lreplace $words $i $i]
  835. set file [open $scrabble(userfile) "w"]
  836. puts $file [join $delete "\n"]
  837. close $file
  838. }
  839. }
  840. }
  841. set file [open $scrabble(userfile) "r"]
  842. set data [read -nonewline $file]
  843. if {$data == ""} {
  844. set file [open $scrabble(userfile) "w"]
  845. close $file
  846. }
  847. }
  848.  
  849. putlog "Black Scrabble 1.1 By BLaCkShaDoW Loaded"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement