Files
cc3k/src/gold.cc

41 lines
903 B
C++

#include "gold.h"
#include "constants.h"
int rand_gold_pile(RNG *rng) {
const int denominator = 8;
const int normal = 5;
const int dragon = 6;
int tmp = rng->rand_under(denominator);
if (tmp < normal)
return GOLD_NORMAL;
else if (tmp < dragon)
return GOLD_DRAGON;
else
return GOLD_SMALL;
return 0;
}
gold get_gold_at(const position &pos, gold_list &glist) {
gold ret = {0, {0, 0}};
for (size_t i = 0; i < glist.size(); ++i)
if (glist[i].pos == pos) {
ret = glist[i];
glist.erase(i + glist.begin());
return ret;
}
return ret;
}
int rand_gold_drop(RNG *rng) {
if (rng->coin_flip())
return GOLD_NORMAL;
return GOLD_SMALL;
}