WhackAZimp

Whack a Zimp

  1. // ==UserScript==
  2. // @name WhackAZimp
  3. // @namespace InGame
  4. // @include http://www.dreadcast.net/Main
  5. // @include https://www.dreadcast.eu/Main
  6. // @version 1.0711
  7. // @grant none
  8. // @description Whack a Zimp
  9. // ==/UserScript==
  10.  
  11. whacAZimpNum = 0;
  12.  
  13. var whacAZimp = (function () {
  14. var CONGRATULATIONS = 'Well done you are The Whac a Zimp champion!',
  15. HEIGHT = 4,
  16. WIDTH = 7,
  17. LEVELUP = 80,
  18. initialize,
  19. levelHolder,
  20. level,
  21. li,
  22. liElements = [],
  23. tronchesZimp = [],
  24. tronchesGentils = [],
  25. prevZimp,
  26. prepGame,
  27. prepStage,
  28. renderZimp,
  29. renderStage,
  30. setUpEvents,
  31. scoreHolder,
  32. score,
  33. vieHolder,
  34. vie,
  35. stage,
  36. speed = 1100,
  37. startGame,
  38. timer,
  39. diff,
  40. utils = {
  41. id: function (id) {
  42. return document.getElementById(id);
  43. },
  44. getNodeAsInt: function (parent) {
  45. return parent.firstChild.nodeValue - 0;
  46. },
  47. setFirstChildValue: function (parentElem, value) {
  48. parentElem.firstChild.nodeValue = value;
  49. },
  50. setTimer: function (func, ms) {
  51. return setInterval(func, ms);
  52. }
  53. };
  54.  
  55. initialize = function (a) {
  56. liElements = [];
  57. if (undefined !== timer)
  58. clearInterval(timer);
  59. prepStage();
  60. renderStage();
  61. prepGame();
  62. setUpEvents();
  63. startGame(a);
  64. };
  65.  
  66. prepStage = function () {
  67. li = document.createElement('li');
  68. li.style.backgroundColor="#ccc";
  69. li.style.display = "inline-block";
  70. li.style.height = "50px";
  71. li.style.margin = "0 0 5px 5px";
  72. li.style.textDecoration = "none";
  73. li.style.width = "50px";
  74. li.style.backgroundImage = "url('http://nsa33.casimages.com/img/2014/06/05/14060503480228466.png')";
  75. li.style.backgroundSize = "cover";
  76.  
  77. stage = document.getElementById('ulStage'+whacAZimpNum);
  78.  
  79. };
  80.  
  81. renderStage = function () {
  82. for (var i = 0; i < (HEIGHT * WIDTH); i++) {
  83. var cloneLi = li.cloneNode(false);
  84.  
  85. stage.appendChild(cloneLi);
  86. liElements.push(cloneLi);
  87. }
  88. };
  89.  
  90. prepGame = function () {
  91. levelHolder = utils.id('level'+whacAZimpNum);
  92. level = utils.getNodeAsInt(levelHolder);
  93. scoreHolder = utils.id('score'+whacAZimpNum);
  94. score = utils.getNodeAsInt(scoreHolder);
  95. vieHolder = utils.id('vie'+whacAZimpNum);
  96. vie = utils.getNodeAsInt(vieHolder);
  97. };
  98.  
  99. setUpEvents = function () {
  100. stage.addEventListener('click', function(e) {
  101. if (e.target && 'li' === e.target.nodeName.toLowerCase()) {
  102. if ('zimp' === e.target.className) {
  103. score += 10;
  104. utils.setFirstChildValue(scoreHolder, score);
  105. e.target.style.backgroundImage = "url('http://nsa34.casimages.com/img/2014/06/05/14060504012010051.jpg')";
  106.  
  107. if (score === level*100) {
  108. clearInterval(timer);
  109. if (1000 === score) {
  110. scoreHolder.parentNode.innerHTML = CONGRATULATIONS;
  111. } else {
  112. speed -= LEVELUP;
  113. if(diff==1)
  114. timer = utils.setTimer(renderZimpFacile, speed);
  115. else if (diff > 1 || diff == -10)
  116. timer = utils.setTimer(renderZimp, speed);
  117.  
  118. level++;
  119. utils.setFirstChildValue(levelHolder, level);
  120. }
  121. }
  122. }
  123. else //erreur
  124. {
  125. if('zentil' === e.target.className)
  126. {
  127. score -= 50;
  128. if(diff > 2 || diff == -10)
  129. {
  130. if(vie > 0)
  131. {
  132. vie -= 1;
  133. utils.setFirstChildValue(vieHolder, vie);
  134. }
  135.  
  136. if(vie == 0)
  137. {
  138. clearInterval(timer);
  139. utils.setFirstChildValue(vieHolder, "Perdu!!");
  140. }
  141. }
  142. }
  143. else
  144. score -= 10;
  145. utils.setFirstChildValue(scoreHolder, score);
  146. e.target.style.backgroundImage = "url('http://nsa34.casimages.com/img/2014/06/05/14060504012010051.jpg')";
  147. setTimeout(function(){e.target.style.backgroundImage = "url('http://nsa33.casimages.com/img/2014/06/05/14060503480228466.png')";},speed);
  148. if (level > 1 && score < ((level-1)*100))
  149. {
  150. clearInterval(timer);
  151. speed += LEVELUP;
  152. if(diff==1)
  153. timer = utils.setTimer(renderZimpFacile, speed);
  154. else if (diff > 1 || diff == -10)
  155. timer = utils.setTimer(renderZimp, speed);
  156. level--;
  157. utils.setFirstChildValue(levelHolder, level);
  158. }
  159. }
  160. }
  161. }, false);
  162. };
  163.  
  164. startGame = function (a) {
  165. diff = a;
  166. if(diff==1)
  167. timer = utils.setTimer(renderZimpFacile, speed);
  168. else if (diff==-10)
  169. {
  170. tronchesZimp = ["Antheim.jpg", "Dann.png","ElfeSombre.jpg","Fitz.jpg","Kinchaka.jpg","Malia.png","Oshean.jpg","Sÿllia.png","Zarah.png"];
  171. tronchesGentils = ["Odul.png"];
  172. timer = utils.setTimer(renderZimp, speed);
  173. }
  174. else if (diff > 1)
  175. {
  176. tronchesZimp = ["Elea.png","Scout.png","Pistache.png","Djino.jpg","Ethayel.jpg","Valmont.jpg","L-X.jpg","Kelvin.jpg","Zalaniz.png","Laetitia.jpg","Kazuki.png","Kmaschta.jpg","Arsenia.png","Alinka.jpg","Ghost.jpg","Saurus.jpg","Manerina.jpg","Ella.jpg","Astaa.png"];
  177. tronchesGentils = ["Fitz.jpg","Kinchaka.jpg","Malia.png","Oshean.jpg","Odul.png","Sÿllia.png","Zarah.png","Junajo.png","Pixelle.jpg","Lorkah.png","EveR.png","Cyberthorvaldr.jpg","Cherakanon.jpg","Gabrielle.png","Vanity.jpg","Alucard.jpg","Joaw.png","Yenahe.jpg","Gotheve.png","Xiya.jpg","Mik.png","Ghazullmor.jpg","Akiross.png"];
  178. timer = utils.setTimer(renderZimp, speed);
  179. if(diff == 4)
  180. setInterval(function(){score -= 10; utils.setFirstChildValue(scoreHolder, score);},10000);
  181. }
  182. };
  183.  
  184. renderZimpFacile = function () {
  185. if (undefined !== prevZimp)
  186. {
  187. prevZimp.className = '';
  188. prevZimp.style.backgroundImage = "url('http://nsa33.casimages.com/img/2014/06/05/14060503480228466.png')";
  189. }
  190. prevZimp = liElements[Math.floor((Math.random()*(HEIGHT * WIDTH))+1)-1];
  191. prevZimp.className = 'zimp';
  192. if(level <= 2)
  193. prevZimp.style.backgroundImage = "url('http://nsa34.casimages.com/img/2014/06/05/140605035115599491.png')";
  194. else
  195. prevZimp.style.backgroundImage = "url('http://www.dreadcast.net/images/avatars/Elea.png')";
  196. };
  197. renderZimp = function () {
  198. if (undefined !== prevZimp)
  199. {
  200. prevZimp.className = '';
  201. prevZimp.style.backgroundImage = "url('http://nsa33.casimages.com/img/2014/06/05/14060503480228466.png')";
  202. }
  203. prevZimp = liElements[Math.floor((Math.random()*(HEIGHT * WIDTH))+1)-1];
  204. var gentilmechant =Math.floor(Math.random()*7);
  205. if (gentilmechant != 0)
  206. {
  207. var tronche = tronchesZimp[Math.floor(Math.random()*tronchesZimp.length)]
  208. prevZimp.className = 'zimp';
  209. }
  210. else
  211. {
  212. var tronche = tronchesGentils[Math.floor(Math.random()*tronchesGentils.length)]
  213. prevZimp.className = 'zentil';
  214. }
  215.  
  216. prevZimp.style.backgroundImage = "url('http://www.dreadcast.net/images/avatars/"+tronche+"')";
  217. }
  218.  
  219. return {
  220. init: initialize
  221. };
  222. })();
  223.  
  224.  
  225. Deck.prototype.executeCommandSave = Deck.prototype.executeCommand;
  226.  
  227. Deck.prototype.executeCommand=function(a,b){
  228. var c=$("#"+b+" .ligne_ecriture input").val();
  229. $.ajaxSetup({async: false});
  230. this.executeCommandSave(a,b);
  231. $.ajaxSetup({async: true});
  232. if(c.toLowerCase() === "waz")
  233. {
  234. $("#" + b + " .ligne_ecrite_fixed:last").html($("#" + b + " .ligne_ecrite_fixed:last").html() + '<div>Tapes waz niveauDeDifficulté (en minuscule) avec </br> Facile : Frappes le zimp qui apparaît et tu marques 10 points. Touches un logo rebz et tu perds dix points.</br> Moyen : Oh non c était un rebz! Si tu le confonds avec un zimp et lui éclate le nez tu perds 50 points! </br> Difficile : Moyen + Tu perds la partie si tu exploses trois rebzs! </br> Hardcore : Difficile + Tu perds dix points toutes les dix secondes. </br></br> Élections : Défoules toi sur les candidats! Mais ne touches pas à Odul! Équivalent à difficile</div>');
  235. }
  236. else if(c.toLowerCase() === "waz facile")
  237. {
  238. whacAZimpNum++;
  239. $("#" + b + " .ligne_ecrite_fixed:last").html($("#" + b + " .ligne_ecrite_fixed:last").html() + '<section style="width: 390px; padding : 5px 0;"><ul id="ulStage'+whacAZimpNum+'" style="padding : 0; margin :0; cursor : url(http://www.dreadcast.net/images/objets/mini/gant-hydro.png), auto;" ></ul><p style="color:#FFF;">Score: <span id="score'+whacAZimpNum+'">0</span> points!</p><p style="color:#FFF;">Level: <span id="level'+whacAZimpNum+'">1</span></p><p style="display:none">Vies: <span id="vie'+whacAZimpNum+'">3</span></p></section>');
  240. whacAZimp.init(1);
  241. }
  242. else if(c.toLowerCase() === "waz moyen")
  243. {
  244. whacAZimpNum++;
  245. $("#" + b + " .ligne_ecrite_fixed:last").html($("#" + b + " .ligne_ecrite_fixed:last").html() + '<section style="width: 390px; padding : 5px 0;"><ul id="ulStage'+whacAZimpNum+'" style="padding : 0; margin :0; cursor : url(http://www.dreadcast.net/images/objets/mini/gant-hydro.png), auto;" ></ul><p style="color:#FFF;">Score: <span id="score'+whacAZimpNum+'">0</span> points!</p><p style="color:#FFF;">Level: <span id="level'+whacAZimpNum+'">1</span></p><p style="display:none;">Vies: <span id="vie'+whacAZimpNum+'">3</span></p></section>');
  246. whacAZimp.init(2);
  247. }
  248. else if(c.toLowerCase() === "waz difficile")
  249. {
  250. whacAZimpNum++;
  251. $("#" + b + " .ligne_ecrite_fixed:last").html($("#" + b + " .ligne_ecrite_fixed:last").html() + '<section style="width: 390px; padding : 5px 0;"><ul id="ulStage'+whacAZimpNum+'" style="padding : 0; margin :0; cursor : url(http://www.dreadcast.net/images/objets/mini/gant-hydro.png), auto;" ></ul><p style="color:#FFF;">Score: <span id="score'+whacAZimpNum+'">0</span> points!</p><p style="color:#FFF;">Level: <span id="level'+whacAZimpNum+'">1</span></p><p style="color:#FFF;">Vies: <span id="vie'+whacAZimpNum+'">3</span></p></section>');
  252. whacAZimp.init(3);
  253. }
  254. else if(c.toLowerCase() === "waz hardcore")
  255. {
  256. whacAZimpNum++;
  257. $("#" + b + " .ligne_ecrite_fixed:last").html($("#" + b + " .ligne_ecrite_fixed:last").html() + '<section style="width: 390px; padding : 5px 0;"><ul id="ulStage'+whacAZimpNum+'" style="padding : 0; margin :0; cursor : url(http://www.dreadcast.net/images/objets/mini/gant-hydro.png), auto;" ></ul><p style="color:#FFF;">Score: <span id="score'+whacAZimpNum+'">0</span> points!</p><p style="color:#FFF;">Level: <span id="level'+whacAZimpNum+'">1</span></p><p style="color:#FFF;">Vies: <span id="vie'+whacAZimpNum+'">3</span></p></section>');
  258. whacAZimp.init(4);
  259. }
  260. else if(c.toLowerCase() === "waz elections")
  261. {
  262. whacAZimpNum++;
  263. $("#" + b + " .ligne_ecrite_fixed:last").html($("#" + b + " .ligne_ecrite_fixed:last").html() + '<section style="width: 390px; padding : 5px 0;"><ul id="ulStage'+whacAZimpNum+'" style="padding : 0; margin :0; cursor : url(http://www.dreadcast.net/images/objets/mini/gant-hydro.png), auto;" ></ul><p style="color:#FFF;">Score: <span id="score'+whacAZimpNum+'">0</span> points!</p><p style="color:#FFF;">Level: <span id="level'+whacAZimpNum+'">1</span></p><p style="color:#FFF;">Vies: <span id="vie'+whacAZimpNum+'">3</span></p></section>');
  264. whacAZimp.init(-10);
  265. }
  266. };

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址