You are on page 1of 5

<?

php
echo "<p>Code written by <strong>Curufea</strong></p>";
echo "<p>Hit 'refresh' to generate a new result</p>";
//Random Species Generator
//Generic Version
//1. Basic Form of Species:
$numForm = mt_rand(1,6)+mt_rand(1,6)+mt_rand(1,6); // simulating 3D6
switch($numForm ){
case 3: $form = "Text description of form";
$traits = "list of traits";
break;
case ($numForm==4 || $numForm==5) : $form = "Text description of form";
$traits = "list of traits";
break;
case ($numForm==6 || $numForm==7): $form = "Text description of form";
$traits = "list of traits";
break;
case ($numForm==8 || $numForm==9): $form = "Text description of form";
$traits = "list of traits";
break;
case ($numForm==10 || $numForm==11): $form = "Text description of form";
$traits = "list of traits";
break;
case ($numForm==12 || $numForm==13): $form = "Text description of form";
$traits = "list of traits")";
break;
case ($numForm==14 || $numForm==15): $form = "Text description of form";
$traits = "list of traits"";
break;
case ($numForm==16 || $numForm==17): $form = "Text description of form";
$traits = "list of traits";
break;
case 18: $form = "Text description of form";
$traits = "list of traits";
break;
};
//2. Physical Details:
// Appendages and Senses
// Array is - Limbs, Head, Tail, Other, Sight, Smell, Hearing, Taste, Other
$PhysicalDetails = array();
$PhysicalDescription = array ("Arms and Legs:","Heads:","Tails:","Unusual Append
ages:","Sight:", "Smell:", "Hearing:", "Taste:", "Unusual Senses:");
$PhysicalResults = array(
2=>array("# limbs","# heads","# tails","# unusual","sight mod","smell mod","he
aring mod","taste mod","unusual mod"),
3=>array("# limbs","# heads","# tails","# unusual","sight mod","smell mod","he
aring mod","taste mod","unusual mod"),
4=>array("# limbs","# heads","# tails","# unusual","sight mod","smell mod","he
aring mod","taste mod","unusual mod"),
5=>array("# limbs","# heads","# tails","# unusual","sight mod","smell mod","he
aring mod","taste mod","unusual mod"),
6=>array("# limbs","# heads","# tails","# unusual","sight mod","smell mod","he
aring mod","taste mod","unusual mod"),
7=>array("# limbs","# heads","# tails","# unusual","sight mod","smell mod","he
aring mod","taste mod","unusual mod"),
8=>array("# limbs","# heads","# tails","# unusual","sight mod","smell mod","he
aring mod","taste mod","unusual mod"),
9=>array("# limbs","# heads","# tails","# unusual","sight mod","smell mod","he
aring mod","taste mod","unusual mod"),
10=>array("# limbs","# heads","# tails","# unusual","sight mod","smell mod","h
earing mod","taste mod","unusual mod"),
11=>array("# limbs","# heads","# tails","# unusual","sight mod","smell mod","h
earing mod","taste mod","unusual mod"),
12=>array("# limbs","# heads","# tails","# unusual","sight mod","smell mod","h
earing mod","taste mod","unusual mod")
);
// Note - for any of the results (such as "# limbs) you can use a PHP function i
nstead [e.g. put in a random number such as mt_rand(1,6)]
for ($counter=0;$counter<10;$counter++) {
$numDetails = mt_rand(1,6)+mt_rand(1,6); // simulate 2D6
$PhysicalDetails[$counter]=$PhysicalResults[$numDetails][$counter];
};
//3. Tech Level:
$TechLevel = mt_rand(1,6)+mt_rand(0,5); // or whatever you need to simulate tech
level
//4. Civilisation:
$CivType = mt_rand(0,5)+mt_rand(0,5)+mt_rand(0,5)+(($TechLevel>5)*1); // genera
te civ type modified by tech level
$CivResults = array("Civ type", "Civ type", "Civ type", "Civ type", "Civ type",
"Civ type", "Civ type", "Civ type", "Civ type", "Civ type", "Civ type", "ICiv ty
pe", "Civ type", "Civ type", "Civ type", "Civ type", "Civ type");
if ($CivType>9){
if ($CivType>11){
if ($CivType>13){
if (mt_rand(1,2)==1) {
$CivExtras = "Extra notes on a variant for this Civ type";
} else {
$CivExtras = "Extra notes on a variant for this Civ type";
};
} else {
switch (mt_rand(1,3)) {
Case 1:
$CivExtras = "Extra notes on a variant for this Civ type";
break;
Case 2:
$CivExtras = "Extra notes on a variant for this Civ type";
break;
Case 3:
$CivExtras = "Extra notes on a variant for this Civ type";
break;
};
};
} else {
$numColonies = mt_rand(1,3);
if ($numColonies>1) {
$CivExtras = "Has colonised ".$numColonies." planets in this system.";
} else {
$CivExtras = "Has colonised ".$numColonies." planet in this system.";
};
$ind=0;
for ($counter=0;$counter<$numColonies;$counter++) {
if (mt_rand(1,3)==3) {
$ind++;
};
};
if ($ind>0) {
if ($numColonies>1) {
$CivExtras .= " ".$ind." of these colonies is independent.";
} else {
$CivExtras .= " This colony is independent.";
};
};
};
} else {
$CivExtras = "";
};
//5. Attributes and Skills
$AttSkillDesc = array("Attribute", "Attribute", "Attribute", "Attribute", "Attri
bute", "Attribute", "Physical or Combat Skill", "Academic Skill", "Tech Skill",
"Physical or Combat Skill", "Academic Skill", "Physical or Combat Skill", "Tech
Skill", "Academic Skill", "Physical or Combat Skill", "Physical or Combat Skill"
, "Tech Skill", "Tech Skill");
$PhysComSkills = array(6,9,11,14,15); // used to allocate skill points from a ra
ndom sized pool
$TechSkills = array(8,12,16,17); // used to allocate skill points from a random
sized pool
$AcadSkills = array(7,10,13); // used to allocate skill points from a random siz
ed pool
// Process starting skills
for ($counter=0;$counter<count($AttSkillDesc);$counter++) {
if ($counter<6) {
$AttSkillStats[$counter]=mt_rand(1,6); // Starting attributes are random bet
ween 1 and 6
} else {
$AttSkillStats[$counter]=0; // Starting skills are zero
};
};
// Physical and Combat skills
$CombatTotal= mt_rand(0,5)+mt_rand(0,5); // Size of the pool to allocate points
from
for ($counter=0;$counter<=$CombatTotal;$counter++) {
$AttSkillStats[$PhysComSkills[mt_rand(0,count($PhysComSkills))]]++; // Increme
nt one of the skills in the category by one
};
// Technical skills
$TechTotal= $TechLevel-mt_rand(1,6); // Size of the pool to allocate points from
for ($counter=0;$counter<=$TechTotal;$counter++) {
$AttSkillStats[$TechSkills[mt_rand(0,count($TechSkills))]]++; // Increment one
of the skills in the category by one
};
// Academic Skills
$AcadTotal= $TechLevel-mt_rand(1,6); // Size of the pool to allocate points from
for ($counter=0;$counter<=$AcadTotal;$counter++) {
$AttSkillStats[$AcadSkills[mt_rand(0,count($AcadSkills))]]++; // Increment one
of the skills in the category by one
};
if ($TechLevel>4) {
$AttSkillStats[2]++; // Increment one of the skills if the civilisations tech
level is high enough
};
if ($TechLevel>7) {
$AttSkillStats[2]++; // Increment one of the skills if the civilisations tech
level is high enough
};
if ($TechLevel>10) {
$AttSkillStats[2]++; // Increment one of the skills if the civilisations tech
level is high enough
};
//6. Species Aggression
$numAggression = (mt_rand(1,6)+mt_rand(1,6)); // 2D6
$PeaceSkills = array (7,8,10,12,13,16,17); // A category of skills for the less
aggressive
if ($numAggression==2) {
$SpecAggression = "Aggression type";
$AttSkillStats[9]=mt_rand(1,3); // Modify skills
$AttSkillStats[11]=mt_rand(1,3);
} else {
if ($numAggression<6) {
$SpecAggression = "Aggression type";
$AttSkillStats[mt_rand(6,17)]=1;
if (mt_rand(1,2)==1) {
$AttSkillStats[9]=1;
} else {
$AttSkillStats[11]=1;
};
} else {
if ($numAggression<9) {
$SpecAggression = "Aggression type";
$AttSkillStats[mt_rand(6,17)]=1;
$AttSkillStats[mt_rand(6,17)]=1;
} else {
if ($numAggression<12) {
$SpecAggression = "Aggression type";
$AttSkillStats[7]=1;
$AttSkillStats[mt_rand(6,17)]=1;
} else {
$SpecAggression = "Aggression type";
$AttSkillStats[7]=mt_rand(1,3);
$AttSkillStats[$PeaceSkills [mt_rand(0,count($PeaceSkills))]]=mt_rand(1,
3);
};
};
};
};
//7. Sociopolitical Attitude
$SocioDesc = array("Social/Political type", "Social/Political type", "Social/Pol
itical type", "Social/Political type", "Social/Political type", "Social/Politica
l type", "Social/Political type", "Social/Political type", "Social/Political typ
e", "Social/Political type", "Social/Political type");
$SocioPolitical = $SocioDesc[mt_rand(0,5)+mt_rand(0,5)];
//X. Display the results
echo "<table width=\"100%\"><tr><td width=\"50%\"><p><strong>Species Form:</st
rong> ".$form."<br />\n";
echo "<strong>Traits:</strong> ".$traits."</p>\n";
echo "<h2>Physical Details</h2>\n<p>";
for ($counter=0;$counter<10;$counter++) {
if ((($counter<4) && ($PhysicalDetails[$counter]=="0")) || (($counter==9) &&
($PhysicalDetails[$counter]=="None"))) {
echo "No ".substr($PhysicalDescription[$counter],0,strlen($PhysicalDescrip
tion[$counter])-1-(($counter>0)*1)).".<br />\n";
} else {
echo "<strong>".$PhysicalDescription[$counter]."</strong> ".$PhysicalDetai
ls[$counter]."<br />\n";
};
};
echo "</p>\n";
echo "<h2>Culture</h2>\n<p>";
echo "<strong>Tech Level:</strong> ".$TechLevel ."<br />\n";
echo "<strong>Civilisation Type:</strong> ".$CivResults[$CivType]."<br />\n";
if ($CivExtras>"") {
echo "<strong>Civilisation Notes:</strong> ".$CivExtras."<br />\n";
};
echo "<strong>Species Aggression:</strong> ".$SpecAggression."<br />\n";
echo "<strong>Sociopolitical Attitude:</strong> ".$SocioPolitical."<br />\n";
echo "</p></td>\n<td>";
echo "<h3>Attributes</h3>\n<p>";
for ($counter=0;$counter<6;$counter++) {
echo "<strong>".$AttSkillDesc[$counter].":</strong> ".$AttSkillStats[$counte
r]."<br />\n";
};
echo "</p>\n";
echo "<h3>Skills</h3>\n<p>";
for ($counter=6;$counter<count($AttSkillDesc);$counter++) {
echo "<strong>".$AttSkillDesc[$counter].":</strong> ".$AttSkillStats[$counte
r]."<br />\n";
};
echo "</p></td></tr></table>\n";
?>