Skip to content

Instantly share code, notes, and snippets.

if user_length >= 4:
roles['RANDOM_ONE'] = ['VILLAGER',
'WITCHDOCTOR',
'MARTYR',
'CURSED',
'PUTRID',
'VILLAGER']
if user_length > 4: # 5 players
required_roles = ['WEREWOLF',
'PSYCHIC',
def assign_roles(self, user_length=None):
from apps.comm.models import Chatroom
import math
import random
# walk through player size and set roles
query_users = self.userrole_set.order_by('?')
users = [u for u in query_users]
if user_length is None:
user_length = len(users)
def assign_roles(self):
from apps.comm.models import Chatroom
import math
# walk through player size and set roles
query_users = self.userrole_set.order_by('?')
users = [u for u in query_users]
user_length = len(users)
# start with smallest group
roles = {}
@robrocker7
robrocker7 / header.php.js
Created October 22, 2010 21:57
Changes for wpaudio javascript
$('.wpaudio').click(function() {
current_image = $(this).css('background-image');
if('<?php the_title(); ?>' == 'Home') {
background_image = '/wp-content/themes/profitfuel/images/icon_listen_home.png';
} else {
background_image = '/wp-content/themes/profitfuel/images/icon_listen_testimonials.png';
}
$('.wpaudio').css('background-image', 'url('+background_image+')');
if(current_image.match(/icon_pause/)){
$(this).css('background-image', 'url('+background_image+')');
@robrocker7
robrocker7 / header.php.js
Created October 22, 2010 18:12
Code that was being used is commented out, new code is below
/*
$('#home_testimonials a.wpaudio').bind('click', function() {^M
if ($(this).hasClass('clicked')) {^M
$(this).css('background-image', 'url(<?php bloginfo("template_directory"); ?>/images/icon_listen_home.png)');^M
$(this).removeClass('clicked');^M
} else {^M
$(this).css('background-image', 'url(<?php bloginfo("template_directory"); ?>/images/icon_pause.png)');^M
$(this).addClass('clicked');^M
}^M
});^M
@robrocker7
robrocker7 / functions.php
Created October 22, 2010 17:45
Changes added for guided tour
// Custom Testimonal scripts written by Robert
class Helper {
protected static $db_connection = false;
protected static $debug = true;
protected static function connect_to_database($args = array()) {
// Create a Database Connection
// accepts an option $args array for testing database connections
// if there is an error, then fail without breaking site
try {