That's what you would use your <<if>> statements for. They will check whether a specific condition is reached and execute the code within accordingly:
<<if $upgrade > 0>>
...
<</if>>
for example checks whether there are any upgrade points left
<<if $upgrade >= 10>>
...
<</if>>
Will check whether there are more than ten upgrade points left.
<<if $pcStats.int < 100>>
...
<</if>>
Would check whether pcStats is smaller than 100 - basically preventing any additional points being added once that limit is reached.
You can combine these conditions using and/or:
<<if $upgrade > 0 and $pcStats.int < 100>>
...
<</if>>
<<if $upgrade >= 10 and $pcStats.int <= 90>>
...
<</if>>