Friday, February 22, 2008

Code Snippet of the day:

from kudos 2:

bool SIM_FoodMemory::IsBoringChoice(std::string foodname)
{
//return true if we ate the same food more than once in the last 14 days
int recentmatches = 0;
iter it;
for(it = Items.begin(); it != Items.end(); ++it)
{
SIM_FoodMemoryItem* pitem = *it;
if(pitem->FoodName == foodname)
{
int diff = SIM_GetSim()->GetTurnCount() - pitem->TurnConsumed;
if(diff < 14)
{
recentmatches++;
}
}
}

if(recentmatches > 1)
{
return true;
}
else
{
return false;
}
}

Links to this post:

Create a Link

<< Home