1.25 Hand in: Character Generator

Computer Programmer - the RPG

Let's say that I have created a role-playing game in which people play computer programmers with different skills and abilities. I know! Brilliant idea! I am going to make a mint!

Let's say that each character could have the following characteristics:

Name Dragos the Security Guru
Typing 5 Random die roll from 1-6
Spelling and Grammar 3 Random die roll from 1-6
Modularizes Code 6 Random die roll from 1-6
Problem Solving 2 Random die roll from 1-6
Awesome with CSS 2 Random die roll from 1-6
Coding Style 6 Random die roll from 1-6

Program planning

I could make a program to roll random characters up quickly!

User interface

Variable structure

I can do this without any global variables. I will need:

I will structure my character information object like this:

characterObject.name stores the name of the character
characterObject.typing stores the Typing skill of the character
characterObject.spellingAndGrammar stores the Spelling and Grammar skill of the character
characterObject.modular stores the Modularizes Code skill of the character
characterObject.problemSolving stores the CSS skill of the character
characterObject.CSS stores the CSS skill of the character
characterObject.style stores the Coding Style skill of the character

Function Pipeline

I will need four functions:

  1. getCharacterName();
  2. generateCharacterStats()
  3. makeCharacterSheet()
  4. outputCharacterSheet()

In mainProcedure(), I can organize these to make the following function pipeline:

returns: aCharacterName
returns: aCharacterObject
returns: aCharacterSheet

An example

When I put all of this together, I can get this:

Please enter a name for your character:

Your character:

Saving your work

Download the template and rename it to your last name, such as "1.25H-CharacterGenerator-LastName.html".

The assignment

Use objects and function pipelines to ask the user for a character name, generate random characteristics, generate a simple character sheet, and then output the sheet.

Use whatever game system you want. Or create your own. Or make something that is a kind-hearted parody. Have fun with this.

Recommended procedure

  1. Read over Qualities of a Programmer again
  2. Plan your user interface first
  3. Plan your variables next paying special attention to your object variable
  4. Plan your separate functions input, process, and output functions. You should have a separate function for generating the character statistics and the character sheet.
  5. Decide on how the functions will work together in a function pipeline
  6. Create your functions empty at first with only the input parameters and return variables, like this:

    function someKindOfFunction (inputVariable) {
          console.log('in someKindOfFunction, inputVariable=' + inputVariable);
          var outputVariable;

          return outputVariable;
  7. Fill in the actual working code of the functions last of all, testing as you go.

Evaluation (out of 10)