-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActionSpawn.java
More file actions
37 lines (35 loc) · 1.32 KB
/
ActionSpawn.java
File metadata and controls
37 lines (35 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* @author John Henry Cooper
* @version 15.0.2
* Contains a constructor for an ActionSpawn object as well as an overridden preformAction method that carries out an
* a spawn command
*/
public class ActionSpawn extends Action{
/**
@param fromRow - row inxed of attacking piece
@param fromColumn - column index of attacking piece
@param toRow - row inxed of where attacking piece will attack
@param toColumn - column index of where attacking piece will attack
calls super constructor and returns an ActionSpawn object
*/
public ActionSpawn(GameS22 game, int fromRow, int fromColumn, int toRow, int toColumn){
super(game, fromRow, fromColumn, toRow, toColumn);
}
/**
*implements the performAction method
*-call From Piece speak method
*-calls spawn method
*-add the piece created to current team and put it on the to square
*-change turn
*/
@Override
public void performAction() {
BoardSquare[][] boardSquares = game.getBoardSquares();
Piece piece1 = boardSquares[fromRow][fromColumn].getPiece();
piece1.speak();
Piece spawn = piece1.spawn();
game.getCurrentTeam().addPieceToTeam(spawn);
boardSquares[toRow][toColumn].setPiece(spawn);
game.changeTurn();
}
}