My goal with coding this RPG is to achieve the following:
-
Neat and organized code achieved by dividing the code into multiple “chunks” (just scripts attached to base Nodes), This way I could avoid the dreaded 300+ lines scripts and also abstract the complexity and encapsulate the logic, Say have a “AttackingManager” Node and a “TakeDamage” Node as children of the parent “Battler” Node
-
Using classes to organize long data, There will be an “Action” class that includes a reference to the battler performing the action + the type of action + action data (attack damage, spell type) + action target (self, enemy, all allies, all enemies), This way we can avoid functions with like 5 arguments.
-
Using inheritance, To simplify logic I’ll make a base “Battler” class, Then have 2 child classes being the “AllyBattler” and the “EnemyBattler”, Each class will override the parent methods like “decide action” and “defeated” in their own way.
-
Straight and easy to track code, I really don’t want any Spaghetti code, I’ll try to make it so that a code sequence is in on place, So no jumping around objects to track errors !
-
Using functions to reduce repeated code, If i find myself using a line of code repeatedly then making a little static function to run that code should reduce the risk of error and simplify code !
-
Using an array to handle battler actions, I think that having each battler “decide an action” and then appending that action in an array of “Actions” in the “BattleManager” scene would be a neat way of coding the turn system, when all battlers have appended their actions we’ll first sort the actions based on the battlers speed stat, Then we’ll iterate over the array and perform each action and remove it once we’re done with it.
Anyway that’s it, Tell me if you have any criticism !