HTML and CSS Reference
In-Depth Information
var client = new twitter({
consumer_key: "YOUR_CONSUMER_KEY",
consumer_secret: "YOUR_CONSUMER_SECRET",
access_token_key: "YOUR_ACCESS_TOKEN_KEY",
access_token_secret: "YOUR_ACCESS_TOKEN_SECRET"
});
var accountName = "hangmanword";
function randomWord() {
var word;
do {
word = words[Math.floor(Math.random()*words.length)];
} while(!word.match(/^\w+$/) || word.length < 5)
return word;
}
var Hangman = function(accountName,client) {
var self = this;
this.gameNumber = 0;
var hangman = "__O-[-<";
this.newWord = function() {
this.word = randomWord();
this.currentWord = this.word.split("");
this.currentGuesses = [];
this.guesses = [];
this.lettersRemaining = this.currentWord.length;
this.guessesRemaining = 5;
this.gameNumber++;
this.sendGameUpdate();
console.log("\n");
console.log("New Word:" + this.word);
};
this.sendTweet = function(status) {
client.updateStatus(status,function(err,data) {
if(!err) {
console.log("Sent Tweet:" + status);
} else {
console.log("Error Sending Tweet:" + status +
"\nError:" + err);
}
});
};
this.sendGameUpdate = function() {
var status = "Game " + this.gameNumber + ": " +
hangman.substring(0,hangman.length -
this.guessesRemaining ) +
" Word:";
for(var i=0;i<this.currentWord.length;i++) {
Search WWH ::




Custom Search