function roll () { return mt_rand(1,6); } echo roll(); function roll ($sides) { return mt_rand(1,$sides); } echo roll(6); // roll a six-sided die echo roll(10); // roll a ten-sided die echo roll(20); // roll a twenty-sided die $male = array( "William", "Henry", "Filbert", "John", "Pat", ); $last = array( "Smith", "Jones", "Winkler", "Cooper", "Cline", ); shuffle($male); shuffle($last); for ($i = 0; $i <= 3; $i++) { echo $male[$i] . ' ' . $last[$i]; } $male = explode('\n', file_get_contents('names.female.txt')); $last = explode('\n', file_get_contents('names.last.txt')); $settings = explode("\n", file_get_contents('scenario.settings.txt')); $objectives = explode("\n", file_get_contents('scenario.objectives.txt')); $antagonists = explode("\n", file_get_contents('scenario.antagonists.txt')); $complications = explode("\n", file_get_contents('scenario.complications.txt')); shuffle($settings); shuffle($objectives); shuffle($antagonists); shuffle($complications); echo $settings[0] . ' ' . $objectives[0] . ' ' . $antagonists[0] . ' ' . $complications[0] . "
\n"; $suits = array ( "Picas", "Corazones", "Tréboles", "Diamantes" ); $faces = array ( "Dos", "Tres", "Cuatro", "Cinco", "Seis", "Siete", "Ocho", "Nueve", "Diez", "J", "Q", "K", "As" ); $deck = array(); foreach ($suits as $suit) { foreach ($faces as $face) { $deck[] = array ("face"=>$face, "suit"=>$suit); } }

Comentarios

Entradas populares