Dark Nonique Posted June 29, 2007 Share Posted June 29, 2007 Okay, for this battle engine I'm currently working on, any single character's creature can have up to 4 different/same moves. When they are in battle, it lists the moves and allows them to pick which one they wish to use for that turn. Now, what I need to do, is have the php connect to the MySQL, determine which moves the user's creature has available for the battle, and then detect the properties of the moves. Now, the moves themselves have their own table in the MySQL, and the creatures have their own as well. In the creature's table, it lists the current moves that the creature has available. Now, I just don't know how to link the two. I'm working on a Beta version right now to be honest, and I just can't get it. Here's the coding... <form> <input type="radio" name="Move 1" value="<? $Move1 ?>"> <input type="radio" name="Move 2" value="<? $Move2 ?>"> <br> <input type="radio" name="Move 3" value="<? $Move3 ?>"> <input type="radio" name="Move 4" value="<? $Move4 ?>"> <input type="submit" value="Attack"> </form> <? //BATTLE Part $Move1 = mysql_query("SELECT * FROM Moves WHERE Attack='Fire'"); $Move2 = mysql_query("SELECT * FROM Moves WHERE Attack='Water'"); $Move3 = mysql_query("SELECT * FROM Moves WHERE Attack='Sliding Kick'"); $Move4 = mysql_query("SELECT * FROM Moves WHERE Attack='Super Punch'"); $EnemyHP = 8000; function SpecialAttack($Level, $BasePower, $SpAtk, $SpDef, $Crit, $STAB, $Type1, $Type2){ $damage = floor(floor(floor(floor(floor(floor(floor(floor(floor(floor(2 + ($Level * 0.4)) * $BasePower * $SpAtk) / $SpDef) / 50) + 2) * $Crit) * (rand(85, 100)) / 100) * $STAB) * $Type1) * $Type2); return $damage; } function Attack($Level, $BasePower, $Atk, $Def, $Crit, $STAB, $Type1, $Type2){ $damage = floor(floor(floor(floor(floor(floor(floor(floor(floor(floor(2 + ($Level * 0.4)) * $BasePower * $Atk) / $Def) / 50) + 2) * $Crit) * (rand(85, 100)) / 100) * $STAB) * $Type1) * $Type2); return $damage; } $myNumber = 0; echo "Before the function, myNumber = ". $myNumber ."<br />"; $SpA = SpecialAttack(1000, 120, 2115, 2155, 1.5, 1.5, 1.5, 1); echo "After the function, Special Attack Damage = " . $SpA ."<br />"; $Atk = Attack(1000, 70, 2115, 2435, 1.5, 1.5, 1, 1); echo "After the function, Attack Damage = " . $Atk ."<br />"; $New_EnemyHP = $EnemyHP - $SpA; $EnemyHP = $New_EnemyHP; echo "<br><br>".$EnemyHP."HP Remains"; $New_EnemyHP = $EnemyHP - $Atk; $EnemyHP = $New_EnemyHP; echo "<br><br>".$EnemyHP."HP Remains"; if(isset($_POST['Attack']') { $New_EnemyHP = $EnemyHP - $Atk; $EnemyHP = $New_EnemyHP; echo "<br><br>".$EnemyHP."HP Remains"; } ?> Now, I really suck at forms. I know I do. I just can't figure out how to link the MySQL moves to the creatures current moves. I'll probably understand what I'm asking a bit better when I'm not typing all of this up. So, any questions for me, no problem... Quote Link to comment Share on other sites More sharing options...
corbin Posted June 29, 2007 Share Posted June 29, 2007 I'm not sure what you're asking (if you posted what your tables look like it might help), but to start off with: <? $Move1 ?> That will not echo anything.... Infact that won't technically do anything. I believe you're looking for <?=$Move1;?>. And this is just a personal preference question.... In your functions with all the floor calls, why not just round it at the end? The damage could be slightly higher, but it would be more accurate.... Quote Link to comment Share on other sites More sharing options...
Dark Nonique Posted June 29, 2007 Author Share Posted June 29, 2007 Yeah, sorry about that. Forgot my ";" there... The floors, that's so it rounds it down after every single operation. Not necessary in some places, but I just don't need to modify the equation anymore... I have three tables. One of which contains all the possible moves of any creature, one of which contains the statistics for each type of creature, and another which contains the creatures themselves. All I need to do really, is this: Link the owned creature with it's stats in the other table, and link the creature with the moves that it, as an individual, knows. My tables have the following fields. Moves Attack Base Power Accuracy Type Category Creatures id user creature level gender slot Move1 Move2 Move3 Move4 Stats number creature HP Attack Defense Special Attack Special Defense Speed Type1 Type2 Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 29, 2007 Share Posted June 29, 2007 Moves +---+Creatures+----+ Stats are saying that relationship should occur moves will relate creature and creature relate with stats? Quote Link to comment Share on other sites More sharing options...
corbin Posted June 29, 2007 Share Posted June 29, 2007 SELECT * from Stats as s, Creatures as c, Moves as m WHERE c.id = '<ID HERE>' AND s.creature = c.id You would be able to link the Moves table that way too, but there's no way to identify rows that I see >.<. Quote Link to comment Share on other sites More sharing options...
Dark Nonique Posted June 29, 2007 Author Share Posted June 29, 2007 I just need to link them on the site...or rather like this. A creature is 'X' level. According to an equation I have, using it's stats in the stats table, that creature real statistics look as it should. It then will have it's "movepool" if you will, by containing 4 of the moves from the 'moves' table. I'm sorry if this isn't exactly "clear". Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.