Skip to content

Commit

Permalink
Anzeige für Konto und Stock
Browse files Browse the repository at this point in the history
  • Loading branch information
mnk7 committed Apr 1, 2015
1 parent 217d315 commit 01025d5
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 40 deletions.
Binary file modified bin/graphik/Graphik$1.class
Binary file not shown.
Binary file modified bin/graphik/Graphik$2.class
Binary file not shown.
Binary file modified bin/graphik/Graphik.class
Binary file not shown.
Binary file modified bin/graphik/SpielmodusDialog.class
Binary file not shown.
Binary file modified bin/server/Server.class
Binary file not shown.
11 changes: 5 additions & 6 deletions src/graphik/Graphik.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ public Graphik(Model model, final Client client) {
this.setLayout(null);
this.setLocationRelativeTo(null);
this.initGUI();
this.setVisible(true);
this.pack();
this.setSize(1130, 740);
this.setVisible(true);

this.addWindowListener(new WindowListener() {

Expand Down Expand Up @@ -151,7 +150,7 @@ private void initGUI() {
gegenspielerKarten[0].nachricht("Spieler 1");

hintergrund.add(gegenspielerKarten[1]);
gegenspielerKarten[1].setBounds(breite, 0, breite, hoehe);
gegenspielerKarten[1].setBounds(breite, 10, breite, hoehe);

gegenspielerKarten[1].nachricht("Spieler 2");

Expand All @@ -164,11 +163,11 @@ private void initGUI() {
spielerKarten = new Spieler(440, 120);
hintergrund.add(spielerKarten);
//Unterhalb der eigenen Meldungen platziert
spielerKarten.setLocation(this.getWidth() / 2 - 220, hoehe*2 + 100);
spielerKarten.setLocation(this.getWidth() / 2 - 220, hoehe*2 + 90);
spielerKarten.setVisible(true);

//Meldungen des Spielers (4 Meldungen werden angezeigt)
spielerMeldungen = new Meldungen(5);
spielerMeldungen = new Meldungen(4);
hintergrund.add(spielerMeldungen);
//Die Meldungen laufen im letzten Fünftel des Fensters
spielerMeldungen.setBounds(breite, hoehe*2, breite, hoehe);
Expand Down Expand Up @@ -206,7 +205,7 @@ public void actionPerformed(ActionEvent evt) {

konto = new Konto();
hintergrund.add(konto);
konto.setLocation(10, this.getHeight() - 210);
konto.setLocation(10, this.getHeight() - 230);
konto.setVisible(true);

//-------------------------------------------------------------hintergrund
Expand Down
14 changes: 7 additions & 7 deletions src/graphik/Konto.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ public Konto() {
this.setLayout(null);

kontostand = new JLabel();
this.add(kontostand);
kontostand.setBounds(50, 65, 100, 30);
this.add(kontostand);
kontostand.setBounds(35, 60, 130, 30);
kontostand.setText("Konto: ");
kontostand.setOpaque(false);
kontostand.setOpaque(false);
kontostand.setForeground(Color.white);

Font schrift = kontostand.getFont();
schrift = schrift.deriveFont(schrift.BOLD);
schrift = schrift.deriveFont(schrift.BOLD, 20);
kontostand.setFont(schrift);

stock = new JLabel();
this.add(stock);
stock.setBounds(50, 105, 100, 30);
stock.setBounds(35, 110, 130, 30);
stock.setText("Stock: ");
stock.setOpaque(false);
stock.setForeground(Color.white);

stock.setFont(schrift);
}

Expand Down
2 changes: 1 addition & 1 deletion src/graphik/SpielmodusDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public String modusZuSprache(modus m) {
return "ein Sie";
}

return "nichts";
return "Nichts";
}

public void reset() {
Expand Down
Binary file modified src/graphik/karten/holzschale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 34 additions & 26 deletions src/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,19 @@ public Server(Graphik graphik, int port) {
public void run() {
try {
while(!beenden) {
//Akzeptiert die Verbindung
Socket client = server.accept();

Mensch neuerSpieler = new Mensch(client, this);
spieler.add(neuerSpieler);

neuerSpieler.name();

ViewTextSetzen();

starten();
if(spieler.size() < 4) {
//Akzeptiert die Verbindung
Socket client = server.accept();

Mensch neuerSpieler = new Mensch(client, this);
spieler.add(neuerSpieler);

neuerSpieler.name();

ViewTextSetzen();

starten();
}
}
} catch(Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -168,9 +170,6 @@ private void starten() throws Exception {
*/
private void neuesSpiel() throws Exception {

synchronized (model) {
synchronized (spieler) {

//Spiel wurde gestartet
while(!nocheins) {

Expand Down Expand Up @@ -235,8 +234,6 @@ private void neuesSpiel() throws Exception {
//neue Runde
naechster();
}
}//synchronized spieler
}//synchronized model
}

/**
Expand Down Expand Up @@ -544,40 +541,50 @@ private synchronized void rundeBeenden() {
}

//Den Spielern Geld abziehen oder hinzufügen
ArrayList<Integer> neuesKonto = new ArrayList<Integer>(4);
for(int i = 0; i < 4; i++) {
neuesKonto.add(0);
}
//Wenn die Spielenden verloren haben
if(spielt > 9) {
konto.set(spielt - 10, konto.get(spielt - 10) - abrechnung(true, pSpielt));
neuesKonto.set(spielt - 10, konto.get(spielt - 10) - abrechnung(true, pSpielt));
if(mitspieler != 4) {
konto.set(mitspieler - 10, konto.get(mitspieler - 10) - abrechnung(true, pSpielt));
neuesKonto.set(mitspieler - 10, konto.get(mitspieler - 10) - abrechnung(true, pSpielt));
}
} else {
//Wenn die Spielenden gewonnen haben
konto.set(spielt, konto.get(spielt) + abrechnung(true, 120 - pSpielt));
neuesKonto.set(spielt, konto.get(spielt) + abrechnung(true, 120 - pSpielt));
if(mitspieler != 4) {
konto.set(mitspieler, konto.get(mitspieler) + abrechnung(true, 120 - pSpielt));
neuesKonto.set(mitspieler, konto.get(mitspieler) + abrechnung(true, 120 - pSpielt));
}

//Wenn ein Sauspiel gewonnen wurde, wird der Stock aufgeteilt
if(mod.equals(modus.SAUSPIELeichel)
|| mod.equals(modus.SAUSPIELgras)
|| mod.equals(modus.SAUSPIELherz)
|| mod.equals(modus.SAUSPIELschellen)) {
konto.set(spielt, konto.get(spielt) + stock / 2);
konto.set(mitspieler, konto.get(mitspieler) + stock / 2);
//Konto aktualiesieren
konto.set(spielt, neuesKonto.get(spielt));
konto.set(mitspieler, neuesKonto.get(mitspieler));
//und Stock addieren
neuesKonto.set(spielt, konto.get(spielt) + stock / 2);
neuesKonto.set(mitspieler, konto.get(mitspieler) + stock / 2);
stock = 0;
}
}
for(int i = 0; i < 4; i++) {
if(i != spielt && i != spielt - 10 && i != mitspieler && i != mitspieler - 10) {
if(spielt > 9) {
//Die Spielenden haben verloren
konto.set(i, konto.get(i) + abrechnung(false, pSpielt));
neuesKonto.set(i, konto.get(i) + abrechnung(false, pSpielt));
} else {
//Die Spielenden haben gewonnen
konto.set(i, konto.get(i) - abrechnung(false, 120 - pSpielt));
neuesKonto.set(i, konto.get(i) - abrechnung(false, 120 - pSpielt));
}
}
}

konto = neuesKonto;
}

/**
Expand Down Expand Up @@ -661,10 +668,11 @@ private int abrechnung(boolean spieler, int punkteVerlierer) {
/**
* Füllt den Stock auf
*/
private void stock() {
private void stock() {
stock += (tarif * 4);
for(int i = 0; i < 4; i++) {
konto.set(i, konto.get(i) - tarif);
int k = konto.get(i);
konto.set(i, k - tarif);
}
}

Expand Down

0 comments on commit 01025d5

Please sign in to comment.