}//end of addRoom /*this method was to find the current location of the player and return it. * it will take two arguements, the players location node as well as the list. It will start from the head and traverse * throught the list until the location matches the node in the list which it will return. * created by Caleb Mathomes on 17/12/14*/ public GameNode findLocation(GameNode location, GameList list) { GameNode current = list.head; while (location != current) { current = current.next; } return current; }//end of findLocation
}//end of GameList /*this will begin pointing nodes from the head to the tail of the list by setting the first node to the head * and each time just setting the next pointer to the new node added to the list * it takes in the new node and checks if there is a head. If its empty, that new node is set to the head of the * list otherwise it will look at where the next pointer is until it reaches the tail and sets the tail to the new * node. * created by Caleb Mathomes on 11/11/14 */ public void addNode(GameNode newNode) { //checks the head if (head == null) { head = newNode; } else { //otherwise traverse to the tail GameNode current = head; while (current.getNode() != null) { current = current.getNode(); } current.setNode(newNode); //newNode.setPrevNode(current); } }
}//end of getBlockName /*this method will set the node that has been passed in to point to the next node * it takes a single argument which is used to set to the next value. * created on 11/11/14 by Caleb Mathomes*/ public void setNode(GameNode newNode) { this.next = newNode; }//end of setNode
}//end of check name /*this method will create the board the players will traverse through *each new instance of a node passes in the new information that node will contain *the first value will identify which node it is *the second value identifies the name of that node *the third identifies whether it is a doorway node or not *the fourth identifies if it is a board node and the last value identifies if it is a room node or not*/ public void populateBoard() { //these will be the board nodes, 7 of which are doorway nodes as well as board nodes GameNode sqaure1 = new GameNode(1, "block 1", false, true, false); GameNode sqaure2 = new GameNode(2, "block 2", true, true, false); GameNode sqaure3 = new GameNode(3, "block 3", false, true, false); GameNode sqaure4 = new GameNode(4, "block 4", true, true, false); GameNode sqaure5 = new GameNode(5, "block 5", false, true, false); GameNode sqaure6 = new GameNode(6, "block 6", false, true, false); GameNode sqaure7 = new GameNode(7, "block 7", false, true, false); GameNode sqaure8 = new GameNode(8, "block 8", false, true, false); GameNode sqaure9 = new GameNode(9, "block 9", false, true, false); GameNode sqaure10 = new GameNode(10, "block 10", true, true, false); GameNode sqaure11 = new GameNode(11, "block 11", false, true, false); GameNode sqaure12 = new GameNode(12, "block 12", false, true, false); GameNode sqaure13 = new GameNode(13, "block 13", false, true, false); GameNode sqaure14 = new GameNode(14, "block 14", true, true, false); GameNode sqaure15 = new GameNode(15, "block 15", false, true, false); GameNode sqaure16 = new GameNode(16, "block 16", true, true, false); GameNode sqaure17 = new GameNode(17, "block 17", false, true, false); GameNode sqaure18 = new GameNode(18, "block 18", true, true, false); GameNode sqaure19 = new GameNode(19, "block 19", false, true, false); GameNode sqaure20 = new GameNode(20, "block 20", false, true, false); GameNode sqaure21 = new GameNode(21, "block 21", false, true, false); GameNode sqaure22 = new GameNode(22, "block 22", true, true, false); GameNode sqaure23 = new GameNode(23, "block 23", false, true, false); GameNode sqaure24 = new GameNode(24, "block 24", false, true, false); //these are the room nodes GameNode room1 = new GameNode(17, "Lecture Theatre", false, false, true); GameNode room2 = new GameNode(13, "Research Lab", false, true, true); GameNode room3 = new GameNode(14, "Laptop Lab", false, true, true); GameNode room4 = new GameNode(15, "Network Lab", false, true, true); GameNode room5 = new GameNode(16, "School Office", false, true, true); GameNode room6 = new GameNode(13, "CEO11", false, true, true); GameNode room7 = new GameNode(14, "Foyer", false, true, true); //each node is then added to the list cList.addNode(sqaure1); cList.addNode(sqaure2); cList.addNode(sqaure3); cList.addNode(sqaure4); cList.addNode(sqaure5); cList.addNode(sqaure6); cList.addNode(sqaure7); cList.addNode(sqaure8); cList.addNode(sqaure9); cList.addNode(sqaure10); cList.addNode(sqaure11); cList.addNode(sqaure12); cList.addNode(sqaure13); cList.addNode(sqaure14); cList.addNode(sqaure15); cList.addNode(sqaure16); cList.addNode(sqaure17); cList.addNode(sqaure18); cList.addNode(sqaure19); cList.addNode(sqaure20); cList.addNode(sqaure21); cList.addNode(sqaure22); cList.addNode(sqaure23); cList.addNode(sqaure24); //each room is added to the list cList.addRoom(room1, sqaure2); cList.addRoom(room2, sqaure4); cList.addRoom(room3, sqaure10); cList.addRoom(room4, sqaure14); cList.addRoom(room5, sqaure16); cList.addRoom(room6, sqaure18); cList.addRoom(room7, sqaure22); //this final call will link the last node added to the head of the list cList.findLast(cList); }//end of populateBoard
/*this method sets the pointer from a board node to a room node * it takes two GameNode arguements which points the board node to the room and the rooms pointer back to the board node * created on 25/11/14 by Caleb Mathomes*/ public void addRoom(GameNode roomNode, GameNode currentNode) { currentNode.room = roomNode; roomNode.next = currentNode; }//end of addRoom
/*the constructor to the GameList which will always set the value of the head to null * created by Caleb Mathomes on 11/11/14*/ public GameList() { head = null; }//end of GameList
}//end of addPlayer /*this is a basic set location where the GameNode passed in is set to the location of the player changing its * location to the new one. * Created by Caleb Mathomes 09/12/14*/ public void setLocation(GameNode newLocation) { location = newLocation; }//end of setLocation