use of ladysnake.pathos.api.ISicknessHandler 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.pathos.api.ISicknessHandler 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.pathos.api.ISicknessHandler 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