IB Comp Sci SL - October 20 2016 Lesson Notes

From Computer Science Wiki

Class plan.png What are we going to learn today?[edit]

  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;



echo "<p>Please choose a class</p>";

$classes = ["Fighter","Wizard","Barbarian","Cleric","Hunter","Warlock","Chef"];
$premium_classes = ["Paladin","Monk","Chuck Norris"];

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")
{

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

}
else
{
echo "<p>If you had premium, you would see premium classes here!</p>";
}

?>

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



Homework.png Homework[edit]

  1. Learn and apply sessions to our character generation program


Target.png How am I being assessed today?[edit]

  1. You will be formatively assessed in class today

Ourstandards.png Standards we are covering today[edit]

Computer1.png As a computer scientist, you have:[edit]

  • 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

Credit.png Credits[edit]