Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
	<body>
		
	<div class= "character-creation">
		
		<h1>Points to Spend:</h1><h1 class="pointsToSpend"></h1>
		<div class="stats strength">
			<h2>Strength:</h2>
			<form id='myform' method='POST' action='#'>
    			<input type='button' value='-' class='qtyminus' field='strength' />
    			<input type='text' name='strength' value='10' class='qty' disabled />
    			<input type='button' value='+' class='qtyplus' field='strength' />
			</form>
		</div>
		<div class="stats dexterity">
			<h2>Dexterity:</h2>
			<form id='myform' method='POST' action='#'>
    			<input type='button' value='-' class='qtyminus' field='dexterity' />
    			<input type='text' name='dexterity' value='10' class='qty' disabled />
    			<input type='button' value='+' class='qtyplus' field='dexterity' />
			</form>
		</div>
		<div class="stats consitution">
			<h2>Consitution:</h2>
			<form id='myform' method='POST' action='#'>
    			<input type='button' value='-' class='qtyminus' field='consitution' />
    			<input type='text' name='consitution' value='10' class='qty' disabled />
    			<input type='button' value='+' class='qtyplus' field='consitution' />
			</form>
			<div>
			<button class="statSubmit" type="button">Choose These Stats</button>
			</div>
		</div>
	</div>

	<div class="character-sheet">

		<form action="index.html" method="post">
			<h1>Character Sheet</h1>
			<div class="top">
				<label for="name">Character Name:</label>
				<input type="text" id="name" name="character_name">

				<label for="health">Hit Points:</label>
				<input type="text" id="health" name="character_health" class="form_stat">
			
			</div>
			<div class="left">
				<h2><span>Stats</span></h2>

				<label for="strength">Strength:</label>
				<input type="text" id="strength" name="character_strength" class="form_stat">
				
				<label for="dexterity">Dexterity:</label>
				<input type="text" id="dexterity" name="character_dexterity" class="form_stat">


				<label for="consitution">Consitution:</label>
				<input type="text" id="consitution" name="character_consitution" class="form_stat">
			</div>
			<div class="right">
				<h2><span>Equiptment</span></h2>

				<label for="weapon">Weapon:</label>
				<input type="text" id="weapon" name="character_weapon"></br>

				<label class="substat" for="weaponMod">Attack Modifier:</label>
				<input type="text" id="weaponMod" name="character_weaponMod" class="form_stat">

				<label class="substat" for="AttDie">Damage Die:</label>
				<input type="text" id="AttDie" name="character_AttDie" class="form_stat">


				</br><label for="armor">Armor:</label>
				<input type="text" id="armor" name="character_armor"></br>

				<label class="substat" for="armorRating">Armor Rating:</label>
				<input type="text" id="armorRating" name="character_armorRating" class="form_stat">
			</div>
		</form>

	</div>
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
		<script src="ObjectsFantasy.js"></script>
	</body>
</html>
              
            
!

CSS

              
                body {
	font-family: 'Helvetica', sans-serif;
}

.character-creation {
  display: none;
	background: #efefef;
	padding: 30px;
	margin: 0 auto;
	width: 600px;
}

.character-creation > h1,
.stats > .plus,
.stats > .minus,
.stats > h2,
.stats > h3,
.stats > form
{
	display: inline-block;
	margin-right: 10px;
}

/* the - and + parts for stat point buy*/

#myform {
    text-align: center;
    padding: 5px;
    border: none;
    margin: 0;
}
.qty {
    width: 40px;
    height: 25px;
    text-align: center;
}
input.qtyplus { width:25px; height:25px;}
input.qtyminus { width:25px; height:25px;}

button {
  	display: none;
 	padding: 19px 39px 18px 39px;
  	color: #333;
  	background-color: #ddd;
  	font-size: 18px;
  	text-align: center;
  	font-style: normal;
  	border-radius: 5px;
  	width: 300px;
  	border: 1px solid #000;
  	border-width: 1px 1px 3px;
  	box-shadow: 0 -1px 0 rgba(255,255,255,0.1) inset;
  	margin-top: 20px;
  	margin-bottom: 10px;
}

.character-creation {
	padding: 2.5%;
}

.character-sheet form input {
	height: 20px;
}

.form_stat {
	height: 25px;
	width: 40px;
	font-size: 18px;
	text-align: center;
}

.left {
	width: 200px;
	float: left;
}

.right {
	width: 400px;
	float: right;
}

.character-sheet input {
	margin-right: 15px;
	font-size: 18px;
}

.right label,
.left label {
	display: inline-block;
	margin-bottom: 5px;
	margin-top: 20px;
}

.character-sheet h1 {
	text-align: left;
	/*border: 2px solid black;*/
	color: #fff;
	background-color: #333;
	padding: 10px;
}

.character-sheet h2 {
	margin-top: 30px;
}

.character-sheet h2 span {
	padding-right: 10px;
	border-bottom: 6px solid black;
}

.character-sheet {
/*	display: none;
*/	width: 600px;
	margin: 50px auto;
	padding: 20px;
	border: 1px solid black;
}

.substat {
	color: #aaa;
}

              
            
!

JS

              
                

 var diceRoll = function (sides) {
	return Math.floor(Math.random()*sides) +1;
};
var strengthModifier;
var consitutionModifier; 
var dexterityModifier;
var attackRoll = 0;

