mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-24 22:49:44 +01:00
Compare commits
5 Commits
75d5a15bdb
...
e780513b35
Author | SHA1 | Date | |
---|---|---|---|
|
e780513b35 | ||
|
d582c59a7d | ||
|
7d2c85f617 | ||
|
4a882bc4ac | ||
|
3c4eac1fcd |
@ -5,6 +5,7 @@ import java.lang.System.Logger.Level;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import pp.monopoly.game.server.Player;
|
||||||
import pp.monopoly.message.client.ClientMessage;
|
import pp.monopoly.message.client.ClientMessage;
|
||||||
import pp.monopoly.message.server.BuyPropertyResponse;
|
import pp.monopoly.message.server.BuyPropertyResponse;
|
||||||
import pp.monopoly.message.server.DiceResult;
|
import pp.monopoly.message.server.DiceResult;
|
||||||
@ -50,6 +51,8 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
/** The current state of the client game logic. */
|
/** The current state of the client game logic. */
|
||||||
private ClientState state = new LobbyState(this);
|
private ClientState state = new LobbyState(this);
|
||||||
|
|
||||||
|
private List<Player> players;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a ClientGameLogic with the specified sender object.
|
* Constructs a ClientGameLogic with the specified sender object.
|
||||||
*
|
*
|
||||||
@ -80,6 +83,10 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
state.entry();
|
state.entry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Player> getPlayers() {
|
||||||
|
return players;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the player's game board.
|
* Returns the player's game board.
|
||||||
*
|
*
|
||||||
@ -236,6 +243,7 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(GameStart msg) {
|
public void received(GameStart msg) {
|
||||||
|
players = msg.getPlayers();
|
||||||
setInfoText("The game has started! Good luck!");
|
setInfoText("The game has started! Good luck!");
|
||||||
setState(new WaitForTurnState(this));
|
setState(new WaitForTurnState(this));
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,7 @@ import java.util.Random;
|
|||||||
import pp.monopoly.message.server.DiceResult;
|
import pp.monopoly.message.server.DiceResult;
|
||||||
import pp.monopoly.model.FieldVisitor;
|
import pp.monopoly.model.FieldVisitor;
|
||||||
import pp.monopoly.model.Figure;
|
import pp.monopoly.model.Figure;
|
||||||
import pp.monopoly.model.IntPoint;
|
import pp.monopoly.model.card.Card;
|
||||||
import pp.monopoly.model.card.DeckHelper;
|
|
||||||
import pp.monopoly.model.fields.BuildingProperty;
|
import pp.monopoly.model.fields.BuildingProperty;
|
||||||
import pp.monopoly.model.fields.EventField;
|
import pp.monopoly.model.fields.EventField;
|
||||||
import pp.monopoly.model.fields.FineField;
|
import pp.monopoly.model.fields.FineField;
|
||||||
@ -89,6 +88,14 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retuns the Playerhandler
|
||||||
|
* @return the Playerhandler
|
||||||
|
*/
|
||||||
|
public PlayerHandler getHandler() {
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns this players id
|
* Returns this players id
|
||||||
* @return th eid of this player
|
* @return th eid of this player
|
||||||
@ -104,6 +111,21 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
public int getFieldID() {
|
public int getFieldID() {
|
||||||
return fieldID;
|
return fieldID;
|
||||||
}
|
}
|
||||||
|
void setActive() {
|
||||||
|
state = new ActiveState();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean finishTurn() {
|
||||||
|
if(canFinishTurn()) {
|
||||||
|
state = new WaitForTurnState();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean canFinishTurn() {
|
||||||
|
return accountBalance >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves by the specified amount of steps
|
* Moves by the specified amount of steps
|
||||||
@ -284,7 +306,8 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visit(EventField field) {
|
public Void visit(EventField field) {
|
||||||
DeckHelper.drawCard();
|
Card c = getHandler().getLogic().getDeckHelper().drawCard();
|
||||||
|
getHandler().getLogic().getDeckHelper().visit(c, this);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,6 +350,26 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getNumHouses() {
|
||||||
|
int total = 0;
|
||||||
|
for (PropertyField field : properties) {
|
||||||
|
if (field.getClass() == BuildingProperty.class) {
|
||||||
|
total += ((BuildingProperty) field).getHouses();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumHotels() {
|
||||||
|
int total = 0;
|
||||||
|
for (PropertyField field : properties) {
|
||||||
|
if (field.getClass() == BuildingProperty.class) {
|
||||||
|
total += ((BuildingProperty) field).getHotel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inner class for dice functionality in the game.
|
* Inner class for dice functionality in the game.
|
||||||
* Rolls random dice values.
|
* Rolls random dice values.
|
||||||
@ -460,47 +503,19 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BankruptState implements PlayerState {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DiceResult rollDice() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'rollDice'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void payBail() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'payBail'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void useJailCard() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'useJailCard'");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class WaitForTurnState implements PlayerState {
|
private class WaitForTurnState implements PlayerState {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DiceResult rollDice() {
|
public DiceResult rollDice() {
|
||||||
// TODO Auto-generated method stub
|
throw new UnsupportedOperationException("not allowed");
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'rollDice'");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void payBail() {
|
public void payBail() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'payBail'");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void useJailCard() {
|
public void useJailCard() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'useJailCard'");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ public class PlayerHandler {
|
|||||||
private Set<Player> readyPlayers = new HashSet<>();
|
private Set<Player> readyPlayers = new HashSet<>();
|
||||||
private ServerGameLogic logic;
|
private ServerGameLogic logic;
|
||||||
private Player hostPlayer;
|
private Player hostPlayer;
|
||||||
|
private Player extra = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contructs a PlayerHandler
|
* Contructs a PlayerHandler
|
||||||
@ -131,8 +132,13 @@ public class PlayerHandler {
|
|||||||
* Completes a player turn and return the next player
|
* Completes a player turn and return the next player
|
||||||
* @return the next players who is active
|
* @return the next players who is active
|
||||||
*/
|
*/
|
||||||
Player nextPlayer() {
|
public Player nextPlayer() {
|
||||||
Player tmp = players.get(0);
|
Player tmp = players.get(0);
|
||||||
|
if (extra != null) {
|
||||||
|
tmp = extra;
|
||||||
|
extra = null;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
players.remove(0);
|
players.remove(0);
|
||||||
players.add(tmp);
|
players.add(tmp);
|
||||||
return players.get(0);
|
return players.get(0);
|
||||||
@ -142,7 +148,7 @@ public class PlayerHandler {
|
|||||||
* Returns the {@link ServerGameLogic} of this PlayerHandler
|
* Returns the {@link ServerGameLogic} of this PlayerHandler
|
||||||
* @return the {@link ServerGameLogic} of this PlayerHandler
|
* @return the {@link ServerGameLogic} of this PlayerHandler
|
||||||
*/
|
*/
|
||||||
ServerGameLogic getLogic() {
|
public ServerGameLogic getLogic() {
|
||||||
return logic;
|
return logic;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,10 +165,15 @@ public class PlayerHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Arranges the players turns in a random order
|
* Arranges the players turns in a random order.
|
||||||
|
* Shuffles the players and sets their state to WaitForNextTurn, the first one will be active
|
||||||
*/
|
*/
|
||||||
void randomOrder() {
|
void randomOrder() {
|
||||||
Collections.shuffle(players);
|
Collections.shuffle(players);
|
||||||
|
for (Player player : players) {
|
||||||
|
player.finishTurn();
|
||||||
|
}
|
||||||
|
players.get(0).setActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStartBalance(int amount) {
|
void setStartBalance(int amount) {
|
||||||
@ -170,4 +181,8 @@ public class PlayerHandler {
|
|||||||
player.setAccountBalance(amount);
|
player.setAccountBalance(amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void extraTurn(Player player) {
|
||||||
|
if (players.contains(player)) extra = player;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import pp.monopoly.message.server.ViewAssetsResponse;
|
|||||||
import pp.monopoly.model.Board;
|
import pp.monopoly.model.Board;
|
||||||
import pp.monopoly.model.Figure;
|
import pp.monopoly.model.Figure;
|
||||||
import pp.monopoly.model.Rotation;
|
import pp.monopoly.model.Rotation;
|
||||||
|
import pp.monopoly.model.card.DeckHelper;
|
||||||
import pp.monopoly.model.fields.BoardManager;
|
import pp.monopoly.model.fields.BoardManager;
|
||||||
import pp.monopoly.model.fields.PropertyField;
|
import pp.monopoly.model.fields.PropertyField;
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
private ServerState state = ServerState.LOBBY;
|
private ServerState state = ServerState.LOBBY;
|
||||||
private static final int MAX_PLAYERS = 6;
|
private static final int MAX_PLAYERS = 6;
|
||||||
private BoardManager boardManager = new BoardManager();
|
private BoardManager boardManager = new BoardManager();
|
||||||
|
private final DeckHelper deckHelper = new DeckHelper();
|
||||||
private int startMoney;
|
private int startMoney;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -169,9 +171,12 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
public void received(EndTurn msg, int from) {
|
public void received(EndTurn msg, int from) {
|
||||||
Player player = playerHandler.getPlayerById(from);
|
Player player = playerHandler.getPlayerById(from);
|
||||||
if (player != null && state == ServerState.INGAME) {
|
if (player != null && state == ServerState.INGAME) {
|
||||||
LOGGER.log(Level.DEBUG, "Ending turn for player {0}", player.getName());
|
if (player.finishTurn()) {
|
||||||
Player next = playerHandler.nextPlayer();
|
LOGGER.log(Level.DEBUG, "Ending turn for player {0}", player.getName());
|
||||||
send(next, new NextPlayerTurn(next));
|
Player next = playerHandler.nextPlayer();
|
||||||
|
next.setActive();
|
||||||
|
send(next, new NextPlayerTurn(next));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,4 +288,8 @@ public class ServerGameLogic implements ClientInterpreter {
|
|||||||
public Player getPlayerById(int id) {
|
public Player getPlayerById(int id) {
|
||||||
return playerHandler.getPlayerById(id);
|
return playerHandler.getPlayerById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DeckHelper getDeckHelper() {
|
||||||
|
return deckHelper;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
package pp.monopoly.model;
|
|
||||||
|
|
||||||
import pp.monopoly.model.card.Card;
|
|
||||||
|
|
||||||
public interface CardVisitor<T> {
|
|
||||||
T visit(Card c);
|
|
||||||
}
|
|
@ -1,5 +1,7 @@
|
|||||||
package pp.monopoly.model.card;
|
package pp.monopoly.model.card;
|
||||||
|
|
||||||
|
import pp.monopoly.game.server.Player;
|
||||||
|
|
||||||
public class Card {
|
public class Card {
|
||||||
private final String description;
|
private final String description;
|
||||||
private final String keyword;
|
private final String keyword;
|
||||||
@ -9,8 +11,8 @@ public class Card {
|
|||||||
this.keyword = keyword;
|
this.keyword = keyword;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void accept(DeckHelper visitor) {
|
public void accept(DeckHelper visitor, Player player) {
|
||||||
visitor.visit(this);
|
visitor.visit(this, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
String getDescription() {
|
String getDescription() {
|
||||||
|
@ -2,25 +2,318 @@ package pp.monopoly.model.card;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
import pp.monopoly.model.CardVisitor;
|
import pp.monopoly.game.server.Player;
|
||||||
|
import pp.monopoly.message.client.EndTurn;
|
||||||
|
|
||||||
public class DeckHelper implements CardVisitor<Void>{
|
public class DeckHelper{
|
||||||
|
|
||||||
private static Queue<Card> cards;
|
private Queue<Card> cards;
|
||||||
|
private List<Card> drawn = new ArrayList<>();
|
||||||
private DeckHelper() {
|
|
||||||
|
|
||||||
|
public DeckHelper() {
|
||||||
|
cards = new LinkedList<Card>();
|
||||||
|
cards.add(new Card("Du wurdest mit einem Dienst KFZ geblitzt. Zahle: 800€", "dienst-kfz-blitzer"));
|
||||||
|
cards.add(new Card("Die erste Spoparty steht bevor. Ziehe vor zum 23er.", "spoparty"));
|
||||||
|
cards.add(new Card("Du kommst aus dem Gulak frei.", "gulak-frei-1"));
|
||||||
|
cards.add(new Card("Du kommst aus dem Gulak frei.", "gulak-frei-2"));
|
||||||
|
cards.add(new Card("Du hast den Dienstführerschein bestanden. Ziehe vor bis Teststrecke.", "dienstfuehrerschein"));
|
||||||
|
cards.add(new Card("Malkmus läd zum Pubquiz ein. Rücke vor bis zum 20er.", "pubquiz"));
|
||||||
|
cards.add(new Card("Du warst ohne Namensschild in der Truppenküche. Rücke vor zum 10er. Gehe nicht über Monatsgehalt. Ziehe keine 2000x€ ein.", "namensschild-truppenkueche"));
|
||||||
|
cards.add(new Card("Du hast heute die Spendierhosen an und gibst eine Runde in der Unibar. Zahle jedem Spieler: 400€", "spendierhosen-unibar"));
|
||||||
|
cards.add(new Card("Du warst in der Prüfungsphase krank. Gehe 3 Felder zurück.", "pruefungsphase-krank"));
|
||||||
|
cards.add(new Card("Ziehe vor bis zum nächsten Monatsgehalt.", "naechstes-monatsgehalt"));
|
||||||
|
cards.add(new Card("Du hast ein Antreten verschlafen. Zahle: 500€", "antreten-verschlafen-1"));
|
||||||
|
cards.add(new Card("Du hast den Maibock organisiert. Du erhältst: 3000€", "maibock-organisiert"));
|
||||||
|
cards.add(new Card("Der Spieß macht eine unangekündigte Inventur. Zahle für jedes Haus: 400€ und jedes Hotel: 2800€", "inventur-haeuser-hotels"));
|
||||||
|
cards.add(new Card("Es gab keine Mozzarella Bällchen mehr für Thoma. Alle Spieler ziehen vor auf Gym.", "dienstsport-gym"));
|
||||||
|
cards.add(new Card("Auf deiner Stube wurde Schimmel gefunden. Gehe ins Gulak. Begib Dich direkt dorthin. Gehe nicht über Monatsgehalt. Ziehe nicht ein.", "schimmel-gulak"));
|
||||||
|
cards.add(new Card("Deine Stube ist nach einer Partynacht nicht mehr bewohnbar. Du ziehst ins Gulak. Begib Dich direkt dorthin. Gehe nicht über Monatsgehalt. Ziehe nicht ein.", "partynacht-gulak"));
|
||||||
|
cards.add(new Card("Das Jahresabschlussantreten steht an. Ziehe vor bis Schwimmhalle.", "jahresabschlussantreten"));
|
||||||
|
cards.add(new Card("Du wurdest beim Verkaufen von Versicherungen erwischt. Zahle: 4000€", "verkaufen-versicherungen"));
|
||||||
|
cards.add(new Card("Du musstest einen Rückstuferantrag stellen. Setze eine Runde aus.", "rueckstuferantrag"));
|
||||||
|
cards.add(new Card("Auf einer Hausfeier bist du betrunken auf der Treppe gestürzt und dabei auf einen Kameraden gefallen. Zahle: 800€ und gehe zurück zu SanZ.", "hausfeier-sturz"));
|
||||||
|
cards.add(new Card("Beförderung. Beim nächsten Monatsgehalt ziehst du ein: 3000€", "befoerderung"));
|
||||||
|
cards.add(new Card("Du entscheidest dich für eine Dienstreise nach Lourd. Zahle: 1000€ und setze eine Runde aus.", "dienstreise-lourd"));
|
||||||
|
cards.add(new Card("Du warst fleißig Blutspenden und erhältst einen Tag Sonderurlaub. Du bist nochmal an der Reihe.", "blutspenden-sonderurlaub"));
|
||||||
|
cards.add(new Card("Dir wurde auf dem Oktoberfest dein Geldbeutel geklaut. Gebe 10% deines Vermögens ab.", "geldbeutel-oktoberfest"));
|
||||||
|
cards.add(new Card("Du wirst von deinem Chef für vorbildliches Verhalten gelobt. Du erhältst: 4000€", "lob-chef"));
|
||||||
|
cards.add(new Card("Deine Bekanntschaft von letzter Nacht war eine Spo. Lasse dich testen und zahle: 200€", "spo-testen"));
|
||||||
|
cards.add(new Card("Du wurdest von Kranz geexmattet. Gehe zurück zu Prüfungsamt.", "kranz-exmatrikulation"));
|
||||||
|
cards.add(new Card("Die letzte Party ist ein wenig eskaliert. Setze eine Runde aus.", "party-eskaliert"));
|
||||||
|
cards.add(new Card("Du wurdest zur VP gewählt und schmeißt eine Einstandsparty. Zahle: 800€", "vp-einstandsparty"));
|
||||||
|
cards.add(new Card("Du hast eine Party veranstaltet und dick Gewinn gemacht. Ziehe ein: 1500€", "party-gewinn"));
|
||||||
|
cards.add(new Card("Zur falschen Zeit am falschen Ort. Du musst einen Bergmarsch planen und setzt eine Runde aus.", "bergmarsch"));
|
||||||
|
cards.add(new Card("Dein Jodel eines Eispenis mit Unterhodenbeleuchtung geht viral. Ziehe ein: 1000€", "jodel-eispenis"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void visit(Card card, Player player) {
|
||||||
public Void visit(Card c) {
|
switch (card.getKeyword()) {
|
||||||
// TODO Auto-generated method stub
|
case "dienst-kfz-blitzer":
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'visit'");
|
dienstKfzBlitzer(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "spoparty":
|
||||||
|
spoparty(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "gulak-frei-1":
|
||||||
|
case "gulak-frei-2":
|
||||||
|
gulakFrei(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "dienstfuehrerschein":
|
||||||
|
dienstfuehrerschein(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "pubquiz":
|
||||||
|
pubquiz(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "namensschild-truppenkueche":
|
||||||
|
namensschildTruppenkueche(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "spendierhosen-unibar":
|
||||||
|
spendierhosenUnibar(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "pruefungsphase-krank":
|
||||||
|
pruefungsphaseKrank(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "naechstes-monatsgehalt":
|
||||||
|
naechstesMonatsgehalt(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "antreten-verschlafen-1":
|
||||||
|
antretenVerschlafen(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "maibock-organisiert":
|
||||||
|
maibockOrganisiert(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "inventur-haeuser-hotels":
|
||||||
|
inventurHaeuserHotels(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "dienstsport-gym":
|
||||||
|
dienstsportGym(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "schimmel-gulak":
|
||||||
|
schimmelGulak(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "partynacht-gulak":
|
||||||
|
partynachtGulak(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "jahresabschlussantreten":
|
||||||
|
jahresabschlussantreten(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "verkaufen-versicherungen":
|
||||||
|
verkaufenVersicherungen(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "rueckstuferantrag":
|
||||||
|
rueckstuferantrag(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "hausfeier-sturz":
|
||||||
|
hausfeierSturz(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "befoerderung":
|
||||||
|
befoerderung(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "dienstreise-lourd":
|
||||||
|
dienstreiseLourd(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "blutspenden-sonderurlaub":
|
||||||
|
blutspendenSonderurlaub(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "geldbeutel-oktoberfest":
|
||||||
|
geldbeutelOktoberfest(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "lob-chef":
|
||||||
|
lobChef(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "spo-testen":
|
||||||
|
spoTesten(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "kranz-exmatrikulation":
|
||||||
|
kranzExmatrikulation(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "party-eskaliert":
|
||||||
|
partyEskaliert(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "vp-einstandsparty":
|
||||||
|
vpEinstandsparty(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "party-gewinn":
|
||||||
|
partyGewinn(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "bergmarsch":
|
||||||
|
bergmarsch(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "jodel-eispenis":
|
||||||
|
jodelEispenis(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void dienstKfzBlitzer(Player player) {
|
||||||
|
player.pay(800);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void spoparty(Player player) {
|
||||||
|
player.movePos(14);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void gulakFrei(Player player) {
|
||||||
|
player.addJailCard();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dienstfuehrerschein(Player player) {
|
||||||
|
player.movePos(20);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pubquiz(Player player) {
|
||||||
|
player.movePos(39);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void namensschildTruppenkueche(Player player) {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
private void spendierhosenUnibar(Player player) {
|
||||||
|
for (Player p : player.getHandler().getPlayers()) {
|
||||||
|
p.earnMoney(400);
|
||||||
|
}
|
||||||
|
player.pay(player.getHandler().getPlayerCount()*400 - 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pruefungsphaseKrank(Player player) {
|
||||||
|
player.movePos(player.getFieldID() - 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void naechstesMonatsgehalt(Player player) {
|
||||||
|
player.movePos(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void antretenVerschlafen(Player player) {
|
||||||
|
player.pay(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void maibockOrganisiert(Player player) {
|
||||||
|
player.earnMoney(3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void inventurHaeuserHotels(Player player) {
|
||||||
|
player.pay(player.getNumHouses() * 400 + player.getNumHotels() * 2800);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dienstsportGym(Player player) {
|
||||||
|
for (Player p : player.getHandler().getPlayers()) {
|
||||||
|
p.movePos(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void schimmelGulak(Player player) {
|
||||||
|
player.movePos(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void partynachtGulak(Player player) {
|
||||||
|
player.movePos(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void jahresabschlussantreten(Player player) {
|
||||||
|
player.movePos(17);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void verkaufenVersicherungen(Player player) {
|
||||||
|
player.pay(4000);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rueckstuferantrag(Player player) {
|
||||||
|
player.getHandler().getLogic().received(new EndTurn(), player.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hausfeierSturz(Player player) {
|
||||||
|
player.pay(800);
|
||||||
|
player.movePos(32);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void befoerderung(Player player) {
|
||||||
|
player.earnMoney(3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dienstreiseLourd(Player player) {
|
||||||
|
player.pay(1000);
|
||||||
|
player.getHandler().getLogic().received(new EndTurn(), player.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void blutspendenSonderurlaub(Player player) {
|
||||||
|
player.getHandler().extraTurn(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void geldbeutelOktoberfest(Player player) {
|
||||||
|
player.pay(player.getAccountBalance() / 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lobChef(Player player) {
|
||||||
|
player.earnMoney( 4000);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void spoTesten(Player player) {
|
||||||
|
player.pay( 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void kranzExmatrikulation(Player player) {
|
||||||
|
player.movePos(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void partyEskaliert(Player player) {
|
||||||
|
player.getHandler().getLogic().received(new EndTurn(), player.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void vpEinstandsparty(Player player) {
|
||||||
|
player.pay( 800);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void partyGewinn(Player player) {
|
||||||
|
player.earnMoney( 1500);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bergmarsch(Player player) {
|
||||||
|
player.getHandler().getLogic().received(new EndTurn(), player.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void jodelEispenis(Player player) {
|
||||||
|
player.earnMoney(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void shuffle() {
|
private void shuffle() {
|
||||||
List<Card> cardList = new ArrayList<>(cards);
|
List<Card> cardList = new ArrayList<>(cards);
|
||||||
Collections.shuffle(cardList);
|
Collections.shuffle(cardList);
|
||||||
@ -28,7 +321,13 @@ public class DeckHelper implements CardVisitor<Void>{
|
|||||||
cards.addAll(cardList);
|
cards.addAll(cardList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Card drawCard() {
|
public Card drawCard() {
|
||||||
return cards != null ? cards.poll() : null;
|
if (cards.isEmpty()) {
|
||||||
|
drawn.forEach(cards::add);
|
||||||
|
shuffle();
|
||||||
|
}
|
||||||
|
Card card = cards.poll();
|
||||||
|
drawn.add(card);
|
||||||
|
return card;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,4 +98,12 @@ public class BuildingProperty extends PropertyField {
|
|||||||
public int getHousePrice() {
|
public int getHousePrice() {
|
||||||
return housePrice;
|
return housePrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getHouses() {
|
||||||
|
return houses;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHotel() {
|
||||||
|
return hotel ? 1:0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@ package pp.monopoly.model.fields;
|
|||||||
|
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
import pp.monopoly.model.card.Card;
|
|
||||||
import pp.monopoly.model.card.DeckHelper;
|
|
||||||
|
|
||||||
public class EventField extends Field{
|
public class EventField extends Field{
|
||||||
|
|
||||||
@ -15,9 +13,4 @@ public class EventField extends Field{
|
|||||||
public void accept(Player player) {
|
public void accept(Player player) {
|
||||||
player.visit(this);
|
player.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Card drawCard() {
|
|
||||||
return DeckHelper.drawCard();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user