<?php
$diceroll=rand(1,170);
$yardage=20;
if ($diceroll >=1){
$commentary= "The Quarterback drops back......Pressure from the backside........ SACK ! Big hit by the defensive end.....wait ! There's a fumble.....recovered by the linebacker ! Touchdown Defense!";
$playgain=-100;
$yardage=($yardage+$playgain);
}
if ($diceroll >=10){
$commentary= "Yes.";
$yardage=($yardage+$playgain);
$playgain=5;
}
if ($diceroll >=20){
$commentary= "No.";
$yardage=($yardage+$playgain);
$playgain=10;
}
if ($diceroll >=30){
$commentary= "Maybe";
$yardage=($yardage+$playgain);
$playgain=15;
}
if($diceroll >=40){
$commentary= "You're an ig+no+ra+moose!!";
$yardage=($yardage+$playgain);
$playgain=20;
}
if ($diceroll >=50){
$commentary= "lol did you seriously just ask that?";
$yardage=($yardage+$playgain);
$playgain=25;
}
if ($diceroll >=60){
$commentary= "umad?";
$yardage=($yardage+$playgain);
$playgain=30;
}
if ($diceroll >=70){
$commentary="Oh heck naw!";
$yardage=($yardage+$playgain);
$playgain=35;
}
if ($diceroll >=80){
$commentary= "LOL@UR SWAG";
$yardage=($yardage+$playgain);
$playgain=40;
}
if($diceroll >=90) {
$commentary= "Ask your mother.";
$yardage=($yardage+$playgain);
$playgain=45;
}
if ($diceroll >=100){
$commentary= "You'll know when you're older.";
$yardage= ($yardage+$playgain);
$playgain=50;
}
if ($diceroll >=110){
$commentary= "Most Definetly!";
$yardage=($yardage+$playgain);
$playgain=55;
}
if ($diceroll >=120){
$commentary= "Oh Yeaaaaaaah!";
$yardage=($yardage+$playgain);
$playgain=60;
}
if ($diceroll >=130){
$commentary= "This is factual.";
$yardage=($yardage+$playgain);
$playgain=65;
}
if ($diceroll >=140){
$commentary= "Google it.";
$yardage=($yardage+$playgain);
$playgain=70;
}
if ($diceroll >=150){
$commentary= "After pondering your inquest most thoroughly I have come to the conclusion that one most certainly could paricpate int the question of your concern";
$yardage=($yardage+$playgain);
$playgain=75;
}
if ($diceroll >=160){
$commentary= "Fo Shizzle My Nizzle.";
$yardage=($yardage+$playgain);
$playgain=80;
}
if ($diceroll >=170){
$commentary= "You betcha.";
$yardage=($yardage+$playgain);
$playgain=85;
}
echo "$commentary<br>";
echo "$yardage<br>";
echo "$diceroll<br>";
echo "$playgain<br>";
?>
When I do it, everything works correctly, but I get huge numbers for Yardage that doesn't make any sense to me, such as -40 for a diceroll of 88, or 95 for a diceroll of 111. Also, ignore the "commentary".....that's not the real commentary of which will be in the game, this is all imported code using the same system as a Magic 8 Ball app i'm currently using on my site.
if ($diceroll >=1){
$commentary= "The Quarterback drops back......Pressure from the backside........ SACK ! Big hit by the defensive end.....wait ! There's a fumble.....recovered by the linebacker ! Touchdown Defense!";
$playgain=-100;
$yardage=($yardage+$playgain);
}
if ($diceroll >=80){
$commentary= "LOL@UR SWAG";
$yardage=($yardage+$playgain);
$playgain=40;
}
Possibly '$yardage=($yardage+$playgain);' should be after the $playgain modification. Otherwise sometimes playgain is -100, it makes $yardage take that into account, then it makes $playgain=40;
if ($diceroll >=1){
$commentary= "The Quarterback drops back......Pressure from the backside........ SACK ! Big hit by the defensive end.....wait ! There's a fumble.....recovered by the linebacker ! Touchdown Defense!";
$playgain=-100;
$yardage=($yardage+$playgain);
}
I have it echoing the playgain for each one, and everytime, it says the right number I have in the code, but the yardage doesn't reflect that. IE:
Yardage 475
Diceroll 148
Playgain 70
I can even set the first number to 0, but it still creates absurd numbers. Another example
Yardage 20
Diceroll 10
Playgain 5
As we see here, it isn't added AT ALL. So confused.
Gah ! Of Course ! Now I feel dumb, lol. I just imported the dice rolls and such from the magic 8 ball like I had said, and because that was dealing with just text, I didn't have those kind of issues. Thanks for your help !
You could also change each IF to an IF/ELSE IF so that only 1 can be completed for each roll. You also need to put the most exceptional result at the top. In this case, that means the highest first, then the next highest, and on down. Like Callen said, when you have >=1 at the top, that will always get called for any roll when 1 is the lowest that can be rolled. You need to have the 170 check first, then 160, 150, etc. And just to be safe, make them all IF/ELSE IF structure
Jackolantern wrote:You could also change each IF to an IF/ELSE IF so that only 1 can be completed for each roll. You also need to put the most exceptional result at the top. In this case, that means the highest first, then the next highest, and on down. Like Callen said, when you have >=1 at the top, that will always get called for any roll when 1 is the lowest that can be rolled. You need to have the 170 check first, then 160, 150, etc. And just to be safe, make them all IF/ELSE IF structure
Thanks alot mate, I did'nt even think about that !