Sep 6, 2017

Posted by in RPG, Sci-Fi | 0 Comments

JavaScript Starfinder Character idea creator

Just in case you want to use the JavaScript Starfinder character creator yourself, here’s the source code. It was a quick and dirty job, so don’t be too hard on me for using a single file and some other not to great choices 😉

<html>
<head>
<script language="javascript">
	var sf_race      = ["Android", "Human", "Kasatha", "Lashunta", 
                            "Shirren", "Vesk", "Ysori" ];

	var sf_class     = ["Envoy", "Mechanic", "Mystic", "Operative", 
                            "Solarian", "Soldier", "Technomancer" ];

	var sf_theme     = ["Ace Pilot", "Bounty Hunter", "Icon", 
                            "Mercenary", "Outlaw", "Priest", "Scholar", 
                            "Spacefarer", "Xenoseeker", "(Themeless)" ];

	var sf_alignment = ["Lawful Good", "Lawful Nutral", "Neutral Good", 
                            "Neutral", "Chaotic Good", "Chaotic Neutral" ];

	var sf_id        = ["sf_alignment", "sf_race", "sf_class", "sf_theme"];
	var sf_data      = [sf_alignment, sf_race, sf_class, sf_theme ];

	function getRandomInt( min, max ) {
	  return Math.floor(Math.random() * (max - min + 1) + min);
	}
	function getRandomElement( data ) {
		return data[ getRandomInt(0, data.length-1) ];
	}
	function setData( id, value ) {
		document.getElementById( id ).innerHTML = value;
	}
	function reroll() {
		for ( var a=0; a < sf_id.length; a++) {
			setData( sf_id[a], getRandomElement( sf_data[a] ) );
		}
	}
</script>
</head>
<body onload="reroll()">
<h1>Random Character Generator for Starfinder Society</h1>
You are a <span id="sf_alignment"></span> <span id="sf_race"></span> 
<span id="sf_class"></span> <span id="sf_theme"></span>.
<br />
<button onclick="reroll()" >Reroll</button>
</body>
</table>

Leave a Reply

Your email address will not be published. Required fields are marked *