// This function is the start of the turn. It orders the characters by stamina public void StartQueue() { turn++; combatLog.UpdateLog("-----Turn " + turn + " Start-----"); // Create a temperary array of charcters Character[] tempChar = new Character[6]; for (int i = 0; i < 3; i++) { tempChar [i] = Player [i]; tempChar [i + 3] = Enemy [i]; } // Sort the temperary array by stamina for (int i = 0; i < 6; i++) { for (int j = i + 1; j < 6; j++) { //The first clause orders by stamina, the second ignores the case where j is out but j-1 is active if (tempChar [j - 1].Stamina < tempChar [j].Stamina && !(tempChar [j].dead && !tempChar [j - 1].dead)) { Character temp = tempChar [j]; tempChar [j] = tempChar [j - 1]; tempChar [j - 1] = temp; } } } // Assign each element of the temperary array to the approrpiate element in CombatQueue for (int i = 0; i < 6; i++) { combatQueue [i] = tempChar [i]; combatQueue [i].gatherBall(); } currentPhase = PHASE.CONFLICT; CUI.ShowPhase(); }