crimsonduex
-
Posts
2 -
Joined
-
Last visited
Never
Posts posted by crimsonduex
-
-
I've looked all over, but I can't seem to find any help at all. I've been asked to try and create a php script for an online breeding sim dealing with horses. I have all the necessary genetics information, have everything planned out nice and pretty, but I can't for the life of me figure out HOW to code it.
I have only the very basic knowledge of php, but I do know C++ and since they look superficially rather similar, I thought I could do it, but I really am lost.
Does anyone know what kind of script I should be writing? I thought maybe OOP might work, since it deals with inheritance, but I'm not entirely sure. Basically, the script needs to take data from each parent -- the stats, breed, and color information are all already coded -- and do the pundit square math. There would be the basic stat conversion, where the foal would inherit the sum of both parents' stat*.35, and then the color genes would do the regular thing... pureblood bayXpureblood bay=pureblood bay and so on.
Can anyone help?
Differentiating Between Variables
in PHP Coding Help
Posted
<?php<br />
//database queries<br />
$query=mysql_query("select hid,name from horses where gender='Mare' and age > 2");<br />
$num=mysql_num_rows($query);<br />
if($num == "0"){<br />
print "You have no mares older than two. Horses must be three or older to breed.";<br />
exit;<br />
}<br />
else {<br />
print "<form method=post action=breed.php?action=breed> Mare to cover: <select name=hid selected=selected><br />
while($i<3; $i=0; $i++){<br />
$row=mysql_fetch_array($query);<br />
print "<option value=$row[hid]>$row[name]</option></form>";<br />
}<br />
//variables<br />
$dadstats=array("Conformation"=>”$row[confirmation]”, "Intelligence"=>"$row[intelligence]", "Endurance"=>"$row[endurance]", "Strength"=>"$row[strength]", "Agility"=>"$row[agility]", "Speed"=>"$row[speed]");<br />
$momstats= array("Conformation"=>”$row[confirmation]”, "Intelligence"=>"$row[intelligence]", "Endurance"=>"$row[endurance]", "Strength"=>"$row[strength]", "Agility"=>"$row[agility]", "Speed"=>"$row[speed]");<br />
$dadcgenes=array("","");<br />
$momcgenes=array("","");<br />
$dadgenetics=array(“$row[bname]”,”$row[bname]”);<br />
$momgenetics=array(“$row[bname]”,”$row[bname]”);<br />
$foalstats=array("Conformation"=>"$v", "Intelligence"=>"$w", "Endurance"=>"$x", "Strength"=>"$y", "Agility"=>"$z", "Speed"=>"$a");<br />
$foalcgenes=array("", "");<br />
$foalgenetics=array(“t”,”t”);<br />
//beginning computations<br />
switch ($foalgenetics)<br />
{<br />
case Thoroughbred Quarter Horse:<br />
$foalgenetics=”Appendix QH”;<br />
break;<br />
case Arabian Apaloosa:<br />
$foalgenetics=”Ara-Apaloosa”;<br />
break;<br />
case Thoroughbred Arabian:<br />
$foalgenetics=”Anglo-Arabian”;<br />
$v=(($momstats[Conformation]+$dadstats[Conformation])*.70);<br />
$w=(($momstats[Intelligence]+$dadstats[Intelligence])*.70);<br />
$x=(($momstats[Endurance]+$dadstats[Endurance])*.70);<br />
$y=(($momstats[Strength]+$dadstats[Strength])*.70);<br />
$z=(($momstats[Agility]+$dadstats[Agility])*.70);<br />
$a=(($momstats[Speed]+$dadstats[Speed])*.70);<br />
array_splice($dadcgenes, 0,2,$foalcgenes);<br />
array_splice($momcgenes,1,2,$foalcgenes);<br />
array_splice($dadgenetics, 0,2,$foalgenetics);<br />
array_splice($momgenetics,1,2,$foalgenetics);<br />
<br />
echo $foalstats<br />
echo $foalcgenes<br />
How do I make sure that I the correct numbers from the mom's db entries versus the dad's? I know I should do something with the horses' ID #, but what and how?