This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CanyonRunner.EmotionalFulcrum = function(game) { | |
this.angelicVoices = null; | |
}; | |
CanyonRunner.EmotionalFulcrum.prototype = { | |
create: function() { | |
this.sound = this.game.add.audioSprite('sound'); | |
this.sound.play('sonar'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Handle incoming sms commands | |
* | |
* Verifies that the requestor is authorized - then determines the request type (start / stop attacking) | |
* | |
* Finally starts or stops an attack as appropriate | |
* | |
* @param {Request} Twilio POST request - generated when a user sends an sms to the associated Twilio number | |
* @param {Response} Express response | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Handle a user phoning the Super CatFacts Attack Call Center | |
* | |
* @param {Request} - POST request from Twilio - generated when a user calls the associated Twilio phone number | |
* @param {Response} | |
* @return {Response} - Response containing valid Twiml as a string - which creates the CatFacts call center experience | |
*/ | |
app.post('/incoming-call', function(req, res){ | |
res.writeHead(200, { 'Content-Type': 'text/xml' }); | |
res.end(generateCallResponseTwiml().toString()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generates valid Twiml that creates the Super CatFacts Attack Call Center menu experience | |
* | |
* @return {String} response - valid Twiml xml complete with say, play and gather commands | |
*/ | |
function generateCallResponseTwiml() { | |
var response = new twilio.TwimlResponse(); | |
response.say("Thank you for calling Cat Facts!", { | |
voice: 'man', | |
language: 'en' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Processes an authorized admin's attack request and launches the attack | |
* | |
* Handles tracking the attack child process at the app-level so it can be referenced later / stopped | |
* | |
* @param {String} requesting_admin - The phone number of the requesting admin | |
* @param {String} target - The phone number of the target to be attacked | |
* | |
* @return void | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Adds given child_process to the app-level array of running attacks so it can be terminated later | |
* | |
* @param {Object} child_process - A node child process representing a currently running attack | |
* | |
* @return void | |
*/ | |
beginTrackingAttack = function(child_process) { | |
var currentAttacks = app.get('activeAttacks'); | |
currentAttacks.push(child_process); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Helper method that determines whether or not a supplied number is currently under attack | |
* | |
* @param {String} target - the phone number to check for current attacks | |
* @return {Boolean} targetIsBeingAttacked - Whether or not the given number is under attack | |
*/ | |
isTargetBeingAttacked = function(target) { | |
if (target.charAt(0) == '+' && target.charAt(1) == '1'){ | |
target = target.replace('+1', ''); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Finds a currently running attack by phone number and terminates it in response to an admin stop attack request | |
* | |
* @param {String} requesting_admin - The phone number of the admin requesting a stop | |
* @param {String} target_number - The phone number that should not be attacked anymore | |
* @return void | |
*/ | |
handleAdminStopRequest = function(requesting_admin, target_number) { | |
var currentAttacks = app.get('activeAttacks'); | |
var foundAttack = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Checks whether a supplied string is a palindrome, | |
* meaning it is spelled the same forwards and backwards | |
* | |
* @param {String} - The string to check | |
* @return {Boolean} - True, if the string is a palindrome. False, if it is not. | |
*/ | |
function isPalindrome(stringToCheck) { | |
/** |