Battle - JayhawkZombie/EECS581Project GitHub Wiki

Extends

does not derive from a parent function

Dependencies

Before Battle can work properly, it needs

  • Skill
  • Party
  • FightActor to be working properly

Member Variables

  • Party m_allies
    • array of 4 for allies
  • Party m_enemies
    • array of 4 for enemies
  • Queue m_turnQueue
  • bool m_canEscape
  • This boolean controls if the allies can escape

Functions

  • int run()

    • run is the encapsulating method that calls all of the other methods and determines whose turn it is, etc
    • When you call battle, you return an int run() which will hold the whole battle
    • It returns one of three ints:
      • 0 = failure //go to loading screen
      • 1 = success //go back to place in map
      • 2 = run away(if applicable) //go back to place you came from
  • turn 1(BattleActor Ally)

    • Ally from an array of good guys
    • good guy decisions are made by player here
    • int choice = int displaychoices();
  • if (choice == 1) //attack BattleActor = SelectEnemy(enemy); a.takeDamage(b.attackDamage); a = the enemy that's taking damage, b = ally's damage checkBattleStatus() = check victory conditions for the enemy and if the entire battle's over

  • if (choice == 2) //skill for (int = 0; i < skills.size(); i++) {check to see if skill can be used from the skillset of the allied class, if so, display} allow option to Execute() skill option to return

  • if (choice == 3) //wait pass turn, go to turn2()

  • if (choice == 4) //use item

    • Check that there are Useable Items in the characters inventory,
    • if there are display them
    • Useable items will have a boolean m_forAllies, if true its a health potion of some kind, and the user should select an ally to apply it to, if false it's some kind of throwable, and the user should pick an enemy to use it against
  • if (choice == 5) //escape check average of all Ally's level vs average of all Enemy's level if level difference is 5 where enemy > ally, 60% chance of leaving % of leaving on run = 10+10*(average level difference)

  • DisplayChoice() = displays the character options:

      1. attack
      1. use skill
      1. wait
      1. escape //sometimes escape will be unavailable depending on game context (boss fights etc)
      • loop for choice 1,2,3,4:
  • turn 2() access the bad guy's AI to determine his action

  • bool isBattleOver() returns true if the battle is over, false else -should be checked after each turn

  • Queue BattleQueue(consists of Battle Actors) determines move order. Turn order alternates between the Allies and the Enemies. Which team goes first should be determined by a coin flip. Assuming the allies go first the queue should function such that if the array m_allies.content has four members: a1,a2, a3, a4, and the m_enemies.content has four members: e1,e2,e3,e4 the move order would be: a1,e1,a2,e2,a3,e3,a4.e4,a1,e1,e2 etc.. whereas if there were only two enemies the move order would be: a1,e1,a2,e2,a3,e1,a4,e2. The weakness of this kind of move order structure is that if one team has only one character they have an unequal amount of strikes per person. But this is the basic structure we want to begin with.

Corresponding Java version

Charles asked that I link the old java version, and I will but I would also like to say that it is not an example of great coding, and I didn't write it. Our Battle class should be modular so its easy to read and were dealing with teams of enemies, not just a single enemy on a different enemy, but if you want to look at it, here's the link: Old Version

Future Plans

After the battlequeue is implemented, if we have time I'd like to extend the battle class to allow for faster characters to attack more quickly than slower characters, and allow larger teams to have a cooresponding advantage over smaller groups (because using the Queue way with one v four allows the one four turns per the four's four turns, which doesn't make sense) An example of a game utilizing this approach if you dont understand what I mean is here: Monster's Den