Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //require 'Personnage.class.php';
- function customRandom($element)
- {
- return rand(0,sizeof($element)-1);
- }
- function getRandomSexe(){
- $sexe_array = ["man", "woman"];
- return $sexe_array[rand(0,1)];
- }
- function getRandomName($sexe){
- if ($sexe == "man") return getManName();
- elseif ($sexe == "woman") return getWomanName();
- }
- function randomEntity(){
- $dir = 'assets/';
- $imgDir = scandir($dir);
- $sexe = getRandomSexe();
- $name = getRandomName($sexe);
- $tab_glasses = ["glasses", false];
- if ($sexe == "man"){
- //size : 7
- $tab_hairMan = ["hair_10", "hair_1", "hair_2", "hair_6", "hair_7", "hair_9"];
- //size : 2
- $tab_clotheMan = ["clothe", false];
- //size : 3
- $tab_suitMan = ["suit_1", "suit_3"];
- //size : 2
- $tab_beard = ["beard", false];
- //size : 2
- $tab_mustache = ["mustache", false];
- $randomClotheMan = $tab_clotheMan[rand(0,1)];
- $randomSuitMan = $tab_suitMan[rand(0,1)];
- if (!empty($randomClotheMan)) $randomSuitMan = false;
- //size : 7
- $tab_imgElements = array($tab_glasses[rand(0,1)], "body", $randomClotheMan, $tab_hairMan[rand(0,6)], $randomSuitMan, $tab_mustache[rand(0,1)], $tab_beard[rand(0,1)]);
- }
- elseif ($sexe == "woman"){
- //size : 8
- $tab_clotheWoman = ["clothe_basic", "clothe_claudine", "clothe_pull", "clothe_roule", "clothe_shirt", "clothe_sweat", "clothe_V", false];
- //size : 3
- $tab_hairWoman = ["hair_3", "hair_4", "hair_8"];
- //size : 2
- $tab_suitWoman = ["suit_2", "suit_4"];
- //size : 2
- $tab_pearl = ["pearl", false];
- $randomClotheWoman = $tab_clotheWoman[rand(0,7)];
- $randomSuitWoman = $tab_suitWoman[rand(0,1)];
- if (!empty($randomClotheWoman)) $randomSuitWoman = false;
- //size : 8
- $tab_imgElements = array($tab_glasses[rand(0,1)], "body", $randomClotheWoman, $tab_hairWoman[rand(0,2)], $randomSuitWoman, false, false, $tab_pearl[rand(0,1)]);
- }
- $tabElement = array();
- $count = 0;
- for($i=0;$i<sizeof($tab_imgElements);$i++) {
- $count = 0;
- foreach($imgDir as $img){
- $imgElement = strstr($img, $tab_imgElements[$i]);
- if($imgElement) {
- $tabElement[$tab_imgElements[$i]][$count] = $imgElement;
- $count++;
- }
- }
- }
- $beard = $tabElement[$tab_imgElements[6]][customRandom($tabElement[$tab_imgElements[6]])];
- $body = $tabElement["body"][customRandom($tabElement["body"])];
- $clothe = $tabElement[$tab_imgElements[2]][customRandom($tabElement[$tab_imgElements[2]])];
- $glasses = $tabElement[$tab_imgElements[0]][customRandom($tabElement[$tab_imgElements[0]])];
- $hair = $tabElement[$tab_imgElements[3]][customRandom($tabElement[$tab_imgElements[3]])];
- $mustache = $tabElement[$tab_imgElements[5]][customRandom($tab_imgElements[5])];
- $pearl = $tabElement[$tab_imgElements[7]][customRandom($tabElement[$tab_imgElements[7]])];
- $suit = $tabElement[$tab_imgElements[4]][customRandom($tabElement[$tab_imgElements[4]])];
- //Affichage
- echo ("Sexe : ".$sexe);
- echo "<br/><br/>";
- echo ("Nom : ".$name);
- echo "<br/><br/>";
- echo("Barbe : ".$beard."\n");
- echo "<br/><br/>";
- echo("Body : ".$body."\n");
- echo "<br/><br/>";
- echo("Clothe : ".$clothe."\n");
- echo "<br/><br/>";
- echo("Glasses : ".$glasses."\n");
- echo "<br/><br/>";
- echo("Hair : ".$hair."\n");
- echo "<br/><br/>";
- echo("Mustache : ".$mustache."\n");
- echo "<br/><br/>";
- echo("Pearl : ".$pearl."\n");
- echo "<br/><br/>";
- echo("Suit : ".$suit."\n");
- echo "<br/><br/>";
- }
- //$randomPersonnage = new Personnage($name, $sexe, $beard, $body, $clothe, $glasses, $hair, $mustache, $pearl, $suit, true, false);
- randomEntity();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement