Dynamic update of reward upon click/key press

ubuntu 20:
PsychoPy version 3:
There is a total of 3 images on the screen. Initial reward on all three images is the same. I am trying to update the reward obtained after clicking an image1. For example, if a person clicks on the image1 then the reward he gets up on the first click should say 80 (reward received on the first click) and then if he clicks on it again then it decreases based on this equation:
0.95**(n-1)reward received previously
n= number of times the image has been clicked
so if its clicked second time then the n=2, previous reward = reward gained in the first click and so on.
If one decides to move from image1 and clicks on another image say image2 then the same reduction based on clicks happens with image2, whereas the reward in image1 gets replenished with another equation say 0.10
(100-reward previously)+previous reward.
I am unable to reduce the reward based on these criteria nor able to include the replenishment thing. I am able to input the constant number as a reward but its dynamic update is not working.
Some help would be highly appreciated.