Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.30 KB | None | 0 0
  1. const hplDataFile = './config/hpl.json';
  2. const hplRoom = 'hpl';
  3.  
  4. const NOMINATION_TIMEOUT = 20000; //en milisegundos
  5. const TIMEOUT_WARN = 5000; //en milisegundos
  6. const MIN_PRIZE = 3; //precio al nominar
  7.  
  8. /*
  9. Script pensado para usarse en la subasta de la hpl. Por: Ecuacion
  10.  
  11. -> Para Instalarse debe colocarse este archivo en la carpeta Chat-plugins de un servidor de PS, no es necesario nada más.
  12.  
  13. Comandos:
  14. /addteam [nombre] - agrega un equipo, solo para administradores
  15. /deleteteam [nombre] - elimina un equipo, solo para administradores
  16. /setteammoney [equipo], [dinero] - establece los ks que tiene un equipo. Se restan autoáticamente al comprar un jugador, pero debe usarse para establecer los valores iniciales.
  17. /setteamauth [equipo], [capitan], [cocapitan] - Establece los usuarios con derecho a nominar en un equipo.
  18. /setmaxplayers [num] - establece el maximo número de jugadores por equipo
  19. /addplayer [jugador] - agrega un usuario a la lista de elegibles
  20. /deletelayer [jugador] - elimina un jugador elegible
  21. /forceaddplayer [equipo], [jugador] - fuerza la entrada de un jugador en un equipo, por derechos de retención
  22. /forcedeleteplayer [equipo], [jugador] - por si alguien se equivoca, quita un jugador de un equipo y lo pone en la lista de elegibles.
  23. /nominationrights [equipo] - Por defecto, los derechos de nominación pasan al siguiente equipo. Esto se puede usar para confusiones o para establecer manualmente quien nomina primero.
  24. /organizador [usuario/off] - Establece un organizador para decidir manualmente el orden.
  25.  
  26. /hplteam [nombre] - muestra el estado de un equipo.
  27. /hplplayers - muestra la lista de jugadores elegibles.
  28.  
  29. /nominar [jugador] - Nomina un jugador si tienes derecho a hacerlo, cuesta 3k
  30. /pujar - puja por un jugador +0.5K
  31. /pujar [dinero] - puja por un jugador un número de Ks superior. NOTA: Dinero es los Ks que aumentas, no los que quieres pujar
  32.  
  33. -Tras un tiempo establecido en la constante NOMINATION_TIMEOUT desde la última puja, el jugador se adjudica a un team y se le restan los Ks correspondientes.
  34. -No se puede usar /pujar si ya tenías la mayor puja.
  35. */
  36.  
  37. var fs = require('fs');
  38.  
  39. var hpl_default = {
  40. maxplayers: 20,
  41. teams: {},
  42. players: {},
  43. minplayers: 10
  44. };
  45.  
  46. if (!fs.existsSync(hplDataFile))
  47. fs.writeFileSync(hplDataFile, JSON.stringify(hpl_default));
  48.  
  49. var hpl = JSON.parse(fs.readFileSync(hplDataFile).toString());
  50.  
  51. var hpl_status = {
  52. status: 0,
  53. timeout: 0,
  54. can_nominate: {},
  55. team_can_nominate: '',
  56. nominated: '',
  57. team: '',
  58. money: 0,
  59. organizer: 0
  60. };
  61.  
  62. /* Functions */
  63.  
  64. function writeHplData() {
  65. fs.writeFileSync(hplDataFile, JSON.stringify(hpl));
  66. }
  67.  
  68. function addHplTeam(team) {
  69. var teamid = toId(team);
  70. if (hpl.teams[teamid]) return false;
  71. hpl.teams[teamid] = {
  72. id: teamid,
  73. name: team,
  74. capi: '',
  75. cocapi: '',
  76. players: {},
  77. numplayers: 0,
  78. money: 0
  79. };
  80. return true;
  81. }
  82.  
  83. function deleteHplTeam(team) {
  84. team = toId(team);
  85. if (!hpl.teams[team]) return false;
  86. delete hpl.teams[team];
  87. return true;
  88. }
  89.  
  90. function findTeamFromPlayer(player) {
  91. player = toId(player);
  92. for (var i in hpl.teams) {
  93. if (hpl.teams[i].players[player]) return i;
  94. }
  95. return false;
  96. }
  97.  
  98. function init_nominate(room, player, team, money) {
  99. hpl_status.status = 1;
  100. hpl_status.nominated = player;
  101. hpl_status.team = team;
  102. hpl_status.money = money;
  103. hpl_status.timeout = NOMINATION_TIMEOUT;
  104. room.addRaw("<div class=\"broadcast-blue\"><b>" + hpl.teams[team].name + " ha nominado al jugador " + player + " por " + money + "K!</b><br />Para pujar por él se debe usar /pujar</div>");
  105. room.update();
  106. var loop = function () {
  107. setTimeout(function () {
  108. hpl_status.timeout -= TIMEOUT_WARN;
  109. if (hpl_status.timeout <= 0) {
  110. aplicate_status(room);
  111. return;
  112. }
  113. room.addRaw("<font color = \"red\"><small>Quedan " + (hpl_status.timeout / 1000) + " segundos para pujar.</small></font>");
  114. room.update();
  115. loop();
  116. }, TIMEOUT_WARN);
  117. };
  118. loop();
  119. }
  120.  
  121. function aplicate_status(room) {
  122. hpl_status.status = 0;
  123. var team = toId(hpl_status.team);
  124. var player = toId(hpl_status.nominated);
  125. var money = hpl_status.money;
  126. if (!hpl.teams[team] || !hpl.players[player]) {
  127. room.addRaw("<div class=\"broadcast-red\"><b>El tiempo ha terminado!</b><br />Algo ha fallado! Es posible que el jugador o el equipo hayan sido alterados manualmente durante el proceso</div>");
  128. room.update();
  129. hpl_status = {
  130. status: 0,
  131. timeout: 0,
  132. can_nominate: {},
  133. team_can_nominate: '',
  134. nominated: '',
  135. team: '',
  136. money: 0,
  137. organizer: hpl_status.organizer
  138. };
  139. } else {
  140. delete hpl.players[player];
  141. hpl.teams[team].players[player] = 1;
  142. hpl.teams[team].numplayers++;
  143. hpl.teams[team].money -= money;
  144. room.addRaw("<div class=\"broadcast-green\"><b>El tiempo ha terminado!</b><br />El jugador " + player + " queda adjudicado al equipo " + hpl.teams[team].name + " por " + money + "K!</div>");
  145. var html = '<strong>' + hpl.teams[team].name + ': </strong><br />';
  146. html += "&nbsp;&nbsp;&nbsp;&nbsp;<b>Capitan:</b> " + hpl.teams[team].capi + "<br />";
  147. html += "&nbsp;&nbsp;&nbsp;&nbsp;<b>Co-Capitan:</b> " + hpl.teams[team].cocapi + "<br />";
  148. html += "&nbsp;&nbsp;&nbsp;&nbsp;<b>Dinero:</b> " + hpl.teams[team].money + "K<br />";
  149. html += "&nbsp;&nbsp;&nbsp;&nbsp;<b>Jugadores:</b> " + Object.keys(hpl.teams[team].players).join(", ") + "<br />";
  150. html += "&nbsp;&nbsp;&nbsp;&nbsp;<b>Numero de Jugadores:</b> " + hpl.teams[team].numplayers + "/" + hpl.maxplayers + "<br />";
  151. room.addRaw("<div class=\"infobox\">" + html + "</div>");
  152. room.update();
  153. writeHplData();
  154. nextTeam(room);
  155. }
  156. }
  157.  
  158. function nextTeam(room) {
  159. if (hpl_status.organizer) {
  160. hpl_status = {
  161. status: 0,
  162. timeout: 0,
  163. can_nominate: {},
  164. team_can_nominate: '',
  165. nominated: '',
  166. team: '',
  167. money: 0,
  168. organizer: hpl_status.organizer
  169. };
  170. var orgUser = Users.get(hpl_status.organizer);
  171. if (!orgUser) return;
  172. var html = '<b>Establece quien tiene el turno para nominar:</b><br />';
  173. for (var i in hpl.teams) {
  174. html += '<button name="send" value="/nturn ' + i + '">' + hpl.teams[i].name + "</button>&nbsp;";
  175. }
  176. orgUser.sendTo(room, '|raw|<div class="infobox">' + html + '</div>');
  177. return;
  178. }
  179. var team = toId(hpl_status.team_can_nominate);
  180. var nextteam = '';
  181. var teamFlag = 0;
  182. for (var i in hpl.teams) {
  183. if (teamFlag) {
  184. nextteam = i;
  185. teamFlag = 0;
  186. break;
  187. }
  188. if (i === team) teamFlag = 1;
  189. }
  190. if (teamFlag) nextteam = Object.keys(hpl.teams)[0];
  191. hpl_status.can_nominate = {};
  192. hpl_status.can_nominate[toId(hpl.teams[nextteam].capi)] = 1;
  193. hpl_status.can_nominate[toId(hpl.teams[nextteam].cocapi)] = 1;
  194. hpl_status.team_can_nominate = nextteam;
  195. room.addRaw("El equipo <b>" + hpl.teams[nextteam].name + "</b> tiene el turno para nominar a un jugador.");
  196. room.update();
  197. }
  198.  
  199. /* Commands */
  200.  
  201. exports.commands = {
  202.  
  203. /* Info */
  204.  
  205. hplhelp: function (target, room, user) {
  206. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  207. if (!this.canBroadcast()) return false;
  208. this.sendReplyBox(
  209. '<strong>Comandos informativos:</strong><br />' +
  210. ' /hplplayers - Muestra la lista de jugadores elegibles.<br />' +
  211. ' /hplteam [equipo] - Muestra info de un equipo.<br />' +
  212. ' /hplteams - Muestra la lista de equipos.<br />' +
  213. '<strong>Comandos básicos:</strong><br />' +
  214. ' /nominar [jugador] - Nomina a un jugador.<br />' +
  215. ' /pujar - puja por un jugador +0.5K<br />' +
  216. ' /pujar [dinero] - puja por un jugador un número de Ks superior.<br />' +
  217. '<strong>Comandos administrativos:</strong><br />' +
  218. ' /addteam [nombre] - agrega un equipo<br />' +
  219. ' /deleteteam [nombre] - elimina un equipo<br />' +
  220. ' /setteammoney [equipo], [dinero] - establece los ks que tiene un equipo.<br />' +
  221. ' /setteamauth [equipo], [capitan], [cocapitan] - Establece los usuarios con derecho a nominar en un equipo.<br />' +
  222. ' /setmaxplayers [num] - establece el maximo número de jugadores por equipo.<br />' +
  223. ' /setminplayers [num] - establece el mínimo número de jugadores por equipo.<br />' +
  224. ' /addplayer [jugador] - agrega un usuario a la lista de elegibles.<br />' +
  225. ' /deletelayer [jugador] - elimina un jugador elegible<br />' +
  226. ' /forceaddplayer [equipo], [jugador] - fuerza la entrada de un jugador en un equipo, por derechos de retención.<br />' +
  227. ' /forcedeleteplayer [equipo], [jugador] - por si alguien se equivoca, quita un jugador de un equipo y lo pone en la lista de elegibles.<br />' +
  228. ' /nominationrights [equipo] - Por defecto, los derechos de nominación pasan al siguiente equipo. Esto se puede usar para confusiones o para establecer manualmente quien nomina primero.<br />'
  229. );
  230. },
  231.  
  232. hplstatus: function (target, room, user) {
  233. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  234. if (!this.canBroadcast()) return false;
  235. var html = '<center><h2>Lista de equipos</h2></center>';
  236. for (var team in hpl.teams) {
  237. html += '<hr /><strong>' + hpl.teams[team].name + ': </strong><br />';
  238. html += "&nbsp;&nbsp;&nbsp;&nbsp;<b>Capitan:</b> " + hpl.teams[team].capi + "<br />";
  239. html += "&nbsp;&nbsp;&nbsp;&nbsp;<b>Co-Capitan:</b> " + hpl.teams[team].cocapi + "<br />";
  240. html += "&nbsp;&nbsp;&nbsp;&nbsp;<b>Dinero:</b> " + hpl.teams[team].money + "K<br />";
  241. html += "&nbsp;&nbsp;&nbsp;&nbsp;<b>Jugadores:</b> " + Object.keys(hpl.teams[team].players).join(", ") + "<br />";
  242. html += "&nbsp;&nbsp;&nbsp;&nbsp;<b>Numero de Jugadores:</b> " + hpl.teams[team].numplayers + "/" + hpl.maxplayers + "<br />";
  243. }
  244. this.sendReplyBox(html);
  245. },
  246.  
  247. hplteams: function (target, room, user) {
  248. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  249. if (!this.canBroadcast()) return false;
  250. var html = '<strong>Lista de equipos: </strong><br />';
  251. for (var i in hpl.teams) {
  252. html += " ->" + hpl.teams[i].name + "<br />";
  253. }
  254. this.sendReplyBox(html);
  255. },
  256.  
  257. hplteam: function (target, room, user) {
  258. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  259. if (!this.canBroadcast()) return false;
  260. var team = toId(target);
  261. if (!hpl.teams[team]) return this.sendReply("El equipo" + team + " no existe");
  262. var html = '<strong>' + hpl.teams[team].name + ': </strong><br />';
  263. html += "&nbsp;&nbsp;&nbsp;&nbsp;<b>Capitan:</b> " + hpl.teams[team].capi + "<br />";
  264. html += "&nbsp;&nbsp;&nbsp;&nbsp;<b>Co-Capitan:</b> " + hpl.teams[team].cocapi + "<br />";
  265. html += "&nbsp;&nbsp;&nbsp;&nbsp;<b>Dinero:</b> " + hpl.teams[team].money + "K<br />";
  266. html += "&nbsp;&nbsp;&nbsp;&nbsp;<b>Jugadores:</b> " + Object.keys(hpl.teams[team].players).join(", ") + "<br />";
  267. html += "&nbsp;&nbsp;&nbsp;&nbsp;<b>Numero de Jugadores:</b> " + hpl.teams[team].numplayers + "/" + hpl.maxplayers + "<br />";
  268. this.sendReplyBox(html);
  269. },
  270.  
  271. hplplayers: function (target, room, user) {
  272. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  273. if (!this.canBroadcast()) return false;
  274. var html = '<strong>Lista de jugadores elegibles: </strong>' + Object.keys(hpl.players).join(", ");
  275. this.sendReplyBox(html);
  276. },
  277.  
  278. /* Basic */
  279.  
  280. nominate: 'nominar',
  281. nominar: function (target, room, user) {
  282. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  283. if (hpl_status.status !== 0) return this.sendReply("No se puede nominar mientras se está pujando");
  284. var player = toId(target);
  285. if (!hpl.players[player]) return this.sendReply("El jugador " + player + " no está en la lista de jugadores elegibles");
  286. //check
  287. var team = 0;
  288. for (var i in hpl.teams) {
  289. if (user.userid === toId(hpl.teams[i].capi) || user.userid === toId(hpl.teams[i].cocapi)) {
  290. team = i;
  291. break;
  292. }
  293. }
  294. if (!team) return this.sendReply("No tienes autoridad en ningún equipo");
  295. if (toId(hpl_status.team_can_nominate) !== team) {
  296. if (!hpl.teams[toId(hpl_status.team_can_nominate)]) return this.sendReply(hpl.teams[team].name + " no tiene el turno para nominar. Lo tiene " + toId(hpl_status.team_can_nominate));
  297. return this.sendReply(hpl.teams[team].name + " no tiene el turno para nominar. Lo tiene " + hpl.teams[toId(hpl_status.team_can_nominate)].name);
  298. }
  299. if (hpl.teams[team].money < MIN_PRIZE) return this.sendReply(hpl.teams[team].name + " no tiene suficiente dinero para nominar.");
  300. if (hpl.teams[team].numplayers >= hpl.maxplayers) return this.sendReply("El equipo está completo");
  301. this.privateModCommand("(" + user.name + " ha nominado al jugador " + player + ")");
  302. init_nominate(room, player, team, MIN_PRIZE);
  303. },
  304.  
  305. p: 'pujar',
  306. bid: 'pujar',
  307. pujar: function (target, room, user) {
  308. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  309. if (hpl_status.status !== 1) return this.sendReply("No hay ningún usuario nominado");
  310. var money;
  311. if (!target || !target.length) money = 0.5;
  312. else money = parseFloat(target) - hpl_status.money;
  313. if (!money || money < 0) return this.sendReply("La cantidad especificada es inferior a la puja actual");
  314. //check
  315. var team = 0;
  316. for (var i in hpl.teams) {
  317. if (user.userid === toId(hpl.teams[i].capi) || user.userid === toId(hpl.teams[i].cocapi)) {
  318. team = i;
  319. break;
  320. }
  321. }
  322. if (!team) return this.sendReply("No tienes autoridad en ningún equipo");
  323. if (toId(hpl_status.team) === team) return this.sendReply("No tiene sentido aumentar la puja si ya tienes la puja más alta");
  324. var totalMoney = hpl_status.money + money;
  325. if (hpl.teams[team].money < totalMoney + (hpl.minplayers - hpl.teams[team].numplayers - 1) * MIN_PRIZE) return this.sendReply(hpl.teams[team].name + " no tiene suficiente dinero para subir la puja. Aun debes completar tu equipo.");
  326. if (hpl.teams[team].money < totalMoney) return this.sendReply(hpl.teams[team].name + " no tiene suficiente dinero para subir la puja.");
  327. if (hpl.teams[team].numplayers >= hpl.maxplayers) return this.sendReply("El equipo está completo");
  328. //do
  329. hpl_status.timeout = NOMINATION_TIMEOUT;
  330. hpl_status.team = team;
  331. hpl_status.money = totalMoney;
  332. room.addRaw(user.name + ": <b>" + hpl.teams[team].name + "</b> sube <b>" + money + "K</b>. Puja actual: <b>" + totalMoney + "K</b> por el jugador <b>" + hpl_status.nominated + "</b>.");
  333. room.update();
  334. },
  335.  
  336. /* Administration */
  337.  
  338. addteam: function (target, room, user) {
  339. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  340. if (!this.can('hlp')) return false;
  341. if (!target || target.length < 3) return this.sendReply("El nombre es demasiado corto");
  342. if (addHplTeam(target)) {
  343. this.addModCommand(user.name + " ha registrado el equipo " + target);
  344. writeHplData();
  345. } else {
  346. this.sendReply("El equipo " + toId(target) + " ya está registrado");
  347. }
  348. },
  349.  
  350. deleteteam: function (target, room, user) {
  351. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  352. if (!this.can('hlp')) return false;
  353. if (deleteHplTeam(target)) {
  354. this.addModCommand(user.name + " ha eliminado el equipo " + target);
  355. writeHplData();
  356. } else {
  357. this.sendReply("El equipo " + toId(target) + " no existe");
  358. }
  359. },
  360.  
  361. stm: 'setteammoney',
  362. setteammoney: function (target, room, user) {
  363. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  364. if (!this.can('hlp')) return false;
  365. var args = target.split(",");
  366. if (args.length < 2) return this.sendReply("Usage: /setteammoney [equipo], [dinero]");
  367. var team = toId(args[0]);
  368. var money = parseFloat(args[1]);
  369. if (!hpl.teams[team]) return this.sendReply("El equipo " + team + " no existe");
  370. if (!money || money < 0) return this.sendReply("La cantidad especificada no es válida");
  371. hpl.teams[team].money = money;
  372. this.addModCommand(user.name + " ha establecido la cantidad inicial de dinero del equipo " + hpl.teams[team].name + ": " + money + "K");
  373. writeHplData();
  374. },
  375.  
  376. setmaxplayers: function (target, room, user) {
  377. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  378. if (!this.can('hlp')) return false;
  379. var maxplayers = parseInt(target);
  380. if (!maxplayers) return this.sendReply("La cantidad especificada no es válida");
  381. hpl.maxplayers = maxplayers;
  382. this.addModCommand(user.name + " ha establecido el número máximo de jugadores por equipo: " + hpl.maxplayers);
  383. writeHplData();
  384. },
  385.  
  386. setminplayers: function (target, room, user) {
  387. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  388. if (!this.can('hlp')) return false;
  389. var minplayers = parseInt(target);
  390. if (!minplayers) return this.sendReply("La cantidad especificada no es válida");
  391. hpl.minplayers = minplayers;
  392. this.addModCommand(user.name + " ha establecido el número mínimo de jugadores por equipo: " + hpl.minplayers);
  393. writeHplData();
  394. },
  395.  
  396. setteamauth: function (target, room, user) {
  397. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  398. if (!this.can('hlp')) return false;
  399. var args = target.split(",");
  400. if (args.length < 3) return this.sendReply("Usage: /setteamauth [equipo], [capitan], [cocapitan]");
  401. var team = toId(args[0]);
  402. var capi = args[1];
  403. var cocapi = args[2];
  404. if (!hpl.teams[team]) return this.sendReply("El equipo " + team + " no existe");
  405. hpl.teams[team].capi = capi;
  406. hpl.teams[team].cocapi = cocapi;
  407. this.addModCommand(user.name + " ha establecido la autoridad del equipo " + hpl.teams[team].name + ": " + capi + " (Capitán) y " + cocapi + " (Co-Capitán)");
  408. writeHplData();
  409. },
  410.  
  411. addplayer: function (target, room, user) {
  412. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  413. if (!this.can('hlp')) return false;
  414. if (!target || target.length < 2) return this.sendReply("El nombre es demasiado corto");
  415. var team = findTeamFromPlayer(target);
  416. if (team) return this.sendReply("El jugador se encontraba dentro del equipo " + hpl.teams[team].name);
  417. if (hpl.players[toId(target)]) return this.sendReply("El jugador ya estaba en la lista de elegibles");
  418. hpl.players[toId(target)] = 1;
  419. this.addModCommand(user.name + " ha agregado un jugador: " + target);
  420. },
  421.  
  422. deleteplayer: function (target, room, user) {
  423. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  424. if (!this.can('hlp')) return false;
  425. if (!hpl.players[toId(target)]) return this.sendReply("El jugador no estaba en la lista de elegibles");
  426. delete hpl.players[toId(target)];
  427. this.addModCommand(user.name + " ha eliminado un jugador: " + target);
  428. writeHplData();
  429. },
  430.  
  431. fap: 'forceaddplayer',
  432. forceaddplayer: function (target, room, user) {
  433. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  434. if (!this.can('hlp')) return false;
  435. var args = target.split(",");
  436. if (args.length < 2) return this.sendReply("Usage: /forceaddplayer [equipo], [jugador]");
  437. var team = toId(args[0]);
  438. var player = toId(args[1]);
  439. if (!hpl.teams[team]) return this.sendReply("El equipo " + team + " no existe");
  440. if (!hpl.players[player]) return this.sendReply("El jugador no estaba en la lista de elegibles");
  441. if (hpl.teams[team].numplayers >= hpl.maxplayers) return this.sendReply("El equipo está completo");
  442. delete hpl.players[player];
  443. hpl.teams[team].players[player] = 1;
  444. hpl.teams[team].numplayers++;
  445. this.addModCommand(user.name + " ha forzado al jugador " + player + " a unirse al equipo " + hpl.teams[team].name);
  446. writeHplData();
  447. },
  448.  
  449. fdp: 'forcedeleteplayer',
  450. forcedeleteplayer: function (target, room, user) {
  451. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  452. if (!this.can('hlp')) return false;
  453. var args = target.split(",");
  454. if (args.length < 2) return this.sendReply("Usage: /forcedeleteplayer [equipo], [jugador]");
  455. var team = toId(args[0]);
  456. var player = toId(args[1]);
  457. if (!hpl.teams[team]) return this.sendReply("El equipo " + team + " no existe");
  458. if (!hpl.teams[team].players[player]) return this.sendReply("El jugador no estaba en el equipo especificado");
  459. hpl.players[player] = 1;
  460. delete hpl.teams[team].players[player];
  461. hpl.teams[team].numplayers--;
  462. this.addModCommand(user.name + " ha forzado al jugador " + player + " a abandonar el equipo " + hpl.teams[team].name);
  463. writeHplData();
  464. },
  465.  
  466. nturn: 'nominationrights',
  467. nominationturn: 'nominationrights',
  468. nominationrights: function (target, room, user) {
  469. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  470. if (!this.can('hlp')) return false;
  471. var team = toId(target);
  472. if (!hpl.teams[team]) return this.sendReply("El equipo " + team + " no existe");
  473. hpl_status.can_nominate = {};
  474. hpl_status.can_nominate[toId(hpl.teams[team].capi)] = 1;
  475. hpl_status.can_nominate[toId(hpl.teams[team].cocapi)] = 1;
  476. hpl_status.team_can_nominate = team;
  477. this.addModCommand(user.name + ": " + hpl.teams[team].name + " tiene el turno para nominar un jugador.");
  478. },
  479.  
  480. setorganizer: 'organizador',
  481. organizador: function (target, room, user) {
  482. if (room.id !== hplRoom) return this.sendReply("Este comando solo puede ser usado en la sala hpl");
  483. if (!this.can('hlp')) return false;
  484. if (toId(target) === "off") {
  485. hpl_status.organizer = 0;
  486. return this.addModCommand(user.name + " ha establecido el orden rotatorio en la subasta");
  487. }
  488. hpl_status.organizer = toId(target);
  489. this.addModCommand(user.name + " ha establecido a " + target + " como organizador de la subasta. Por lo que el orden será decidido manualmente.");
  490. }
  491. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement