init commit
This commit is contained in:
75
libs/phantombot/scripts/games/8ball.js
Normal file
75
libs/phantombot/scripts/games/8ball.js
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2020 phantombot.github.io/PhantomBot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 8ball.js
|
||||
*
|
||||
* A game that answers questions with random (Non-relating) answers
|
||||
*/
|
||||
(function() {
|
||||
var responseCount = 0,
|
||||
lastRandom = 0;
|
||||
|
||||
/**
|
||||
* @function loadResponses
|
||||
*/
|
||||
function loadResponses() {
|
||||
var i;
|
||||
for (i = 1; $.lang.exists('8ball.answer.' + i); i++) {
|
||||
responseCount++;
|
||||
}
|
||||
$.consoleDebug($.lang.get('8ball.console.loaded', responseCount));
|
||||
};
|
||||
|
||||
/**
|
||||
* @event command
|
||||
*/
|
||||
$.bind('command', function(event) {
|
||||
var sender = event.getSender().toLowerCase(),
|
||||
command = event.getCommand(),
|
||||
args = event.getArgs(),
|
||||
random;
|
||||
|
||||
/**
|
||||
* @commandpath 8ball [question] - Ask the 8ball for advice
|
||||
*/
|
||||
if (command.equalsIgnoreCase('8ball')) {
|
||||
if (!args[0]) {
|
||||
$.say($.resolveRank(sender) + ' ' + $.lang.get('8ball.usage'));
|
||||
$.returnCommandCost(sender, command, $.isModv3(sender, event.getTags()));
|
||||
return
|
||||
}
|
||||
|
||||
do {
|
||||
random = $.randRange(1, responseCount);
|
||||
} while (random == lastRandom);
|
||||
|
||||
$.say($.lang.get('8ball.response', $.lang.get('8ball.answer.' + random)));
|
||||
lastRandom = random;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @event initReady
|
||||
*/
|
||||
$.bind('initReady', function() {
|
||||
if (responseCount == 0) {
|
||||
loadResponses();
|
||||
}
|
||||
$.registerChatCommand('./games/8ball.js', '8ball', 7);
|
||||
});
|
||||
})();
|
||||
537
libs/phantombot/scripts/games/adventureSystem.js
Normal file
537
libs/phantombot/scripts/games/adventureSystem.js
Normal file
@@ -0,0 +1,537 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2020 phantombot.github.io/PhantomBot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var joinTime = $.getSetIniDbNumber('adventureSettings', 'joinTime', 60),
|
||||
coolDown = $.getSetIniDbNumber('adventureSettings', 'coolDown', 900),
|
||||
gainPercent = $.getSetIniDbNumber('adventureSettings', 'gainPercent', 30),
|
||||
minBet = $.getSetIniDbNumber('adventureSettings', 'minBet', 10),
|
||||
maxBet = $.getSetIniDbNumber('adventureSettings', 'maxBet', 1000),
|
||||
enterMessage = $.getSetIniDbBoolean('adventureSettings', 'enterMessage', false),
|
||||
warningMessage = $.getSetIniDbBoolean('adventureSettings', 'warningMessage', false),
|
||||
coolDownAnnounce = $.getSetIniDbBoolean('adventureSettings', 'coolDownAnnounce', false),
|
||||
currentAdventure = {},
|
||||
stories = [],
|
||||
moduleLoaded = false,
|
||||
lastStory;
|
||||
|
||||
|
||||
function reloadAdventure() {
|
||||
joinTime = $.getIniDbNumber('adventureSettings', 'joinTime');
|
||||
coolDown = $.getIniDbNumber('adventureSettings', 'coolDown');
|
||||
gainPercent = $.getIniDbNumber('adventureSettings', 'gainPercent');
|
||||
minBet = $.getIniDbNumber('adventureSettings', 'minBet');
|
||||
maxBet = $.getIniDbNumber('adventureSettings', 'maxBet');
|
||||
enterMessage = $.getIniDbBoolean('adventureSettings', 'enterMessage');
|
||||
warningMessage = $.getIniDbBoolean('adventureSettings', 'warningMessage');
|
||||
coolDownAnnounce = $.getIniDbBoolean('adventureSettings', 'coolDownAnnounce');
|
||||
};
|
||||
|
||||
/**
|
||||
* Loads stories from the prefixes 'adventuresystem.stories.default' (only if the language
|
||||
* property of 'adventuresystem.stories.default.enabled' is set to 'true') and
|
||||
* 'adventuresystem.stories'.
|
||||
*
|
||||
* Clears any previously loaded stories.
|
||||
*
|
||||
* @function loadStories
|
||||
*/
|
||||
function loadStories() {
|
||||
currentAdventure.users = [];
|
||||
currentAdventure.survivors = [];
|
||||
currentAdventure.caught = [];
|
||||
currentAdventure.gameState = 0;
|
||||
|
||||
stories = [];
|
||||
|
||||
// For backwards compatibility, load default stories if the variable is not set
|
||||
if (!$.lang.exists('adventuresystem.stories.default') || $.lang.get('adventuresystem.stories.default') === 'true') {
|
||||
loadStoriesFromPrefix('adventuresystem.stories');
|
||||
}
|
||||
|
||||
loadStoriesFromPrefix('adventuresystem.stories.custom');
|
||||
|
||||
$.consoleDebug($.lang.get('adventuresystem.loaded', stories.length));
|
||||
|
||||
for (var i in stories) {
|
||||
if (stories[i].game === null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$.log.warn('You must have at least one adventure that doesn\'t require a game to be set.');
|
||||
currentAdventure.gameState = 2;
|
||||
};
|
||||
|
||||
/**
|
||||
* Loads stories from a specific prefix in the language table and adds them to the
|
||||
* global stories array.
|
||||
*
|
||||
* @param {string} prefix - The prefix underneath which the stories can be found
|
||||
* @example
|
||||
* // Import stories with adventuresystem.stories.custom.X.title as title and
|
||||
* // adventuresystem.stories.custom.X.chapter.Y as chapters
|
||||
* loadStoriesFromPrefix('adventuresystem.stories.custom');
|
||||
*/
|
||||
function loadStoriesFromPrefix(prefix) {
|
||||
var storyId = 1,
|
||||
chapterId,
|
||||
lines;
|
||||
|
||||
for (storyId; $.lang.exists(prefix + '.' + storyId + '.title'); storyId++) {
|
||||
lines = [];
|
||||
for (chapterId = 1; $.lang.exists(prefix + '.' + storyId + '.chapter.' + chapterId); chapterId++) {
|
||||
lines.push($.lang.get(prefix + '.' + storyId + '.chapter.' + chapterId));
|
||||
}
|
||||
|
||||
stories.push({
|
||||
game: ($.lang.exists(prefix + '.' + storyId + '.game') ? $.lang.get(prefix + '.' + storyId + '.game') : null),
|
||||
title: $.lang.get(prefix + '.' + storyId + '.title'),
|
||||
lines: lines,
|
||||
});
|
||||
}
|
||||
|
||||
$.consoleDebug($.lang.get('adventuresystem.loaded.prefix', storyId - 1, prefix));
|
||||
};
|
||||
|
||||
/**
|
||||
* @function top5
|
||||
*/
|
||||
function top5() {
|
||||
var payoutsKeys = $.inidb.GetKeyList('adventurePayouts', ''),
|
||||
temp = [],
|
||||
counter = 1,
|
||||
top5 = [],
|
||||
i;
|
||||
|
||||
if (payoutsKeys.length == 0) {
|
||||
$.say($.lang.get('adventuresystem.top5.empty'));
|
||||
}
|
||||
|
||||
for (i in payoutsKeys) {
|
||||
if (payoutsKeys[i].equalsIgnoreCase($.ownerName) || payoutsKeys[i].equalsIgnoreCase($.botName)) {
|
||||
continue;
|
||||
}
|
||||
temp.push({
|
||||
username: payoutsKeys[i],
|
||||
amount: parseInt($.inidb.get('adventurePayouts', payoutsKeys[i])),
|
||||
});
|
||||
}
|
||||
|
||||
temp.sort(function(a, b) {
|
||||
return (a.amount < b.amount ? 1 : -1);
|
||||
});
|
||||
|
||||
for (i in temp) {
|
||||
if (counter <= 5) {
|
||||
top5.push(counter + '. ' + temp[i].username + ': ' + $.getPointsString(temp[i].amount));
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
$.say($.lang.get('adventuresystem.top5', top5.join(', ')));
|
||||
};
|
||||
|
||||
/**
|
||||
* @function checkUserAlreadyJoined
|
||||
* @param {string} username
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function checkUserAlreadyJoined(username) {
|
||||
var i;
|
||||
for (i in currentAdventure.users) {
|
||||
if (currentAdventure.users[i].username == username) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @function adventureUsersListJoin
|
||||
* @param {Array} list
|
||||
* @returns {string}
|
||||
*/
|
||||
function adventureUsersListJoin(list) {
|
||||
var temp = [],
|
||||
i;
|
||||
for (i in list) {
|
||||
temp.push($.username.resolve(list[i].username));
|
||||
}
|
||||
return temp.join(', ');
|
||||
};
|
||||
|
||||
/**
|
||||
* @function calculateResult
|
||||
*/
|
||||
function calculateResult() {
|
||||
var i;
|
||||
for (i in currentAdventure.users) {
|
||||
if ($.randRange(0, 20) > 5) {
|
||||
currentAdventure.survivors.push(currentAdventure.users[i]);
|
||||
} else {
|
||||
currentAdventure.caught.push(currentAdventure.users[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @function replaceTags
|
||||
* @param {string} line
|
||||
* @returns {string}
|
||||
*/
|
||||
function replaceTags(line) {
|
||||
if (line.indexOf('(caught)') > -1) {
|
||||
if (currentAdventure.caught.length > 0) {
|
||||
return line.replace('(caught)', adventureUsersListJoin(currentAdventure.caught));
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
if (line.indexOf('(survivors)') > -1) {
|
||||
if (currentAdventure.survivors.length > 0) {
|
||||
return line.replace('(survivors)', adventureUsersListJoin(currentAdventure.survivors));
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
return line
|
||||
};
|
||||
|
||||
/**
|
||||
* @function startHeist
|
||||
* @param {string} username
|
||||
*/
|
||||
function startHeist(username) {
|
||||
currentAdventure.gameState = 1;
|
||||
|
||||
var t = setTimeout(function() {
|
||||
runStory();
|
||||
}, joinTime * 1e3);
|
||||
|
||||
$.say($.lang.get('adventuresystem.start.success', $.resolveRank(username), $.pointNameMultiple));
|
||||
};
|
||||
|
||||
/**
|
||||
* @function joinHeist
|
||||
* @param {string} username
|
||||
* @param {Number} bet
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function joinHeist(username, bet) {
|
||||
if (stories.length < 1) {
|
||||
$.log.error('No adventures found; cannot start an adventure.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentAdventure.gameState > 1) {
|
||||
if (!warningMessage) return;
|
||||
$.say($.whisperPrefix(username) + $.lang.get('adventuresystem.join.notpossible'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkUserAlreadyJoined(username)) {
|
||||
if (!warningMessage) return;
|
||||
$.say($.whisperPrefix(username) + $.lang.get('adventuresystem.alreadyjoined'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (bet > $.getUserPoints(username)) {
|
||||
if (!warningMessage) return;
|
||||
$.say($.whisperPrefix(username) + $.lang.get('adventuresystem.join.needpoints', $.getPointsString(bet), $.getPointsString($.getUserPoints(username))));
|
||||
return;
|
||||
}
|
||||
|
||||
if (bet < minBet) {
|
||||
if (!warningMessage) return;
|
||||
$.say($.whisperPrefix(username) + $.lang.get('adventuresystem.join.bettoolow', $.getPointsString(bet), $.getPointsString(minBet)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (bet > maxBet) {
|
||||
if (!warningMessage) return;
|
||||
$.say($.whisperPrefix(username) + $.lang.get('adventuresystem.join.bettoohigh', $.getPointsString(bet), $.getPointsString(maxBet)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentAdventure.gameState == 0) {
|
||||
startHeist(username);
|
||||
} else {
|
||||
if (enterMessage) {
|
||||
$.say($.whisperPrefix(username) + $.lang.get('adventuresystem.join.success', $.getPointsString(bet)));
|
||||
}
|
||||
}
|
||||
|
||||
currentAdventure.users.push({
|
||||
username: username,
|
||||
bet: parseInt(bet),
|
||||
});
|
||||
|
||||
$.inidb.decr('points', username, bet);
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @function runStory
|
||||
*/
|
||||
function runStory() {
|
||||
var progress = 0,
|
||||
temp = [],
|
||||
story,
|
||||
line,
|
||||
t;
|
||||
|
||||
currentAdventure.gameState = 2;
|
||||
calculateResult();
|
||||
|
||||
var game = $.getGame($.channelName);
|
||||
|
||||
for (var i in stories) {
|
||||
if (stories[i].game != null) {
|
||||
if (game.equalsIgnoreCase(stories[i].game)) {
|
||||
//$.consoleLn('gamespec::' + stories[i].title);
|
||||
temp.push({
|
||||
title: stories[i].title,
|
||||
lines: stories[i].lines
|
||||
});
|
||||
}
|
||||
} else {
|
||||
//$.consoleLn('normal::' + stories[i].title);
|
||||
temp.push({
|
||||
title: stories[i].title,
|
||||
lines: stories[i].lines
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
story = $.randElement(temp);
|
||||
} while (story == lastStory && stories.length != 1);
|
||||
|
||||
$.say($.lang.get('adventuresystem.runstory', story.title, currentAdventure.users.length));
|
||||
|
||||
t = setInterval(function() {
|
||||
if (progress < story.lines.length) {
|
||||
line = replaceTags(story.lines[progress]);
|
||||
if (line != '') {
|
||||
$.say(line.replace(/\(game\)/g, $.twitchcache.getGameTitle() + ''));
|
||||
}
|
||||
} else {
|
||||
endHeist();
|
||||
clearInterval(t);
|
||||
}
|
||||
progress++;
|
||||
}, 7e3);
|
||||
};
|
||||
|
||||
/**
|
||||
* @function endHeist
|
||||
*/
|
||||
function endHeist() {
|
||||
var i, pay, username, maxlength = 0;
|
||||
var temp = [];
|
||||
|
||||
for (i in currentAdventure.survivors) {
|
||||
pay = (currentAdventure.survivors[i].bet * (gainPercent / 100));
|
||||
$.inidb.incr('adventurePayouts', currentAdventure.survivors[i].username, pay);
|
||||
$.inidb.incr('adventurePayoutsTEMP', currentAdventure.survivors[i].username, pay);
|
||||
$.inidb.incr('points', currentAdventure.survivors[i].username, currentAdventure.survivors[i].bet + pay);
|
||||
}
|
||||
|
||||
for (i in currentAdventure.survivors) {
|
||||
username = currentAdventure.survivors[i].username;
|
||||
maxlength += username.length();
|
||||
temp.push($.username.resolve(username) + ' (+' + $.getPointsString($.inidb.get('adventurePayoutsTEMP', currentAdventure.survivors[i].username)) + ')');
|
||||
}
|
||||
|
||||
if (temp.length == 0) {
|
||||
$.say($.lang.get('adventuresystem.completed.no.win'));
|
||||
} else if (((maxlength + 14) + $.channelName.length) > 512) {
|
||||
$.say($.lang.get('adventuresystem.completed.win.total', currentAdventure.survivors.length, currentAdventure.caught.length)); //in case too many people enter.
|
||||
} else {
|
||||
$.say($.lang.get('adventuresystem.completed', temp.join(', ')));
|
||||
}
|
||||
|
||||
clearCurrentAdventure();
|
||||
temp = "";
|
||||
$.coolDown.set('adventure', false, coolDown, false);
|
||||
if (coolDownAnnounce) {
|
||||
setTimeout(function() {
|
||||
$.say($.lang.get('adventuresystem.reset', $.pointNameMultiple));
|
||||
}, coolDown*1000);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @function clearCurrentAdventure
|
||||
*/
|
||||
function clearCurrentAdventure() {
|
||||
currentAdventure = {
|
||||
gameState: 0,
|
||||
users: [],
|
||||
survivors: [],
|
||||
caught: [],
|
||||
}
|
||||
$.inidb.RemoveFile('adventurePayoutsTEMP');
|
||||
};
|
||||
|
||||
/**
|
||||
* @event command
|
||||
*/
|
||||
$.bind('command', function(event) {
|
||||
var sender = event.getSender().toLowerCase(),
|
||||
command = event.getCommand(),
|
||||
args = event.getArgs(),
|
||||
action = args[0],
|
||||
actionArg1 = args[1],
|
||||
actionArg2 = args[2];
|
||||
|
||||
/**
|
||||
* @commandpath adventure - Adventure command for starting, checking or setting options
|
||||
* @commandpath adventure [amount] - Start/join an adventure
|
||||
*/
|
||||
if (command.equalsIgnoreCase('adventure')) {
|
||||
if (!action) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('adventuresystem.adventure.usage', $.pointNameMultiple));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isNaN(parseInt(action))) {
|
||||
joinHeist(sender, parseInt(action));
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @commandpath adventure top5 - Announce the top 5 adventurers in the chat (most points gained)
|
||||
*/
|
||||
if (action.equalsIgnoreCase('top5')) {
|
||||
top5();
|
||||
}
|
||||
|
||||
/**
|
||||
* @commandpath adventure set - Base command for controlling the adventure settings
|
||||
*/
|
||||
if (action.equalsIgnoreCase('set')) {
|
||||
if (actionArg1 === undefined || actionArg2 === undefined) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('adventuresystem.set.usage'));
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @commandpath adventure set jointime [seconds] - Set the join time
|
||||
*/
|
||||
if (actionArg1.equalsIgnoreCase('joinTime')) {
|
||||
if (isNaN(parseInt(actionArg2))) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('adventuresystem.set.usage'));
|
||||
return;
|
||||
}
|
||||
joinTime = parseInt(actionArg2);
|
||||
$.inidb.set('adventureSettings', 'joinTime', parseInt(actionArg2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @commandpath adventure set cooldown [seconds] - Set cooldown time
|
||||
*/
|
||||
if (actionArg1.equalsIgnoreCase('coolDown')) {
|
||||
if (isNaN(parseInt(actionArg2))) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('adventuresystem.set.usage'));
|
||||
return;
|
||||
}
|
||||
coolDown = parseInt(actionArg2);
|
||||
$.inidb.set('adventureSettings', 'coolDown', parseInt(actionArg2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @commandpath adventure set gainpercent [value] - Set the gain percent value
|
||||
*/
|
||||
if (actionArg1.equalsIgnoreCase('gainPercent')) {
|
||||
if (isNaN(parseInt(actionArg2))) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('adventuresystem.set.usage'));
|
||||
return;
|
||||
}
|
||||
gainPercent = parseInt(actionArg2);
|
||||
$.inidb.set('adventureSettings', 'gainPercent', parseInt(actionArg2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @commandpath adventure set minbet [value] - Set the minimum bet
|
||||
*/
|
||||
if (actionArg1.equalsIgnoreCase('minBet')) {
|
||||
if (isNaN(parseInt(actionArg2))) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('adventuresystem.set.usage'));
|
||||
return;
|
||||
}
|
||||
minBet = parseInt(actionArg2);
|
||||
$.inidb.set('adventureSettings', 'minBet', parseInt(actionArg2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @commandpath adventure set maxbet [value] - Set the maximum bet
|
||||
*/
|
||||
if (actionArg1.equalsIgnoreCase('maxBet')) {
|
||||
if (isNaN(parseInt(actionArg2))) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('adventuresystem.set.usage'));
|
||||
return;
|
||||
}
|
||||
maxBet = parseInt(actionArg2);
|
||||
$.inidb.set('adventureSettings', 'maxBet', parseInt(actionArg2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @commandpath adventure set warningmessages [true / false] - Sets the per-user warning messages
|
||||
*/
|
||||
if (actionArg1.equalsIgnoreCase('warningmessages')) {
|
||||
if (args[2].equalsIgnoreCase('true')) warningMessage = true, actionArg2 = $.lang.get('common.enabled');
|
||||
if (args[2].equalsIgnoreCase('false')) warningMessage = false, actionArg2 = $.lang.get('common.disabled');
|
||||
$.inidb.set('adventureSettings', 'warningMessage', warningMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @commandpath adventure set entrymessages [true / false] - Sets the per-user entry messages
|
||||
*/
|
||||
if (actionArg1.equalsIgnoreCase('entrymessages')) {
|
||||
if (args[2].equalsIgnoreCase('true')) enterMessage = true, actionArg2 = $.lang.get('common.enabled');
|
||||
if (args[2].equalsIgnoreCase('false')) enterMessage = false, actionArg2 = $.lang.get('common.disabled');
|
||||
$.inidb.set('adventureSettings', 'enterMessage', enterMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @commandpath adventure set cooldownannounce [true / false] - Sets the cooldown announcement
|
||||
*/
|
||||
if (actionArg1.equalsIgnoreCase('cooldownannounce')) {
|
||||
if (args[2].equalsIgnoreCase('true')) coolDownAnnounce = true, actionArg2 = $.lang.get('common.enabled');
|
||||
if (args[2].equalsIgnoreCase('false')) coolDownAnnounce = false, actionArg2 = $.lang.get('common.disabled');
|
||||
$.inidb.set('adventureSettings', 'coolDownAnnounce', coolDownAnnounce);
|
||||
}
|
||||
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('adventuresystem.set.success', actionArg1, actionArg2));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @event initReady
|
||||
*/
|
||||
$.bind('initReady', function() {
|
||||
$.registerChatCommand('./games/adventureSystem.js', 'adventure', 7);
|
||||
$.registerChatSubcommand('adventure', 'set', 1);
|
||||
$.registerChatSubcommand('adventure', 'top5', 3);
|
||||
|
||||
loadStories();
|
||||
});
|
||||
|
||||
$.reloadAdventure = reloadAdventure;
|
||||
})();
|
||||
153
libs/phantombot/scripts/games/gambling.js
Normal file
153
libs/phantombot/scripts/games/gambling.js
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2020 phantombot.github.io/PhantomBot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var winGainPercent = $.getSetIniDbNumber('gambling', 'winGainPercent', 30),
|
||||
winRange = $.getSetIniDbNumber('gambling', 'winRange', 50),
|
||||
max = $.getSetIniDbNumber('gambling', 'max', 100),
|
||||
min = $.getSetIniDbNumber('gambling', 'min', 5),
|
||||
gain = Math.abs(winGainPercent / 100);
|
||||
|
||||
/**
|
||||
* @function reloadGamble
|
||||
*/
|
||||
function reloadGamble() {
|
||||
winGainPercent = $.getIniDbNumber('gambling', 'winGainPercent');
|
||||
winRange = $.getIniDbNumber('gambling', 'winRange');
|
||||
max = $.getIniDbNumber('gambling', 'max');
|
||||
min = $.getIniDbNumber('gambling', 'min');
|
||||
gain = Math.abs(winGainPercent / 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* @function gamble
|
||||
*
|
||||
* @param {int amout}
|
||||
* @param {string} sender
|
||||
*/
|
||||
function gamble(sender, amount) {
|
||||
var winnings = 0,
|
||||
winSpot = 0,
|
||||
range = $.randRange(1, 100);
|
||||
|
||||
if ($.getUserPoints(sender) < amount) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('gambling.need.points', $.pointNameMultiple));
|
||||
return;
|
||||
}
|
||||
|
||||
if (max < amount) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('gambling.error.max', $.getPointsString(max)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (min > amount) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('gambling.error.min', $.getPointsString(min)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (range <= winRange) {
|
||||
$.say($.lang.get('gambling.lost', $.resolveRank(sender), range, $.getPointsString(amount), $.getPointsString($.getUserPoints(sender) - amount), $.gameMessages.getLose(sender, 'gamble')));
|
||||
$.inidb.decr('points', sender, amount);
|
||||
} else {
|
||||
winnings = Math.floor(amount + (amount * gain));
|
||||
$.say($.lang.get('gambling.won', $.resolveRank(sender), range, $.getPointsString(winnings - amount), $.getPointsString($.getUserPoints(sender) + (winnings - amount)), $.gameMessages.getWin(sender, 'gamble')));
|
||||
$.inidb.decr('points', sender, amount);
|
||||
$.inidb.incr('points', sender, winnings);
|
||||
}
|
||||
}
|
||||
|
||||
$.bind('command', function(event) {
|
||||
var sender = event.getSender(),
|
||||
command = event.getCommand(),
|
||||
args = event.getArgs(),
|
||||
action = args[0];
|
||||
|
||||
/**
|
||||
* @commandpath gamble [amount] - Gamble your points.
|
||||
*/
|
||||
if (command.equalsIgnoreCase('gamble')) {
|
||||
if (!parseInt(action)) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('gambling.usage'));
|
||||
return;
|
||||
}
|
||||
|
||||
gamble(sender, parseInt(action));
|
||||
}
|
||||
|
||||
/**
|
||||
* @commandpath gamblesetmax [amount] - Set how many points people can gamble.
|
||||
*/
|
||||
if (command.equalsIgnoreCase('gamblesetmax')) {
|
||||
if (action === undefined || isNaN(parseInt(action)) || action < 1) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('gambling.set.max.usage'));
|
||||
return;
|
||||
}
|
||||
max = action;
|
||||
$.inidb.set('gambling', 'max', max);
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('gambling.set.max', $.getPointsString(max)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @commandpath gamblesetmin [amount] - Set the minumum amount of points people can gamble.
|
||||
*/
|
||||
if (command.equalsIgnoreCase('gamblesetmin')) {
|
||||
if (action === undefined || isNaN(parseInt(action)) || action < 1) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('gambling.set.min.usage'));
|
||||
return;
|
||||
}
|
||||
min = action;
|
||||
$.inidb.set('gambling', 'min', min);
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('gambling.set.min', $.getPointsString(min)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @commandpath gamblesetwinningrange [range] - Set the winning range from 0-100.
|
||||
*/
|
||||
if (command.equalsIgnoreCase('gamblesetwinningrange')) {
|
||||
if (action === undefined || isNaN(parseInt(action)) || action.includes('-') || action < 1 || action > 100) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('gambling.win.range.usage'));
|
||||
return;
|
||||
}
|
||||
winRange = action;
|
||||
$.inidb.set('gambling', 'winRange', winRange);
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('gambling.win.range', parseInt(winRange) + 1, winRange));
|
||||
}
|
||||
|
||||
/**
|
||||
* @commandpath gamblesetgainpercent [amount in percent] - Set the winning gain percent.
|
||||
*/
|
||||
if (command.equalsIgnoreCase('gamblesetgainpercent')) {
|
||||
if (action === undefined || isNaN(parseInt(action)) || action < 1 || action > 100) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('gambling.percent.usage'));
|
||||
return;
|
||||
}
|
||||
winGainPercent = action;
|
||||
$.inidb.set('gambling', 'winGainPercent', winGainPercent);
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('gambling.percent', winGainPercent));
|
||||
}
|
||||
});
|
||||
|
||||
$.bind('initReady', function() {
|
||||
$.registerChatCommand('./games/gambling.js', 'gamble', 7);
|
||||
$.registerChatCommand('./games/gambling.js', 'gamblesetmax', 1);
|
||||
$.registerChatCommand('./games/gambling.js', 'gamblesetmin', 1);
|
||||
$.registerChatCommand('./games/gambling.js', 'gamblesetwinningrange', 1);
|
||||
$.registerChatCommand('./games/gambling.js', 'gamblesetgainpercent', 1);
|
||||
});
|
||||
|
||||
$.reloadGamble = reloadGamble;
|
||||
})();
|
||||
128
libs/phantombot/scripts/games/killCommand.js
Normal file
128
libs/phantombot/scripts/games/killCommand.js
Normal file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2020 phantombot.github.io/PhantomBot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* killCommand.js
|
||||
*
|
||||
* Viewers can show each other the love of REAL friends by expressing it in pain.
|
||||
*/
|
||||
(function() {
|
||||
var selfMessageCount = 0,
|
||||
otherMessageCount = 0,
|
||||
lastRandom = -1,
|
||||
jailTimeout = $.getSetIniDbNumber('settings', 'killTimeoutTime', 60),
|
||||
lang,
|
||||
rand;
|
||||
|
||||
/**
|
||||
* @function reloadKill
|
||||
*/
|
||||
function reloadKill() {
|
||||
jailTimeout = $.getIniDbNumber('settings', 'killTimeoutTime', 60);
|
||||
}
|
||||
|
||||
/**
|
||||
* @function loadResponses
|
||||
*/
|
||||
function loadResponses() {
|
||||
var i;
|
||||
for (i = 1; $.lang.exists('killcommand.self.' + i); i++) {
|
||||
selfMessageCount++;
|
||||
}
|
||||
for (i = 1; $.lang.exists('killcommand.other.' + i); i++) {
|
||||
otherMessageCount++;
|
||||
}
|
||||
$.consoleDebug($.lang.get('killcommand.console.loaded', selfMessageCount, otherMessageCount));
|
||||
};
|
||||
|
||||
function selfKill(sender) {
|
||||
do {
|
||||
rand = $.randRange(1, selfMessageCount);
|
||||
} while (rand == lastRandom);
|
||||
$.say($.lang.get('killcommand.self.' + rand, $.resolveRank(sender)));
|
||||
lastRandom = rand;
|
||||
};
|
||||
|
||||
function kill(sender, user) {
|
||||
var tries = 0;
|
||||
do {
|
||||
tries++;
|
||||
rand = $.randRange(1, otherMessageCount);
|
||||
} while (rand == lastRandom && tries < 5);
|
||||
lang = $.lang.get('killcommand.other.' + rand, $.resolveRank(sender), $.resolveRank(user), jailTimeout, $.botName);
|
||||
if (lang.startsWith('(jail)')) {
|
||||
lang = $.replace(lang, '(jail)', '');
|
||||
$.say(lang);
|
||||
if (!$.isMod(sender) && jailTimeout > 0) {
|
||||
setTimeout(function() {
|
||||
$.session.say('.timeout ' + sender + ' ' + jailTimeout);
|
||||
}, 1500);
|
||||
}
|
||||
} else {
|
||||
$.say(lang);
|
||||
}
|
||||
lastRandom = rand;
|
||||
};
|
||||
|
||||
/**
|
||||
* @event command
|
||||
*/
|
||||
$.bind('command', function(event) {
|
||||
var sender = event.getSender().toLowerCase(),
|
||||
command = event.getCommand(),
|
||||
args = event.getArgs();
|
||||
|
||||
/**
|
||||
* @commandpath kill [username] - Kill a fellow viewer (not for real!), omit the username to kill yourself
|
||||
*/
|
||||
if (command.equalsIgnoreCase('kill')) {
|
||||
if (args.length <= 0 || args[0].toLowerCase() == sender) {
|
||||
selfKill(sender);
|
||||
} else {
|
||||
kill(sender, args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @commandpath jailtimeouttime [amount in seconds] - Set the timeout time for jail time on the kill command.
|
||||
*/
|
||||
if (command.equalsIgnoreCase('jailtimeouttime')) {
|
||||
if (args.length == 0) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('killcommand.jail.timeout.usage'));
|
||||
return;
|
||||
}
|
||||
|
||||
jailTimeout = args[0];
|
||||
$.inidb.set('settings', 'killTimeoutTime', args[0]);
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('killcommand.jail.timeout.set', jailTimeout));
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @event initReady
|
||||
*/
|
||||
$.bind('initReady', function() {
|
||||
if (selfMessageCount == 0 && otherMessageCount == 0) {
|
||||
loadResponses();
|
||||
}
|
||||
|
||||
$.registerChatCommand('./games/killCommand.js', 'kill', 7);
|
||||
$.registerChatCommand('./games/killCommand.js', 'jailtimeouttime', 1);
|
||||
});
|
||||
|
||||
$.reloadKill = reloadKill;
|
||||
})();
|
||||
112
libs/phantombot/scripts/games/random.js
Normal file
112
libs/phantombot/scripts/games/random.js
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2020 phantombot.github.io/PhantomBot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* random.js
|
||||
*
|
||||
* A command that randomly picks a random message from the the randoms stack and post it in the chat.
|
||||
*/
|
||||
(function() {
|
||||
var pg13toggle = $.getSetIniDbBoolean('randomSettings', 'pg13toggle', false),
|
||||
randomsCount = 0,
|
||||
lastRandom = 0,
|
||||
randomsPG13Count = 0,
|
||||
lastPG13Random = 0;
|
||||
|
||||
/**
|
||||
* @event webPanelSocketUpdate
|
||||
*/
|
||||
$.bind('webPanelSocketUpdate', function(event) {
|
||||
if (event.getScript().equalsIgnoreCase('./games/random.js')) {
|
||||
pg13toggle = $.getIniDbBoolean('randomSettings', 'pg13toggle');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @function loadResponses
|
||||
*/
|
||||
function loadResponses() {
|
||||
var i;
|
||||
for (i = 1; $.lang.exists('randomcommand.' + i); i++) {
|
||||
randomsCount++;
|
||||
}
|
||||
for (i = 1; $.lang.exists('randomcommand.pg13.' + i); i++) {
|
||||
randomsPG13Count++;
|
||||
}
|
||||
$.consoleDebug($.lang.get('randomcommand.console.loaded', (randomsCount + randomsPG13Count)));
|
||||
};
|
||||
|
||||
/**
|
||||
* @event command
|
||||
*/
|
||||
$.bind('command', function(event) {
|
||||
var command = event.getCommand(),
|
||||
args = event.getArgs(),
|
||||
doPG13Random = false,
|
||||
rand;
|
||||
|
||||
/**
|
||||
* @commandpath random - Something random will happen
|
||||
* @commandpath random pg13toggle - Toggle PG-13 mode on and off
|
||||
*/
|
||||
if (command.equalsIgnoreCase('random')) {
|
||||
if (args[0] !== undefined) {
|
||||
if (args[0].equalsIgnoreCase('pg13toggle')) {
|
||||
pg13toggle = !pg13toggle;
|
||||
$.setIniDbBoolean('randomSettings', 'pg13toggle', pg13toggle);
|
||||
$.say($.lang.get('randomcommand.pg13toggle', pg13toggle));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (pg13toggle) {
|
||||
if ($.randRange(1, 100) > 80) {
|
||||
doPG13Random = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (doPG13Random) {
|
||||
do {
|
||||
rand = $.randRange(1, randomsPG13Count);
|
||||
} while (rand == lastPG13Random);
|
||||
|
||||
lastPG13Random = rand;
|
||||
$.say($.tags(event, $.lang.get('randomcommand.pg13.' + rand), false));
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
rand = $.randRange(1, randomsCount);
|
||||
} while (rand == lastRandom);
|
||||
|
||||
lastRandom = rand;
|
||||
$.say($.tags(event, $.lang.get('randomcommand.' + rand), false));
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @event initReady
|
||||
*/
|
||||
$.bind('initReady', function() {
|
||||
if (randomsCount == 0) {
|
||||
loadResponses();
|
||||
}
|
||||
|
||||
$.registerChatCommand('./games/random.js', 'random');
|
||||
$.registerChatSubcommand('random', 'pg13toggle', 1);
|
||||
});
|
||||
})();
|
||||
135
libs/phantombot/scripts/games/roll.js
Normal file
135
libs/phantombot/scripts/games/roll.js
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2020 phantombot.github.io/PhantomBot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* roll.js
|
||||
*
|
||||
* A game where the bot will generate two random dices and award the sender with the points corresponding to the output.
|
||||
*/
|
||||
(function() {
|
||||
var prizes = [];
|
||||
|
||||
/* Set default prices in the DB for the Panel */
|
||||
$.getSetIniDbNumber('rollprizes', 'prizes_0', 4);
|
||||
$.getSetIniDbNumber('rollprizes', 'prizes_1', 16);
|
||||
$.getSetIniDbNumber('rollprizes', 'prizes_2', 36);
|
||||
$.getSetIniDbNumber('rollprizes', 'prizes_3', 64);
|
||||
$.getSetIniDbNumber('rollprizes', 'prizes_4', 100);
|
||||
$.getSetIniDbNumber('rollprizes', 'prizes_5', 144);
|
||||
|
||||
/**
|
||||
* @function loadPrizes
|
||||
*/
|
||||
function loadPrizes() {
|
||||
prizes[0] = $.getSetIniDbNumber('rollprizes', 'prizes_0', 4);
|
||||
prizes[1] = $.getSetIniDbNumber('rollprizes', 'prizes_1', 16);
|
||||
prizes[2] = $.getSetIniDbNumber('rollprizes', 'prizes_2', 36);
|
||||
prizes[3] = $.getSetIniDbNumber('rollprizes', 'prizes_3', 64);
|
||||
prizes[4] = $.getSetIniDbNumber('rollprizes', 'prizes_4', 100);
|
||||
prizes[5] = $.getSetIniDbNumber('rollprizes', 'prizes_5', 144);
|
||||
}
|
||||
|
||||
/**
|
||||
* @event command
|
||||
*/
|
||||
$.bind('command', function(event) {
|
||||
var sender = event.getSender().toLowerCase(),
|
||||
command = event.getCommand(),
|
||||
args = event.getArgs(),
|
||||
dice1,
|
||||
dice2,
|
||||
resultMessage;
|
||||
|
||||
/**
|
||||
* @commandpath roll - Roll the dice for some points
|
||||
*/
|
||||
if (command.equalsIgnoreCase('roll')) {
|
||||
|
||||
/**
|
||||
* @commandpath roll rewards [double 1's] [2's] [3's] [4's] [5's] [6's] - Set the reward for each set of doubles.
|
||||
*/
|
||||
if (args[0] !== undefined) {
|
||||
if (args[0].equalsIgnoreCase('rewards')) {
|
||||
if (args.length != 7) {
|
||||
loadPrizes();
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('roll.rewards.usage', prizes.join(' ')));
|
||||
return;
|
||||
}
|
||||
|
||||
if (isNaN(args[1]) || isNaN(args[2]) || isNaN(args[3]) || isNaN(args[4]) || isNaN(args[5]) || isNaN(args[6])) {
|
||||
loadPrizes();
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('roll.rewards.usage', prizes.join(' ')));
|
||||
return;
|
||||
}
|
||||
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('roll.rewards.success'));
|
||||
$.inidb.set('rollprizes', 'prizes_0', args[1]);
|
||||
$.inidb.set('rollprizes', 'prizes_1', args[2]);
|
||||
$.inidb.set('rollprizes', 'prizes_2', args[3]);
|
||||
$.inidb.set('rollprizes', 'prizes_3', args[4]);
|
||||
$.inidb.set('rollprizes', 'prizes_4', args[5]);
|
||||
$.inidb.set('rollprizes', 'prizes_5', args[6]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
dice1 = $.randRange(1, 6);
|
||||
dice2 = $.randRange(1, 6);
|
||||
resultMessage = $.lang.get('roll.rolled', $.resolveRank(sender), dice1, dice2);
|
||||
|
||||
if (dice1 == dice2) {
|
||||
loadPrizes();
|
||||
switch (dice1) {
|
||||
case 1:
|
||||
resultMessage += $.lang.get('roll.doubleone', $.getPointsString(prizes[dice1 - 1]));
|
||||
break;
|
||||
case 2:
|
||||
resultMessage += $.lang.get('roll.doubletwo', $.getPointsString(prizes[dice1 - 1]));
|
||||
break;
|
||||
case 3:
|
||||
resultMessage += $.lang.get('roll.doublethree', $.getPointsString(prizes[dice1 - 1]));
|
||||
break;
|
||||
case 4:
|
||||
resultMessage += $.lang.get('roll.doublefour', $.getPointsString(prizes[dice1 - 1]));
|
||||
break;
|
||||
case 5:
|
||||
resultMessage += $.lang.get('roll.doublefive', $.getPointsString(prizes[dice1 - 1]));
|
||||
break;
|
||||
case 6:
|
||||
resultMessage += $.lang.get('roll.doublesix', $.getPointsString(prizes[dice1 - 1]));
|
||||
break;
|
||||
}
|
||||
|
||||
$.say(resultMessage + $.gameMessages.getWin(sender, 'roll'));
|
||||
$.inidb.incr('points', sender, prizes[dice1 - 1]);
|
||||
} else {
|
||||
$.say(resultMessage + $.gameMessages.getLose(sender, 'roll'));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @event initReady
|
||||
*/
|
||||
$.bind('initReady', function() {
|
||||
$.registerChatCommand('./games/roll.js', 'roll');
|
||||
$.registerChatSubcommand('roll', 'rewards', 1);
|
||||
});
|
||||
|
||||
|
||||
$.loadPrizes = loadPrizes;
|
||||
})();
|
||||
130
libs/phantombot/scripts/games/roulette.js
Normal file
130
libs/phantombot/scripts/games/roulette.js
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2020 phantombot.github.io/PhantomBot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* roulette.js
|
||||
*
|
||||
* Resolve issues with a game of russian roulette.
|
||||
*/
|
||||
(function() {
|
||||
var timeoutTime = $.getSetIniDbNumber('roulette', 'timeoutTime', 60),
|
||||
responseCounts = {
|
||||
win: 0,
|
||||
lost: 0,
|
||||
},
|
||||
lastRandom = 0;
|
||||
|
||||
function reloadRoulette() {
|
||||
timeoutTime = $.getIniDbNumber('roulette', 'timeoutTime');
|
||||
};
|
||||
|
||||
/**
|
||||
* @function loadResponses
|
||||
*/
|
||||
function loadResponses() {
|
||||
var i;
|
||||
|
||||
for (i = 1; $.lang.exists('roulette.win.' + i); i++) {
|
||||
responseCounts.win++;
|
||||
}
|
||||
|
||||
for (i = 1; $.lang.exists('roulette.lost.' + i); i++) {
|
||||
responseCounts.lost++;
|
||||
}
|
||||
|
||||
$.consoleDebug($.lang.get('roulette.console.loaded', responseCounts.win, responseCounts.lost));
|
||||
};
|
||||
|
||||
/**
|
||||
* @function timeoutUser
|
||||
* @param {string} username
|
||||
*/
|
||||
function timeoutUserR(username) {
|
||||
$.session.say('.timeout ' + username + ' ' + timeoutTime);
|
||||
};
|
||||
|
||||
/**
|
||||
* @event command
|
||||
*/
|
||||
$.bind('command', function(event) {
|
||||
var sender = event.getSender().toLowerCase(),
|
||||
command = event.getCommand(),
|
||||
args = event.getArgs(),
|
||||
random,
|
||||
d1,
|
||||
d2;
|
||||
|
||||
/**
|
||||
* @commandpath roulette - Pull the trigger and find out if there's a bullet in the chamber
|
||||
*/
|
||||
if (command.equalsIgnoreCase('roulette')) {
|
||||
d1 = $.randRange(1, 2);
|
||||
d2 = $.randRange(1, 2);
|
||||
|
||||
if (d1 == d2) {
|
||||
do {
|
||||
random = $.randRange(1, responseCounts.win);
|
||||
} while (random == lastRandom);
|
||||
$.say($.lang.get('roulette.win.' + random, $.resolveRank(sender)));
|
||||
} else {
|
||||
do {
|
||||
random = $.randRange(1, responseCounts.lost);
|
||||
} while (random == lastRandom);
|
||||
$.say($.lang.get('roulette.lost.' + random, $.resolveRank(sender)));
|
||||
if (!$.isModv3(sender, event.getTags())) {
|
||||
if ($.getBotWhisperMode()) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('roulette.timeout.notifyuser', timeoutTime));
|
||||
}
|
||||
timeoutUserR(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @commandpath roulettetimeouttime [seconds] - Sets for how long the user gets timed out for when loosing at roulette
|
||||
*/
|
||||
if (command.equalsIgnoreCase('roulettetimeouttime')) {
|
||||
if (!$.isAdmin(sender)) {
|
||||
$.say($.whisperPrefix(sender) + $.adminMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isNaN(parseInt(args[0]))) {
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('roulette.set.timeouttime.usage'));
|
||||
return;
|
||||
}
|
||||
|
||||
timeoutTime = parseInt(args[0]);
|
||||
$.inidb.set('roulette', 'timeoutTime', timeoutTime);
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('roulette.set.timeouttime.success', timeoutTime));
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @event initReady
|
||||
*/
|
||||
$.bind('initReady', function() {
|
||||
if (responseCounts.win == 0 && responseCounts.lost == 0) {
|
||||
loadResponses();
|
||||
}
|
||||
|
||||
$.registerChatCommand('./games/roulette.js', 'roulette', 7);
|
||||
$.registerChatCommand('./games/roulette.js', 'roulettetimeouttime', 1);
|
||||
});
|
||||
|
||||
$.reloadRoulette = reloadRoulette;
|
||||
})();
|
||||
188
libs/phantombot/scripts/games/slotMachine.js
Normal file
188
libs/phantombot/scripts/games/slotMachine.js
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2020 phantombot.github.io/PhantomBot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* slotMachine.js
|
||||
*
|
||||
* When the user uses the slots, the bot will generate three random numbers.
|
||||
* These numbers represent an emote. Each emote has a value.
|
||||
* The amount of points; corresponding to the output, will be added to the user's balance.
|
||||
*/
|
||||
(function() {
|
||||
var prizes = [],
|
||||
emoteList = [];
|
||||
|
||||
/* Set default prizes and emotes in the DB for the Panel */
|
||||
$.getSetIniDbNumber('slotmachine', 'prizes_0', 75);
|
||||
$.getSetIniDbNumber('slotmachine', 'prizes_1', 150);
|
||||
$.getSetIniDbNumber('slotmachine', 'prizes_2', 300);
|
||||
$.getSetIniDbNumber('slotmachine', 'prizes_3', 450);
|
||||
$.getSetIniDbNumber('slotmachine', 'prizes_4', 1000);
|
||||
$.getSetIniDbString('slotmachineemotes', 'emote_0', 'Kappa');
|
||||
$.getSetIniDbString('slotmachineemotes', 'emote_1', 'KappaPride');
|
||||
$.getSetIniDbString('slotmachineemotes', 'emote_2', 'BloodTrail');
|
||||
$.getSetIniDbString('slotmachineemotes', 'emote_3', 'ResidentSleeper');
|
||||
$.getSetIniDbString('slotmachineemotes', 'emote_4', '4Head');
|
||||
|
||||
/**
|
||||
* @function loadEmotes
|
||||
*/
|
||||
function loadEmotes() {
|
||||
emoteList[0] = $.getIniDbString('slotmachineemotes', 'emote_0');
|
||||
emoteList[1] = $.getIniDbString('slotmachineemotes', 'emote_1');
|
||||
emoteList[2] = $.getIniDbString('slotmachineemotes', 'emote_2');
|
||||
emoteList[3] = $.getIniDbString('slotmachineemotes', 'emote_3');
|
||||
emoteList[4] = $.getIniDbString('slotmachineemotes', 'emote_4');
|
||||
};
|
||||
|
||||
/**
|
||||
* @function loadPrizes
|
||||
*/
|
||||
function loadPrizes() {
|
||||
prizes[0] = $.getIniDbNumber('slotmachine', 'prizes_0');
|
||||
prizes[1] = $.getIniDbNumber('slotmachine', 'prizes_1');
|
||||
prizes[2] = $.getIniDbNumber('slotmachine', 'prizes_2');
|
||||
prizes[3] = $.getIniDbNumber('slotmachine', 'prizes_3');
|
||||
prizes[4] = $.getIniDbNumber('slotmachine', 'prizes_4');
|
||||
}
|
||||
|
||||
/**
|
||||
* @function getEmoteKey
|
||||
* @returns {Number}
|
||||
*/
|
||||
function getEmoteKey() {
|
||||
var rand = $.randRange(1, 1000);
|
||||
loadEmotes();
|
||||
if (rand <= 75) {
|
||||
return 4;
|
||||
}
|
||||
if (rand > 75 && rand <= 200) {
|
||||
return 3;
|
||||
}
|
||||
if (rand > 200 && rand <= 450) {
|
||||
return 2;
|
||||
}
|
||||
if (rand > 450 && rand <= 700) {
|
||||
return 1;
|
||||
}
|
||||
if (rand > 700) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @function calculateResult
|
||||
* @param {string} sender
|
||||
*/
|
||||
function calculateResult(sender) {
|
||||
var e1 = getEmoteKey(),
|
||||
e2 = getEmoteKey(),
|
||||
e3 = getEmoteKey(),
|
||||
message = $.lang.get('slotmachine.result.start', $.resolveRank(sender), emoteList[e1], emoteList[e2], emoteList[e3]);
|
||||
|
||||
loadPrizes();
|
||||
|
||||
if (e1 == e2 && e2 == e3) {
|
||||
message += $.lang.get('slotmachine.result.win', ($.getPointsString(prizes[e1]) + '.'));
|
||||
$.say(message + $.gameMessages.getWin(sender, 'slot'));
|
||||
$.inidb.incr('points', sender, prizes[e1]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e1 == e2 || e2 == e3 || e3 == e1) {
|
||||
message += $.lang.get('slotmachine.result.win', (e1 == e2 ? $.getPointsString(Math.floor(prizes[e1] * 0.3)) : $.getPointsString(Math.floor(prizes[e3] * 0.3))) + '.');
|
||||
$.say(message + $.gameMessages.getWin(sender, 'slot'));
|
||||
$.inidb.incr('points', sender, (e1 == e2 ? (Math.floor(prizes[e1] * 0.3)) : (Math.floor(prizes[e3] * 0.3))));
|
||||
return;
|
||||
}
|
||||
$.say(message + $.gameMessages.getLose(sender, 'slot'));
|
||||
};
|
||||
|
||||
/**
|
||||
* @event command
|
||||
*/
|
||||
$.bind('command', function(event) {
|
||||
var command = (event.getCommand() + '').toLowerCase(),
|
||||
sender = event.getSender().toLowerCase(),
|
||||
args = event.getArgs();
|
||||
|
||||
/**
|
||||
* @commandpath slot - Play the slot machines for some points
|
||||
*/
|
||||
if (command.equalsIgnoreCase('slot')) {
|
||||
/**
|
||||
* @commandpath slot rewards [val1] [val2] [val3] [val4] [val5] - Set the reward values for the slots.
|
||||
*/
|
||||
if (args[0] !== undefined) {
|
||||
if (args[0].equalsIgnoreCase('rewards')) {
|
||||
if (args.length != 6) {
|
||||
loadPrizes();
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('slotmachine.rewards.usage', prizes.join(' ')));
|
||||
return;
|
||||
}
|
||||
|
||||
if (isNaN(args[1]) || isNaN(args[2]) || isNaN(args[3]) || isNaN(args[4]) || isNaN(args[5])) {
|
||||
loadPrizes();
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('slotmachine.rewards.usage', prizes.join(' ')));
|
||||
return;
|
||||
}
|
||||
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('slotmachine.rewards.success'));
|
||||
$.inidb.set('slotmachine', 'prizes_0', args[1]);
|
||||
$.inidb.set('slotmachine', 'prizes_1', args[2]);
|
||||
$.inidb.set('slotmachine', 'prizes_2', args[3]);
|
||||
$.inidb.set('slotmachine', 'prizes_3', args[4]);
|
||||
$.inidb.set('slotmachine', 'prizes_4', args[5]);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @commandpath slot emotes [emote1] [emote2] [emote3] [emote4] [emote5] - Set the emotes for the slots.
|
||||
*/
|
||||
if (args[0].equalsIgnoreCase('emotes')) {
|
||||
if (args.length < 6) {
|
||||
loadEmotes();
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('slotmachine.emote.usage', emoteList.join(' ')));
|
||||
return;
|
||||
}
|
||||
|
||||
$.say($.whisperPrefix(sender) + $.lang.get('slotmachine.emote.success'));
|
||||
$.inidb.set('slotmachineemotes', 'emote_0', args[1]);
|
||||
$.inidb.set('slotmachineemotes', 'emote_1', args[2]);
|
||||
$.inidb.set('slotmachineemotes', 'emote_2', args[3]);
|
||||
$.inidb.set('slotmachineemotes', 'emote_3', args[4]);
|
||||
$.inidb.set('slotmachineemotes', 'emote_4', args[5]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Slot machine */
|
||||
calculateResult(sender);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @event initReady
|
||||
*/
|
||||
$.bind('initReady', function() {
|
||||
$.registerChatCommand('./games/slotMachine.js', 'slot', 7);
|
||||
$.registerChatSubcommand('slot', 'rewards', 1);
|
||||
$.registerChatSubcommand('slot', 'emotes', 1);
|
||||
});
|
||||
|
||||
$.loadPrizesSlot = loadPrizes;
|
||||
})();
|
||||
Reference in New Issue
Block a user