forked from Mirrors/openclonk
Refactoring: Stackable: Use InitialStackCount() where it makes sense
parent
d8a68f5655
commit
350088525c
|
@ -181,7 +181,7 @@ private func UpdateName()
|
|||
|
||||
private func UpdateMass()
|
||||
{
|
||||
SetMass(GetID()->GetMass() * Max(GetStackCount(), 1) / MaxStackCount());
|
||||
SetMass(GetID()->GetMass() * Max(GetStackCount(), 1) / InitialStackCount());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -206,7 +206,7 @@ protected func RejectEntrance(object into)
|
|||
|
||||
public func CalcValue(object in_base, int for_plr)
|
||||
{
|
||||
return GetID()->GetValue() * Max(GetStackCount(), 1) / MaxStackCount();
|
||||
return GetID()->GetValue() * Max(GetStackCount(), 1) / InitialStackCount();
|
||||
}
|
||||
|
||||
/* Tries to add this object to another stack. Returns true if successful.
|
||||
|
@ -294,7 +294,7 @@ public func SaveScenarioObject(props)
|
|||
props->Remove("Name");
|
||||
if (IsInfiniteStackCount())
|
||||
props->AddCall("Stack", this, "SetInfiniteStackCount");
|
||||
else if (GetStackCount() != MaxStackCount())
|
||||
else if (GetStackCount() != InitialStackCount())
|
||||
props->AddCall("Stack", this, "SetStackCount", GetStackCount());
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ global func Test3_OnStart(int plr){ return true;}
|
|||
global func Test3_OnFinished(){ return; }
|
||||
global func Test3_Execute()
|
||||
{
|
||||
Log("Test the behaviour of CalcValue()");
|
||||
Log("Test the behaviour of CalcValue() and UpdateMass()");
|
||||
|
||||
var stackable = CreateObject(Arrow);
|
||||
var passed = true;
|
||||
|
@ -227,8 +227,11 @@ global func Test3_Execute()
|
|||
{
|
||||
stackable->SetStackCount(i);
|
||||
var comparison = "Got %d, expected %d.";
|
||||
var description = Format("A stack with %d object(s) should have %d times the value of the definition. %s", i, i, comparison);
|
||||
var passed = doTest(description, stackable->CalcValue(), (Arrow->GetValue() * i) / Arrow->MaxStackCount());
|
||||
var description = Format("A stack with %d object(s) should have value proportional to the value of the definition. %s", i, comparison);
|
||||
passed &= doTest(description, stackable->CalcValue(), (Arrow->GetValue() * i) / Arrow->InitialStackCount());
|
||||
|
||||
description = Format("A stack with %d object(s) should have mass proportional to that of the definition. %s", i, comparison);
|
||||
passed &= doTest(description, stackable->GetMass(), Max(1, (Arrow->GetMass() * i) / Arrow->InitialStackCount()));
|
||||
}
|
||||
|
||||
stackable->RemoveObject();
|
||||
|
|
Loading…
Reference in New Issue