def touch(self, threatRange, modifier, other_ac): attackRoll = Dice(20).roll() critical = attackRoll >= threatRange critical_miss = (attackRoll == 1) touch = (attackRoll + modifier >= other_ac) print '-- Dice roll: %s + %s = %s' % (attackRoll, modifier, attackRoll + modifier) return (touch, critical, critical_miss)
def testRollAndRemoveWorst(self): for i in xrange(2, 100): d = Dice(6) res = d.rollAndRemoveWorst(i) self.assertEquals( i - 1, len(res), 'Not enough results, expected %s, got %s, with %s' % (i - 1, len(res), res)) self.assertGreaterEqual( sum(res), i - 1, 'Expected %s to be greater than %s, with %s' % (sum(res), i - 1, res)) self.assertLessEqual(sum(res), 6 * i)
def __init__(self, host, port, run_server=False): self._running = True self._screen = None self.reset_sound = None self.run_server = run_server self.size = self.width, self.height = 1800, 960 self.board = Board(self) self.dice = Dice(self) self.init_pieces() self.player_count = 0 self.other_mouse = OtherMouse() if self.run_server: self.server = BackgammonServer(localaddr=(host, port)) self.Connect((host, port))
def testDice10(self): d = Dice(10) for i in xrange(100): roll = d.roll() self.assertGreaterEqual(roll, 0) self.assertLessEqual(roll, 10)
def __init__(self, diceType=6, diceCount=1, modifier=0): self.dice = Dice(diceType) self.diceCount = diceCount self.modifier = modifier