head 1.2;
access;
symbols;
locks; strict;
comment @# @;
1.2
date 2011.09.13.08.56.41; author phaller; state Exp;
branches;
next 1.1;
1.1
date 2011.09.13.08.56.17; author phaller; state Exp;
branches;
next ;
desc
@original
@
1.2
log
@simplified game "engine"
@
text
@
Famous People
@
1.1
log
@Initial revision
@
text
@d27 1
a27 1
var r = Math.floor( Math.random() * a.length) ;
d40 21
a60 14
teams: 0,
team_current: 0,
round_current: 0,
cards: [],
cards_all : [],
cards_random: function(n){ return array_shuffle(Game.cards_all).slice(0,n); },
cards_shuffled: [],
next_move : function() {
if (Game.cards_shuffled[Game.team_current] == 0) {
Game.cards_shuffled[Game.team_current] = array_shuffle(Game.cards[Game.team_current]);
Game.team_current++;
if (Game.team_current > Game.teams) {
Game.team_current = 0;
Game.round_current++;
d62 1
a62 10
$('#name').html( "Yay! Team done! Next team is " + Game.team_current);
if (Game.round_current > 2) {
$('#name').html('Game Over! Rematch?');
$(document).unbind('keypress');
Game.round_current = 0;
}
return;
}else{
$('#team').html('Team '+ Game.team_current + ', ' + (Game.cards_shuffled[Game.team_current].length -1) + ' cards left');
$('#name').html( Game.cards_shuffled[Game.team_current].pop() );
d64 1
a64 10
},
init : function(teams, ppl, card_count) {
Game.cards_all = ppl;
Game.teams = teams;
for (var i=0;i<=teams;i++) {
Game.cards[i] = Game.cards_random(card_count);
Game.cards_shuffled[i] = Game.cards[i].concat([]);
}
$('#team').html('Team '+Game.team_current);
$('#name').html('Ready? Hit the space bar!');
d74 3
a76 3
var cards = args.pop();
var teams = args.pop() - 1; // silly humans
$.getJSON('/projects/times_up/famous_people.js', function(d) { Game.init(teams, d, cards); });
a79 1
a80 1
@