Search in sources :

Example 1 with IBreathingHandler

use of ladysnake.gaspunk.api.IBreathingHandler in project Gaspunk by Ladysnake.

the class SicknessTests method testSarinTick2.

@Test
public void testSarinTick2() {
    IBreathingHandler breathingHandler = CapabilityBreathing.getHandler(mockedCreeper).get();
    final float concentration = 0.5f;
    final float time = 5;
    for (int i = 0; i < time; i++) {
        breathingHandler.setConcentration(ModGases.SARIN_GAS, concentration);
        breathingHandler.tick();
    }
    ISicknessHandler sicknessHandler = CapabilitySickness.getHandler(mockedCreeper).get();
    LingeringAgent sarinAgent = (LingeringAgent) GasAgents.NERVE;
    SicknessEffect effect = sicknessHandler.getActiveEffect(GasAgents.LINGERING_EFFECTS.get(sarinAgent));
    float potency = ModGases.SARIN_GAS.getAgents().get(0).getPotency();
    float toxicityPerTick = potency * concentration / 20;
    float oracle = toxicityPerTick * time;
    assertEquals(oracle, effect.getSeverity(), 1E-8f);
}
Also used : IBreathingHandler(ladysnake.gaspunk.api.IBreathingHandler) LingeringAgent(ladysnake.gaspunk.gas.agent.LingeringAgent) ISicknessHandler(ladysnake.pathos.api.ISicknessHandler) SicknessEffect(ladysnake.pathos.api.SicknessEffect) Test(org.junit.Test)

Example 2 with IBreathingHandler

use of ladysnake.gaspunk.api.IBreathingHandler in project Gaspunk by Ladysnake.

the class SicknessTests method testMustardGas.

@Test
public void testMustardGas() {
    IBreathingHandler breathingHandler = CapabilityBreathing.getHandler(mockedCreeper).get();
    final float concentration = 1.0f;
    final float time = 5;
    for (int i = 0; i < time; i++) {
        breathingHandler.setConcentration(ModGases.MUSTARD_GAS, concentration);
        breathingHandler.tick();
    }
    float potency = ModGases.MUSTARD_GAS.getAgents().get(0).getPotency();
    float oracle = potency * time;
// TODO make a test for evolution in gas concentration
// assertEquals(oracle, breathingHandler.getGasConcentrations().get(ModGases.MUSTARD_GAS), 1E-8f);
}
Also used : IBreathingHandler(ladysnake.gaspunk.api.IBreathingHandler) Test(org.junit.Test)

Example 3 with IBreathingHandler

use of ladysnake.gaspunk.api.IBreathingHandler in project Gaspunk by Ladysnake.

the class SicknessTests method testGasTick.

@Test
public void testGasTick() {
    IBreathingHandler handler = CapabilityBreathing.getHandler(mockedCreeper).get();
    handler.setConcentration(ModGases.SMOKE, 0.5f);
    assertTrue(handler.getGasConcentrations().containsKey(ModGases.SMOKE));
    handler.tick();
    assertFalse(handler.getGasConcentrations().containsKey(ModGases.SMOKE));
}
Also used : IBreathingHandler(ladysnake.gaspunk.api.IBreathingHandler) Test(org.junit.Test)

Example 4 with IBreathingHandler

use of ladysnake.gaspunk.api.IBreathingHandler in project Gaspunk by Ladysnake.

the class SicknessTests method testSarinTick.

@Test
public void testSarinTick() {
    IBreathingHandler handler = CapabilityBreathing.getHandler(mockedCreeper).get();
    handler.setConcentration(ModGases.SARIN_GAS, 0.5f);
    handler.tick();
    ISicknessHandler sicknessHandler = CapabilitySickness.getHandler(mockedCreeper).get();
    assertNotNull(sicknessHandler.getActiveEffect(GasAgents.LINGERING_EFFECTS.get(GasAgents.NERVE)));
}
Also used : IBreathingHandler(ladysnake.gaspunk.api.IBreathingHandler) ISicknessHandler(ladysnake.pathos.api.ISicknessHandler) Test(org.junit.Test)

Example 5 with IBreathingHandler

use of ladysnake.gaspunk.api.IBreathingHandler in project Gaspunk by Ladysnake.

the class SicknessTests method setUp.

@Before
public void setUp() {
    mockedCreeper = mock(EntityCreeper.class);
    // prevent entity.world.isRemote check from crashing
    mockedCreeper.world = mock(World.class);
    // allow the testing of the air supply attribute
    AbstractAttributeMap attributeMap = new AttributeMap();
    attributeMap.registerAttribute(CapabilityBreathing.MAX_AIR_SUPPLY);
    when(mockedCreeper.getAttributeMap()).thenReturn(attributeMap);
    when(mockedCreeper.getEntityAttribute(any())).then(InvocationOnMock::callRealMethod);
    // setup capabilities
    IBreathingHandler breathingHandler = new CapabilityBreathing.DefaultBreathingHandler(mockedCreeper);
    ISicknessHandler sicknessHandler = new CapabilitySickness.DefaultSicknessHandler(mockedCreeper);
    when(mockedCreeper.getCapability(any(), any())).then(invocation -> invocation.getArgument(0) == CapabilitySickness.CAPABILITY_SICKNESS ? sicknessHandler : breathingHandler);
    when(mockedCreeper.getItemStackFromSlot(any())).thenReturn(ItemStack.EMPTY);
    when(mockedCreeper.decreaseAirSupply(anyInt())).then(InvocationOnMock::callRealMethod);
}
Also used : AbstractAttributeMap(net.minecraft.entity.ai.attributes.AbstractAttributeMap) AttributeMap(net.minecraft.entity.ai.attributes.AttributeMap) AbstractAttributeMap(net.minecraft.entity.ai.attributes.AbstractAttributeMap) IBreathingHandler(ladysnake.gaspunk.api.IBreathingHandler) EntityCreeper(net.minecraft.entity.monster.EntityCreeper) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ISicknessHandler(ladysnake.pathos.api.ISicknessHandler) World(net.minecraft.world.World) Before(org.junit.Before)

Aggregations

IBreathingHandler (ladysnake.gaspunk.api.IBreathingHandler)5 Test (org.junit.Test)4 ISicknessHandler (ladysnake.pathos.api.ISicknessHandler)3 LingeringAgent (ladysnake.gaspunk.gas.agent.LingeringAgent)1 SicknessEffect (ladysnake.pathos.api.SicknessEffect)1 AbstractAttributeMap (net.minecraft.entity.ai.attributes.AbstractAttributeMap)1 AttributeMap (net.minecraft.entity.ai.attributes.AttributeMap)1 EntityCreeper (net.minecraft.entity.monster.EntityCreeper)1 World (net.minecraft.world.World)1 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1