Advertisement
Guest User

Untitled

a guest
May 12th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.03 KB | None | 0 0
  1. ;IRcap8 5d392377c1039a9bf1dbd1318bec2ab0
  2.  
  3. alias Ajedrez {
  4. .enable #ajedrez
  5. if (!%ajed.skin) { %ajed.skin = 2D } | if (!%ajed.zoom) { %ajed.zoom = 100 | %ajed.zom = 100 } | if (!%ajed.crono) { %ajed.crono = $calc(60) }
  6. if $1 == >zoom { %aje.zoom = $2 | %ajed.zom = $2 | goto rezoom }
  7.  
  8. unset %aje.*
  9.  
  10. if ($2) { %aje.soyneg = 1 }
  11. aje.skin %ajed.skin
  12.  
  13. %aje.spr = 8 1 2,8 2 3,8 3 4,8 4 $iif($2 == $null,5,6) $+ ,8 5 $iif($2 == $null,6,5) $+ ,8 6 4,8 7 3,8 8 2
  14. %aje.spr = %aje.spr $+ ,7 1 1,7 2 1,7 3 1,7 4 1,7 5 1,7 6 1,7 7 1,7 8 1
  15. %aje.spr = %aje.spr $+ ,2 1 7,2 2 7,2 3 7,2 4 7,2 5 7,2 6 7,2 7 7,2 8 7
  16. %aje.spr = %aje.spr $+ ,1 1 8,1 2 9,1 3 10,1 4 $iif($2 == $null,11,12) $+ ,1 5 $iif($2 == $null,12,11) $+ ,1 6 10,1 7 9,1 8 8
  17.  
  18. :rezoom
  19. unset %aje.fzom2
  20. ajedrez.win
  21. if $1 == >zoom { pinta | if (%aje.nick) aje.marcador | return }
  22.  
  23. %aje.turno = N | if ($2) { %aje.turno = B }
  24. %aje.nick = $upper($me) | if ($1) { %aje.nick = $1 }
  25. if (!%tmp.ajecrono) { %tmp.ajecrono = %ajed.crono }
  26. %aje.cronoB = $calc(%tmp.ajecrono * 60) | %aje.cronoN = $calc(%tmp.ajecrono * 60) | unset %tmp.ajecrono
  27.  
  28. pinta
  29.  
  30. clear @ajedrez2 | aje.histo $s(2) | aje.histo %aje.nick
  31. var %a = $aje.stat(v,%aje.nick) | aje.histo $s(61) $+ : $+ $gettok(%a,5,32) $s(63) $+ : $+ $gettok(%a,8,32) $s(62) $+ : $+ $gettok(%a,6,32) ( $+ $gettok(%a,7,32) $+ % $+ )
  32. aje.histo $s(3) $duration(%aje.cronoB,3) | aje.histo $asctime(HH:nn * dd/mm/yy) | aje.histo $str(*,16)
  33. %aje.nummo = 0
  34.  
  35. aje.turno
  36. }
  37.  
  38. #ajedrez off
  39. alias -l aje.turno {
  40. if (%aje.turno == B) { %aje.turno = N } | else { %aje.turno = B }
  41. if (%aje.ultmovH) { inc %aje.nummo | aje.histo %aje.nummo $+ . %aje.ultmovH %aje.notex | unset %aje.ultmovH %aje.notex }
  42. .timerAJEDREZ off
  43. aje.marcador
  44. aje.crono | .timerAJEDREZ.crono -o 0 1 ajedrez.crono
  45.  
  46. if (%aje.turno == B) || (%aje.nick == $me) {
  47. if ($aje.cjaque(%aje.turno)) { aje.histo << $s(4) >> | sss flod }
  48. .timerAJEDREZ -mo 0 200 ajedrezraton
  49. }
  50. }
  51.  
  52.  
  53. alias UCLICK.@ajedrez {
  54. if (!$inrect($mouse.x,$mouse.y,20,40,$gettok(%aje.fzom2,1,32),$gettok(%aje.fzom2,2,32))) || (!$timer(ajedrez)) return
  55.  
  56. if (%aje.promopend) { aje.promo %aje.promopend | return }
  57.  
  58. if (!%aje.sely) {
  59. var %a = $aje.inf(%aje.cuy,%aje.cux)
  60. if (%a) {
  61. if $gettok(%a,6,32) != %aje.turno return
  62. %aje.selx = %aje.cux
  63. %aje.sely = %aje.cuy
  64. aje.POM %aje.cux %aje.cuy
  65. sss clik
  66. pinta sel
  67. }
  68. return
  69. }
  70.  
  71. if (%aje.selx %aje.sely == %aje.cux %aje.cuy) { rclick.@ajedrez | return }
  72.  
  73. sss clik
  74.  
  75. var %a = %aje.spr , %u = %aje.ultmov , %fg = %aje.flag
  76.  
  77. if (R isin $aje.inf(%aje.sely,%aje.selx)) && (T isin $aje.inf(%aje.cuy,%aje.cux)) {
  78. var %selx = %aje.selx , %di
  79. if (%aje.cux == 8) && ($enrocalibre(%aje.sely,%aje.selx,%aje.cux) == si) {
  80. %di = 1
  81. if (B isin $aje.inf(%aje.sely,%aje.selx)) { if (RB isin %aje.flag) || (T18 isin %aje.flag) || ($aje.amenaza(B,1 %aje.selx $+ -1 $calc(%aje.selx + 1) $+ -1 $calc(%aje.selx + 2))) { var %di } }
  82. if (N isin $aje.inf(%aje.sely,%aje.selx)) { if (RN isin %aje.flag) || (T88 isin %aje.flag) || ($aje.amenaza(N,8 %aje.selx $+ -8 $calc(%aje.selx + 1) $+ -8 $calc(%aje.selx + 2))) { var %di } }
  83. }
  84. if (%aje.cux == 1) && ($enrocalibre(%aje.sely,%aje.cux,%aje.selx) == si) {
  85. %di = -1
  86. if (B isin $aje.inf(%aje.sely,%aje.selx)) { if (RB isin %aje.flag) || (T11 isin %aje.flag) || ($aje.amenaza(B,1 %aje.selx $+ -1 $calc(%aje.selx - 1) $+ -1 $calc(%aje.selx - 2))) { var %di } }
  87. if (N isin $aje.inf(%aje.sely,%aje.selx)) { if (RN isin %aje.flag) || (T81 isin %aje.flag) || ($aje.amenaza(N,8 %aje.selx $+ -8 $calc(%aje.selx - 1) $+ -8 $calc(%aje.selx - 2))) { var %di } }
  88. }
  89. if (%di) {
  90. %aje.noturno = 1
  91. var %a = %aje.sely %selx %aje.sely $calc(%selx + (2 * %di)) , %b = %aje.cuy %aje.cux %aje.cuy $calc(%selx + (1 * %di)) | aje.mueve %b | var %u = %aje.ultmov | %aje.notex = 0-0 | aje.mueve %a
  92. if ($aje.cjaque(%aje.turno)) { %aje.spr = %a | %aje.ultmov = %u | %aje.flag = %fg | pinta | bip | return }
  93. aje.ctcp M %u * | aje.ctcp M %aje.ultmov 0-0 %aje.cronoB T
  94. aje.turno
  95. return
  96. }
  97. }
  98.  
  99. if (!$findtok(%aje.pom,%aje.cuy %aje.cux,1,44)) { bip | return }
  100.  
  101.  
  102. if (P isin $aje.inf(%aje.sely,%aje.selx)) && (%aje.cuy == 8) { var %nt = * }
  103.  
  104. aje.mueve %aje.sely %aje.selx %aje.cuy %aje.cux
  105.  
  106. if ($aje.cjaque(%aje.turno)) { %aje.spr = %a | %aje.ultmov = %u | %aje.flag = %fg | unset %aje.notex | pinta | bip | return }
  107.  
  108. if (P isin $aje.inf(%aje.cuy,%aje.cux)) {
  109. if (%aje.cuy == 8) { aje.promo promo %aje.ultmov | return }
  110. if (%aje.cuy == 1) && (%aje.nick == $me) { aje.promo promo %aje.ultmov | return }
  111. }
  112.  
  113. aje.ctcp M %aje.ultmov %nt %aje.cronoB T
  114. aje.turno
  115. }
  116.  
  117. alias -l enrocalibre {
  118. var %y = $1 , %x = $2 , %z = $3 | inc %x | dec %z
  119. while (%x <= %z) {
  120. if ($aje.inf(%y,%x)) { return no }
  121. inc %x
  122. }
  123. return si
  124. }
  125.  
  126. alias RCLICK.@ajedrez {
  127. if (!$inrect($mouse.x,$mouse.y,20,40,$gettok(%aje.fzom2,1,32),$gettok(%aje.fzom2,2,32))) return
  128. unset %aje.selx %aje.sely %aje.pom
  129. pinta sel
  130. }
  131.  
  132.  
  133. alias -l aje.mueve {
  134. %aje.ultmov = $1-
  135. var %a = $aje.inf($1,$2)
  136. var %p = $gettok(%aje.spr,$gettok(%a,1,32),44)
  137. %p = $3 $4 $gettok(%a,4,32)
  138. var %h = $aje.inf($3,$4)
  139. %aje.spr = $puttok(%aje.spr,%p,$gettok(%a,1,32),44)
  140. if (%h) {
  141. %aje.spr = $deltok(%aje.spr,$gettok(%h,1,32),44)
  142. %aje.notex = %aje.notex x $+ $gettok(%h,5,32)
  143. }
  144. else {
  145. if ($gettok(%a,5,32) == P) {
  146. if ($gettok(%a,6,32) == B) && ($1 == 5) { var %ap = $aje.inf($calc($3 - 1),$4) | if (P N isin %ap) { %aje.spr = $deltok(%aje.spr,$gettok(%ap,1,32),44) | %aje.notex = $s(5) } }
  147. if ($gettok(%a,6,32) == N) && ($1 == 4) { var %ap = $aje.inf($calc($3 + 1),$4) | if (P B isin %ap) { %aje.spr = $deltok(%aje.spr,$gettok(%ap,1,32),44) | %aje.notex = $s(5) } }
  148. }
  149. }
  150. unset %aje.selx %aje.sely %aje.pom
  151. pinta
  152. %aje.ultmovH = $iif(%aje.turno == B,) $+ $gettok(%a,5,32) $+ $chr($calc(96 + $2)) $+ $1 > $gettok(%a,5,32) $+ $chr($calc(96 + $4)) $+ $3
  153.  
  154. if (T B isin %a) && ($1 $2 == 1 1) { %aje.flag = $addtok(%aje.flag,T11,32) }
  155. if (T B isin %a) && ($1 $2 == 1 8) { %aje.flag = $addtok(%aje.flag,T18,32) }
  156. if (R B isin %a) { %aje.flag = $addtok(%aje.flag,RB,32) }
  157. if (T N isin %a) && ($1 $2 == 8 1) { %aje.flag = $addtok(%aje.flag,T81,32) }
  158. if (T N isin %a) && ($1 $2 == 8 8) { %aje.flag = $addtok(%aje.flag,T88,32) }
  159. if (R N isin %a) { %aje.flag = $addtok(%aje.flag,RN,32) }
  160. }
  161.  
  162. alias aje.CTCP if (%aje.nick != $me) { qc .ctcp %aje.nick AJEDREZ $1- | resetidle }
  163.  
  164. alias aje.tablas {
  165. %tmp.aje.pido = tablas
  166. aje.fin T Tablas
  167. aje.ctcp TABLAS OK %aje.cronoB T
  168. }
  169.  
  170.  
  171. alias aje.promo {
  172. if $1 == promo { smenu aje.promo 60 $s(6) $+  $+ $s(7) $+  $+ $s(8) $+  $+ $s(9) | %aje.promopend = $1- | return }
  173. unset %aje.promopend
  174. var %f = $aje.inf($gettok(%aje.ultmov,3,32),$gettok(%aje.ultmov,4,32))
  175. var %fe = 5
  176. if ($1 == 2) { %fe = 2 }
  177. if ($1 == 3) { %fe = 4 }
  178. if ($1 == 4) { %fe = 3 }
  179. if ($gettok(%f,6,32) == B) { inc %fe 6 }
  180. %aje.spr = $puttok(%aje.spr,$gettok(%f,2-3,32) %fe,$gettok(%f,1,32),44)
  181. var %nf = $gettok($aje.inf($gettok(%aje.ultmov,3,32),$gettok(%aje.ultmov,4,32)),5,32)
  182. aje.ctcp M %aje.ultmov *
  183. aje.ctcp promo $gettok(%aje.ultmov,3-4,32) 0 0 %fe %nf %aje.cronoB T
  184. pinta
  185. %aje.notex = %aje.notex p $+ %nf
  186. aje.turno
  187. }
  188.  
  189. alias -l pinta {
  190. drawpic -nc @ajedrezbuf 0 0 mod\ajedrez\ $+ %aje.fondo
  191.  
  192. if (%aje.ultmov) {
  193. var %y1 = $gettok(%aje.ultmov,1,32) , %x1 = $gettok(%aje.ultmov,2,32) , %y2 = $gettok(%aje.ultmov,3,32) , %x2 = $gettok(%aje.ultmov,4,32) , %t1 = $gettok(%aje.tab,%y1,44) , %t2 = $gettok(%aje.tab,%y2,44)
  194. dec %x1 | dec %x2
  195. drawline -rnd @ajedrezbuf $rgb(0,80,0) 3 $calc($gettok(%t1,1,32) + ($gettok(%t1,3,32) * %x1) + 1) $calc($gettok(%t1,2,32) - ($gettok(%t1,3,32) / 2.5) + 1) $calc($gettok(%t2,1,32) + ($gettok(%t2,3,32) * %x2) + 1) $calc($gettok(%t2,2,32) - ($gettok(%t2,3,32) / 2.5) + 1)
  196. drawrect -rnfd @ajedrezbuf $rgb(0,80,0) 1 $calc($gettok(%t1,1,32) + ($gettok(%t1,3,32) * %x1) - 4) $calc($gettok(%t1,2,32) - ($gettok(%t1,3,32) / 2.5) - 3) 12 10 16 16
  197. drawline -rnd @ajedrezbuf $rgb(0,150,0) 3 $calc($gettok(%t1,1,32) + ($gettok(%t1,3,32) * %x1)) $calc($gettok(%t1,2,32) - ($gettok(%t1,3,32) / 2.5)) $calc($gettok(%t2,1,32) + ($gettok(%t2,3,32) * %x2)) $calc($gettok(%t2,2,32) - ($gettok(%t2,3,32) / 2.5))
  198. drawrect -rnfd @ajedrezbuf $rgb(0,150,0) 1 $calc($gettok(%t1,1,32) + ($gettok(%t1,3,32) * %x1) - 5) $calc($gettok(%t1,2,32) - ($gettok(%t1,3,32) / 2.5) - 4) 12 10 16 16
  199. }
  200.  
  201. %aje.spr = $sorttok(%aje.spr,44,nr)
  202.  
  203. if (%aje.cuy) { var %cursor = %aje.cuy %aje.cux 13 }
  204.  
  205. if (%aje.sely) { var %cursor = %cursor $+ , $+ %aje.sely %aje.selx 14 }
  206.  
  207. if (%aje.pom) { var %a , %i = 1 | :L3 | var %n = $gettok(%aje.pom,%i,44) | if (%n) { %a = $addtok(%a,%n 14,44) | inc %i | goto L3 } | var %cursor = %a $ + , $+ %cursor }
  208.  
  209. var %i = 1 , %t = %cursor $+ , $+ %aje.spr | :L2
  210. var %n = $gettok(%t,%i,44) | if (%n) {
  211. sprite %n
  212. inc %i | goto L2
  213. }
  214.  
  215. if (!%aje.fzom2) { %aje.fzom2 = $int($calc($gettok(%aje.fzom,1,32) / (100 / %aje.zoom))) $int($calc($gettok(%aje.fzom,2,32) / (100 / %aje.zoom))) }
  216.  
  217. drawcopy -mn @ajedrezbuf 0 0 %aje.fzom @ajedrez 20 40 %aje.fzom2 | drawline @ajedrez
  218. }
  219.  
  220. alias -l sprite {
  221. var %sp = $3 | if (%aje.soyneg) { if (%aje.rev) { if (%sp < 7) { inc %sp 6 } | else if (%sp > 6) && (%sp < 13) { dec %sp 6 } } }
  222.  
  223. var %z = $calc(%aje.z * ($1 - 1))
  224. var %tx = $int($calc(%aje.dx - (%aje.dx * %z / 100)))
  225. var %ty = $int($calc(%aje.dy - (%aje.dy * %z / 100)))
  226.  
  227. var %l = $gettok(%aje.tab,$1,44) , %xi = $gettok(%l,1,32) , %yi = $gettok(%l,2,32) , %di = $gettok(%l,3,32)
  228. var %x = $calc(%xi + (%di * ($2 - 1))) , %y = %yi
  229.  
  230. drawpic -nctms @ajedrezbuf $rgb(0,255,0) $calc(%x - (%tx / 2)) $calc(%y - %ty) %tx %ty $calc(%aje.dx * (%sp - 1)) 0 %aje.dx %aje.dy mod\ajedrez\ $+ %aje.fichas
  231. }
  232.  
  233.  
  234. alias -l ajedrez.zoomcord {
  235. unset %aje.tabz
  236. var %i = 1 | :L1
  237. var %a = $gettok(%aje.tab,%i,44) | if (%a) {
  238. var %b = $int($calc($gettok(%a,1,32) / (100 / %aje.zoom))) $int($calc($gettok(%a,2,32) / (100 / %aje.zoom))) $calc($gettok(%a,3,32) / (100 / %aje.zoom))
  239. %aje.tabz = $addtok(%aje.tabz,%b,44)
  240. inc %i | goto L1
  241. }
  242. }
  243.  
  244. alias -l ajedrez.win {
  245. window -c @ajedrez
  246. :L1
  247. var %x = $int($calc(186 + $gettok(%aje.fzom,1,32) / (100 / %aje.zoom)))
  248. var %y = $int($calc(146 + $gettok(%aje.fzom,2,32) / (100 / %aje.zoom)))
  249. if (%x > $window(-3).w) || (%y > $window(-3).h) { dec %aje.zoom 5 | goto L1 }
  250. if (%y < 300) { %y = 300 }
  251. if (%x < 400) { %x = 400 }
  252. guiwin @ajedrez c c %x %y $s(T)
  253.  
  254. var %n = 1, %s | :L2 | var %d = $finddir(mod\ajedrez\,*,%n,1) | if (%d) { %s = $addtok(%s,$nopath(%d),22) | inc %n | goto L2 } | %s = $sorttok(%s,22,a)
  255. %ajedrez.cb = $calc(%x - 124) $calc(%y - 51) 96 aje.zoom 25%50%75%-100%-125%150%175%200%300%400% $+ $s(10) $chr(124) $calc(%x - 124) $calc(%y - 31) 96 ajed.skin %s $+  $+ $s(11)
  256.  
  257. %ajedrez.ls1 = 20 $calc(%y - 92) $calc(%x - 205) 4 1 0 ajenosel @ajedrez1
  258. window -hl @ajedrez1
  259. guilista @ajedrez ajedrez.ls1
  260.  
  261. %ajedrez.ls2 = $calc(%x - 156) 104 120 $int($calc((%y / 14) - 18)) 1 0 ajenosel @ajedrez2
  262. window -hl @ajedrez2
  263. guilista @ajedrez ajedrez.ls2
  264.  
  265. %ajedrez.bt = $calc(%x - 156) $calc(%y - 140) 122 return -| $calc(%x - 156) $calc(%y - 105) 50 ajedrez.menu_w $s(12) $chr(124) $calc(%x - 84) $calc(%y - 105) 50 ajedrez.menu_j $s(13 ) $chr(124) $calc(%x - 156) $calc(%y - 80) 122 ajedrez.menu_st $s(T)
  266. aje.botonera
  267. %ajedrez.tx = 20 $calc(%y - 33) $calc(%x - 185) aje.chat
  268.  
  269. guidib @ajedrez
  270. window -wa @ajedrez
  271. ajedrez.zoomcord
  272. }
  273. alias -l aje.botonera {
  274. var %a = $gettok($gettok(%ajedrez.bt,1,124),1-3,32)
  275. if ($1 == restaura) { %a = %a ajedrez.menu_rea $s(14) }
  276. else if (!%aje.fin) { %a = %a ajedrez.menu_o $s(15) }
  277. else {
  278. if (%aje.soyneg) { %a = %a ajedrez.menu_rn $s(16) }
  279. else { %a = %a return - }
  280. }
  281. %ajedrez.bt = $puttok(%ajedrez.bt,%a,1,124)
  282. }
  283.  
  284.  
  285. alias -l AJEDREZraton {
  286. if ($mouse.win != @ajedrez) || (!$inrect($mouse.x,$mouse.y,20,40,$gettok(%aje.fzom2,1,32),$gettok(%aje.fzom2,2,32))) return
  287. var %x = $calc($mouse.x - 20) , %y = $calc($mouse.y - 40) , %ry = %aje.cuy , %rx = %aje.cux
  288. var %i = 1 , %m = 999 | :l1
  289. var %n = $gettok($gettok(%aje.tabz,%i,44),2,32) | if (%n) {
  290. var %d = $abs($calc((%n - $calc(($gettok(%aje.tabz,2,32) - $gettok(%aje.tabz,-2,32)) / 16)) - %y))
  291. if %m > %d { %m = %d | var %yy = %i }
  292. inc %i | goto L1
  293. }
  294. var %i = $gettok(%aje.tabz,%yy,44)
  295. %aje.cuy = %yy | %aje.cux = $int($calc((%x - $gettok(%i,1,32) + ($gettok(%i,3,32) / 2) ) / $gettok(%i,3,32) + 1))
  296. if (%aje.cux < 1) || (%aje.cux > 8) { return }
  297. if (%yy) { if (%rx != %aje.cux) || (%ry != %aje.cuy) { pinta cursor } }
  298. }
  299.  
  300. alias -l aje.inf {
  301. var %i = 1 | :L1
  302. var %a = $gettok(%aje.spr,%i,44) | if (%a) {
  303. if ($gettok(%a,1-2,32) == $1 $2) {
  304. return %i %a $aje.pieza($gettok(%a,3,32)) $iif(($gettok(%a,3,32) > 6),B,N)
  305. }
  306. inc %i | goto L1
  307. }
  308. }
  309. alias -l aje.pieza return $gettok(P T C A D R P T C A D R,$1,32)
  310.  
  311.  
  312. alias -l aje.POM {
  313. unset %aje.pom
  314. var %f = $gettok($aje.inf($2,$1),5,32) , %c = $gettok($aje.inf($2,$1),6,32)
  315. goto %f
  316. :D
  317. di $1- -1 0 8
  318. di $1- -1 1 8
  319. di $1- 0 1 8
  320. di $1- 1 1 8
  321. di $1- 1 0 8
  322. di $1- 1 -1 8
  323. di $1- 0 -1 8
  324. di $1- -1 -1 8
  325. goto L1
  326. :R
  327. di $1- -1 0 1
  328. di $1- -1 1 1
  329. di $1- 0 1 1
  330. di $1- 1 1 1
  331. di $1- 1 0 1
  332. di $1- 1 -1 1
  333. di $1- 0 -1 1
  334. di $1- -1 -1 1
  335. goto L1
  336. :A
  337. di $1- -1 1 8
  338. di $1- 1 1 8
  339. di $1- 1 -1 8
  340. di $1- -1 -1 8
  341. goto L1
  342. :T
  343. di $1- -1 0 8
  344. di $1- 0 1 8
  345. di $1- 1 0 8
  346. di $1- 0 -1 8
  347. goto L1
  348. :P
  349. if %c == B {
  350. if (!$aje.inf($calc($2 + 1),$1)) di $1- 0 1 1
  351. if ($2 == 2) { if (!$aje.inf($calc($2 + 2),$1)) && (!$aje.inf($calc($2 + 1),$1)) di $1- 0 1 2 }
  352. if ($aje.inf($calc($2 + 1),$calc($1 - 1))) di $1- -1 1 1
  353. if ($aje.inf($calc($2 + 1),$calc($1 + 1))) di $1- 1 1 1
  354. if ($2 == 5) { if (%aje.ultmov == 7 $calc($1 + 1) 5 $calc($1 + 1)) di $1- 1 1 1 | if (%aje.ultmov == 7 $calc($1 - 1) 5 $calc($1 - 1)) di $1- -1 1 1 }
  355. }
  356. if %c == N {
  357. if (!$aje.inf($calc($2 - 1),$1)) di $1- 0 -1 1
  358. if ($2 == 7) { if (!$aje.inf($calc($2 - 2),$1)) && (!$aje.inf($calc($2 - 1),$1)) di $1- 0 -1 2 }
  359. if ($aje.inf($calc($2 - 1),$calc($1 - 1))) di $1- -1 -1 1
  360. if ($aje.inf($calc($2 - 1),$calc($1 + 1))) di $1- 1 -1 1
  361. if ($2 == 4) { if (%aje.ultmov == 2 $calc($1 + 1) 4 $calc($1 + 1)) di $1- 1 -1 1 | if (%aje.ultmov == 2 $calc($1 - 1) 4 $calc($1 - 1)) di $1- -1 -1 1 }
  362. }
  363. goto L1
  364. :C
  365. di $1- -2 1
  366. di $1- -1 2
  367. di $1- 2 1
  368. di $1- 1 2
  369. di $1- -2 -1
  370. di $1- -1 -2
  371. di $1- 2 -1
  372. di $1- 1 -2
  373. goto L1
  374. :L1
  375. }
  376.  
  377. alias -l DI {
  378. var %x = $1 , %y = $2 , %w = $3 , %h = $4 , %n = $5 , %c = $gettok($aje.inf(%y,%x),6,32)
  379. :L1
  380. inc %x %w | inc %y %h
  381. if (%x < 1) || (%x > 8) || (%y < 1) || (%y > 8) return
  382. var %cc = $gettok($aje.inf(%y,%x),6,32)
  383. if (%cc) {
  384. if (%cc != %c) { %aje.pom = $addtok(%aje.pom,%y %x,44) }
  385. return
  386. }
  387. %aje.pom = $addtok(%aje.pom,%y %x,44)
  388. dec %n | if %n > 0 goto L1
  389. }
  390.  
  391. alias -l DI2 {
  392. var %x = $1 , %y = $2 , %w = $3 , %h = $4 , %c = $gettok($aje.inf(%y,%x),6,32)
  393. inc %x %
  394. %aje.pom = $addtok(%aje.pom,%y %x,44)
  395. }
  396.  
  397.  
  398. alias ajedrez.cierra .timerAJEDREZ* off | if (!%aje.sefue) { if (!%aje.fin) { aje.ctcp Q | aje.stat - %aje.nick } | aje.ctcp CV } | window -c @ajedrezbuf | unset %aje.* | .disable #ajedrez
  399.  
  400. alias -l aje.skin {
  401. var %c = mod\ajedrez\ $+ $1 $+ \ajskin.ini
  402. %aje.tab = $readini(%c,ajedrez,xyz)
  403. %aje.z = $readini(%c,ajedrez,zoom)
  404. %aje.dx = $readini(%c,ajedrez,ancho)
  405. %aje.dy = $readini(%c,ajedrez,alto)
  406. %aje.fzom = $readini(%c,ajedrez,tabla)
  407. %aje.fichas = $1 $+ \ $+ $readini(%c,ajedrez,fichas)
  408. %aje.fondo = $1 $+ \ $+ $readini(%c,ajedrez,tablero)
  409. unset %aje.rev | if ($readini(%c,ajedrez,neg) == 1) { %aje.rev = 1 }
  410.  
  411. %ajed.skin = $1
  412.  
  413. drawpic -c | window -c @ajedrezbuf | window -pBwh +d @ajedrezbuf 100 100 %aje.fzom
  414. ajedrez >zoom %ajed.zom
  415. }
  416.  
  417.  
  418. alias ctcp.ajedrez.nosonido if $nick == %aje.nick return $true | else return $false
  419. alias ctcp.ajedrez.noecho if $nick == %aje.nick return $true | else return $false
  420.  
  421.  
  422. alias -l aje.cjaque {
  423. var %t = $ticks
  424. var %j
  425. var %n = 1 | :L1 | var %a = $gettok(%aje.spr,%n,44) | if (%a) { if ($gettok(%a,3,32) == 6) { var %rn = $gettok(%a,1-2,32) } | if ($gettok(%a,3,32) == 12) { var %rb = $gettok(%a,1-2,32) } | inc %n | goto L1 }
  426. if (N isin $1) {
  427. var %n = 1 | :L2 | var %a = $gettok(%aje.spr,%n,44) | if (%a) {
  428. if ($gettok(%a,3,32) > 6) { aje.pom $gettok(%a,2,32) $gettok(%a,1,32) | if ($findtok(%aje.pom,%rn,1,44)) { %j = %j $+ N } }
  429. inc %n | goto L2
  430. }
  431. }
  432. if (B isin $1) {
  433. var %n = 1 | :L3 | var %a = $gettok(%aje.spr,%n,44) | if (%a) {
  434. if ($gettok(%a,3,32) < 7) { aje.pom $gettok(%a,2,32) $gettok(%a,1,32) | if ($findtok(%aje.pom,%rb,1,44)) { %j = %j $+ B } }
  435. inc %n | goto L3
  436. }
  437. }
  438. unset %aje.pom
  439. return %j
  440. }
  441.  
  442. alias -l aje.amenaza {
  443. var %t = $ticks
  444. var %j
  445. if (B isin $1) {
  446. var %n = 1 | :L1 | var %a = $gettok(%aje.spr,%n,44) | if (%a) {
  447. if ($gettok(%a,3,32) < 7) {
  448. aje.pom $gettok(%a,2,32) $gettok(%a,1,32)
  449. var %m = 1 | :L2 | var %r = $gettok($2-,%m,45) | if (%r) {
  450. if ($findtok(%aje.pom,%r,1,44)) { %j = $addtok(%j,%r,44) }
  451. inc %m | goto L2
  452. }
  453. }
  454. inc %n | goto L1
  455. }
  456. }
  457. if (N isin $1) {
  458. var %n = 1 | :L4 | var %a = $gettok(%aje.spr,%n,44) | if (%a) {
  459. if ($gettok(%a,3,32) > 6) {
  460. aje.pom $gettok(%a,2,32) $gettok(%a,1,32)
  461. var %m = 1 | :L5 | var %r = $gettok($2-,%m,45) | if (%r) {
  462. if ($findtok(%aje.pom,%r,1,44)) { %j = $addtok(%j,%r,44) }
  463. inc %m | goto L5
  464. }
  465. }
  466. inc %n | goto L4
  467. }
  468. }
  469. unset %aje.pom
  470. return %j
  471. }
  472.  
  473. alias onCOMBO.@ajedrez {
  474. if $1 == aje.zoom { ajedrez >zoom $remove(%aje.zoom,%) }
  475. if $1 == ajed.skin { aje.skin %ajed.skin }
  476. }
  477.  
  478. alias -l aje.marcador {
  479. var %x = $calc($window(@ajedrez).w - 156)
  480. cuagi @ajedrez %x 40 140 55 $rgb(40,40,40)
  481. var %c1 = $rgb(255,255,255) , %t1 = 11 , %c2 = $rgb(100,100,100) , %t2 = 9 | if %aje.turno == N { %c1 = %c2 | %t1 = %t2 | var %c2 = $rgb(255,255,255) , %t2 = 11 }
  482. var %t = $me $iif(%aje.turno == N,* $duration(%aje.cronoB,3)) , %xx = $calc(%x + 70 - ($width(%t,verdana,%t1,1) / 2)) | if %xx < %x { %xx = %x } | drawtext -ocnr @ajedrez %c1 Verdana %t1 %xx 80 140 14 %t
  483. var %t = %aje.nick $iif(%aje.turno == B,* $duration(%aje.cronoN,3)) , %xx = $calc(%x + 70 - ($width(%t,verdana,%t2,1) / 2)) | if %xx < %x { %xx = %x } | drawtext -ocnr @ajedrez %c2 Verdana %t2 %xx 42 140 14 %t
  484. drawline @ajedrez
  485. }
  486.  
  487. alias -l aje.crono {
  488. drawtext -ocnrb @ajedrez $rgb(255,255,255) $rgb(40,40,40) Verdana 20 $calc($window(@ajedrez).w - 135) 55 99 24 $duration(% [ $+ [ aje.crono $+ [ %aje.turno ] ] ],3)
  489. drawline @ajedrez
  490. }
  491.  
  492. alias -l ajedrez.crono {
  493. var %a = % [ $+ [ aje.crono $+ [ %aje.turno ] ] ]
  494. dec %a
  495. if %a == 0 {
  496. if (%aje.turno == B) aje.ctcp TIEMPO
  497. if (%aje.nick == $me) aje.fin $iif(%aje.turno == B,N,B) $s(17)
  498. else { if (%aje.turno == B) aje.fin N $s(17) }
  499. }
  500. if (%a < 0) { %a = 0 } | % [ $+ [ aje.crono $+ [ %aje.turno ] ] ] = %a
  501. aje.crono
  502. }
  503.  
  504. alias -l aje.histo {
  505. var %a = $1-
  506. if ($3 == >) {
  507. var %t = $s(1)
  508. %a = $replacexCS($1-,P,$gettok(%t,1,44),T,$gettok(%t,2,44),C,$gettok(%t,3,44),A,$gettok(%t,4,44),D,$gettok(%t,5,44),R,$gettok(%t,6,44))
  509. }
  510. aline @ajedrez2 %a
  511.  
  512. %ajedrez.ls2 = $puttok(%ajedrez.ls2,$line(@ajedrez2,0),5,32)
  513. guilista @ajedrez ajedrez.ls2
  514. drawline @ajedrez
  515. }
  516.  
  517. alias -l aje.fin {
  518. .timerajedrez* off
  519. %aje.fin = 1
  520. aje.marcador | aje.crono
  521. aje.histo $str(*,16)
  522. aje.histo $s(18)
  523. aje.histo $2-
  524. if ($1 !isin TC) aje.histo $s(19) $iif($1 == B,$me,%aje.nick)
  525. aje.histo $asctime(HH:nn * dd/mm/yy)
  526. aje.botonera | guidib @ajedrez
  527. if $1 == B aje.stat + %aje.nick | if $1 == N aje.stat - %aje.nick | if $1 == T aje.stat T %aje.nick
  528. }
  529.  
  530.  
  531. alias onEDIT.@ajedrez {
  532. if (%aje.chat) {
  533. aje.ctcp C %aje.chat
  534. aje.chat $strip($timestamp) < $+ $me $+ > %aje.chat | unset %aje.chat
  535. }
  536. }
  537. on 1:KEYDOWN:@ajedrez:*: if (%ajedrez.tx) { guipulsatx 20 $calc($window(@ajedrez).h - 33) 20 $calc($window(@ajedrez).h - 33) $calc($window(@ajedrez).w - 185) aje.chat | editbox -a $keychar }
  538.  
  539.  
  540. alias -l aje.Chat {
  541. if $1- == refres { guilista @ajedrez ajedrez.ls1 | guidib @ajedrez | return }
  542. var %l = $1- , %w = $calc($window(@ajedrez).w - 210) , %n = $wrap(%l,verdana,9,%w,0) , %i = 1 | while (%i <= %n) { aline @ajedrez1 $wrap(%l,verdana,9,%w,%i) | inc %i }
  543. :L1 | if ($line(@ajedrez1,0) > 25) { dline @ajedrez1 1 | goto L1 }
  544. %ajedrez.ls1 = $puttok(%ajedrez.ls1,$line(@ajedrez1,0),5,32)
  545. %ajedrez.ls1 = $puttok(%ajedrez.ls1,0,6,32)
  546. .timerajedrezCHAT -m 1 50 aje.chat refres
  547. write " $+ $logdir $+ $mkfn(%aje.nick) $+ .log" $strip($1-)
  548. }
  549. alias ajenosel sline -r @ajedrez1 | aje.chat refres
  550.  
  551. alias -l turno if %aje.turno == B return $me | else return %aje.nick
  552.  
  553. alias ajedrez.menu {
  554. goto $1
  555. :o
  556. if (%aje.fin) return
  557. smenu ajedrez.menu_sm 160 $s(20) - $s(21) - $s(22)
  558. return
  559. :sm
  560. if $2 == 1 {
  561. if (!$aje.cjaque(%aje.turno)) { sss fallo | return }
  562. aje.ctcp JMATE %aje.cronoB T
  563. aje.fin $iif(%aje.turno == B,N,B) $s(23)
  564. return
  565. }
  566. if $2 == 3 { set -u180 %tmp.aje.pido tablas | aje.ctcp TABLAS | aje.histo * $s(25) | if %aje.nick == $me aje.tablas }
  567. if $2 == 5 { aje.fin N $me $s(26) | aje.ctcp Q }
  568. return
  569. :w | url $urlcap $+ /fset/ajedrez.html | return
  570. :j | j $s(27) | return
  571. :st
  572. smenu ajedrez.menu_sm2 160 $s(28) ( %ajed.crono m.)- $s(29) - $s(30)
  573. return
  574. :rn
  575. %aje.reto = %aje.nick | ctcp %aje.nick AJEDREZ reto %ajed.crono $aje.version %ircapv $version
  576. return
  577. :rea
  578. if ($gettok(%tmp.aje.restaura,1,32) != $me) { aje.histo * $s(31) | aje.histo * $gettok(%tmp.aje.restaura,1,32) | fallo | return }
  579. set -u180 %tmp.aje.pido rest %aje.nick
  580. aje.ctcp REST %tmp.aje.restaura
  581. return
  582. :sm2
  583. if $2 == 1 { %ajed.crono = $$?="$s(32) %ajed.crono )" | return }
  584. if $2 == 5 { aje.stat w %aje.nick | return }
  585. if $2 == 3 {
  586. var %a = $sfile($logdir $+ \ajedrez- $+ $mkfn(%aje.nick) $+ - $+ $remove($date $+ $time,/,:) $+ .log)
  587. if (%a) savebuf @ajedrez2 " $+ %a $+ "
  588. return
  589. }
  590.  
  591. }
  592.  
  593. raw 401:*: if $2 == %aje.nick { %aje.sefue = on | if (!%aje.fin) aje.fin C $s(33) | aje.chat *** %aje.nick $s(34) | aje.restaura g }
  594. on 1:disconnect: if (!%aje.fin) { aje.fin C $s(35) | aje.restaura g }
  595. on 1:nick: if ($nick == $me) && (!%aje.fin) { aje.fin C $s(36) | aje.restaura g }
  596. #ajedrez end
  597.  
  598. menu menubar {
  599. $lower($s(T))
  600. .$s(39): ajedrez
  601. .-
  602. .$s(28) ( %ajed.crono m.): %ajed.crono = $$?=" $s(32) %ajed.crono )"
  603. .-
  604. .$s(38): aje.stat w
  605. }
  606. menu nicklist,query {
  607. $lower($s(T))
  608. .$s(37) ( %ajed.crono m.): if $1 == $me { ajedrez } | else { %aje.reto = $1 | ctcp $1 AJEDREZ reto %ajed.crono $aje.version %ircapv $version }
  609. .-
  610. .$s(38): aje.stat w $1
  611. .$s(40) $active: var %a = $aje.stat(v,$1) | say $s(T) $+ : $s(41) $+  $1 $+ : $gettok(%a,5,32) / $s(42) $+ : $gettok(%a,6,32) ( $+ $gettok(%a,7,32) $+ % $+ ) / $s(43) $+ : $gettok(%a,8,32)
  612. }
  613. alias -l aje.version return 1.0
  614.  
  615. CTCP 1:AJEDREZ: {
  616. if ($2 == RETO) {
  617. if $3 == OK { if $nick == %aje.reto { %tmp.ajecrono = %ajed.crono | ajedrez $nick } | return }
  618. if ($4 != $aje.version) { qc notice $nick $s(T) $+ : $s(44) | return }
  619. if ($window(@ajedrez)) && (!%aje.sefue) && ($nick != %aje.nick) { qc notice $nick $s(T) $+ : $s(45) | return }
  620. %tmp.ajecrono = $3
  621. pregunta $nick $s(46) ( $+ $s(3) $+ : $duration($calc($3 * 60),3) $+ )  aje.acepto $nick  qc .notice $nick $s(47)
  622. return
  623. }
  624. if ($2 == REST) {
  625. if $3 == OK {
  626. if (%tmp.aje.pido != rest $nick) return
  627. unset unset %tmp.aje.pido | aje.restaura i 0 %tmp.aje.restaura | return
  628. }
  629. pregunta $nick $s(48)  aje.restaura i 1 $3-  qc .notice $nick $s(47)
  630. return
  631. }
  632. if $nick != %aje.nick return
  633. inc -u15 %tmp.ajeflod 1 | if (%tmp.ajeflod < 10) { %cflod = $remove(%cflod,$site) }
  634.  
  635. if $2 == Q { if (!%aje.fin) aje.fin B %aje.nick $s(26) | return }
  636. if $2 == CV { aje.chat *** %aje.nick $s(50) | %aje.sefue = on | unset %ajedrez.tx | return }
  637.  
  638. if $2 == C { aje.chat $strip($timestamp) < $+ %aje.nick $+ > $3- | return }
  639.  
  640. if (%aje.fin) { inc -u20 %tmp.ajeflod 2 | aje.ctcp C $s(51) | return }
  641.  
  642. if ($gettok($3-,-1,32) == T) { %aje.cronoN = $gettok($3-,-2,32) }
  643.  
  644. if $2 == JMATE { aje.fin B $s(23) | return }
  645.  
  646. if ($2 == TABLAS) {
  647. if $2- == TABLAS { pregunta $nick $s(52)  aje.tablas  aje.ctcp TABLAS NO | return }
  648. if $2-3 == TABLAS NO { unset %tmp.aje.pido | aje.histo * $s(53) | return }
  649. if $2-3 == TABLAS OK { if (%tmp.aje.pido == tablas) { aje.fin T $s(43) | unset %tmp.aje.pido } | return }
  650. }
  651. var %y = $calc(9 - $3) , %x = $calc(9 - $4) , %y1 = $calc(9 - $5) , %x1 = $calc(9 - $6)
  652.  
  653. if $2 == M {
  654. if (0-0 isin $3-) { %aje.notex = 0-0 }
  655. aje.mueve %y %x %y1 %x1
  656. if (* !isin $3-) aje.turno
  657. }
  658. if $2 == PROMO {
  659. var %a = $aje.inf(%y,%x)
  660. %aje.spr = $puttok(%aje.spr,%y %x $calc($7 - 6),$gettok(%a,1,32),44)
  661. pinta
  662. %aje.notex = %aje.notex p $+ $8
  663. aje.turno
  664. }
  665. if $2 == TIEMPO {
  666. aje.fin B $s(17)
  667. }
  668. }
  669. alias aje.acepto .timer 1 1 ajedrez $1 1 | .ctcp $1 AJEDREZ RETO OK | unset %cflod
  670.  
  671. alias aje.restaura {
  672. if $1 == g {
  673. %tmp.aje.restaura = $me %aje.nick %aje.turno $iif((%aje.soyneg),1,0) %aje.cronoB %aje.cronoN %aje.nummo - $+ $replace(%aje.flag,$chr(32),-) %aje.spr
  674. aje.botonera restaura
  675. guidib @ajedrez
  676. }
  677. if $1 == i {
  678. .enable #ajedrez
  679. unset %aje.*
  680. %aje.nick = $iif($2 == 1,$3,$4)
  681. %aje.turno = $5 | if $2 == 0 { %aje.turno = $iif($5 == B,N,B) }
  682. if ($6 == 0) && ($2 == 1) { %aje.soyneg = 1 } | if ($6 == 1) && ($2 == 0) { %aje.soyneg = 1 }
  683. %aje.cronoN = $iif($2 == 1,$7,$8)
  684. %aje.cronoB = $iif($2 == 1,$8,$7)
  685. %aje.nummo = $9
  686. %aje.flag = $replace($10,-,$chr(32))
  687. %aje.spr = $11-
  688. if $2 == 1 {
  689. var %n = 1 , %nu | :L1
  690. var %a = $gettok(%aje.spr,%n,44) | if (%a) {
  691. var %f = $gettok(%a,3,32),44) | if (%f > 6) { dec %f 6 } | else { inc %f 6 }
  692. %nu = $addtok(%nu,$calc(9 - $gettok(%a,1,32)) $calc(9 - $gettok(%a,2,32)) %f,44)
  693. inc %n | goto L1
  694. }
  695. %aje.spr = %nu
  696. %aje.flag = $replacex(%aje.flag,RB,RN,RN,RB,T11,T88,T88,T11,T18,T81,T81,T18)
  697. aje.ctcp REST OK
  698. }
  699. .timer 1 1 ajedrez.win
  700. .timer 1 1 aje.skin %ajed.skin
  701. .timer 1 1 pinta
  702. .timer 1 1 aje.turno
  703. .timer 1 1 aje.histo * $s(54)
  704. }
  705. }
  706.  
  707. alias aje.stat {
  708. if $1 == w { .load -rs mod\ajedrez\ajedrezstats.mrc | ajedrezstats $2 | return }
  709. var %j = $replace($2,$chr(124),!)
  710. var %f = usr\ajedrezstats.ini , %t = $readini(%f,%j,t) , %g = $readini(%f,%j,g) , %e = $readini(%f,%j,e) , %gt = $readini(%f,global.,t) , %gg = $readini(%f,global.,g) , %ge = $readini(%f,global.,e)
  711.  
  712. if $1 == + || $1 == - || $1 == T {
  713. inc %gt | writeini %f global. t %gt
  714. inc %t | writeini %f %j t %t
  715. }
  716.  
  717. if $1 == + {
  718. inc %g | writeini %f %j g %g
  719. inc %gg | writeini %f global. g %gg
  720. }
  721.  
  722. if $1 == T {
  723. inc %e | writeini %f %j e %e
  724. inc %ge | writeini %f global. e %ge
  725. }
  726.  
  727. if $1 == v {
  728. return $nonull(%gt) $nonull(%gg) $nonull($round($calc((%gg * 100) / %gt),1)) $nonull(%ge) $nonull(%t) $nonull(%g) $nonull($round($calc((%g * 100) / %t),1)) $nonull(%e)
  729. }
  730. if $1 == b { remini usr/ajedrezstats.ini %j | if %j == - remove usr/ajedrezstats.ini }
  731. }
  732.  
  733. alias -l S return $hget(ajedrez,$1)
  734. on 1:SIGNAL:idioma: if ($1 != $2) { hload ajedrez "lng\ $+ %idioma $+ \ajedrez.lnh" }
  735.  
  736. on 1:unload: {
  737. window -c @ajedrez | window -c @ajedrez1 | window -c @ajedrez2 | window -c @ajedrezbuf | window -c @ajedrezstats
  738. unset %aje.* %ajed.* %ajedrez* | .timerAjedrez* off | hfree ajedrez
  739. }
  740. on 1:start: if (!%ajed.crono) { %ajed.crono = 30 } | .disable #ajedrez | .hmake -s ajedrez | hload ajedrez "lng\ $+ %idioma $+ \ajedrez.lnh"
  741. ;EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement