View Single Post
  #44  
Old 03-24-2012, 09:25 PM
!Alive !Alive is offline
Member
 
Join Date: Feb 2012
Posts: 39
Gender: Male
Credits: 1,069
!Alive is on a distinguished road
Default

XD Glad to.
Lets see to start I suppose I'l go over how the rarity thing actually works.
First you'll see
PHP Code:
$uncommon rand(1,50);   
    
$rare rand(1,100);   
    
$ultrarare rand(1,200); 
These variables set the likelihood of a certain rarity of adoptable appearing. Uncommon 1 in 50
Rare 1 in 100
Ultrarare 1 in 200
You can change the chances simply by the last(max) number of the rand function.

Moving on to the actual selecting of the adoptables. You will see this:
PHP Code:
 if ($uncommon==&& $onlyone==0){   
    
$query "SELECT * FROM ".$prefix."adoptables WHERE rarity='1' ORDER BY RAND() LIMIT 1"
$onlyone 1;   
    }   
    else if (
$rare==&& $onlyone==0){   
    
$query "SELECT * FROM ".$prefix."adoptables WHERE rarity='2' ORDER BY RAND() LIMIT 1"
$onlyone 1;   
    }       
    else if (
$ultrarare==1  && $onlyone==0){   
    
$query "SELECT * FROM ".$prefix."adoptables WHERE rarity='3' ORDER BY RAND() LIMIT 1"
$onlyone 1;   
    }       
    else{   
    
$query "SELECT * FROM ".$prefix."adoptables WHERE rarity='0' ORDER BY RAND() LIMIT 1";   
    } 
First the if statement tests if something other than a common adoptable is to be shown. If it is than it pulls a random adoptable from the database with the corresponding rarity value.
Since the $onlyone variable is shown I'll go over what it does now. The reason for this variable is to check if a rarer adoptable(anything above common) is already selected to be shown. If one isn't chosen choose one if one is already chosen show a common one.

I think the last piece is the $clicked variable that only allows you to click on(adopt) an egg once. This works by setting $clicked to 0 when the page is loaded When the egg is clicked the canclick function runs checking the value of clicked. If it is 0 then the egg is adopted if it is a 1 the user can not adopt it.

I think I covered it. If you want/need more clarification fell free to ask. *is not confident I explained it really well* X3
Reply With Quote