Waaaaagh
I lost all my rep and my title being a jerk
- Reaction score
- 70
What is the best way to do this? e.g.:
I want to randomly pick an index of goodid, but, I don't want to pick a null index. Should I just keep trying (random between 1 and 8190) until I get one? That works okay if you have 7104 of them, but if you have 2...
The best solution I can see is to keep track of the max index of goodid. How do I do that?
JASS:
struct goodid extends pitemtype
integer BUYid
integer DISid
static method create takes integer id, integer PUAid, integer BUYid, integer DISid, integer encumbrance returns goodid
local goodid g=goodid.allocate()
set g.id=id
set g.PUAid=PUAid
set g.BUYid=BUYid
set g.DISid=DISid
set g.encumbrance=encumbrance
return g
endmethod
endstruct
I want to randomly pick an index of goodid, but, I don't want to pick a null index. Should I just keep trying (random between 1 and 8190) until I get one? That works okay if you have 7104 of them, but if you have 2...
The best solution I can see is to keep track of the max index of goodid. How do I do that?