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);
}
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);
}
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));
}
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)));
}
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);
}
Aggregations