Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Trying not to reinvent the wheel here so thought 'i'd ask you guys;

There is an existing database for a computer game that records - map name, time it took to finish the map, the difficulty level, id of person. This database is used to record best finish times for each player. So the player can type a certain command and it shows the best finish times for a particular map.

Now i would like to create a ranking system that rewards the player points for finishing the maps based on the difficulty level, e.g completing it on easy rewards the player 1 point, 2 points for medium ,etc. This ranking system will show the top players with most points.

My question is, would it be better to use the current database and use PHP to accomplish the new ranking system

or

create a new database to accomplish it?

In either case, a simple logic example would be appreciated.

share|improve this question

3 Answers 3

As Kyle said use your current database/table and let php/ SQL do the work. I would do something

select player,
       Map,
       Count(*)
From mytable
Group by player, map

That should give you a count of player completes by map. Test this though. After you get the count you can loop through your counts and based on map multiply by the points awarded.

share|improve this answer

Could you try this:

SELECT *, (count(*) * difficulty) AS total
FROM `map`
GROUP BY user_id
ORDER BY total DESC
LIMIT 10

difficulty is a table field, which is 1 for easy, 2 for medium, etc.

share|improve this answer

I think it is best to just use your already existing database. What do you mean logic example?

share|improve this answer
    
Well for example, what would be the best way to print out the Top 10 (players with most points) . with the current database, each finish time is recorded for each map per player, so a player can have multiple entries for a map –  Katalyst Jul 14 '13 at 1:44
    
Maybe you should have it overwrite the old time. Then use some sort of search/sort algorithm. –  Kyle Jul 14 '13 at 2:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.