示例#1
0
def start():
    for i in range(len(char_name)):
        char[i] = roll('2D6')
        
    update_dm(char_dm)
        
    for i in range(len(char_name)):
        print '%s: %2d  DM %2d' % (char_name[i], char[i], char_dm[i])
        
    skill[gun_combat] = 1
    skill[melee] = 2
    skill[computers] = 4
    skill[pilot] = 0
    
# Gun Combat test
    print '--Gun Combat skill test--'
    effect, natural = test(skill[gun_combat], char_dm[DEX], -2)
    print 'Effect:', effect
    print 'Natural roll:', natural
    
# Stealth test
    print '--Stealth skill test--'
    effect, natural = test(skill[stealth], char_dm[DEX], 2)
    print 'Effect:', effect
    print 'Natural roll:', natural
    
# Pilot test
    print '--Pilot skill test--'
    effect, natural = test(skill[pilot], char_dm[DEX], 6)
    print 'Effect:', effect
    print 'Natural roll:', natural    
 def roll2d6_buttonClicked(self):
     self.natural_roll_1 = roll('1D6')
     self.natural_roll_2 = roll('1D6')
     self.natural_roll = self.natural_roll_1 + self.natural_roll_2
     self.total_rolled = self.natural_roll + self.inputskilllevel.value() + self.inputcharmod.value() + self.inputDM.value() + self.diffdial.value()
     self.die_result.setText(str(self.total_rolled))        
     self.die1Label.setPixmap(QPixmap(':/images/die1_' + str(self.natural_roll_1) + '.png'))
     self.die2Label.setPixmap(QPixmap(':/images/die2_' + str(self.natural_roll_2) + '.png'))
     self.roll_effect = self.total_rolled - 8
     if self.roll_effect <= -6:
         self.effect_result.setText('%d: Exceptional Failure' % self.roll_effect)
         if not self.muted:
             m_media.setCurrentSource(Phonon.MediaSource(":/sounds/exceptional_failure.mp3"))
             m_media.play()
     if self.roll_effect >= -5 and self.roll_effect <= -2:
         self.effect_result.setText('%d: Average Failure' % self.roll_effect)
         if not self.muted:
             m_media.setCurrentSource(Phonon.MediaSource(":/sounds/average_failure.mp3"))
             m_media.play()
     if self.roll_effect == -1:
         self.effect_result.setText('%d: Marginal Failure' % self.roll_effect)
         if not self.muted:
             m_media.setCurrentSource(Phonon.MediaSource(":/sounds/marginal_failure.mp3"))
             m_media.play()
     if self.roll_effect == 0:
         self.effect_result.setText('%d: Marginal Success' % self.roll_effect)
         if not self.muted:
             m_media.setCurrentSource(Phonon.MediaSource(":/sounds/marginal_success.mp3"))
             m_media.play()
     if self.roll_effect >= 1 and self.roll_effect <= 5:
         self.effect_result.setText('%d: Average Success' % self.roll_effect)
         if not self.muted:
             m_media.setCurrentSource(Phonon.MediaSource(":/sounds/average_success.mp3"))
             m_media.play()
     if self.roll_effect >= 6:
         self.effect_result.setText('%d: Exceptional Success' % self.roll_effect)
         if not self.muted:
             m_media.setCurrentSource(Phonon.MediaSource(":/sounds/exceptional_success.mp3"))
             m_media.play()
     self.update_graph()
示例#3
0
 def rollButton_clicked(self):
     if self.diceDM.value() >= 0:
         math_op = '+'
     else:
         math_op = ''
     if self.diceType.currentIndex() > 2:
         self.dice_to_roll = ''
     else:
         self.dice_to_roll = str(self.diceCount.value())
     self.dice_to_roll += self.dice_type
     if self.diceType.currentIndex() <> 7:
         self.dice_to_roll += math_op + str(self.diceDM.value())
     self.diceRoll.setText(str(roll(self.dice_to_roll)))
     print self.dice_to_roll, '=', self.diceRoll.text()
示例#4
0
	def setUp (self):
		self.result = roll("1")
示例#5
0
	def test_subexpression (self):
		# Test that subexpressions work correctly,
		# as there is no operator precedence
		self.assertEquals(roll("8/2*2"), 8)
		self.assertEquals(roll("8/(2*2)"), 2)
示例#6
0
	def test_type (self):
		self.assertIsInstance(roll("2d6"), RolledDice)
示例#7
0
def roll (event, args):
	result = diceroll.roll(args if args else "1d6")
	event.reply("Rolled {}".format(result))
示例#8
0
def test(sk, cm, diff):
    natural = roll('2D6')
    effect = natural +sk + cm + diff - 8
    return effect, natural
示例#9
0
def do_roll():
    spec = request.forms.get('roll')
    return str(roll(spec))
示例#10
0
	def test_keep (self, op):
		""" Assert that there are no rolls below `limit` """
		result = roll("6d3 {0} {1}".format(op, 2))
		self.assertIsInstance(result, RolledDice)
		self.assertFalse(filter(lambda x: x <= 2, result))
		self.assertEquals(len(result), 6)
示例#11
0
	def setUp (self):
		self.results = roll("d2, d4, d6, d8, d10, d20")
示例#12
0
	def test_drop (self, op):
		result = roll("2d1 "+op+" 1")
		self.assertIsInstance(result, RolledDice)
		self.assertEquals(len(result), 1)
示例#13
0
	def test_keep (self, op):
		result = roll("6d3 "+op+" 2")
		self.assertIsInstance(result, RolledDice)
		self.assertEquals(len(result), 6)
示例#14
0
	def test_total (self, op, subatom):
		self.assertIsInstance(roll(subatom + op), int)
示例#15
0
	def test_sort (self, op, subatom):
		result = roll(subatom + op)
		self.assertIsInstance(result, RolledDice)
		self.assertEquals(result, sorted(result))
示例#16
0
	def test_explode (self, op, subatom):
		self.assertIsInstance(roll(subatom + op), RolledDice)
示例#17
0
	def test_comment (self):
		self.assertIsInstance(roll("d6 // This is a comment"), RolledDice)
示例#18
0
	def setUpClass (cls):
		cls.basic_result = roll("6d6 success 4")
示例#19
0
	def test_return_single (self):
		# An expression with a single result returns only that result
		self.assertIsInstance(roll("d6"), RolledDice)
示例#20
0
	def test_success_cancel (self):
		result = roll("6d6 successC 4")
		self.assertGreaterEqual(result, -6)
		self.assertLessEqual(result, 6)
示例#21
0
文件: roll.py 项目: benrady/slackroll
def roll_result(expr):
    result = diceroll.roll(expr)
    if isinstance(result, (int, long)):
        return [result]
    return result
示例#22
0
def do_roll():
    spec = request.forms.get('roll')
    return str(roll(spec))
示例#23
0
	def test_parse_2d6 (self):
		self.assertIsInstance(roll("2d6"), RolledDice)
示例#24
0
	def test_parse_default_n (self):
		self.assertEquals(roll("d1"), roll("1d1"))
示例#25
0
	def test_success_bonus (self):
		result = roll("6d6 successB 4")
		self.assertGreaterEqual(result, 0)
		self.assertLessEqual(result, 12)
示例#26
0
	def test_parse_alternate_case (self):
		self.assertIsInstance(roll("D6"), RolledDice)
ax = subplot(111, projection='3d')

x = []
y = []
z = []
colors = []
sizes = []

barrens = False

for row in range(df.shape[0]):
    if not pd.isnull(df.ix[row, 'Trade_Codes']):
        trade_codes = df.ix[row, 'Trade_Codes']
        if 'Ba' in trade_codes:
            barrens = True
            px = hex_code[df.ix[row, px_name]] + roll('FLUX') / 10.0
            x.append(px)
            py = hex_code[df.ix[row, py_name]] + roll('FLUX') / 10.0
            y.append(py)
            pz = hex_code[df.ix[row, pz_name]] + roll('FLUX') / 10.0
            z.append(pz)
            ps = hex_code[df.ix[row, bubble_size]]
            if ps == 0:
                ps = 0.3
            #sizes.append(ps ** scaler)
            sizes.append(scaler)

if barrens:
    ax.scatter(x, y, z, marker='h', c='cyan', s=sizes, linewidths=1, edgecolor='black')
    plot([], [], [], marker='h', markerfacecolor='cyan', markersize = 12, markeredgewidth=1, markeredgecolor='black', label='Barren')
示例#28
0
	def test_success_both (self):
		result = roll("6d6 successCB 4")
		self.assertGreaterEqual(result, -6)
		self.assertLessEqual(result, 12)