-
-
Save nimitmaru/9282878 to your computer and use it in GitHub Desktop.
This file contains 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
// TextOlympics - Driver File | |
// Road to Code - Fullstack Academy | |
// | |
// This is the file you have to edit | |
var my_channel = "nimits_channel"; //select your channel name. must be one word (no spaces). | |
var sendQuestion = function () { | |
var question_text = $('#question_text').val(); | |
var phone_numbers = $('#phone_numbers_input').val(); | |
addLog("Trying to send question to friends..."); | |
sendMessageToSMSExchange(question_text, phone_numbers); | |
// Remove the following line once you write this function | |
// addLog("You need to define the sendQuestion() function in 'textolympics.driver.js' before this will work! Follow the workshop for help."); | |
// START YOUR CODE HERE | |
// how can we send the question to the SMS exchange using the variables & function provided in textolympics.js? | |
}; | |
var verifyResponse = function(responseObj) { | |
var answer_expected = $('#answer_expected_input').val(); | |
var friends_answer = responseObj.response; | |
var friends_cell_num = responseObj.number; | |
addLog("Friend response received and starting to verifyResponse.") | |
if (answer_expected === friends_answer) { | |
sendSMS("You got it! Good job.", friends_cell_num); | |
reportGameOverToAll(friends_cell_num, answer_expected); | |
} else { | |
sendSMS("Wrong answer, sorry.", friends_cell_num); | |
} | |
// START YOUR CODE HERE | |
// how can you use the variables we have to check the answer submitted by your friend? | |
// Once you check the answer, you must notify them, either way. If the answer is correct | |
// you must end the game by calling reportGameOverToAll(). | |
}; | |
var reportGameOverToAll = function (winners_number, correct_answer) { | |
addLog("Reporting Game Over") | |
pusher.unsubscribe(my_channel); | |
var phone_numbers = $('#phone_numbers_input').val(); | |
var all_phone_numbers = phone_numbers.split(','); | |
var number; | |
for(var i=0; i<all_phone_numbers.length; i++) { | |
number = all_phone_numbers[i]; | |
sendSMS("Game is over. " + winners_number + " won. The right answer is: "+ correct_answer, number); | |
} | |
// START YOUR CODE HERE | |
// we should report to all friends the game is over by sending an SMS to them. | |
// you may want to tell them also who won! | |
}; | |
$('#send_question_button').click(function() { | |
sendQuestion(); | |
$(this).prop("disabled", true); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment