A very uncomfortable feeling

It’s very rare, when you’re programming video games, that writing code becomes mentally uncomfortable.

Just now, I wrote this code:

[code type=”c++”]
int mmoSubscriber::AvailableCash()
{
int availableCash = m_disposableCash;
if ( m_addiction >= c_addictionThreshold )
availableCash += m_savings;
return availableCash;
}
[/code]

It’s a function which determines how much money a particular subscriber has, for the purposes of figuring out whether or not they can afford your game’s subscription and/or various microtransactions. Each subscriber has two stores of money; their disposable cash, and their savings. Ordinarily, a subscriber will only spend their disposable money. If they run out of disposable cash, they’ll stop buying. But if they’re addicted enough, they’ll consider spending their savings on your game as well.

Of course, in the real world it’s not nearly as simple as I’ve represented it in this system. There are all sorts of other factors which will come into consideration regarding whether or not a purchase can be afforded. But I guess the thing that makes me uncomfortable isn’t the condition that’s present in the ‘if’ statement; it’s that there has to be an ‘if’ statement at all. And there has to be an ‘if’ statement because we know that in Real Life for some players, whatever conditions are inside that Real Life ‘if’ statement evaluate to ‘true’.

So I imagine that I’ll have to think very carefully before again accepting a job to work on microtransaction-funded F2P games.