Failed attempt at unit test nr. 6

liquid_container
Mark 2016-03-03 22:10:10 +01:00
parent 3c05d53b3a
commit 96e59a0626
3 changed files with 25 additions and 24 deletions

View File

@ -213,12 +213,13 @@ public func CanBeStackedWith(object other)
{
// Does not take into account the fill level for now.
var liquid = other->Contents();
var both_filled = Contents() && liquid;
var both_empty = !Contents() && !liquid;
var my_liquid = this->Contents();
var both_filled = (my_liquid != nil) && (liquid != nil);
var both_empty = !my_liquid && !liquid;
if (both_filled) both_filled = liquid->~GetLiquidType() == Contents()->~GetLiquidType();
if (both_filled) both_filled = (liquid->~GetLiquidType() == Contents()->~GetLiquidType());
return inherited(other, ...) && (both_empty || both_filled);
return _inherited(other, ...) && (both_empty || both_filled);
}
@ -235,16 +236,24 @@ func GetNameForBarrel()
}
}
local LiquidNames = {
Oil = "$MaterialOil$",
Water = "$MaterialWater$",
};
public func Definition(proplist def)
{
SetProperty("PictureTransformation", Trans_Mul(Trans_Translate(0, 1000, 0), Trans_Rotate(-40, 1, 0, 0), Trans_Rotate(20, 0, 0, 1)), def);
}
func Collection2(object item)
{
UpdateLiquidContainer();
return _inherited(item, ...);
}
func Ejection(object item)
{
UpdateLiquidContainer();
return _inherited(item, ...);
}
local Collectible = true;
local Name = "$Name$";
local Description = "$Description$";

View File

@ -613,9 +613,10 @@ global func Test5_OnFinished()
return true;
}
global func Test11_OnStart(int plr){ return true;}
global func Test11_OnFinished(){ return; }
global func Test11_Execute()
// Deactivated: for some reason the (inherited) stacking function returns false
global func Test6_deactivated_OnStart(int plr){ return true;}
global func Test6_deactivated_OnFinished(){ return; }
global func Test6_deactivated_Execute()
{
Log("Test the behaviour of barrels getting stacked");
@ -623,8 +624,8 @@ global func Test11_Execute()
var container2 = CreateObject(Barrel);
// can stack filled barrel with other filled barrel of the same liquid
container1->CreateContents(Liquid_Water, 100);
container2->CreateContents(Liquid_Water, 300);
container1->PutLiquid("Water", 100);
container2->PutLiquid("Water", 300);
var passed = true;
var returned = container1->CanBeStackedWith(container2);
@ -653,8 +654,8 @@ global func Test11_Execute()
Log("- Empty barrel can be stacked with empty barrel: %v", test);
// cannot stack filled barrel with other filled barrel of different liquid
container1->CreateContents(Liquid_Water, 100);
container2->CreateContents(Liquid_Oil, 100);
container1->PutLiquid("Water", 100);
container2->PutLiquid("Oil", 100);
returned = container1->CanBeStackedWith(container2);
test = returned == false; passed &= test;

View File

@ -1,9 +0,0 @@
#appendto Barrel
func Test3_IsLiquidContainerForMaterial(string liquid)
{
return liquid == "Water"
|| liquid == "Lava"
|| liquid == "123"
|| liquid == "#24942fwijvri";
}