Ejemplo n.º 1
0
Tile getSpecialCreatureSprite(const ViewObject& obj, bool humanoid) {
  RandomGen r;
  r.init(hash<string>()(obj.getBareDescription()));
  if (humanoid)
    return Tile(r.getRandom(7), 10);
  else
    return Tile(r.getRandom(7, 10), 10);
}
Ejemplo n.º 2
0
Tile getSpecialCreature(const ViewObject& obj, bool humanoid) {
  RandomGen r;
  r.init(hash<string>()(obj.getBareDescription()));
  string let = humanoid ? "WETUIPLKJHFAXBM" : "qwetyupkfaxbnm";
  char c;
  if (contains(let, obj.getBareDescription()[0]))
    c = obj.getBareDescription()[0];
  else
  if (contains(let, tolower(obj.getBareDescription()[0])))
    c = tolower(obj.getBareDescription()[0]);
  else
    c = let[r.getRandom(let.size())];
  Color col(r.getRandom(80, 250), r.getRandom(80, 250), 0);
  return Tile(c, col);
}
Ejemplo n.º 3
0
Tile getSpecialCreature(const ViewObject& obj, bool humanoid) {
  RandomGen r;
  r.init(hash<string>()(obj.getBareDescription()));
  string let = humanoid ? "WETUIPLKJHFAXBM" : "qwetyupkfaxbnm";
  char c;
  if (contains(let, obj.getBareDescription()[0]))
    c = obj.getBareDescription()[0];
  else
  if (contains(let, tolower(obj.getBareDescription()[0])))
    c = tolower(obj.getBareDescription()[0]);
  else
    c = let[r.getRandom(let.size())];
  return Tile::unicode(c, ColorId(Random.getRandom(EnumInfo<ColorId>::getSize())));
}
Ejemplo n.º 4
0
vector<Vec2> Vec2::box(int radius, bool shuffle) {
  if (radius == 0)
    return {*this};
  vector<Vec2> v;
  for (int k = -radius; k < radius; ++k)
    v.push_back(*this + Vec2(k, -radius));
  for (int k = -radius; k < radius; ++k)
    v.push_back(*this + Vec2(radius, k));
  for (int k = -radius; k < radius; ++k)
    v.push_back(*this + Vec2(-k, radius));
  for (int k = -radius; k < radius; ++k)
    v.push_back(*this + Vec2(-radius, -k));
  if (shuffle)
    random_shuffle(v.begin(), v.end(), [](int a) { return Random.getRandom(a);});
  return v;
}
Ejemplo n.º 5
0
Vec2 Rectangle::randomVec2() const {
  return Vec2(Random.getRandom(px, kx), Random.getRandom(py, ky));
}
Ejemplo n.º 6
0
vector<Vec2> Vec2::neighbors4(bool shuffle) const {
  vector<Vec2> res = { Vec2(x, y + 1), Vec2(x + 1, y), Vec2(x, y - 1), Vec2(x - 1, y)};
  if (shuffle)
    random_shuffle(res.begin(), res.end(),[](int a) { return Random.getRandom(a);});
  return res;
}