The Hero Dispenser

by Sam Fereday

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/chance/1.0.4/chance.min.js"></script>
<div id="output"></div>

<h3>
What's this?
</h3>

<p>
  You're the main boss of a guild (of your choosing) and your job is to assign various adventurers with tasks, deliver the rewards and keep a general eye on their training. Using the visual linkshell, you can have a quick look to see how they're getting
  on.
</p>

<p>
  Don't worry, they know about it.
</p>

CSS

body {
  font: 75%/1.4em arial;
  color: #333;
}

JavaScript

var output = document.getElementById("output");
var chance = new Chance();

/// Quick name generator (note that these only run once, and also, if you generate random names, the lore for each may be sketchy to do. So either generate that randomly, or, let others do it like no man's sky, or, just do it in a fixed manner instead.)
// Granted doing this will allow random names to be easier thought of, so it's a useful tool.
var firsts = [
	// Ok to have mid
	"Ba",
  "Me",
  "Hon",
  "Lae",
  "Ray",
  "Sal",
  "Serel",
  // The following shouldn't have a 'mid' after them (cheap but works)
  "Grass ",
  "Water ",
  "Dark ",
  "Diseased ",
  "Enraged "
]

var mids = [
	"fron ",
  "alla ",
  "jelle ",
  "hellegen ",
  "weidanas "
]

var lasts = [
	"Ghoul",
  "Necron",
  "Trog",
  "Gnoll",
  "Construct",
  "Spirit"
]

function hasWhiteSpace(s) {
  return /\s/g.test(s);
}

function pickMonsterName() {

	var first = firsts[chance.integer({min: 0, max: firsts.length - 1})],
  middle = "",
  last = "";
  
  // It's not that great, but it'll do for now.
  if(!hasWhiteSpace(first))
  	middle = mids[chance.integer({min: 0, max: mids.length - 1})];
  
  // Assuming we always want a 'last'
  last = lasts[chance.integer({min: 0, max: lasts.length - 1})];

	return first + middle + last;

}

/// Some random enemy data to use (let's use a name generator)
// Allow for multiples too
var enemies = [{
	name: pickMonsterName(),
  exp: 250
},
{
	name: pickMonsterName(),
  exp: 500
},
{
	name: pickMonsterName(),
  exp: 700
},
{
	name: pickMonsterName(),
  exp: 950
},
{
	name: pickMonsterName(),
  exp: 1200
}];

/// And some helpers
var playerStats = {
	playerTotalExp: 0,
  playerCurrentExp: 0,
  currentLevel: 0,
  nextLevel: 0,
  totalNeeded: 0,
  totalLeft: 0,
  maxHP: 0,
  currentHP: 0
};
var battleHelpers = {

  getAverageLevelForOpponent: function(level) {

    // Should return the best level for you to fight against based on your current level (wip)

  },

  // Algorithm used:
  //...