Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #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,198
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
  #2  
Old 10-25-2009, 12:26 PM
BMR777 BMR777 is offline
Member
 
Join Date: Jan 2011
Posts: 1,122
Gender: Male
Credits: 10,642
BMR777 is on a distinguished road
Default RE: Breeding

What I would recommend is that you use the alternate images system as a basis for gendering your adoptables. Make each adoptable have a 1 in 2 chance of using the alternate images. Then when you make new adoptables always use alternate images and make the primary images female and the alternates male. That way then you have a 50/50 shot of getting a male or female adoptable.

Then for breeding, simply check if the adoptable is using the primary or alternate images. So, for sample breeding what you could do is check if the user has one adoptable of type x that is male and one of type x that is female. If they do, then they are allowed to breed. :)

Hope it helps,
Brandon
Reply With Quote
  #3  
Old 10-25-2009, 12:59 PM
Arianna's Avatar
Arianna Arianna is offline
Dev Staff
 
Join Date: Sep 2009
Posts: 334
Gender: Female
Credits: 21,198
Arianna will become famous soon enough
Default RE: Breeding

Hmm, that makes sense. However, I already made the whole gender system and I quite like it. :/ We have alt images which are different things (not female/male) so I don't think that that would work.
Is there any way that this script would ever work, or would it make sense to scrap it?
Reply With Quote
  #4  
Old 10-25-2009, 01:58 PM
gabeki gabeki is offline
Premium Member
 
Join Date: Oct 2009
Posts: 24
Gender: Female
Credits: 1,291
gabeki
Default RE: Breeding

I would do like that: create a table to store adoptables that users want do breed

then create a page so users can put the adoptables there, like a 'daycare', and while they are there, they are removed from the owned_adoptables

then a page that displays the adoptables in the daycare, and allows users to choose if there's any that they want to breed with, and when they choose, the other adoptable go to the daycare table too, and also the date is inserted, so you can put something that allows the user to return and see if they bred well just after some days

and I guess each user has to keep one egg.. idk

just some ideas '-'
Reply With Quote
  #5  
Old 10-25-2009, 02:05 PM
Arianna's Avatar
Arianna Arianna is offline
Dev Staff
 
Join Date: Sep 2009
Posts: 334
Gender: Female
Credits: 21,198
Arianna will become famous soon enough
Default RE: Breeding

I was thinking more of an instant system. I don't really know what to do. Do you think that your way would make it harder or easier for a PHP novice like me to complete?
Does anyone have any advice on the pieces of code I'm missing?
Reply With Quote
  #6  
Old 10-25-2009, 02:17 PM
gabeki gabeki is offline
Premium Member
 
Join Date: Oct 2009
Posts: 24
Gender: Female
Credits: 1,291
gabeki
Default RE: Breeding

that way would be harder I guess '-' but I don't understand very well what you're trying to do x_x
is it like, just breeding two of your adoptables into one new?

I'm a PHP novice too like you, but I'll see your code e_e

$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?

for this part... you have to estabilish a $result variable first, and the $query is not being used at all.. also, the 'level' is not a colum in owned_adoptables.. do you want to select the rows just from the adoptables that are level 2?

well I'll guess you forgot an important thing.. how the user will select the adoptables that he wants to breed? .-.
I'll try to create a code to that and I'll post here
but I'm not sure I can haha x_x
Reply With Quote
  #7  
Old 10-25-2009, 02:23 PM
Arianna's Avatar
Arianna Arianna is offline
Dev Staff
 
Join Date: Sep 2009
Posts: 334
Gender: Female
Credits: 21,198
Arianna will become famous soon enough
Default RE: Breeding

Basically what I want is that the user selects adoptable 'a' which is a female, and then it displays all males. They then choose the male. This sets adoptable a's id to parent1 and adoptable b's id to parent2. This then determines how the egg with be.
I'm a PHP beginner would be better to describe it. The only thing I've learnt from is this script. -.-
Yes, I'd like to select the ones which are level 2 (grown ups).
Good luck with the code! I'm sorry I had no idea, what to do there. xP
Reply With Quote
  #8  
