From 54e8358776548d59c393be4992c9e9fc825068ed Mon Sep 17 00:00:00 2001 From: Alex De Arnas Date: Mon, 9 Jan 2017 12:16:47 -0500 Subject: [PATCH] improved search with candy --- pokemonSystem/scripts/games/pokemonSystem.js | 48 ++++++++++--------- waifuGames/scripts/games/waifuGames.js | 49 +++++++++++--------- 2 files changed, 53 insertions(+), 44 deletions(-) diff --git a/pokemonSystem/scripts/games/pokemonSystem.js b/pokemonSystem/scripts/games/pokemonSystem.js index e8d4f78..68fb1a7 100644 --- a/pokemonSystem/scripts/games/pokemonSystem.js +++ b/pokemonSystem/scripts/games/pokemonSystem.js @@ -409,7 +409,7 @@ } function rareChance(action) { - var toggle = $.inidb.get('settings', 'rChance'); + var toggle = $.inidb.get('settings', 'rChance'); if (toggle == 'true') { $.say($.lang.get('waifugames.rare.over')); @@ -421,7 +421,7 @@ $.inidb.set('settings', 'rChance', 'true'); } else { - return; + return; } } @@ -637,7 +637,10 @@ * @param {Number} id */ function addharem(username, id) { - var atk = 1, def = 1, love = 1, lewd = 1; + var atk = 1, + def = 1, + love = 1, + lewd = 1; if (!waifuExists(id)) { $.say($.lang.get('waifugames.exist.404', $.whisperPrefix(username))); @@ -719,15 +722,16 @@ * @param {String} sender */ function useCandy(username, amount, id) { - if (getCandy(username) < 1) { - $.say($.lang.get('waifugames.candy.nostock', $.whisperPrefix(username))); - return; - } - if (id === undefined) { - id = getWaifuId(amount); - amount = 1; + if (getCandy(username) < 1) { + $.say($.lang.get('waifugames.candy.nostock', $.whisperPrefix(username))); + return; + } + if (id === '') { + id = getWaifuId(amount); + amount = 1; } else { - id = getWaifuId(id); + id = getWaifuId(id); + amount = amount; } if (!waifuExists(id)) { @@ -740,13 +744,13 @@ return; } - $.inidb.incr(username, 'team', id, 100*amount); - $.inidb.incr(username, 'pAttack', id, 1*amount); - $.inidb.incr(username, 'pDefense', id, 1*amount); - $.inidb.incr(username, 'pLove', id, 1*amount); - $.inidb.incr(username, 'pLewdness', id, 1*amount); - $.inidb.decr(username, 'pcandy', 1*amount); - $.say($.lang.get('waifuGames.candy.use', $.whisperPrefix(username), replace(getWaifu(id)), replace2(getWaifu(id)), (100*amount), getEXP(username, id), getLevel(username, id), getCandy(username, id))); + $.inidb.incr(username, 'team', id, 100 * amount); + $.inidb.incr(username, 'pAttack', id, 1 * amount); + $.inidb.incr(username, 'pDefense', id, 1 * amount); + $.inidb.incr(username, 'pLove', id, 1 * amount); + $.inidb.incr(username, 'pLewdness', id, 1 * amount); + $.inidb.decr(username, 'pcandy', 1 * amount); + $.say($.lang.get('waifuGames.candy.use', $.whisperPrefix(username), replace(getWaifu(id)), replace2(getWaifu(id)), (100 * amount), getEXP(username, id), getLevel(username, id), getCandy(username, id))); } /* @@ -766,7 +770,7 @@ attacker = $.userPrefix(username); if (!action == '') { - id =getWaifuId(action); + id = getWaifuId(action); player1 = getWaifu(getWaifuId(action)); } else { id = getRandomharemIdFromUser(username); @@ -828,8 +832,8 @@ return; } if ($.isOnline($.channelName)) { - startBattle(sender, action.toLowerCase(), args.slice(1).join(' ')); - } + startBattle(sender, action.toLowerCase(), args.slice(1).join(' ')); + } } if (command.equalsIgnoreCase('candy')) { @@ -837,7 +841,7 @@ $.say($.lang.get('waifugames.candy.get', $.whisperPrefix(sender), getCandy(sender))); return; } else { - useCandy(sender, action, subAction); + useCandy(sender, action, args.slice(1).join(' ')); } } diff --git a/waifuGames/scripts/games/waifuGames.js b/waifuGames/scripts/games/waifuGames.js index 47427b5..64ed7b4 100644 --- a/waifuGames/scripts/games/waifuGames.js +++ b/waifuGames/scripts/games/waifuGames.js @@ -409,7 +409,7 @@ } function rareChance(action) { - var toggle = $.inidb.get('settings', 'rChance'); + var toggle = $.inidb.get('settings', 'rChance'); if (toggle == 'true') { $.say($.lang.get('waifugames.rare.over')); @@ -421,7 +421,7 @@ $.inidb.set('settings', 'rChance', 'true'); } else { - return; + return; } } @@ -637,7 +637,10 @@ * @param {Number} id */ function addHarem(username, id) { - var atk = 1, def = 1, love = 1, lewd = 1; + var atk = 1, + def = 1, + love = 1, + lewd = 1; if (!waifuExists(id)) { $.say($.lang.get('waifugames.exist.404', $.whisperPrefix(username))); @@ -720,15 +723,17 @@ */ function useCandy(username, amount, id) { - if (getCandy(username) < 1) { - $.say($.lang.get('waifugames.candy.nostock', $.whisperPrefix(username))); - return; - } - if (id === undefined) { - id = getWaifuId(amount); - amount = 1; + if (getCandy(username) < 1) { + $.say($.lang.get('waifugames.candy.nostock', $.whisperPrefix(username))); + return; + } + + if (id === '') { + id = getWaifuId(amount); + amount = 1; } else { - id = getWaifuId(id); + id = getWaifuId(id); + amount = amount; } if (!waifuExists(id)) { @@ -742,13 +747,13 @@ } - $.inidb.incr(username, 'harem', id, 100*amount); - $.inidb.incr(username, 'wAttack', id, 1*amount); - $.inidb.incr(username, 'wDefense', id, 1*amount); - $.inidb.incr(username, 'wLove', id, 1*amount); - $.inidb.incr(username, 'wLewdness', id, 1*amount); - $.inidb.decr(username, 'candy', 1*amount); - $.say($.lang.get('waifuGames.candy.use', $.whisperPrefix(username), replace(getWaifu(id)), replace2(getWaifu(id)), (100*amount), getEXP(username, id), getLevel(username, id), getCandy(username, id))); + $.inidb.incr(username, 'harem', id, 100 * amount); + $.inidb.incr(username, 'wAttack', id, 1 * amount); + $.inidb.incr(username, 'wDefense', id, 1 * amount); + $.inidb.incr(username, 'wLove', id, 1 * amount); + $.inidb.incr(username, 'wLewdness', id, 1 * amount); + $.inidb.decr(username, 'candy', 1 * amount); + $.say($.lang.get('waifuGames.candy.use', $.whisperPrefix(username), replace(getWaifu(id)), replace2(getWaifu(id)), (100 * amount), getEXP(username, id), getLevel(username, id), getCandy(username, id))); } /* @@ -768,7 +773,7 @@ attacker = $.userPrefix(username); if (!action == '') { - id =getWaifuId(action); + id = getWaifuId(action); player1 = getWaifu(getWaifuId(action)); } else { id = getRandomHaremIdFromUser(username); @@ -830,8 +835,8 @@ return; } if ($.isOnline($.channelName)) { - startBattle(sender, action.toLowerCase(), args.slice(1).join(' ')); - } + startBattle(sender, action.toLowerCase(), args.slice(1).join(' ')); + } } if (command.equalsIgnoreCase('candy')) { @@ -839,7 +844,7 @@ $.say($.lang.get('waifugames.candy.get', $.whisperPrefix(sender), getCandy(sender))); return; } else { - useCandy(sender, action, subAction); + useCandy(sender, action, args.slice(1).join(' ')); } }