I'm trying to make a system of RPG battles. The fight will be between 6 characters (3X3) Each character is represented by a single object, and the object have variables as name, level, hit points, and speed.
I have an array with the names, level, hit points and speed of each character and wanted a way to object when the object.character was created in the layout, it fill its variables with the array information.
Another doubt would be setting up an attack order system based on the highest speed of the character. In descending order the characters attack, but if the first character to attack owning ((variavel.velocidade / 3) * 2) greater than the second character, the first attack 2 times before the second.
How do I create a comparison speeds that meet the conditions, taking account of the possibility of a character dying and having to recaulculate the order to attack.