Esempio n. 1
0
def test_visit_flowers_two_bees_two_flowers():
    game = GameState(
        game_params=DEFAULT_GAME_PARAMETERS,
        game_id=sentinel.game_id,
        boards=1,
        board_width=10,
        board_height=10,
        hives=(sentinel.hives, ),
        flowers=((Flower(5,
                         5,
                         DEFAULT_GAME_PARAMETERS,
                         1,
                         expires=DEFAULT_GAME_PARAMETERS.flower_lifespan),
                  Flower(5,
                         4,
                         DEFAULT_GAME_PARAMETERS,
                         1,
                         expires=DEFAULT_GAME_PARAMETERS.flower_lifespan)), ),
        game_length=sentinel.game_length)

    game.boards[0].inflight[sentinel.bee_1] = Bee(5, 5, 0, 10,
                                                  DEFAULT_GAME_PARAMETERS, 0)
    game.boards[0].inflight[sentinel.bee_2] = Bee(5, 4, 0, 10,
                                                  DEFAULT_GAME_PARAMETERS, 0)
    game.visit_flowers()

    assert game.boards[0].inflight == {
        sentinel.bee_1:
        Bee(5, 5, 0, 10 + DEFAULT_GAME_PARAMETERS.bee_energy_boost_per_nectar,
            DEFAULT_GAME_PARAMETERS, 1),
        sentinel.bee_2:
        Bee(5, 4, 0, 10 + DEFAULT_GAME_PARAMETERS.bee_energy_boost_per_nectar,
            DEFAULT_GAME_PARAMETERS, 1),
    }
Esempio n. 2
0
def test_seed_does_not_visit_flower():
    game = GameState(
        game_params=DEFAULT_GAME_PARAMETERS,
        game_id=sentinel.game_id,
        boards=1,
        board_width=10,
        board_height=10,
        hives=(sentinel.hives, ),
        flowers=((Flower(
            5, 5, DEFAULT_GAME_PARAMETERS, 1,
            DEFAULT_GAME_PARAMETERS.flower_lifespan_visit_impact), ), ),
        game_length=sentinel.game_length)

    game.boards[0].inflight[sentinel.seed_1] = Seed(5, 5, 0)
    game.visit_flowers()

    assert game.boards[0].inflight == {sentinel.seed_1: Seed(5, 5, 0)}
Esempio n. 3
0
def test_visiting_flower_does_not_create_seeds_when_not_seed_threshold(visits):
    game = GameState(
        game_params=DEFAULT_GAME_PARAMETERS,
        game_id=sentinel.game_id,
        boards=1,
        board_width=10,
        board_height=10,
        hives=(sentinel.hives, ),
        flowers=((Flower(
            5, 5, DEFAULT_GAME_PARAMETERS, 3, visits - 1,
            DEFAULT_GAME_PARAMETERS.flower_lifespan_visit_impact), ), ),
        game_length=sentinel.game_length)

    game.boards[0].inflight[sentinel.bee_1] = Bee(5, 5, 0, 10,
                                                  DEFAULT_GAME_PARAMETERS)
    game.visit_flowers()

    assert game.boards[0].inflight == {
        sentinel.bee_1: Bee(5, 5, 0, 85, DEFAULT_GAME_PARAMETERS, 3)
    }
Esempio n. 4
0
def test_visiting_flower_creates_seed_every_ten_visits(_, visits):
    game = GameState(
        game_params=DEFAULT_GAME_PARAMETERS,
        game_id=sentinel.game_id,
        boards=1,
        board_width=10,
        board_height=10,
        hives=(sentinel.hives, ),
        flowers=((Flower(
            5, 5, DEFAULT_GAME_PARAMETERS, 3, visits - 1,
            DEFAULT_GAME_PARAMETERS.flower_lifespan_visit_impact), ), ),
        game_length=sentinel.game_length)

    game.boards[0].inflight[sentinel.bee_1] = Bee(5, 5, 0, 10,
                                                  DEFAULT_GAME_PARAMETERS)
    game.visit_flowers()

    assert game.boards[0].inflight == {
        sentinel.bee_1: Bee(5, 5, 0, 85, DEFAULT_GAME_PARAMETERS, 3),
        'sentinel.uuid': Seed(5, 5, ANY)
    }
Esempio n. 5
0
def test_visit_flowers_two_bees_two_flowers_more_potent_and_live_longer():
    flower1 = Flower(5,
                     5,
                     DEFAULT_GAME_PARAMETERS,
                     3,
                     expires=DEFAULT_GAME_PARAMETERS.flower_lifespan)
    flower2 = Flower(5,
                     4,
                     DEFAULT_GAME_PARAMETERS,
                     2,
                     expires=DEFAULT_GAME_PARAMETERS.flower_lifespan)

    game = GameState(game_params=DEFAULT_GAME_PARAMETERS,
                     game_id=sentinel.game_id,
                     boards=1,
                     board_width=10,
                     board_height=10,
                     hives=(sentinel.hives, ),
                     flowers=((flower1, flower2), ),
                     game_length=sentinel.game_length)

    game.boards[0].inflight[sentinel.bee_1] = Bee(5, 5, 0, 10,
                                                  DEFAULT_GAME_PARAMETERS, 3)
    game.boards[0].inflight[sentinel.bee_2] = Bee(5, 4, 0, 10,
                                                  DEFAULT_GAME_PARAMETERS, 2)
    game.visit_flowers()

    assert flower1.expires == flower2.expires == DEFAULT_GAME_PARAMETERS.flower_lifespan + DEFAULT_GAME_PARAMETERS.flower_lifespan_visit_impact

    assert game.boards[0].inflight == {
        sentinel.bee_1:
        Bee(5, 5, 0,
            10 + 3 * DEFAULT_GAME_PARAMETERS.bee_energy_boost_per_nectar,
            DEFAULT_GAME_PARAMETERS, 5),
        sentinel.bee_2:
        Bee(5, 4, 0,
            10 + 2 * DEFAULT_GAME_PARAMETERS.bee_energy_boost_per_nectar,
            DEFAULT_GAME_PARAMETERS, 4),
    }
Esempio n. 6
0
def test_visit_flowers_does_not_feed_bee_if_not_on_flower():
    game = GameState(
        game_params=DEFAULT_GAME_PARAMETERS,
        game_id=sentinel.game_id,
        boards=1,
        board_width=10,
        board_height=10,
        hives=(sentinel.hives, ),
        flowers=((Flower(
            5,
            5,
            DEFAULT_GAME_PARAMETERS,
            1,
            expires=DEFAULT_GAME_PARAMETERS.flower_lifespan), ), ),
        game_length=sentinel.game_length)

    game.boards[0].inflight[sentinel.bee_1] = Bee(5, 4, 0, 10,
                                                  DEFAULT_GAME_PARAMETERS, 1)
    game.visit_flowers()

    assert game.boards[0].inflight == {
        sentinel.bee_1: Bee(5, 4, 0, 10, DEFAULT_GAME_PARAMETERS, 1)
    }