- Messages
- 562
- Reaction score
- 1
- Points
- 18
Hello
As some may remember, I am making a PHP RPG.
I am currently about to add a complete skill system to allow special attacks during battles. While I had already implemented a few special attacks, I need to make a standard and complete system to manage them all.
I know pretty much how I want to do this, but I am concerned about resource usage. I'll try to explain simply.
1. Players can buy skills depending on their level and the number of skill points they have.
2. Each skill can be used once per battle (excluding permanent abilities, which are simply always active).
3. Some skills allow additional uses to be purchased/learn.
So the part of my system that leaves me pondering is the part where I check
1. If the skill has already been used and
2. If it can still be used (if the player has purchased more than one usage per battle).
I have thought of two possibilities to do this, but neither seems efficient to me.
The first is to use my battle SQL table and add to it a column for each skill, telling how many times it has been used in that particular battle. The problem is that if I end up with, say, 20 skills in total, I will need to add 40 columns to a table which is already about that size (20 for each player taking part in the battle). As far as I know (but hopefully I could be wrong), that will slow the queries made to that table a lot, which should always be avoided.
My second option was thought of to avoid overloading the database, but seems awkward to me. I thought I could set variables for each player and each skill, and send them from page to page (my battles are turn-based and offer an attack option to the player every turn) with hidden form inputs. But, using my previous example, I wonder if sending 40 hidden inputs on each page load actually makes sense.
So my question to you experts is in two parts:
1. If either of these options is efficient enough to be used, which would the best be?
2. Can you figure out a better way to create, store/send and use that information? I thought an array could make it easier to use the second option, but I don't know enough about them yet to tell if it would solve the problem.
Thanks in advance! And as a side note, I'm not looking for code, I really just want your advice on how to better use my resource.
As some may remember, I am making a PHP RPG.
I am currently about to add a complete skill system to allow special attacks during battles. While I had already implemented a few special attacks, I need to make a standard and complete system to manage them all.
I know pretty much how I want to do this, but I am concerned about resource usage. I'll try to explain simply.
1. Players can buy skills depending on their level and the number of skill points they have.
2. Each skill can be used once per battle (excluding permanent abilities, which are simply always active).
3. Some skills allow additional uses to be purchased/learn.
So the part of my system that leaves me pondering is the part where I check
1. If the skill has already been used and
2. If it can still be used (if the player has purchased more than one usage per battle).
I have thought of two possibilities to do this, but neither seems efficient to me.
The first is to use my battle SQL table and add to it a column for each skill, telling how many times it has been used in that particular battle. The problem is that if I end up with, say, 20 skills in total, I will need to add 40 columns to a table which is already about that size (20 for each player taking part in the battle). As far as I know (but hopefully I could be wrong), that will slow the queries made to that table a lot, which should always be avoided.
My second option was thought of to avoid overloading the database, but seems awkward to me. I thought I could set variables for each player and each skill, and send them from page to page (my battles are turn-based and offer an attack option to the player every turn) with hidden form inputs. But, using my previous example, I wonder if sending 40 hidden inputs on each page load actually makes sense.
So my question to you experts is in two parts:
1. If either of these options is efficient enough to be used, which would the best be?
2. Can you figure out a better way to create, store/send and use that information? I thought an array could make it easier to use the second option, but I don't know enough about them yet to tell if it would solve the problem.
Thanks in advance! And as a side note, I'm not looking for code, I really just want your advice on how to better use my resource.