Problem description:
I'm trying to put together a money system in this format.
1 Coin=1000 bits
1 Byte=100 bits
Bits=1
I want it so that whenever the player gets bits, say if they get 1000 bits, that it will automatically be transferred over into the highest currency to hold it efficiently.
In other words in this example,
If I got 1000 bits, it would convert into 1 Coin.
If I then got 750 bits, it would convert into 7 bytes and 50 bits.
In total I'd have 1 Coin, 4 bytes and 50 bits.
For a real world example of this- Dragon Age Origins money system is basically what I'm trying to recreate.
However the "roll over" process is what is confusing me, I'm a little foggy on the best way to approach it. Any ideas?
This is what I have thus far : (though I feel it's not exactly correct)
GainAyo(var/cc)
var/image/x=image('Items.dmi',"coinup",src)
src<<x
x.pixel_x=-8
animate(x,pixel_y=48,time=15)
spawn(15)
del(x)
//src<<sound('Music_Sfx/FX/coinjingle.ogg',0,0,0,client.vol)
src.ayo=max(0,ayo+round(cc))
if(ayo>=1000)
var/f=dyo%1000
GainRyo(round(ayo/1000))//coins
ayo=f
if(ayo>100)
var/f=dyo%100
GainDyo(round(ayo/100))//bytes
ayo=f
src<<"got [cc]"
src<<"Money :Ryo [ryo],Dyo:[dyo],Ayo:[ayo]"//ayo is bits.
I'd argue your denominations are a bit wonky, but that's up to you.