Sorry I'm trying to type on the go. Here's the actual code:
Code:
/// Current influence trend on this player
InfluenceLevelTrend CvPlayerCulture::GetInfluenceTrend(PlayerTypes ePlayer) const
{
InfluenceLevelTrend eRtnValue = INFLUENCE_TREND_STATIC;
CvPlayer &kOtherPlayer = GET_PLAYER(ePlayer);
// PctTurn1 = InfluenceT1 / LifetimeCultureT1
// PctTurn2 = InfluenceT2 / LifetimeCultureT2
// So if looking at is PctT2 > PctT1, can see if (InfluenceT2 * LifetimeCultureT1) > (InfluenceT1 * LifetimeCultureT2)
int iLHS = GetInfluenceOn(ePlayer) * kOtherPlayer.GetCulture()->GetLastTurnLifetimeCulture();
int iRHS = GetLastTurnInfluenceOn(ePlayer) * kOtherPlayer.GetJONSCultureEverGenerated();
if (kOtherPlayer.GetCulture()->GetLastTurnLifetimeCulture() > 0 && kOtherPlayer.GetJONSCultureEverGenerated() > 0)
{
if (iLHS > iRHS && m_pPlayer->GetCulture()->GetOtherPlayerCulturePerTurnIncludingInstant(ePlayer) < m_pPlayer->GetCulture()->GetTourismPerTurnIncludingInstant(ePlayer))
{
eRtnValue = INFLUENCE_TREND_RISING;
}
else if (iLHS < iRHS)
{
eRtnValue = INFLUENCE_TREND_FALLING;
}
}
return eRtnValue;
}
The values grabbed in GetOtherPlayerCulturePerTurnIncludingInstant && GetTourismPerTurnIncludingInstant are simply the total amounts of yields (Culture/Tourism) over the past 10 turns, no averages needed.
G
A bit confusing.
Let's see.
GetInfluenceOn(ePlayer): Our total influence over ePlayer.
GetLastTurnInfluenceOn(ePlayer): Our influence gained over ePlayer in the last turn.
kOtherPlayer.GetJONSCultureEverGenerated(): Total culture generated by other civ.
kOtherPlayer.GetCulture()->GetLastTurnLifetimeCulture(): Culture generated by the other civ in the last turn.
So far, I understand that you compare (Total_inf * cult_last_turn) to (inf_last_turn * total_cult).
I don't see why you need to make sure that
if (kOtherPlayer.GetCulture()->GetLastTurnLifetimeCulture() > 0 && kOtherPlayer.GetJONSCultureEverGenerated() > 0)
Can it really go into the negatives? Is it only to avoid turn 0 issues? That makes no sense, since you are not dividing in any moment.
Then.
There are two conditions: iLHS > iRHS, and the other one regarding the last 10 turns. Why wasn't it enough with the first condition? Because 'GetInfluenceOn(ePlayer)' doesn't take instant values into account?
If this is the case, then I'm a bit lost, because the second condition after the && is not going to change the result. It only does something when iLHS=iRHS. If first condition was not giving proper results, it is still not giving proper results. EDIT (Oh. It returns STATIC by default. So even if the TPT/CPT values says that the trend is rising, it can be countered by the last ten turns, if not meeting this requirement it won't say that the trend is rising).
EDIT. So there's a bug here. In my games it's usually showing FALLING, when it is not the case. I see that you have not placed a second condition for the FALLING case, so it's ignoring what happened in the last ten turns when the static values say that the trend is FALLING.
I understand now that storing values for the last turn for N civs might be daunting. I'll try to think on something with the variables you are showing here.