Old 10-25-2009, 02:29 PM
aroymart aroymart is offline
Member
 
Join Date: Jan 2009
Posts: 74
Credits: 6,469
aroymart
Default RE: Breeding

i've been on the verge of finishing my breeding script but i had homework, i started like 2 weeks ago
Reply With Quote
  #9  
Old 10-25-2009, 02:52 PM
Arianna's Avatar
Arianna Arianna is offline
Dev Staff
 
Join Date: Sep 2009
Posts: 334
Gender: Female
Credits: 21,198
Arianna will become famous soon enough
Default RE: Breeding

Awesome!
Is there any chance that I could use it or something like that? I'd really love to be able to use it.
Do you use something like genders on your script, or do you use alt images?
Reply With Quote
  #10  
Old 10-25-2009, 03:06 PM
gabeki gabeki is offline
Premium Member
 
Join Date: Oct 2009
Posts: 24
Gender: Female
Credits: 1,291
gabeki
Default RE: Breeding

ok, I did it... I did not test it, because my gender system is a little different, but I'll test soon.

I'm not sure it'll work, but I tried to explain everything for you, so you can change what is necessary

If it works, or if you change it so it works, you can release it in mods forum :D

PHP Code:
<?php

// Basic Rusnak PHP Adoptables Script configurations
include("inc/functions.php");
include(
"inc/config.php");

$themeurl grabanysetting("themeurl");
$links getlinks();

$ads getads("any");

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

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

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

// End of basic configurations

$femaleid $_POST['female'];
$maleid $_POST['male'];
$breed $_POST['breed'];
// this two variables will get the female and male ID's from the selection form and the answer if the user has selected the adoptables or not.

// First let's create a page so the users can choose the two adoptables that they want to breed

