예제 #1
0
def test_build_ship():
    game_state = initialise_gamestate()
    game = Game(game_state)
    game_state.world.speed = 1000000
    earth = PlanetLocation(1, 1, 3)

    outcome = game.action_build_ship("max", earth, "light_fighter")

    assert not outcome.success

    game.update(24 * 3600)

    success = game.action_upgrade_building("max", earth, "shipyard")

    assert success

    outcome = game.action_build_ship("max", earth, "light_fighter")

    assert not outcome.success

    assert game.action_upgrade_building("max", earth, "research_lab")
    assert game.action_upgrade_research("max", earth, "energy")
    assert game.action_upgrade_research("max", earth, "combustion_drive")

    outcome = game.action_build_ship("max", earth, "light_fighter")
    assert outcome.success

    assert len(game_state.players["max"].fleets) == 1
    assert (
        game_state.players["max"]
        .fleets[0]
        .light_fighter.components[ShipComponent]
        .number
        == 1
    )
예제 #2
0
def test_colonize_planet():
    game_state = init_state_complex()
    game = Game(game_state)

    earth = PlanetLocation(1, 1, 3)

    game.update(100)
    game.action_upgrade_building("max", earth, "shipyard")
    game.update(100)
    game.action_build_ship("max", earth, "colony_ship")

    game.action_send_mission(
        "max", earth, "COLONIZE", PlanetLocation(1, 1, 6), cargo={Resources.Metal: 5}
    )

    game.update(25)
    game.update(25)

    assert len(game_state.world.planets) == 4
    new_planet = game_state.world.planets[PlanetLocation(1, 1, 6)]
    new_planet_comp = new_planet.components[PlanetComponent]

    assert new_planet.buildings["metal_mine"].components[BuildingComponent].level == 0