Legger til manglende kommentarer og fikser filnavn

This commit is contained in:
Kristian Knarvik 2020-05-03 16:15:33 +02:00
parent 448440a28d
commit ea3c3b46c4
6 changed files with 32 additions and 5 deletions

View File

@ -43,6 +43,7 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
* @param boardName The playerName of the board to use * @param boardName The playerName of the board to use
* @param playerName The name of the player of this instance of the game * @param playerName The name of the player of this instance of the game
* @param server The server if this player is host. Should be null otherwise * @param server The server if this player is host. Should be null otherwise
* @param testingMode Whether the game should use the test deck rather than the proper deck
*/ */
public RoboRallyGame(List<Player> playerList, String boardName, String playerName, public RoboRallyGame(List<Player> playerList, String boardName, String playerName,
RoboRallyServer server, Boolean testingMode) { RoboRallyServer server, Boolean testingMode) {

View File

@ -42,5 +42,10 @@ public interface RoboRallyUI {
*/ */
void setShouldHurry(boolean shouldHurry); void setShouldHurry(boolean shouldHurry);
/**
* Gets whether the game should be started in test mode
*
* @return Whether the game should be started in test mode
*/
boolean isTesting(); boolean isTesting();
} }

View File

@ -2,6 +2,7 @@ package inf112.fiasko.roborally.ui.screens;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input; import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox; import com.badlogic.gdx.scenes.scene2d.ui.SelectBox;
import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Skin;
@ -66,6 +67,9 @@ public class LobbyScreen extends InteractiveScreen {
stage.setViewport(viewport); stage.setViewport(viewport);
} }
/**
* Makes the server send information to players about the selected map and connected players
*/
private void startGame() { private void startGame() {
roboRallyWrapper.server.startGame(); roboRallyWrapper.server.startGame();
Map<Connection, String> playerNames = roboRallyWrapper.server.getPlayerNames(); Map<Connection, String> playerNames = roboRallyWrapper.server.getPlayerNames();
@ -97,7 +101,7 @@ public class LobbyScreen extends InteractiveScreen {
return true; return true;
} else if (keyCode == Input.Keys.T) { } else if (keyCode == Input.Keys.T) {
roboRallyWrapper.isTesting = true; roboRallyWrapper.isTesting = true;
String testBoard = "Manuall_testing"; String testBoard = "manual_testing";
selectBox.getItems().add(testBoard); selectBox.getItems().add(testBoard);
selectBox.setSelected(testBoard); selectBox.setSelected(testBoard);
startGame(); startGame();
@ -107,7 +111,9 @@ public class LobbyScreen extends InteractiveScreen {
@Override @Override
public void render(float delta) { public void render(float delta) {
super.render(delta); Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
camera.update();
roboRallyWrapper.batch.setProjectionMatrix(camera.combined); roboRallyWrapper.batch.setProjectionMatrix(camera.combined);
roboRallyWrapper.batch.begin(); roboRallyWrapper.batch.begin();
@ -119,6 +125,8 @@ public class LobbyScreen extends InteractiveScreen {
applicationWidth / 2f - 380 / 2f, applicationHeight / 2f + 100, 380, 1, applicationWidth / 2f - 380 / 2f, applicationHeight / 2f + 100, 380, 1,
true); true);
roboRallyWrapper.batch.end(); roboRallyWrapper.batch.end();
stage.draw();
stage.act();
} }
} }

View File

@ -22,14 +22,27 @@ public final class DeckLoaderUtil {
* @throws IOException If the programming cards file is invalid * @throws IOException If the programming cards file is invalid
*/ */
public static ProgrammingCardDeck loadProgrammingCardsDeck() throws IOException { public static ProgrammingCardDeck loadProgrammingCardsDeck() throws IOException {
return loadCards("programming_cards.txt"); return loadProgrammingCardsDeck("programming_cards.txt");
} }
/**
* Returns a programming card deck containing nine cards to use for testing
*
* @return A programming card deck with nine programming cards
* @throws IOException If the programming cards file is invalid
*/
public static ProgrammingCardDeck loadProgrammingCardsTestDeck() throws IOException { public static ProgrammingCardDeck loadProgrammingCardsTestDeck() throws IOException {
return loadCards("programming_cards_manuall_testing.txt"); return loadProgrammingCardsDeck("programming_cards_manual_testing.txt");
} }
private static ProgrammingCardDeck loadCards(String cardFile) throws IOException { /**
* Loads programming cards from a file
*
* @param cardFile The file containing the cards to load
* @return A deck of programming cards
* @throws IOException If the programming cards file is invalid
*/
private static ProgrammingCardDeck loadProgrammingCardsDeck(String cardFile) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader( BufferedReader reader = new BufferedReader(new InputStreamReader(
ResourceUtil.getResourceAsInputStream(cardFile))); ResourceUtil.getResourceAsInputStream(cardFile)));
int numberOfCards = Integer.parseInt(reader.readLine()); int numberOfCards = Integer.parseInt(reader.readLine());