Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
MattByers committed Aug 5, 2015
1 parent 6f5031d commit 3121527
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
11 changes: 3 additions & 8 deletions src/game/GameOfCluedo.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
import game.cards.rooms.*;
import game.cards.item.*;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Queue;
import java.util.Scanner;

public class GameOfCluedo {

protected boolean playing;
protected Player winner = null;

private int numPlayers;
private ArrayList<Player> players;
Expand Down Expand Up @@ -84,8 +81,8 @@ private void startGame() {
}

if(this.players.size() <= 1) {
this.winner = this.players.get(0);
System.out.println("All players other have been eliminated. Player " + this.winner.getPlayerNum() + ", you are the winner! \n");
Player winner = this.players.get(0);
System.out.println("All players other have been eliminated. Player " + winner.getPlayerNum() + ", you are the winner! \n");
break;
}

Expand Down Expand Up @@ -171,9 +168,7 @@ private void addPlayers(){
this.retiredPlayers = new ArrayList<Player>();

for(int i = 0; i < this.numPlayers; i++){
Collections.shuffle(this.personCards);
PersonCard identity = this.personCards.get(0);
this.players.add(new Player(identity, i+1, this.board, this));
this.players.add(new Player(i+1, this.board, this));
}
}

Expand Down
14 changes: 5 additions & 9 deletions src/game/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Player {
private static final ArrayList<String> DIR_LIST = new ArrayList<String>(Arrays.asList("u", "d", "l", "r"));

private int playerNum;
private PersonCard identity;

private ArrayList<Card> hand;
private Square location;
private Room room;
Expand All @@ -39,12 +39,11 @@ public class Player {
private Board board;
private HashSet<String> possibleActions;

public Player(PersonCard identity, int playerNum, Board board, GameOfCluedo game){
public Player(int playerNum, Board board, GameOfCluedo game){
this.game = game;
this.board = board;
this.retired = false;

this.identity = identity;
this.playerNum = playerNum;

this.location = this.board.addPlayer(this);
Expand Down Expand Up @@ -76,7 +75,7 @@ public void takeTurn(Scanner input) {
if(this.room.getStairs() != null) this.possibleActions.add(STAIRS);
}

this.possibleActions.addAll(DEBUG); //Debug tools
//this.possibleActions.addAll(DEBUG); //Debug tools

GameOfCluedo.clearConsole();

Expand Down Expand Up @@ -140,7 +139,6 @@ public void takeTurn(Scanner input) {
/**
* Shows the current envelope to the user, method only used for debug purposes, wont be shown to a user unless enabled prior.
*/

private void showEnvelope() {
System.out.println("WARNING: About to show the game's envelope, you are either Matt, Jashon or cheating!\n");

Expand All @@ -161,7 +159,7 @@ private void showEnvelope() {
*/
private void rollDice(){
this.diceRoll = (int)(Math.random() * 5) + (int)(Math.random() * 5) + 2;
this.diceRoll = 20; //DEBUG line
//this.diceRoll = 20; //DEBUG line
System.out.println("You rolled a " + this.diceRoll + "!\n");
}

Expand Down Expand Up @@ -319,8 +317,7 @@ private void accusation() {
RoomCard room = this.game.getRoomCards().get(roomInd);

if(envelope.contains(person) && envelope.contains(item) && envelope.contains(room)){
System.out.println("\nYour accusation was correct. You win!");
this.game.winner = this;
System.out.println("\nYour accusation was correct. Player " + this.playerNum + "you win!");
this.game.playing = false;
this.finished = true;
}
Expand Down Expand Up @@ -366,7 +363,6 @@ private void endTurn(){
* Asks the user to specify a direction, then checks the validity of the move with board and moves them to the new square if valid.
* This continues until they are out of dice rolls. Will cause the player to enter a room if they move onto a doorway.
*/
//THIS METHOD IS BROKE TO FUCK
private void movePlayer(){
while(this.diceRoll > 0){

Expand Down

0 comments on commit 3121527

Please sign in to comment.