示例#1
0
def _test_acceleration(direction,
                       expected_position,
                       orientation={},
                       keep_mass=True,
                       reactor_power=20):
    # Generate the components and build the ship
    thruster = Thruster(max_force=10.0)
    reactor = Reactor(max_output=reactor_power)
    panel = ShipPanel(side=directions.COUNTER_DIRECTIONS[direction],
                      thrusters=[thruster])
    ship = Ship(
        **{
            "reactors": [reactor],
            F"{direction}_panel": panel,
            directions.YAW: orientation.get(directions.YAW, 0),
            directions.ROLL: orientation.get(directions.ROLL, 0),
            directions.PITCH: orientation.get(directions.PITCH, 0),
        })

    # Set total mass to 1 in order to negate any mass affects on propulsion
    if not keep_mass:
        ship.mass = 1

    # Set thruster throttle to 50%
    for thruster in ship.get_thrusters_by_orientation(direction):
        thruster.throttle = 1.0

    # Apply acceleration for one tick
    ship.apply_acceleration_vectors()

    # Error
    assert ship.position == expected_position, \
        F"{ship.position} != {expected_position}"
示例#2
0
def test_current_force_status_report_no_throttle():
    thruster = Thruster(max_force=15)
    Ship(port_panel=ShipPanel(side=PORT, thrusters=[thruster]))
    thruster.throttle = 0.1
    reported_force = thruster.status_report["current_force"]
    actual_force = thruster.power_adjusted_current_force
    assert reported_force == actual_force, \
        "Thruster.power_adjusted_current_force is innacurately reported"
示例#3
0
def _build_ship(direction, pos, orientation, throttle):
    # Generate the components and build the ship
    thruster = Thruster(max_force=10.0)
    reactor = Reactor(max_output=60)
    panel = ShipPanel(side=COUNTER_DIRECTIONS[direction], thrusters=[thruster])
    ship = Ship(
        **{
            "reactors": [reactor],
            F"{direction}_panel": panel,
            YAW: orientation.get(YAW, 0),
            ROLL: orientation.get(ROLL, 0),
            PITCH: orientation.get(PITCH, 0),
        })

    for thruster in ship.get_thrusters_by_orientation(direction):
        thruster.throttle = 1.0

    return ship
def test_thruster_degredation():
    # Generate the components and build the ship
    thruster = Thruster(max_force=10.0)
    panel = ShipPanel(
        side=directions.FORWARD,
        thrusters=[thruster]
    )
    ship = Ship(**{F"{directions.FORWARD}_panel": panel})

    # Set thruster throttle to 120%
    for thruster in ship.thrusters:
        thruster.throttle = 1.2

    # Apply acceleration for one hundred ticks
    for _ in range(0, 100):
        ship.apply_acceleration_vectors()

    # Error
    assert ship.thrusters[0].integrity == 0.996, \
        F"{ship.thrusters[0].integrity} != {0.996}"
示例#5
0
def test_low_throttle_status_report():
    thruster = Thruster(max_force=15)
    thruster.throttle = 0.1
    Ship(port_panel=ShipPanel(side=PORT, thrusters=[thruster]))
    assert thruster.status_report["throttle"] == thruster.throttle, \
        "Thruster throttle is innacurately reported"
示例#6
0
def test_power_consumption_low_throttle_status_report():
    t = Thruster(max_force=15)
    Ship(port_panel=ShipPanel(side=PORT, thrusters=[t]))
    t.throttle = 0.1
    assert t.status_report["power_consumption"] == t.power_consumption, \
        "Thruster power_consumption is innacurately reported"
示例#7
0
def test_current_acceleration_status_report_lothruster_throttle():
    t = Thruster(max_force=15)
    Ship(port_panel=ShipPanel(side=PORT, thrusters=[t]))
    t.throttle = 0.2
    assert t.status_report["current_acceleration"] == t.current_acceleration, \
        "Thruster current_acceleration is innacurately reported"
示例#8
0
def test_degredation_rate_status_report_high_throttle():
    t = Thruster(max_force=15)
    Ship(port_panel=ShipPanel(side=PORT, thrusters=[t]))
    t.throttle = 1.2
    assert t.status_report["degredation_rate"] == t.degredation_rate, \
        "Thruster degredation_rate is innacurately reported"