Liquid object: Test for liquid leaving the container

liquid_container
Mark 2016-02-20 21:10:41 +01:00
parent 7cc88bd909
commit 862e69655e
2 changed files with 29 additions and 4 deletions

View File

@ -73,6 +73,12 @@ func SetLiquidItem(object item)
}
}
func ResetLiquidItem()
{
liquid_container_item = nil;
this->~UpdateLiquidContainer();
}
func GetLiquidType()
{
if (GetLiquidItem())
@ -219,3 +225,11 @@ func SetLiquidContainer(string liquid_name, int amount)
SetLiquidType(liquid_name);
SetLiquidFillLevel(amount);
}
// lose the liquid item if it exits the container
func Ejection(object item)
{
if (item == GetLiquidItem())
ResetLiquidItem();
_inherited(...);
}

View File

@ -730,7 +730,7 @@ global func Test12_Execute()
liquid->Enter(container);
returned = liquid;
var test = (returned == nil); passed &= test;
test = (returned == nil); passed &= test;
Log("- Liquid can enter filled barrel, liquid got removed: %v", test);
returned = container->GetLiquidFillLevel();
test = (200 == returned); passed &= test;
@ -742,7 +742,7 @@ global func Test12_Execute()
liquid->Enter(container);
returned = liquid->Contained();
var test = (returned == nil); passed &= test;
test = (returned == nil); passed &= test;
Log("- Liquid cannot enter filled barrel if the capacity is exceeded: %v", test);
returned = container->GetLiquidFillLevel();
test = (300 == returned); passed &= test;
@ -760,8 +760,8 @@ global func Test12_Execute()
liquid->SetLiquidAmount(50);
liquid->Enter(container);
var returned = liquid->Contained();
var test = (returned == nil); passed &= test;
returned = liquid->Contained();
test = (returned == nil); passed &= test;
Log("- Liquid cannot enter filled barrel of a different liquid type: %v", test);
returned = container->GetLiquidFillLevel();
test = (200 == returned); passed &= test;
@ -769,6 +769,17 @@ global func Test12_Execute()
liquid->RemoveObject();
// barrel gets emptied when liquid exits it
liquid = container->GetLiquidItem();
liquid->Exit();
returned = container->LiquidContainerIsEmpty();
test = returned; passed &= test;
Log("- Liquid container should be empty when liquid leaves it: %v", test);
test = (liquid != nil); passed &= test;
Log("- Liquid exists after leaving the container: %v", test);
liquid->RemoveObject();
container->RemoveObject();
return passed;