if($isloggedin == "yes"){ 
// we have to put that in the start of the breeding system, so users that are not logged in cannot see the selection forms

if($breed != 'yes'){
// if the anser if the user has selected the adoptables or not, is different than YES, we have to show the options so the user can select them

// This will start a selection form to select the females
$article_content $article_content."<p>Select the Two adoptables you want to Breed:</p><p><form method='post'><select name = 'female'>"

//This will select all the female adoptables the user has
$result mysql_query("SELECT * FROM ".$prefix."owned_adoptables WHERE owner = '$loggedinname' AND gender = 'female'");
$num mysql_num_rows($result);

// Loop Out code < this will loop so you select all the rows and not just one
$i 0;
while (
$i $num){
$aid mysql_result($result,$i,'aid');
$type mysql_result($result,$i,'type');
$name mysql_result($result,$i,'name');

$article_content $article_content."<option value='".$aid."'>".$name." (".$type.")</option>";
//this will display something like that: cute kitty (cat), the name (the type); for each adptable (female) the user has

$i++;
}

$article_content $article_content."</select><select name='male'>"//now let's do the same for the males

$result2 mysql_query("SELECT * FROM ".$prefix."owned_adoptables WHERE owner = '$loggedinname' AND gender = 'male'");
$num2 mysql_num_rows($result2);

// Loop Out code
$i2 0;
while (
$i $num){
$aid mysql_result($result2,$i2,'aid');
$type mysql_result($result2,$i2,'type');
$name mysql_result($result2,$i2,'name');

$article_content $article_content."<option value='".$aid."'>".$name." (".$type.")</option>";

$i2++;
}

$article_content $article_content."</select><input type='hidden' name='breed' value='yes'><input type='submit' value='Breed It'></form>";

// ok now the user has two selection forms to those a female and a male adoptable and when they click Breed It, it will be posted to the variables $_POST['female'] and $_POST['male'], which will be two aid (adoptables ids), and with that ID we can select the information that we need from the database, and breed them

// the hidden input will give us an answer to our question, the user has selected it? and it'll be 'yes'

// this is the end of if($breed != 'yes'), so now we have to put an ELSE statment, that means that the answer IS yes, and we can proceed with the breeding

else {
// ok, if the user gets here, it means that we have the male and female ID, and with it we can select the informations from the database.

// here you can estabilish what you want.. the adoptables have to be which level to breed? the adoptables have to be the same type? 

// I will do something like that: the adoptables have to be the same type, and level 2 or more. but you can do what you want.. if you have an element system like me, you can estabilish that two water adoptables breed a another water adoptable. or fire and water are incompatible, etc

// first let's get the information we need

$result mysql_query("SELECT * FROM ".$prefix."owned_adoptables WHERE aid = '$femaleid'");
// the result should be just one row, so we don't need a loop

$female_type mysql_result($result,0,'type'); 
// 0 means that we are selecting the very first row, in this case, the only one
$female_name mysql_result($result,0,'name');
$female_level mysql_result($result,0,'currentlevel');


$result2 mysql_query("SELECT * FROM ".$prefix."owned_adoptables WHERE aid = '$maleid'");
// the result should be just one row, so we don't need a loop

$male_type mysql_result($result2,0,'type'); 
// 0 means that we are selecting the very first row, in this case, the only one
$male_name mysql_result($result2,0,'name');
$male_level mysql_result($result2,0,'currentlevel');

// now we have all we need. let's start the security system, to guarantee that the user has the requirements

if($male_level OR $female_level 2){
$article_content $article_content."Sorry, one of your adoptables don't have the minimum level to breed. Keep training them.";
}
else {
if (
$male_type != $female_type){
$article_content $article_content."Sorry, your adoptables are not the same type, they cannot breed."
}
else{
// ok, we can go one and BREED it, let's make it more real and estabilish a certain chance that the breed will not work. let's say the chance of it to fail, is a formula with the difference of the levels, that way if a adoptable is very old, it will be difficult to breed

$article_content $article_content."<p>Your adoptables are breeding.</p>"

$rand rand(1,100);

if(
$male_level $female_level){
$failchance $male_level $female_level 3
else{
$failchance $female_level $male_level 3;
}
// that way if one is level 2 and the other is level 4, they have a 6% chance of failing, because the formula is higher level - lower level x 3

if($rand $failchance){
$article_content $article_content."<p>Result: <b>FAIL</b></p><p>I'm sorry, your adoptables failed at breeding, you can try again later.</p>";
}
else{
$article_content $article_content."<p>Result: <b>Bred Succesfully</b></p><p>Your new egg is being transferred to you right now.</p>";

// now let's insert the new egg at owned_adoptables

$gender_rand rand(0,1);

if(
$gender_rand 0){
$new_name $male_name." & ".$female_name."'s Son";
$gender 'male';
}
else{
$new_name $male_name." & ".$female_name."'s Daughter";
$gender 'female';
}

$code rand(120000);

$result3 mysql_query("SELECT * FROM ".$prefix."adoptables WHERE type='$male_type'");
$aid=@mysql_result($result3,0,"id"); //The adoptable's ID
$eggimage=$mysql_result($result3,0,'eggimage');

$alts getaltstatus($aid00);

mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$male_type', '$new_name','$loggedinname','0','0', '$code', '','$alts','notfortrade','no','$gender')");

$article_content $article_content."<p><img src='".$eggimage."'><br /><a href='myadopts.php'>Manage ".$new_name." now!</a> You can change its name.</p>";

}

}
}
}

// this is the end of if($isloggedin == "yes")

else { //this is the else of if($isloggedin == "yes")

$article_content $article_content."You are not logged in.";

}

// **********************************************************************
// 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
// **********************************************************************
?>
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Breeding Bug? Need help :) Missy Master Questions and Supports 7 08-14-2014 02:29 PM
Breeding help SilverDragonTears Questions and Supports 0 04-12-2012 11:41 PM
Random breeding outcome/ rare breeding SilverDragonTears Questions and Supports 0 03-25-2012 02:33 AM
breeding Ruffsta Feedback and Suggestions 3 06-06-2011 04:09 PM
No breeding RoconzaArt Questions and Supports 15 01-24-2011 02:48 PM


All times are GMT -5. The time now is 07:09 PM.

Currently Active Users: 531 (0 members and 531 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636