Skip to content

Instantly share code, notes, and snippets.

@etoxin
Last active April 11, 2019 23:54
Show Gist options
  • Save etoxin/0ed108a7bde896725f016625c7d680b5 to your computer and use it in GitHub Desktop.
Save etoxin/0ed108a7bde896725f016625c7d680b5 to your computer and use it in GitHub Desktop.
const sample = require("lodash/sample");
const flatMapDeep = require("lodash/flatMapDeep");
const lineCollection = [
{ symbol: "■", rarity: 25 },
{ symbol: "─", rarity: 25 },
{ symbol: "=", rarity: 20 },
{ symbol: "-=", rarity: 20 },
{ symbol: "✦", rarity: 20 },
{ symbol: "<>", rarity: 20 },
{ symbol: "░", rarity: 15 },
{ symbol: " ", rarity: 10 },
{ symbol: "/\\", rarity: 10 },
{ symbol: "↯ ", rarity: 10 },
{ symbol: "★ ", rarity: 10 },
{ symbol: "■ ", rarity: 5 },
{ symbol: "∆ ", rarity: 5 },
{ symbol: "😊 ", rarity: 3 },
{ symbol: "♥ ", rarity: 1 }
];
const line = sample(
flatMapDeep(lineCollection, line => Array(line.rarity).fill(line.symbol))
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment