Thread: Breeding
View Single Post
  #1  
Old 10-25-2009, 04:58 AM
Arianna's Avatar
Arianna Arianna is offline
Dev Staff
 
Join Date: Sep 2009
Posts: 334
Gender: Female
Credits: 21,569
Arianna will become famous soon enough
Default Breeding

Yes, I know that this will take a lot of work and I'm certainly not the right person to be doing this, given my knowledge of PHP.
Is anyone here making a script right now, or would anyonee like to give me some help on my current page (which is very drafty and probably not the right way to code it)?

Here's my current code, if anyone would like to look and help me. Most of the things which I need help on are in comments, where I have no idea what to do.

PHP Code:
<?php

// **********************************************************************
// Rusnak PHP Adoptables Script
// Copyright 2009 Brandon Rusnak
// For help and support: http://www.rusnakweb.com/forum/
//
// Redistribution prohibited without written permission
// **********************************************************************

// Wake the sleeping giant

// **********************************************************************
// Basic Configuration Info
// **********************************************************************

include("inc/functions.php");
include(
"inc/config.php");

$themeurl grabanysetting("themeurl");

// **********************************************************************
// Define our top links by calling getlinks()
// **********************************************************************

$links getlinks();

// **********************************************************************
// Define our ads by calling getads()
// **********************************************************************

$ads getads("any");

// **********************************************************************
// Grab any dynamic article content from the content table
// **********************************************************************

$pagecontent getsitecontent("index");
$article_title $pagecontent[title];
$article_content $pagecontent[content];
$article_content nl2br($article_content);

// **********************************************************************
// Grab any settings that we will need for the current page from the DB
// **********************************************************************

$browsertitle grabanysetting("browsertitle");
$sitename grabanysetting("sitename");
$slogan grabanysetting("slogan");

// **********************************************************************
// Check and see if the user is logged in to the site
// **********************************************************************

$loginstatus logincheck();
$isloggedin $loginstatus[loginstatus];
$loggedinname $loginstatus[username];

// **********************************************************************
// End Prepwork - Output the page to the user
// **********************************************************************


$aid=@mysql_result($result,$i,"id"); //The adoptable's ID
$type=@mysql_result($result,$i,"type");
$description=@mysql_result($result,$i,"description");
$gender=@mysql_result($result,$i,"gender");
$eggimage=@mysql_result($result,$i,"eggimage");

$query "SELECT * FROM ".$prefix."owned_adoptables WHERE level='2' AND owner='$loggedinname'"//is this how we select it, somehow?

if($isloggedin == "yes"){
/////How do I define what the parents are equal to? Like $parent1 == aid76 or something like that. How do I choose?

//how do I select which adoptable I'm looking at here. basically what I'm trying to do is say:
//If *this* adoptable's gender is female, follow this script. But right now, I'm only saying if the variable $gender is female. xP
if ($gender == female && $aid == ??? ) { //can I use getelementbyid or something like that?
///do I use this:
//$query = "SELECT * FROM ".$prefix."owned_adoptables WHERE gender=male";
//or this, which is under this line?
if ($owner == $loggedinname && $gender == "male") {
//here we display all the males the adoptable can breed with
//how do I list them?
//basically I'd list them here
//loop out the code with i++ or the like, right?
//and all of them would be sort of like, if you click on them, it sets them as the parent2 variable, right?
}

/* //// Now we're going to start making the adoptable
   //// We have to define three things:
   //// It's gender, it's type, and if it's an alt (I don't know how to define alts, please help!)
*/
// **********************************************************************
// ADOPTABLE GENDER
// **********************************************************************
// I'm pretty confident on this. I think I understand it. I like it being random.
$tempgender rand(01);
if(
$tempgender == "0") {
$gender "female";
unset(
$tempgender);
}
else {
$gender "male";
unset(
$tempgender);
}

// **********************************************************************
// ADOPTABLE TYPE
// **********************************************************************
// This comes from one of the two parents. I don't get how to make this part.
// What I want is if $temptype turns out to be '0', we set $type to the $type of parent 1
// Otherwise it sets to be the type of parent 2
$temptype rand(0,1);
if(
$temptype == "0") {
$type = ???? //This needs to be the type of parent #1
//Do I use? $query = "SELECT * FROM ".$prefix."owned_adoptables WHERE aid=[parent1's aid]"; and then somehow get the type?
unset($temptype); }

else {
$type = ???? //This needs to be the type of parent #2
//see above, where the same question was stated for parent1.
unset($temptype); }

}

// so we've declared everything, time to produce the adoptable
// **********************************************************************
// ADOPTABLE IS BORN!
// **********************************************************************
mysql_query("INSERT INTO".$prefix."owned_adoptables VALUES ('','$type','$loggedinname','0','0','$code','$alts','notfortrade','no','$gender')");

// We have now made the adoptable, take us to the myadopts page.
// TAKE US TO MYADOPTS.PHP
$article_title $name." was born!";
$article_content "<img src='".$eggimage."'><a href='myadopts.php'>Manage ".$name." now!</a>"

}
// *****************************************************************************
// Yay, we're done! Well, sort of. Can you help me with what I don't understand?
// *****************************************************************************
else {
$article_content $article_content."<p><b> Guests can't breed. Please register or login. </b></p>";
}


// **********************************************************************
// Begin Template Definition
// **********************************************************************

//Define our current theme
$file $themeurl;

// Do the template changes and echo the ready template
$template file_get_contents($file);

$template replace(':ARTICLETITLE:',$article_title,$template);
$template replace(':ARTICLECONTENT:',$article_content,$template);
$template replace(':ARTICLEDATE:',$article_date,$template);

$template replace(':BROWSERTITLE:',$browsertitle,$template);
$template replace(':SITENAME:',$sitename,$template);

//Define our links
$template replace(':LINKSBAR:',$links,$template);

//Get the content for the side bar...

$sidebar getsidebar();
$template replace(':SIDEFEED:',$sidebar,$template);

//Get the ad content...
$template replace(':ADS:',$ads,$template);

//Get the slogan info
$template replace(':SLOGAN:',$slogan,$template);


echo 
$template;

// **********************************************************************
// End Template Definition
// **********************************************************************



?>
Thanks,
Arianna
Reply With Quote