Example #1
0
def diceRollerTask():	
	form = DiceRollerForm(request.form)
	if request.method == "POST":
		
		#ok roll them dice
		#	
		listOfDiceResults = diceRoller.rollDice(int(form.numberOfDice.data), int(form.diceType.data))
		
		#now send that info to the correct template
		#
		return render_template('diceRollerResults.html', listOfResults = listOfDiceResults, totalResults = sum(listOfDiceResults))
	elif request.method == 'GET':
		print 'Get'
		return render_template('diceRollerForm.html', form=form)
def rollToHit(passedChance, passedNumberOfRolls):
	
	listOfDiceRolls = diceRoller.rollDice(passedNumberOfRolls, 10)
	
	numberOfHits = 0
	
	#check if a list element is above a certain number
	#
	for i in xrange(0, listOfDiceRolls):
	
		if(listOfDiceRolls[i] >= passedChance):
			numberOfHits += 1
			
	return numberOfHits
Example #3
0
def duneDiceRollerTask():
	form = DuneDiceRollerForm(request.form)
	
	#ugly if statements FIX THIS SON
	#
	if(form.factionDice1Freeze.data != True):
		form.factionDice1 = diceRoller.rollDice(1, 6)[0]
		form.factionDice1Hidden.data = form.factionDice1
	else:
		form.factionDice1 = form.factionDice1Hidden.data
		
	if(form.factionDice2Freeze.data != True):
		form.factionDice2 = diceRoller.rollDice(1, 6)[0]
		form.factionDice2Hidden.data = form.factionDice2
	else:
		form.factionDice2 = form.factionDice2Hidden.data
	
	if(form.factionDice3Freeze.data != True):
		form.factionDice3 = diceRoller.rollDice(1, 6)[0]
		form.factionDice3Hidden.data = form.factionDice3
	else:
		form.factionDice3 = form.factionDice3Hidden.data
			
	if(form.factionDice4Freeze.data != True):
		form.factionDice4 = diceRoller.rollDice(1, 6)[0]
		form.factionDice4Hidden.data = form.factionDice4
	else:
		form.factionDice4 = form.factionDice4Hidden.data
			
	if(form.kanlyDiceFreeze.data != True):
		form.kanlyDice = diceRoller.rollDice(1, 6)[0]
		form.kanlyDiceHidden.data = form.kanlyDice
	else:
		form.kanlyDice = form.kanlyDiceHidden.data
	
	if(form.spiceDiceFreeze.data != True):
		form.spiceDice = diceRoller.rollDice(1, 6)[0]
		form.spiceDiceHidden.data = form.spiceDice
	else:
		form.spiceDice = form.spiceDiceHidden.data
			
	if(form.regionDiceFreeze.data != True):
		form.regionDice = diceRoller.rollDice(1, 6)[0]
		form.regionDiceHidden.data = form.regionDice
	else:
		form.regionDice = form.regionDiceHidden.data
	
	if request.method == "POST":
		return render_template('duneDiceRoller.html', form=form)
	elif request.method == 'GET':
		return render_template('duneDiceRoller.html', form =form)