Skip to content
Colin-Lane edited this page May 7, 2014 · 18 revisions

Almost all of these things need to be able to be initiated (function call, whatever) from Interface.java, which is in the com.client branch.

  1. Create a unit for a player (By unit I also mean agent, I think we can use them interchangeably now?) - Answered
  2. Get all units for a player - Answered
  3. Get information about a specific unit - Answered
  4. Create a building for a player - Answered
  5. Get all buildings for a player - Answered
  6. Get information about a specific unit - Answered
  7. Create a trade agreement - Answered
  8. View all trade agreements for a player - Answered
  9. Get information about a specific trade agreement - Answered
  10. Get resources for a player - Answered

----Added 4/26/2014----

  1. Get all agents for a player - Answered
  2. Resources information for a given building. Do certain buildings produce/consume certain resources? E.g., Farm produces food; consumes wood?
  3. Possible to separate base units and agents into two respective enums?
  4. Available actions for an agent

Answers:

1 and 4)

All objects are created by sending a command to the controller when the game is running. A create unit command has the following structure :

BuildingProductionCommand(int playerId, UUID buildingId,UnitType unitType);

This will create a unit in the factory, and place it into the game after a certain production time. A user must specify what player, what building, and what type of unit is to be built. UnitType is an Enum that contains all of the various units in the game. Building and player id's are found by calling getID and getUUID. The name of this Command should be subject to change.

ConstructBuildingCommand(Player p, int playerId, BuildingType bt,int xco, int yco, GameBoard gb);

This command is more complex because it needs a reference to the gameboard. This is because the GameBoard marks which tiles are occupied by the building once it is created. GameModel.getBoard() returns a reference to the GameBoard(). BuildingType contains a list of all Building types in the game.

Once the Command is created, it must be sent to the Controller. Controller.addCommand(yourCommand) will add the command to the queue, and it will be scheduled to be performed.

2,5)

The game will be instantiated with a Controller and GameModel Class. The GameModel class contains a list of all the players. GameModel.getPlayers() will return a list of all players, and GameModel.getPlayer(int) will return the player at the given index. Each Player has a subclass called PlayerUnits, that contains references to the players under its command. Player.getPlayerUnits().getUnits() will give a HashMap of the units. Similarly, there is getBuildings() and getGameObjects(), the latter will provide a list of both units and buildings. There is obviously some coupling here.

3,6)

Buildings and Units are both GameObjects that use the same stat structure. This can be accessed by calling Object.getStats(). This returns a UnitStats object. In this class, all of the information about the current state of the unit can be found. Ex: health, attack speed.

For some player object 'p1', call: 'p1.getResources();'. This will return a Resources object which consists of ints Wood, Gold, Stone, Research, and Food. All of these can be accessed from the Resources object via getWood(), getGold(), getStone(), getResearchPts(), and getFood() respectively.

----Added 4/26/2014----

  1. To get all agents for a player object Bob => Bob.getGameObjects().getAgents();
  2. Resource Buildings produce resources. Currently generateResource() is the method that returns a resources object for how much this building produces per tick. Though there was some talk about splitting this functionality from the resource building, and adding it to a resource generator (at least I overheard Sean, Travis, and Ben discussing this possibility. So one of them might want to chime in). Currently no buildings consume a resource to produce a resource, except for the initial cost to build them.
  3. No need, We have decided to just deal with units for this sprint.
  4. See number 3.

Questions 7, 8, 9

  1. To Create a Trade, gameModel.getTradeManager().createProposal(ITrade trade); and pass in the Trade Instance that you are willing to propose to another player.

  2. To view all trade agreements that have been accepted for a player. gameModel.getTradeManager().getAcceptedTrades(int playerId); To view all trade agreements that have been proposed to a player. gameModel.getTradeManager().getProposedTrades(int playerId);

  3. Each trade agreement exists in the tradeManager. List trades = gameModel.getTradeManager().getAcceptedTrades(int playerId); now just get the correct trade index. ITrade trade = trades.get(int i); if (trade instanceof IntervalResourceTrade) { IntervalResourceTrade intervalTrade = (IntervalResourceTrade) trade; } Then just get the information out of the trade by accessing the fields with their getters.

Clone this wiki locally