Exemple #1
0
def test_five_rock_rule_not_all_inplay():
    takeout = utils.newStone(c.P1_COLOR)
    takeout.is_guard = False
    space = utils.Space()
    space.thrownStonesCount = lambda: 2
    space.shooter_color = c.P2_COLOR
    assert utils.five_rock_rule(takeout, space) is False
Exemple #2
0
def test_five_rock_rule_fifth():
    takeout = utils.newStone(c.P1_COLOR)
    takeout.is_guard = True
    space = utils.Space()
    space.get_stones = lambda: ['test'] * 5
    space.shooter_color = c.P2_COLOR
    assert utils.five_rock_rule(takeout, space) is True
Exemple #3
0
def test_five_rock_rule_sixth():
    takeout = utils.newStone(c.P1_COLOR)
    takeout.is_guard = True
    space = utils.Space()
    space.thrownStonesCount = lambda: 6
    space.shooter_color = c.P2_COLOR
    assert utils.five_rock_rule(takeout, space) is False
Exemple #4
0
    def addStone(self, color: str, x, y, action=None, stone_id=None):
        stone = utils.newStone(color)
        board = self.getBoard()
        if stone_id is None:
            stone_id = getNextStoneId(board)
        stone.id = stone_id

        stone.body.position = x, y
        stone.updateGuardValue()

        if action is not None:
            handle, weight, broom = utils.decodeAction(action)
            stone.body.angular_velocity = handle
            stone.body.velocity = utils.calculateVelocityVector(weight, broom)
            stone.is_shooter = True

            log.debug(f'Setting HWB: {handle, weight, broom}')
            log.debug(f'Velocity: {stone.body.velocity}')
        else:
            stone.body.angular_velocity = 0
            stone.body.velocity = utils.ZERO_VECTOR

        log.debug("+ %s" % stone)
        self.space.add(stone.body, stone)

        data_position = stone_id if color == c.P1_COLOR else stone_id + 8
        self.space.thrown_stones[data_position] = c.THROWN
        self.space.inplay_stones[data_position] = c.IN_PLAY
        return stone
Exemple #5
0
def test_five_rock_rule_first():
    takeout = utils.newStone(c.P1_COLOR)
    space = utils.Space()
    space.get_stones = lambda: []
    space.shooter_color = c.P1_COLOR
    assert utils.five_rock_rule(takeout, space) is False