COSC 3P91
Assignment 1

Instructor: Michael Winter, Office J323, email: mwinter@brocku.ca


RoboRace (Part 1)

In the first assignment we will concentrate on the class GameMaster managing the rules and execution of the game.

Constructor

In the constructor of this class do the following:
  1. Store the players in the corresponding variable of the class.
  2. Load the factory hall from the file "factory.xml" using the static method load of the Factory class.
  3. Create the array of robots using the names and the the start configurations of the factory hall (method getStartConfigByID).
  4. Create a board using the robots and the factory.
  5. Give the board to the players by using receiveBoard.
  6. Initialize the cardFactory.

Method run

This method will run the game. It should do the following:
  1. Create an array of CardLists, one CardList for each player.
  2. Create an EventList.
  3. Loop through the following until a victory has occurred, i.e., the event list contains a victory event.
    1. Reset all card lists in the array and fill them with 7 new cards each. Use the CardFactory.
    2. Let the Players select cards. Use the method selectCards.
    3. Clear the event list, and then loop through the following up to 5 times or a victory has occurred.
      1. Get the i-th card of each player.
      2. Sort the cards. Use Collections.sort.
      3. Execute the cards.
      4. Execute the effect of the board on each robot in random order. Use the method effect of the class Board. A random order can be achieved by using Collections.shuffle on a list that contains the numbers 0,...,numPlayers-1.
      5. If the event list does not contain a victory event, add a EventRunDecorations to the event list.
    4. If the event list does not contain a victory event, revive all dead robots (method revitalize of the class Board).
    5. Give the event list to each player (method of the class receiveEvents).

Sources


COSC Home Page
COSC 3P91 Home Page
© M. Winter, 2023