i have a question in regards to php calculations.
i am restructuring a text based game.
the game has two “native players” right now. they get inserted periodically by a cron file.
the insert is :
//player 1 Login id = 54
mysql_query("INSERT INTO {$game}_ships (ship_name,login_name,shipclass,class_name,class_name_abbr,fighters,max_fighters,max_shields,cargo_bays,mine_rate_metal,mine_rate_fuel,config,size,upgrades,move_turn_cost,point_value,location,login_id
) values( 'Three 7','A','8','name','WM','4773','4773','8353','2003','5','45','bs:dt:ot','6','99','19','10',FLOOR(RAND() * 298 + 2),'54')");
player two has the same insert, only the player id is different. lets say 44.
they get inserted in random locations FLOOR(RAND() * 298 + 2) which vary from 2 to 300.
i want to create an AI in the game by selecting ships from these two players that are in the same system, comparing the fighter counts and deleting from the database the weakest.
So far i have:
mysql_query("SELECT * FROM `{$game}_ships` WHERE `login_id` = 54 AND 54 AND `location` = 234");
but im having some problems as to the rest.
Any comments or help would be greatly appreciated.
PS: i selected location = 234″ arbitrarily.
This query will give you a list of locations where both players 54 and 44 have ships:
And this query will delete the weakest ship of player 54 or 44 in location 234: