# IB Comp Sci SL - October 20 2016 Lesson Notes

## What are we going to learn today?

1. You've done quite a bit so far!
2. Please implement a "final" character sheet.
1. The sheet must have all attributes
2. The race should impact attribute (maybe Dwarves are a bit stronger). You should note these changes on the character sheet
3. The HP, MP should be calculated mathematically. Please INFORM the user how this number was arrived at.

```<?php

session_start();

\$pay_to_win = \$_POST['paytowin'];
\$race = \$_POST['race'];
\$gender = \$_POST['gender'];

\$_SESSION['pay_to_win'] = \$pay_to_win;
\$_SESSION['race'] = \$race;
\$_SESSION['gender'] = \$gender;

print_r(\$_POST);

// echo "debug: you are passing pay to win = \$pay_to_win, race = \$race
// and gender = \$gender";

if (\$pay_to_win == "yes")

{

\$strength = mt_rand(50,100);
\$intelligence = mt_rand(0,50);
\$agility =mt_rand(0,100);
\$stamina = mt_rand(0,100);
\$luck = mt_rand(50,100);
\$charisma = mt_rand(0,100);

}

else

{

\$strength = mt_rand(0,100);
\$intelligence = mt_rand(0,100);
\$agility =mt_rand(0,100);
\$stamina = mt_rand(0,100);
\$luck = mt_rand(50,100);
\$charisma = mt_rand(0,100);

}

echo "<p>Strength: \$strength </p>";
echo "<p>Intelligence: \$intelligence </p>";
echo "<p>Agility: \$agility </p>";
echo "<p>Stamina: \$stamina </p>";
echo "<p>Luck: \$luck </p>";
echo "<p>Charisma: \$charisma </p>";

\$_SESSION["strength"] = \$strength;
\$_SESSION["intelligence"] = \$intelligence;
\$_SESSION["agility"] = \$agility;
\$_SESSION["stamina"] = \$stamina;
\$_SESSION["luck"] = \$luck;
\$_SESSION["charisma"] = \$charisma;

\$classes = ["Fighter","Wizard","Barbarian","Cleric","Hunter","Warlock","Chef"];

echo "<form action=\"char_gen_3.php\" method=\"post\">";

foreach (\$classes as \$i)
{
echo "<p> <input type=\"radio\" name=\"player_class\" value=\"\$i\"> \$i </p>";
}

if (\$pay_to_win == "yes")
{

{
echo "<p> <input type=\"radio\" name=\"player_class\" value=\"\$i\"> \$i </p>";
}

}
else
{
}

?>

<input type="submit" value="Onto step 3" />
</form>
```

## Homework

1. Learn and apply sessions to our character generation program

## How am I being assessed today?

1. You will be formatively assessed in class today

## As a computer scientist, you have:

• Confidence in dealing with complexity
• Persistence in working with difficult problems
• Tolerance for ambiguity
• The ability to deal with open-ended problems
• The ability to communicate and work with others to achieve a common goal or solution