var chainmail = {
	name: "Chainmail Armor",
	armorRating: 5,
	rarity: "Common",
	armorType: "Medium",
	value: 30
}

var basicSword = {
	name: "Basic Sword",
	weaponModifier: 2,
	attackRandom: 6,
	randomMultiplier: 1,
	type: "Sword",
	rarity: "Common",
	value: 15
}



//start to build a character
// var namePrompt = prompt("What would you like to name your character?");

// var character = {
// 	name: namePrompt,

// };

var pointsToSpend = 10;

	jQuery(document).ready(function(){
		$('.pointsToSpend').append(pointsToSpend);
	    // This button will increment the value
	    $('.qtyplus').click(function(e){
	        // Stop acting like a button
	        e.preventDefault();
	        // Get the field name
	        fieldName = $(this).attr('field');
	        // Get its current value
	        var currentVal = parseInt($('input[name='+fieldName+']').val());
	        // If is not undefined
	       if (pointsToSpend === 0) {
	        	$('input[name='+fieldName+']').val(currentVal + 0);
	        } else if (pointsToSpend === 1) {
	        	$('input[name='+fieldName+']').val(currentVal + 1);
	        	pointsToSpend -= 1;
	        	$('.statSubmit').show('slow');
	        } else if (!isNaN(currentVal)) {
	            // Increment
	            $('input[name='+fieldName+']').val(currentVal + 1);
	            pointsToSpend -= 1;
	        } else {
	            // Otherwise put a 0 there
	            $('input[name='+fieldName+']').val(0);
	        }
	        $('.pointsToSpend').text("")
	       	$('.pointsToSpend').append(pointsToSpend);
	    });
	    // This button will decrement the value till 0
	    $(".qtyminus").click(function(e) {
	        // Stop acting like a button
	        e.preventDefault();
	        // Get the field name
	        fieldName = $(this).attr('field');
	        // Get its current value
	        var currentVal = parseInt($('input[name='+fieldName+']').val());
	        // If it isn't undefined or its greater than 0
	        if (!isNaN(currentVal) && currentVal > 10) {
	            // Decrement one
	            $('input[name='+fieldName+']').val(currentVal - 1);
	            pointsToSpend += 1;
	            $('.statSubmit').hide('slow');
	        } else {
	            // Otherwise put a 0 there
	            $('input[name='+fieldName+']').val(10);
	        }
	        $('.pointsToSpend').text("")
	        $('.pointsToSpend').append(pointsToSpend);
	    });
	});



$('.statSubmit').click(function() {
	//Sets Character's Stats that generate other scores
	character.strength = parseInt($('input[name=strength]').val());
	character.dexterity = parseInt($('input[name=dexterity]').val());
	character.consitution = parseInt($('input[name=consitution]').val());
	
	//Sets the modifiers that most of the score generaters take.
	strengthModifier = Math.floor((character.strength - 10) / 2);
	consitutionModifier = Math.floor((character.consitution - 10) / 2); 
	dexterityModifier = Math.floor((character.dexterity - 10) / 2);
	
	//Determines total health.
	character.totalHealth = 0; 
	for (var i = 0; i < 1 + consitutionModifier; i++) {
		character.totalHealth += diceRoll(6);
		console.log(character.totalHealth);
	} 
	character.totalHealth = character.totalHealth + consitutionModifier + 10;

	//Basic Equiptment
	character.armor = chainmail;
	character.weapon = basicSword;
	character.sharpeningStone = false;

	//Armor Class
	character.armorClass = character.armor.armorRating + dexterityModifier + 10;

	//Expanded Critical
	character.criticalRange = 20 - dexterityModifier;

	//Attack Damage

	character.damage = function () {
		var weaponRandom = 0;
		for (var i = 0; i < character.weapon.randomMultiplier; i++) {
		weaponRandom += diceRoll(character.weapon.attackRandom);
		console.log(weaponRandom);
	} 

		var attackDamage = character.weapon.weaponModifier + weaponRandom + strengthModifier;
		if (character.sharpeningStone === true) { attackDamage += 1};
		if (attackRoll >= character.criticalRange ) {
			attackDamage *= 2.5
			console.log(attackDamage);
			attackDamage = Math.floor(attackDamage);
		}
		return attackDamage;
	};

	//Attack Chance

		character.basicAttack = function() {
		attackRoll = diceRoll(20);
		var chanceToHit = strengthModifier + character.weapon.weaponModifier + attackRoll;
		return chanceToHit;
	};

var characterPrintout = "";

$('.character-creation').hide('fast');
$('.character-sheet').show('fast');
$('input[name="character_name"]').val(character.name);
$('input[name="character_health"]').val(character.totalHealth);
$('input[name="character_strength"]').val(character.strength);
$('input[name="character_dexterity"]').val(character.dexterity);
$('input[name="character_consitution"]').val(character.consitution);
$('input[name="character_weapon"]').val(character.weapon.name);
$('input[name="character_weaponMod"]').val(character.weapon.weaponModifier);
$('input[name="character_AttDie"]').val(character.weapon.randomMultiplier + "d" + character.weapon.attackRandom);
$('input[name="character_armor"]').val(character.armor.name);
$('input[name="character_armorRating"]').val(character.armor.armorRating);


});




              
            
!
999px

Console