From 25f30237d28014dbfb8da9b09aecedb72b9120e7 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Fri, 21 Jan 2022 14:18:17 +0100 Subject: [PATCH 001/108] init GameWindow --- .gitignore | 22 +++++++++++++++ src/main/java/hauptmenue/GameWindow.java | 27 ++++++++++++++++++ src/main/java/hauptmenue/main.java | 10 +++++++ src/main/java/solitaer/SolitaerGamePanel.java | 28 +++++++++++++++++++ 4 files changed, 87 insertions(+) create mode 100644 src/main/java/hauptmenue/GameWindow.java create mode 100644 src/main/java/hauptmenue/main.java create mode 100644 src/main/java/solitaer/SolitaerGamePanel.java diff --git a/.gitignore b/.gitignore index 84adb3f..c837958 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,25 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +.mvn/wrapper/maven-wrapper.jar + +# Eclipse m2e generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# End of https://www.toptal.com/developers/gitignore/api/maven + diff --git a/src/main/java/hauptmenue/GameWindow.java b/src/main/java/hauptmenue/GameWindow.java new file mode 100644 index 0000000..a2c7479 --- /dev/null +++ b/src/main/java/hauptmenue/GameWindow.java @@ -0,0 +1,27 @@ +package hauptmenue; + +import java.awt.Dimension; + +import javax.swing.JFrame; + +import solitaer.SolitaerGamePanel; + +public class GameWindow extends JFrame { + + /** + * + */ + private static final long serialVersionUID = 1L; + private final SolitaerGamePanel gamePanel = new SolitaerGamePanel(); + + public GameWindow() { + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + gamePanel.setPreferredSize(new Dimension(1180, 780)); + + add(gamePanel); + pack(); + + setVisible(true); + } + +} diff --git a/src/main/java/hauptmenue/main.java b/src/main/java/hauptmenue/main.java new file mode 100644 index 0000000..3f53c7f --- /dev/null +++ b/src/main/java/hauptmenue/main.java @@ -0,0 +1,10 @@ +package hauptmenue; + +public class main { + + public static void main(String[] args) { + // TODO Auto-generated method stub + new GameWindow(); + } + +} diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java new file mode 100644 index 0000000..3fa1888 --- /dev/null +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -0,0 +1,28 @@ +package solitaer; + +import java.awt.Color; +import java.awt.Graphics; + +import javax.swing.JPanel; + +public class SolitaerGamePanel extends JPanel { + + /** + * + */ + private static final long serialVersionUID = 1L; + + + public SolitaerGamePanel() { + setLayout(null); + } + + + @Override + protected void paintComponent(Graphics g) { + // TODO Auto-generated method stub + super.paintComponent(g); + g.setColor(Color.green); + g.fillRect(0, 0, this.getWidth(), this.getHeight()); + } +} From 9346c4222389381a0b320b7d03f6b4b7e7cfc44a Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Fri, 21 Jan 2022 16:11:22 +0100 Subject: [PATCH 002/108] implement CardDeck with 52 Cards --- src/main/java/solitaer/Card.java | 28 ++++++++++++++++++++++++ src/main/java/solitaer/CardDeck.java | 23 +++++++++++++++++++ src/test/java/solitaer/CardDeckTest.java | 21 ++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 src/main/java/solitaer/Card.java create mode 100644 src/main/java/solitaer/CardDeck.java create mode 100644 src/test/java/solitaer/CardDeckTest.java diff --git a/src/main/java/solitaer/Card.java b/src/main/java/solitaer/Card.java new file mode 100644 index 0000000..38bb04d --- /dev/null +++ b/src/main/java/solitaer/Card.java @@ -0,0 +1,28 @@ +package solitaer; + +import javax.swing.JPanel; + +enum Symbol { + Herz, Karo, Kreuz, Pik +} + +public class Card extends JPanel { + + /** + * + */ + private static final long serialVersionUID = 1L; + private int nr; + private Symbol symbol; + + private boolean faceUp; + + public Card(int nr, Symbol symbol, boolean faceUp) { + this.nr = nr; + this.symbol = symbol; + this.faceUp = faceUp; + } + + + +} diff --git a/src/main/java/solitaer/CardDeck.java b/src/main/java/solitaer/CardDeck.java new file mode 100644 index 0000000..522a7fd --- /dev/null +++ b/src/main/java/solitaer/CardDeck.java @@ -0,0 +1,23 @@ +package solitaer; + +import java.util.ArrayList; + +public class CardDeck { + + private ArrayList deck = new ArrayList(); + + + public CardDeck() { + for(int i= 0; i<52; i++) { + deck.add(new Card(i, Symbol.Herz, false)); + } + + } + + + public ArrayList getDeck() { + return deck; + } + + +} diff --git a/src/test/java/solitaer/CardDeckTest.java b/src/test/java/solitaer/CardDeckTest.java new file mode 100644 index 0000000..751c85d --- /dev/null +++ b/src/test/java/solitaer/CardDeckTest.java @@ -0,0 +1,21 @@ +package solitaer; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +class CardDeckTest { + + @Test + void testCardDeckSize() { + CardDeck deck = new CardDeck(); + + int result = deck.getDeck().size(); + + assertEquals(52, result, "Kartendeck muss genau 52 Carden haben") ; + + } + + + +} From 84fab3b0848014d25da6c569bf0b598160d24d83 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Fri, 21 Jan 2022 17:14:36 +0100 Subject: [PATCH 003/108] CardDeck with different Symbole --- src/main/java/solitaer/Card.java | 23 +++++++++++++- src/main/java/solitaer/CardDeck.java | 29 +++++++++++++----- src/test/java/solitaer/CardDeckTest.java | 39 ++++++++++++++++++++++-- 3 files changed, 79 insertions(+), 12 deletions(-) diff --git a/src/main/java/solitaer/Card.java b/src/main/java/solitaer/Card.java index 38bb04d..9fed8b5 100644 --- a/src/main/java/solitaer/Card.java +++ b/src/main/java/solitaer/Card.java @@ -23,6 +23,27 @@ public class Card extends JPanel { this.faceUp = faceUp; } + public boolean isFaceUp() { + return faceUp; + } + + public void setFaceUp(boolean faceUp) { + this.faceUp = faceUp; + } + + public int getNr() { + return nr; + } + + public Symbol getSymbol() { + return symbol; + } + + @Override + public String toString() { + return "Card [nr=" + nr + ", symbol=" + symbol + ", faceUp=" + faceUp + "]"; + } + - + } diff --git a/src/main/java/solitaer/CardDeck.java b/src/main/java/solitaer/CardDeck.java index 522a7fd..1387542 100644 --- a/src/main/java/solitaer/CardDeck.java +++ b/src/main/java/solitaer/CardDeck.java @@ -3,21 +3,34 @@ package solitaer; import java.util.ArrayList; public class CardDeck { - + private ArrayList deck = new ArrayList(); - - + public CardDeck() { - for(int i= 0; i<52; i++) { - deck.add(new Card(i, Symbol.Herz, false)); + for (int j = 0; j < 4; j++) { + for (int i = 0; i < 13; i++) { + switch (j) { + case 0: + deck.add(new Card(1, Symbol.Herz, false)); + break; + case 1: + deck.add(new Card(1, Symbol.Karo, false)); + break; + case 2: + deck.add(new Card(1, Symbol.Kreuz, false)); + break; + case 3: + deck.add(new Card(1, Symbol.Pik, false)); + break; + } + + } } - - } + } public ArrayList getDeck() { return deck; } - } diff --git a/src/test/java/solitaer/CardDeckTest.java b/src/test/java/solitaer/CardDeckTest.java index 751c85d..448cc87 100644 --- a/src/test/java/solitaer/CardDeckTest.java +++ b/src/test/java/solitaer/CardDeckTest.java @@ -1,21 +1,54 @@ package solitaer; import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.verify; + +import java.util.stream.Stream; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; class CardDeckTest { + + private CardDeck deck = new CardDeck(); @Test - void testCardDeckSize() { - CardDeck deck = new CardDeck(); - + void testCardDeckSize() { int result = deck.getDeck().size(); assertEquals(52, result, "Kartendeck muss genau 52 Carden haben") ; } + + + @ParameterizedTest + @MethodSource("testSymbole") + void testCardDeckSymbole(String msg, Symbol _sym) { + + boolean result = false; + + for(int i = 0; i testSymbole(){ + return Stream.of( + Arguments.of("Herz", Symbol.Herz), + Arguments.of("Karo", Symbol.Karo), + Arguments.of("Pik", Symbol.Pik), + Arguments.of("Kreuz",Symbol.Kreuz) + ); + + + } } From 2de3d41bfd1d4a57d6945200794323f34f249d2e Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Fri, 21 Jan 2022 17:44:58 +0100 Subject: [PATCH 004/108] CardDeck with 13 Cards of each Symbol --- src/main/java/solitaer/Card.java | 19 +++++++++++++++++ src/main/java/solitaer/CardDeck.java | 10 ++++----- src/test/java/solitaer/CardDeckTest.java | 27 +++++++++++++++++++++++- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/src/main/java/solitaer/Card.java b/src/main/java/solitaer/Card.java index 9fed8b5..76cc107 100644 --- a/src/main/java/solitaer/Card.java +++ b/src/main/java/solitaer/Card.java @@ -1,5 +1,7 @@ package solitaer; +import java.util.Objects; + import javax.swing.JPanel; enum Symbol { @@ -44,6 +46,23 @@ public class Card extends JPanel { return "Card [nr=" + nr + ", symbol=" + symbol + ", faceUp=" + faceUp + "]"; } + @Override + public int hashCode() { + return Objects.hash(faceUp, nr, symbol); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Card other = (Card) obj; + return faceUp == other.faceUp && nr == other.nr && symbol == other.symbol; + } + } diff --git a/src/main/java/solitaer/CardDeck.java b/src/main/java/solitaer/CardDeck.java index 1387542..f5036df 100644 --- a/src/main/java/solitaer/CardDeck.java +++ b/src/main/java/solitaer/CardDeck.java @@ -8,19 +8,19 @@ public class CardDeck { public CardDeck() { for (int j = 0; j < 4; j++) { - for (int i = 0; i < 13; i++) { + for (int i = 1; i <= 13; i++) { switch (j) { case 0: - deck.add(new Card(1, Symbol.Herz, false)); + deck.add(new Card(i, Symbol.Herz, false)); break; case 1: - deck.add(new Card(1, Symbol.Karo, false)); + deck.add(new Card(i, Symbol.Karo, false)); break; case 2: - deck.add(new Card(1, Symbol.Kreuz, false)); + deck.add(new Card(i, Symbol.Kreuz, false)); break; case 3: - deck.add(new Card(1, Symbol.Pik, false)); + deck.add(new Card(i, Symbol.Pik, false)); break; } diff --git a/src/test/java/solitaer/CardDeckTest.java b/src/test/java/solitaer/CardDeckTest.java index 448cc87..daa7371 100644 --- a/src/test/java/solitaer/CardDeckTest.java +++ b/src/test/java/solitaer/CardDeckTest.java @@ -1,7 +1,6 @@ package solitaer; import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.verify; import java.util.stream.Stream; @@ -50,5 +49,31 @@ class CardDeckTest { } + + @Test + void testCardDeckNumber() { + + boolean result = true; + + result = CheckAllCards(Symbol.Herz) && + CheckAllCards(Symbol.Karo) && + CheckAllCards(Symbol.Kreuz) && + CheckAllCards(Symbol.Pik); + + assertTrue(result); + } + + + private boolean CheckAllCards(Symbol _sym) { + boolean result = true; + for(int i =1; i<=13; i++) { + if(deck.getDeck().contains(new Card(i, _sym, false))== false) { + result = false; + break; + } + } + return result; + } + } From a10127d1b227a91831a48e2bbb2c2ef603b71c87 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Wed, 26 Jan 2022 14:36:44 +0100 Subject: [PATCH 005/108] Refactor CardDeck and CardDeckTest --- src/main/java/solitaer/CardDeck.java | 14 +++++++------- src/test/java/solitaer/CardDeckTest.java | 10 ++++++---- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/solitaer/CardDeck.java b/src/main/java/solitaer/CardDeck.java index f5036df..41a6518 100644 --- a/src/main/java/solitaer/CardDeck.java +++ b/src/main/java/solitaer/CardDeck.java @@ -7,20 +7,20 @@ public class CardDeck { private ArrayList deck = new ArrayList(); public CardDeck() { - for (int j = 0; j < 4; j++) { - for (int i = 1; i <= 13; i++) { - switch (j) { + for (int symboleZähler = 0; symboleZähler < 4; symboleZähler++) { + for (int nrZähler = 1; nrZähler <= 13; nrZähler++) { + switch (symboleZähler) { case 0: - deck.add(new Card(i, Symbol.Herz, false)); + deck.add(new Card(nrZähler, Symbol.Herz, false)); break; case 1: - deck.add(new Card(i, Symbol.Karo, false)); + deck.add(new Card(nrZähler, Symbol.Karo, false)); break; case 2: - deck.add(new Card(i, Symbol.Kreuz, false)); + deck.add(new Card(nrZähler, Symbol.Kreuz, false)); break; case 3: - deck.add(new Card(i, Symbol.Pik, false)); + deck.add(new Card(nrZähler, Symbol.Pik, false)); break; } diff --git a/src/test/java/solitaer/CardDeckTest.java b/src/test/java/solitaer/CardDeckTest.java index daa7371..48776f9 100644 --- a/src/test/java/solitaer/CardDeckTest.java +++ b/src/test/java/solitaer/CardDeckTest.java @@ -24,12 +24,13 @@ class CardDeckTest { @ParameterizedTest @MethodSource("testSymbole") + //Jedes Symbol muss einmal vorhand sein void testCardDeckSymbole(String msg, Symbol _sym) { boolean result = false; - for(int i = 0; i Date: Wed, 26 Jan 2022 15:31:53 +0100 Subject: [PATCH 006/108] init startStack --- src/main/java/solitaer/SolitaerGamePanel.java | 2 ++ src/main/java/solitaer/StartStack.java | 34 ++++++++++++++++++ src/main/java/solitaer/images/back.png | Bin 0 -> 1361 bytes 3 files changed, 36 insertions(+) create mode 100644 src/main/java/solitaer/StartStack.java create mode 100644 src/main/java/solitaer/images/back.png diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 3fa1888..520ae04 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -15,6 +15,8 @@ public class SolitaerGamePanel extends JPanel { public SolitaerGamePanel() { setLayout(null); + StartStack a = new StartStack(25,25); + this.add(a); } diff --git a/src/main/java/solitaer/StartStack.java b/src/main/java/solitaer/StartStack.java new file mode 100644 index 0000000..79b3242 --- /dev/null +++ b/src/main/java/solitaer/StartStack.java @@ -0,0 +1,34 @@ +package solitaer; + +import java.awt.Graphics; +import java.awt.Image; +import java.util.ArrayList; + +import javax.swing.ImageIcon; +import javax.swing.JPanel; + +public class StartStack extends JPanel { + + private static final long serialVersionUID = 1L; + private Image im; + private ArrayList Stack = new ArrayList(); + + + + public StartStack(int _x, int _y) { + super.setLocation(_x, _y); + super.setSize(72,450); + super.setOpaque(false); + super.setLayout(null); + } + + @Override + protected void paintComponent(Graphics g) { + // TODO Auto-generated method stub + super.paintComponent(g); + ImageIcon ii = new ImageIcon(getClass().getResource("images/back.png")); + im = ii.getImage(); + g.drawImage(im, 0, 0, this.getWidth(), 96, this); + } + +} diff --git a/src/main/java/solitaer/images/back.png b/src/main/java/solitaer/images/back.png new file mode 100644 index 0000000000000000000000000000000000000000..9457b3025989f05a6724f9688f0e4b4007b5030b GIT binary patch literal 1361 zcmV-X1+MyuP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1m;OZK~#8N?V7DZ zD?1Q?E0M@bB#(eZRw8+X%1RuPN2o;d2uLIn$s-_+9>))fLA0 z$9B8L%K^{N&*aY7f4|@3wF7LNEJRG&Wdd~rvCGR#jFH?PvS@f7UI+krAC0|1Lnx+6 zmuKWg#1h*RE*fC(B=Y(-g_y;Fkz3dpiQ*v@B0WzTEkTVKaC8d;>BXcw!`u32%z6(^n-mZD)2z~B}pt#ZZT$`Yf9<@@`4x7*=| z50pkAtistS)sJ$;y6gFLCx)_#Knea66Tc`teAO9q^P31fULNVA{2#6Qz z040db=E^UUo&gSh6Q-GHa*zsl#PO+{RJf&LBu*1CX>IUBwj9JWz*AX=K)o2-RFaYh z-B>Y05yo3<*ct*`fts-B_Vo0GAF5bQ!*ofbq9`UmOG;^*E;dow3XG|BiyO5vUD9D? zh-r6=a|PHI!G z<*Kv@rLo>HQ3TPgl@idQ{8*@4+m|n()nR3Ty0yv`5YNCqN*?OgHX{4CKU zO^YdJU>Y12__u0K*jEl_XYon}abE#FtuRY5c-=%C^u&n@fMH>DV{_H5ucSngoh^2A zyG2^7Pr4)}fF0>&Zt=kAkgG)PrT0|j#%|cuxyrUvc26^IY+p@kRj=d`-J};w^UF$_ zw32N%c{d2up|8?DfKACm-QsjrJ|JdlCC||f!o|-s{9}PcHzm*D#kDcYUq3h z8W^@57pq{-KFml9|HF;tgg&<8RQLVZYx)%e6A8S!*fO4aUaX+Z&{1v)No+T;Ph-tk>)9b_)?O+({YSzP`R*US6P2 zZfI%~G`T2==Efe&)y}f;Sc!2jW zn1Og@`7}P?X2qY|GWm0x4P~!;?lbNiD&S6J^B2~6;oQ!_B*wXAzoE_tUtC#^{TAyr z{Ez&Tu&`ND#Gl(T8M&Rw==Y%3K`j17lVyWuXL-b-S#Sm{ee`?&H?!od`2GD4F1)}x Tv1aIi00000NkvXXu0mjfOWB0! literal 0 HcmV?d00001 From cd0645ba09e538137cf121cb7765a393d1ae0eee Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Wed, 26 Jan 2022 16:32:36 +0100 Subject: [PATCH 007/108] implement render for cards and ADD image files for cards --- src/main/java/solitaer/Card.java | 56 +++++++++++++++++- src/main/java/solitaer/SolitaerGamePanel.java | 2 + src/main/java/solitaer/StartStack.java | 29 ++++++--- src/main/java/solitaer/images/01Herz.png | Bin 0 -> 523 bytes src/main/java/solitaer/images/01Karo.png | Bin 0 -> 539 bytes src/main/java/solitaer/images/01Kreuz.png | Bin 0 -> 564 bytes src/main/java/solitaer/images/01Pik.png | Bin 0 -> 506 bytes src/main/java/solitaer/images/02Herz.png | Bin 0 -> 530 bytes src/main/java/solitaer/images/02Karo.png | Bin 0 -> 546 bytes src/main/java/solitaer/images/02Kreuz.png | Bin 0 -> 574 bytes src/main/java/solitaer/images/02Pik.png | Bin 0 -> 517 bytes src/main/java/solitaer/images/03Herz.png | Bin 0 -> 532 bytes src/main/java/solitaer/images/03Karo.png | Bin 0 -> 547 bytes src/main/java/solitaer/images/03Kreuz.png | Bin 0 -> 576 bytes src/main/java/solitaer/images/03Pik.png | Bin 0 -> 518 bytes src/main/java/solitaer/images/04Herz.png | Bin 0 -> 530 bytes src/main/java/solitaer/images/04Karo.png | Bin 0 -> 547 bytes src/main/java/solitaer/images/04Kreuz.png | Bin 0 -> 574 bytes src/main/java/solitaer/images/04Pik.png | Bin 0 -> 516 bytes src/main/java/solitaer/images/05Herz.png | Bin 0 -> 531 bytes src/main/java/solitaer/images/05Karo.png | Bin 0 -> 548 bytes src/main/java/solitaer/images/05Kreuz.png | Bin 0 -> 575 bytes src/main/java/solitaer/images/05Pik.png | Bin 0 -> 519 bytes src/main/java/solitaer/images/06Herz.png | Bin 0 -> 540 bytes src/main/java/solitaer/images/06Karo.png | Bin 0 -> 555 bytes src/main/java/solitaer/images/06Kreuz.png | Bin 0 -> 584 bytes src/main/java/solitaer/images/06Pik.png | Bin 0 -> 527 bytes src/main/java/solitaer/images/07Herz.png | Bin 0 -> 525 bytes src/main/java/solitaer/images/07Karo.png | Bin 0 -> 542 bytes src/main/java/solitaer/images/07Kreuz.png | Bin 0 -> 567 bytes src/main/java/solitaer/images/07Pik.png | Bin 0 -> 510 bytes src/main/java/solitaer/images/08Herz.png | Bin 0 -> 543 bytes src/main/java/solitaer/images/08Karo.png | Bin 0 -> 557 bytes src/main/java/solitaer/images/08Kreuz.png | Bin 0 -> 588 bytes src/main/java/solitaer/images/08Pik.png | Bin 0 -> 530 bytes src/main/java/solitaer/images/09Herz.png | Bin 0 -> 540 bytes src/main/java/solitaer/images/09Karo.png | Bin 0 -> 555 bytes src/main/java/solitaer/images/09Kreuz.png | Bin 0 -> 584 bytes src/main/java/solitaer/images/09Pik.png | Bin 0 -> 527 bytes src/main/java/solitaer/images/10Herz.png | Bin 0 -> 523 bytes src/main/java/solitaer/images/10Karo.png | Bin 0 -> 539 bytes src/main/java/solitaer/images/10Kreuz.png | Bin 0 -> 563 bytes src/main/java/solitaer/images/10Pik.png | Bin 0 -> 507 bytes src/main/java/solitaer/images/11Herz.png | Bin 0 -> 499 bytes src/main/java/solitaer/images/11Karo.png | Bin 0 -> 518 bytes src/main/java/solitaer/images/11Kreuz.png | Bin 0 -> 540 bytes src/main/java/solitaer/images/11Pik.png | Bin 0 -> 483 bytes src/main/java/solitaer/images/12Herz.png | Bin 0 -> 509 bytes src/main/java/solitaer/images/12Karo.png | Bin 0 -> 525 bytes src/main/java/solitaer/images/12Kreuz.png | Bin 0 -> 552 bytes src/main/java/solitaer/images/12Pik.png | Bin 0 -> 494 bytes src/main/java/solitaer/images/13Herz.png | Bin 0 -> 511 bytes src/main/java/solitaer/images/13Karo.png | Bin 0 -> 527 bytes src/main/java/solitaer/images/13Kreuz.png | Bin 0 -> 554 bytes src/main/java/solitaer/images/13Pik.png | Bin 0 -> 495 bytes 55 files changed, 77 insertions(+), 10 deletions(-) create mode 100644 src/main/java/solitaer/images/01Herz.png create mode 100644 src/main/java/solitaer/images/01Karo.png create mode 100644 src/main/java/solitaer/images/01Kreuz.png create mode 100644 src/main/java/solitaer/images/01Pik.png create mode 100644 src/main/java/solitaer/images/02Herz.png create mode 100644 src/main/java/solitaer/images/02Karo.png create mode 100644 src/main/java/solitaer/images/02Kreuz.png create mode 100644 src/main/java/solitaer/images/02Pik.png create mode 100644 src/main/java/solitaer/images/03Herz.png create mode 100644 src/main/java/solitaer/images/03Karo.png create mode 100644 src/main/java/solitaer/images/03Kreuz.png create mode 100644 src/main/java/solitaer/images/03Pik.png create mode 100644 src/main/java/solitaer/images/04Herz.png create mode 100644 src/main/java/solitaer/images/04Karo.png create mode 100644 src/main/java/solitaer/images/04Kreuz.png create mode 100644 src/main/java/solitaer/images/04Pik.png create mode 100644 src/main/java/solitaer/images/05Herz.png create mode 100644 src/main/java/solitaer/images/05Karo.png create mode 100644 src/main/java/solitaer/images/05Kreuz.png create mode 100644 src/main/java/solitaer/images/05Pik.png create mode 100644 src/main/java/solitaer/images/06Herz.png create mode 100644 src/main/java/solitaer/images/06Karo.png create mode 100644 src/main/java/solitaer/images/06Kreuz.png create mode 100644 src/main/java/solitaer/images/06Pik.png create mode 100644 src/main/java/solitaer/images/07Herz.png create mode 100644 src/main/java/solitaer/images/07Karo.png create mode 100644 src/main/java/solitaer/images/07Kreuz.png create mode 100644 src/main/java/solitaer/images/07Pik.png create mode 100644 src/main/java/solitaer/images/08Herz.png create mode 100644 src/main/java/solitaer/images/08Karo.png create mode 100644 src/main/java/solitaer/images/08Kreuz.png create mode 100644 src/main/java/solitaer/images/08Pik.png create mode 100644 src/main/java/solitaer/images/09Herz.png create mode 100644 src/main/java/solitaer/images/09Karo.png create mode 100644 src/main/java/solitaer/images/09Kreuz.png create mode 100644 src/main/java/solitaer/images/09Pik.png create mode 100644 src/main/java/solitaer/images/10Herz.png create mode 100644 src/main/java/solitaer/images/10Karo.png create mode 100644 src/main/java/solitaer/images/10Kreuz.png create mode 100644 src/main/java/solitaer/images/10Pik.png create mode 100644 src/main/java/solitaer/images/11Herz.png create mode 100644 src/main/java/solitaer/images/11Karo.png create mode 100644 src/main/java/solitaer/images/11Kreuz.png create mode 100644 src/main/java/solitaer/images/11Pik.png create mode 100644 src/main/java/solitaer/images/12Herz.png create mode 100644 src/main/java/solitaer/images/12Karo.png create mode 100644 src/main/java/solitaer/images/12Kreuz.png create mode 100644 src/main/java/solitaer/images/12Pik.png create mode 100644 src/main/java/solitaer/images/13Herz.png create mode 100644 src/main/java/solitaer/images/13Karo.png create mode 100644 src/main/java/solitaer/images/13Kreuz.png create mode 100644 src/main/java/solitaer/images/13Pik.png diff --git a/src/main/java/solitaer/Card.java b/src/main/java/solitaer/Card.java index 76cc107..a5b7128 100644 --- a/src/main/java/solitaer/Card.java +++ b/src/main/java/solitaer/Card.java @@ -1,7 +1,10 @@ package solitaer; +import java.awt.Graphics; +import java.awt.Image; import java.util.Objects; +import javax.swing.ImageIcon; import javax.swing.JPanel; enum Symbol { @@ -9,20 +12,31 @@ enum Symbol { } public class Card extends JPanel { - + /** * */ private static final long serialVersionUID = 1L; private int nr; private Symbol symbol; - + private boolean faceUp; + private Image Up; + private Image back; + public Card(int nr, Symbol symbol, boolean faceUp) { + this.setSize(72,96); this.nr = nr; this.symbol = symbol; this.faceUp = faceUp; + + String cardName = "" + getFileNr() + getFileSymbole(); + ImageIcon iiup = new ImageIcon(getClass().getResource("images/" + cardName + ".png")); + Up = iiup.getImage(); + + ImageIcon iiback = new ImageIcon(getClass().getResource("images/back.png")); + back = iiback.getImage(); } public boolean isFaceUp() { @@ -37,10 +51,41 @@ public class Card extends JPanel { return nr; } + private String getFileNr() { + if (this.nr < 10) { + return "0" + this.nr; + } else { + return "" + this.nr; + } + } + public Symbol getSymbol() { return symbol; } + private String getFileSymbole() { + switch (this.symbol) { + case Herz: + return "Herz"; + case Karo: + return "Karo"; + case Pik: + return "Pik"; + case Kreuz: + return "Kreuz"; + default: + return null; + } + } + + public Image getImage() { + if (faceUp) { + return Up; + } else { + return back; + } + } + @Override public String toString() { return "Card [nr=" + nr + ", symbol=" + symbol + ", faceUp=" + faceUp + "]"; @@ -63,6 +108,11 @@ public class Card extends JPanel { return faceUp == other.faceUp && nr == other.nr && symbol == other.symbol; } - + @Override + protected void paintComponent(Graphics g) { + // TODO Auto-generated method stub + super.paintComponent(g); + g.drawImage(getImage(), 0, 0, this.getWidth(), this.getHeight(), this); + } } diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 520ae04..73fc4d0 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -16,6 +16,8 @@ public class SolitaerGamePanel extends JPanel { public SolitaerGamePanel() { setLayout(null); StartStack a = new StartStack(25,25); + a.addCard(new Card(13, Symbol.Karo, true)); + a.addCard(new Card(1, Symbol.Karo, true)); this.add(a); } diff --git a/src/main/java/solitaer/StartStack.java b/src/main/java/solitaer/StartStack.java index 79b3242..2ab0504 100644 --- a/src/main/java/solitaer/StartStack.java +++ b/src/main/java/solitaer/StartStack.java @@ -11,24 +11,39 @@ public class StartStack extends JPanel { private static final long serialVersionUID = 1L; private Image im; - private ArrayList Stack = new ArrayList(); - - + private ArrayList stack = new ArrayList(); public StartStack(int _x, int _y) { super.setLocation(_x, _y); - super.setSize(72,450); + super.setSize(72, 450); super.setOpaque(false); super.setLayout(null); } + public void addCard(Card _card) { + stack.add(_card); + System.out.println("dfsfdsf"); + addtoPanel(); + } + + void addtoPanel() { + + this.removeAll(); + for(int i = stack.size()-1; i>=0; i-- ) { + System.out.println("for"); + this.add(stack.get(i)); + } + } + @Override protected void paintComponent(Graphics g) { // TODO Auto-generated method stub super.paintComponent(g); - ImageIcon ii = new ImageIcon(getClass().getResource("images/back.png")); - im = ii.getImage(); - g.drawImage(im, 0, 0, this.getWidth(), 96, this); + if (stack.size() == 0) { + ImageIcon ii = new ImageIcon(getClass().getResource("images/back.png")); + im = ii.getImage(); + g.drawImage(im, 0, 0, this.getWidth(), 96, this); + } } } diff --git a/src/main/java/solitaer/images/01Herz.png b/src/main/java/solitaer/images/01Herz.png new file mode 100644 index 0000000000000000000000000000000000000000..62d0956036088f5c44006ad1f8e3bcc22060673e GIT binary patch literal 523 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FcyzVAc}{hNBKI z|FvH;lj!-F;`~XpA~dXLQ_>XC#cL!|k7{VgP4WJyy0jv&OMU4N>o6Nl_k}V?yNg8h zy*@4xsXyK|yGTU*sYc!@xQaVd9(iiUO?l+1ISm4Eakt!FczeW0sC5!%>Hq z|JtwlYiP{clD;9lO+4|ahPGRz;i;~`u%1ni7TI*=YaVsgw9`C#f8(RcMIxsHW2P+L zp>fpPvTJ`bh-@zs(SHgQe6&#J==@EOmWs@u@@SEW_)-gyviV)@K^py!CV$eXJJ~fo zs3xeZJ1Ay~lV#WcjxTDUNUEM`Md5yX=2u&cB zi)4;26yaa`!wck|{>YC(eIQ$1HTAqc0%e!V9Cg-|^ZGayrq};epoaU$sX!aSa+X~{ zgWH2@ye+waMj!6#{-m*QDbS@qmH>Sa{4t>GKhU@Fo06u8E?y&%iX03>Oz0nD_^v&E U`5oE^fRWDN>FVdQ&MBb@0DH9N+W-In literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/01Kreuz.png b/src/main/java/solitaer/images/01Kreuz.png new file mode 100644 index 0000000000000000000000000000000000000000..a202c885615d14cccd85cbfeb05b50a1036c08b3 GIT binary patch literal 564 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!Fcyz;3{o)0oIMd zzvH(sF|+aS`&oA(=tf|od#kKySqPAke^u^Ayw;nwhxUcs*f0ET>8-Xb>2G1Vhwo{< zS$wPQuXUpQRkJsNxrgmm*>2d*RULABLp@Liq&m8FZ|Du6%6%a#z8%;XQk?)a#=F&a z)!zelhwMO1pmcOA$h5bOdqZyr0L=i2{smf5+fo~HV>(y$>J8ho|nPEWpnE~wti}Jq-OawXgR@>gzTA-jiNFUTu{an9+j{Fytdsq(W zUhl2EzXhRwS$qiM6L*7UHx3vIVCg!0ES=`5dZ)H literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/01Pik.png b/src/main/java/solitaer/images/01Pik.png new file mode 100644 index 0000000000000000000000000000000000000000..faa496eae00ca694295a9816f5cb18d65c464a15 GIT binary patch literal 506 zcmeAS@N?(olHy`uVBq!ia0vp^oAx>Eakt!FczeBbPL%h|9*R z@Ag~RqDYGbx5|o^h1>{CbZ`9|x0Uy|eCyuO>V*2>#QdxGHn?wP-xhk~eQWK? zZ3}O;?G3%XVLR9F726W~v!o&7A-92Qcz>_>cHo}Y8}HV?3lG)lzgc`}U&xJUpgA|D zb5)1jSbRwCs@WU%Lv|n)K*8wNT9CF@Tdkbc+Y2ds r66D}^kSl=Ra{&7i?%koo_{(l6_|9+QuMdxaamwK7>gTe~DWM4f_yye^ literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/02Herz.png b/src/main/java/solitaer/images/02Herz.png new file mode 100644 index 0000000000000000000000000000000000000000..559fbbebcda0b7e008345bf5cb0327b40ea46200 GIT binary patch literal 530 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FcyzV3w>S!x4v< z|JuXY#HJn8H#--;VD%b_)T0{OZjpwkx&p&$7TR>_Pl^5*)HOTkkA2vkDT@R89xatQ z>TKE79&~5QqyHPBy!RSMoi+2kKK_pYtF3X@l=CVK?wb8cBhL$HM*F9gKV-GzKtlV2 z`W`K;(TY12sNw!GNbV^Al*KS9|5Jf`raW3E!v9o5?o^-+P@=I&WPjRGZ;;8YMIz=) zcW54U{uyF3BJ_&ilVg)#%N6CDz_@1c MboFyt=akR{03n{`wEzGB literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/02Karo.png b/src/main/java/solitaer/images/02Karo.png new file mode 100644 index 0000000000000000000000000000000000000000..028c2762d7bd5cc0f5cb08fcb3ce50cc3dc7e4ef GIT binary patch literal 546 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeW0sC5!%>Hq z|JtvqsED}UmfIKJCZ2dyL)$IV@Kje|SkIv3yNMaG#T9S9_7j zbRY_{nX>qYbr_J`0c3Or#dsBJx_?~0rb6TB?4Um`ntDqufZ_}Gh)xgE2>-Y&=BR$; z$AB*Lr9Y;DG;6qj{6FPU&^n+EBBuiXw2AUBtqAT~KV@-+M*pMeQ(!X}$Q)fNbJTt_ z#Ck`|F7u}vAR}dtE(DrTvlQg0^FaIDK^8BQIm*5i=n^pZ=u(k*O|URf9_(nK)_p-x zr-M8YRO4;Q^;Dzoa2Nln&^?;*Kv(Y3JnCGjt+(_?XOZas6y#t?nj*S*jYR4Y6Z*^k YNpqjy_Je*$fN{^@>FVdQ&MBb@04|v6<^TWy literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/02Kreuz.png b/src/main/java/solitaer/images/02Kreuz.png new file mode 100644 index 0000000000000000000000000000000000000000..8a0fd4621f952f65b945028e960b8785ba6395c7 GIT binary patch literal 574 zcmeAS@N?(olHy`uVBq!ia0vp^o6H~ja%;k}jjs@a>xx7uu1 z<=$9)$PP&USBLTKLx4hZK>2#nZ-I&WqTl#MzpdD?_Ey{8kQLt!!~u<(4l>4ltNac3 z8}6-pLvF-_OmW)E`#bDyW9{l~3vad6hTQOO{ks&%Xn`kgw>RW>qpjAPrHABz-U7Qv mZUxjQNWldUw;{mz%l@!hC6@j9?H9mw!QkoY=d#Wzp$PzocmZbs literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/02Pik.png b/src/main/java/solitaer/images/02Pik.png new file mode 100644 index 0000000000000000000000000000000000000000..0a1e2742c2958a1adc8208604cbec9d62793e615 GIT binary patch literal 517 zcmeAS@N?(olHy`uVBq!ia0vp^oAs>Eakt!FczeW0nr50P9Ba z@Ag~lL`1fHthl+^L-Wmw4T}%;aan7<`MoOl#(#}B%d_}_SbjtJ*7+OUx3X^wz45)Z zcEz@Zx7zjs6)e8hW~=okH21LFRkNJc8{TtQhu#J%vAO+<;kHx9ZygyO7_kKs!NZB(CTB-30S8-0wq#@r!+y{YSs<-U+LL(aYfJ>gTe~ HDWM4f5~%(% literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/03Herz.png b/src/main/java/solitaer/images/03Herz.png new file mode 100644 index 0000000000000000000000000000000000000000..05c7794ded6624585c53161a173f95268e28fc8a GIT binary patch literal 532 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeXO@B^!x4v< z|NF0rh?w-6+o(IcMHrsy3JmMnlr%+j@tPkFJG=O&Y=5*+B;V^}`I?I0J}1kr_9Bt# zKoqn`^XUDJj~2=tT`F_5e9EJsF7u^7tix=kJo44tw*)8((z7h)=;f4BQmy(_LvLwCaF@3w6v=D2f6Rs&xfo*Q z(weXsuaC@6HU71W@&naB)z}Areceq+SCR+U~DsZ My85}Sb4q9e08{(q1ONa4 literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/03Karo.png b/src/main/java/solitaer/images/03Karo.png new file mode 100644 index 0000000000000000000000000000000000000000..da7c45d468da5f8ee534c8eb10823f26b53153d5 GIT binary patch literal 547 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeW0sC5!%>Hq z|JtvqsED}MS8oV!6Hh#0Z z20!vX6{z9m7T#*hlK!@8TVg+u zTCpK~EAQ|6LvdHl-UQ|z{uhwg&s80Ad&7UNH=&90T5rrj;)&5fH3186G5-#D+gQ6| z1Hb6E72lY@aaD)jXy^JJ_O@}a7Enw6RXLzt(yMYIHsu2u+DL}HZLM9sE%823bn&e= zTdgA!>Eakt!Fcze<0@u$0oIM- z-|e?BF*BQ;jJN8ZcBqfbTI~-+Ywd~+ z|ATT5%ZYwlcnC^sD36yy?w}y#fSa{0Ikt~lMd0BdlEakt!FcyzV3w>S!x4v< z|JuXY#HK0gn|%vkuzHO|>QN1Cw@AZNU4dbLTq{N51G{Di-I?;}|HenlWLk?v=1*C? zL-VMw=0ADuxKn{PAYT8YWg_NFf7Gw307(EvHGou}S7ERmke=fHF~CmLKKZCOQ0QYo z-=l!8*`HQcXu2R6`D^31}VA)CvutzP?A&rvm@X5Y=A_v~pq1 zQi~}-oA{pwe+=l#2g*x_?SUxt1l!itUL^8=3DCiPkEXBL0k*&%XC#VFn%T0&Rkc`~>8-4|GA0gP(~Pgg&e IbxsLQ0J_58k^lez literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/04Karo.png b/src/main/java/solitaer/images/04Karo.png new file mode 100644 index 0000000000000000000000000000000000000000..4c37a84176457f1d57be15be14e0b4bc114837a3 GIT binary patch literal 547 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeW0sC5!%>Hq z|JtvqsED}UmfIKJCZ2dyL)$IV@Kje|SkIk amHMq+hx}BP^v!^g&*16m=d#Wzp$P!+MCMxn literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/04Kreuz.png b/src/main/java/solitaer/images/04Kreuz.png new file mode 100644 index 0000000000000000000000000000000000000000..acbfba91d74e04b725ef4ca882230a8490378765 GIT binary patch literal 574 zcmeAS@N?(olHy`uVBq!ia0vp^oZ^%!S2bvU^d$&sE=!iG5#}fPSJ{;F~2w*m@XJRUHx3vIVCg!0Fe$E`2YX_ literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/04Pik.png b/src/main/java/solitaer/images/04Pik.png new file mode 100644 index 0000000000000000000000000000000000000000..d33a44881739141cd42462d9b4baa08a42f8b188 GIT binary patch literal 516 zcmeAS@N?(olHy`uVBq!ia0vp^oA$>Eakt!Fcze<0@@VF_(=N zzvH)X3Gw{=@pfT#!O{(j5A|_bYrR>q;r{AviT~Xb>qDy(;zMqDZ{5GaeJlI6&>Qbt z_lDdK$UXcoF!ykr)|?=5zjDu`RJbOZrEakt!FcyzpqGLp!_fmz z{P<;gL>I4-NIj~d?H2j5@soyKK;BVr%{;G<Z`eL ziHP~qAJ$=erYx?|aQ_(8rLPGT{nsa|zjTM@QRkha<{;X)5~wOb?x^$6H9sV^Bwf#%N+`qLj| zGv(1Tpy=jD3q|e+^gS|PQ=#ep5yPebp3%rk!)x@XEGW1y+&Fi#tv>Iw|&K?#Q;BDA93!+49|9&?2U Qz{qCsboFyt=akR{0HPP;4FCWD literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/05Karo.png b/src/main/java/solitaer/images/05Karo.png new file mode 100644 index 0000000000000000000000000000000000000000..45d75cae6bd3abd070b5d525dcbf2727d1f4a127 GIT binary patch literal 548 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FcyzV3&+1!%>Hq z|Jtvqsff7l-dnMcEv`j$@fwNLqZ-<7k%p(b_)mq_1l;Rt589)7^!>(1zLs21HSSG$ zq`kC4!~J9R8X#Gy>HaaGYyFf*L4A+HBY{lwr8}lKe)?#C(wpKpi#mQ*?mAmg5-{dpIW?Q%HkgjWR5PCIcmT8 z(L#}YuaD+lK&yb-*nuVht$5_`^>LZV|1(|fMIzISMB+7pE&(Zbw(RoO)LZ&vGFTWW zZ~jzc%3_d1fz|{-RfF^d)hv~1EfTR$1e&O2r_m2|9MESA_lQmp`qNt^YM%lNgTSz! jO-WNwf@O#Z{bm0ca=_2&XlXhy_8B}~{an^LB{Ts5b-L%O literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/05Kreuz.png b/src/main/java/solitaer/images/05Kreuz.png new file mode 100644 index 0000000000000000000000000000000000000000..7ab055a1da5c0b484637a7de6bde9666e635e393 GIT binary patch literal 575 zcmeAS@N?(olHy`uVBq!ia0vp^orH6x z;eT^Cgm2}o4!OM{y!G$WLvmNm-puE!4!z;tYP+g7L0)uQ=c1J%{R6ZA-KV8s-kN z4QTw|pxncDhvGzmhW=j+vKOeepX>M1TlzN^gIu~Cs4e)$>RWBLK%+p$ffWIb+z(U; z!a#$7eo5TlQX6tR0O*RVW;v_3C9VfL4JZfn%dIvL26`UkOQCPUK=%i46^Hs^!~ejy xt$#z_HgZ*m{AR6gl@%=uxe=J?KExPT>JtyE$KKsi)Cx=(44$rjF6*2UngE1f{>uOW literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/05Pik.png b/src/main/java/solitaer/images/05Pik.png new file mode 100644 index 0000000000000000000000000000000000000000..6bbfab9ab0cc9d3dd2965c4bc39c19da4c70ae18 GIT binary patch literal 519 zcmeAS@N?(olHy`uVBq!ia0vp^oAw>Eakt!FczeW0nr50P9Ba z@Ag~RxVUcBRNvg}q4{RThQ){axU99_{9cuN--JwTiLgT-uT{H zyJFkITWz%~Hrx-nvHDhN zaRzGJ;NEJh^(HX)@IHk%p^5Tf<~Fd7@U6VnKy`;eJlVwcT)zVn_pbyQXAk65hpgC^ z7%vPom|yf;JCJ(=r1foUtuM^_e4rB+ANm&nvLDDSZ-F>*FUV!NhvT5S76Tpac*Fmy z91zEWT<8pPPH1AhKv~F*z(n^}SAUiO5sFc1T%QL`njxgN@xNA-NoVb literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/06Herz.png b/src/main/java/solitaer/images/06Herz.png new file mode 100644 index 0000000000000000000000000000000000000000..04e7477972180d16619eeb2ee187d5f5113db8c1 GIT binary patch literal 540 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeW0sC5!%>Hq z|JtvqsE8cR@81~SCZ2dyL)$IV@Kje|SkI3h47K-G16>7E?iROEKTn1Dcx(CFW{%Pe8No_fh z(DWkFQ-L;9{Es?Yay`|M1Dfw_*)<=g(Y;U;h>p$?GfjZ2A+CZMP)0_`Eakt!FczeW0sC5!%>Hq z|JtwlduViROWzRQCZ2dyL)$IV@Kje|SkIwTXxx}9(C5dH|0?f*HbMZ70~yn`BPYo*TR^ivx`Lcr$8mw z0S##n(s2LyAEGPfq&XW`IlA%gA4(oN|F0Paz~fS9A$s1q4!jy?hH`F9?hdm zf$k{ObYBP-=UcjC$|G%%Ci%^efI>jkPy})lKTsoB0n7lPv!^VE_@F(=X3F9nQx;o* z$Vbtq0)cLk4yy@R_edM;ZeLBgQ_+Q*N9zOEJ(|8oA{9AElBS3*9%4c(>L2-^@H1>| Ro(oI_44$rjF6*2UngBT#?-c+5 literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/06Kreuz.png b/src/main/java/solitaer/images/06Kreuz.png new file mode 100644 index 0000000000000000000000000000000000000000..c79e6727f4bbe41ea1f7faf32a8f222191b92cb7 GIT binary patch literal 584 zcmeAS@N?(olHy`uVBq!ia0vp^o+S^9566Xiv}y>F=vxgC&u*ltzs4SmsX ztF|Tn_q(zBR+}x5zxY<$-=&A-uA04>&s80I!@bp3E2KI>UUXaN?G620SLJTFZ)N`$ z2r^~GH|}pxC97(xxFF0wKn8NJWxm*V(E%)iTzp9KwXFGfEL;V zjdS11TO9(l;cpPoDTm@jfyVZ8{ayhQ2U@@QP~A$P4J&}Q{$2@mlnBV3U=yGeSbyjZ zeV|$p4utwAQ66kPP$kgr)raChQi=5|w}J4&Tg=r!i}$zu4SC!6H|T96(1{=)zNrtX w20E#F0np=h2jddmTV+MdLT&^OF~(QmdKI;Vst0021u$N&HU literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/06Pik.png b/src/main/java/solitaer/images/06Pik.png new file mode 100644 index 0000000000000000000000000000000000000000..35e3403c443db87800f4c90e66db2ee282171b15 GIT binary patch literal 527 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeBbRi9nCr&s zZ~HSuYYZ%w7?<$R6DbS15t!)SDl7V}`l{KR{~B-nugbmAziPLkKdb)Gye$50p*P;Q z)~?*P@Kzg;OsroCl#u=wa(lztLv{LZ7T;>K1!@CI{PzZ`+OR(aq&norbgpWxkm?Qk zqTiMtng?WqRM-oA3rvg$GQTYVniX=xeJd|WV#C^7ZGYWvxP!DWhZ^@y{mo*aKA_3z zhwQZ8c(>X@4Eo*9RlTYzopr03FK&s{jB1 literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/07Herz.png b/src/main/java/solitaer/images/07Herz.png new file mode 100644 index 0000000000000000000000000000000000000000..b16d6637329b15ee268ef5dd4e3df5d40c96b6da GIT binary patch literal 525 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FcyzVAc}{hNBKI z|FvH;ljxC5cm5<=5gOLBDQSx6;x!VfM>VwVG^RiDtkl-?`nW`-{&<)AQ;jK$f3yX~ zOnKy~`L9pZ{HccCslXaf%dYMq8_lElH$GY>;_vlQb?FYxqmzLmK+T#{ybA;Gb5E zF8*N)_K&aTJ&^FcDba<&UFJ{M0v+HMX?UtD5XI+1OX!t+)Rql?JLAh;fYHq0>FVdQ I&MBb@0FB<>+yDRo literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/07Karo.png b/src/main/java/solitaer/images/07Karo.png new file mode 100644 index 0000000000000000000000000000000000000000..854f4f072eb4e64329009bb1627dd82253d3c8d1 GIT binary patch literal 542 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FcyzV3&+1!%>Hq z|Jtvqsff6KU-Pj>GOk5*@fwNLqZ-<7k%p(b_)mrI(Y)W~t$Arn%kAnIhxt|J*@ha4G|L7n2F`&zQ>5qv)Hd7t}<(fZ*#ds}@IXb&Y zbbrcGXOJngi$wUB0;SGRc@(tnQFD>VslY#NqWnuMg1hp)J}$HAlGp49nF*AcUL;a~ zwyQm8kLFSKryBRBEC!iaB+?!fnt~DtfnhyE cP3Rvp^OHS(f=*(uf$`4Z>FVdQ&MBb@0QEakt!Fcyz;3{o)0oIMd zzvH(sF}E4+`&oA(=tf|od#kKySqPAEf0gZq=~?z0+*|jC+}JPtEhyJ{EAQ`m(Qhj@ z^k+$bd*4zUa(jb2P{?~LZ*|Cx#kbo21}DmkehW&hU%8>5>-MVL8{Vy1{BM@tVy<4f zVLDfJ$nVBlpeCT`-xb?{DuD{N1LdQ)@?JH2v-nV))*F2wLm9#Z+4}pyzR=qn@_~YZ zxrgOICfkDyy#aR7cAy);P68S(f3+^5p9{zUsg1q?bW}CaZTX_#)*g}rn_UOw?uR(H zdgZo6`$KW7a)EBR4{`$6Zy>9m3*-$DzA6XO|JxhvHg}*?!A`&Nf5o@P+ST72T5VVT pJz#gJkIP!?&58|+hZy6P{jXZZ*n_r#Yk&!Y!PC{xWt~$(69A(@7Lfn| literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/07Pik.png b/src/main/java/solitaer/images/07Pik.png new file mode 100644 index 0000000000000000000000000000000000000000..9391d2aa16195660d813fd540438e04da4647c6a GIT binary patch literal 510 zcmeAS@N?(olHy`uVBq!ia0vp^oAz>Eakt!FczedZxkXmAEaXODqI>J#xUIau`gjEd+n-iiTPS@_(i|1_}28-2WGjy=(m-J{sn*x23nurvUlaSg}2&3iswTVZ*T|t zrE!Bl(EZc7eg`GiuK+nPEakt!FczeW0sC5!%>Hq z|JtvqsED-w?%x>RCZ2dyL)$IV@Kje|SkIEau589)7^!~<2zLs21HRMhO z#sHDm$7Le*$Gh5#M5Y4~NWoH(e6Nq?YbrF3&JF^pfGWyA6}m^WwMcaOrwdFwi z_@Az=(3lU>dn(Xo%IY6&MI!deN1ZkAO?ed52S#1yOLt6J3_)P&G^jLK;*qbW-qYYh z&7npHIM!e?0YnQO+|2@lO?h%oh`fky*~P%3j8xqG+rb8W9z3d zn<+p8?@e+47|`W^YWbt|H4>@Fp^!91bny@qTJfKua^gO}?Ocv?ff3K(>FVdQ&MBb@ E0Mriby#N3J literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/08Karo.png b/src/main/java/solitaer/images/08Karo.png new file mode 100644 index 0000000000000000000000000000000000000000..064e2349b1574d44e467959dcf1e8c1b688ecee5 GIT binary patch literal 557 zcmeAS@N?(olHy`uVBq!ia0vp^o>Eakt!FcyzV3w>S!x4v< z|JuXY*rq+Tl?CYrS_2Ue z=j9%P8kl*K!y0G+uWL@x#^xCgdnA=F*`Pc`(OYVZNcr9g`` zfGRk(?KHwaI#$A62-F@Ab}}?HdNw6Z5nYTDKtn|66~EHKQ+`P^)~^I60|rl5KbLh* G2~7Z3R`Fo~ literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/08Kreuz.png b/src/main/java/solitaer/images/08Kreuz.png new file mode 100644 index 0000000000000000000000000000000000000000..3ed11e711022282641ec081ed3b971e7e6ffc9f0 GIT binary patch literal 588 zcmeAS@N?(olHy`uVBq!ia0vp^oT<5L4)uBMef4zYWhzdENHG#Q@<*vrvSPxbQwcbwa z4af$;Z>u0SySD<`(2HG^ybngR4m=xv}8AZPrZ4)nI|hHwyTL;O`aprP_NRv!Xd4-6Fdt>Pe; s1I_)${*B98>&=P{ix2e;HO7C&%>iby4+9eTfT@JR)78&qol`;+0PV3K!2kdN literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/08Pik.png b/src/main/java/solitaer/images/08Pik.png new file mode 100644 index 0000000000000000000000000000000000000000..65191129baf87ebdebad122c05e7a85391a935e7 GIT binary patch literal 530 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeW0!V>kn6_k zZ~HS$Z44|l|6Q=<(0sFE!{S4IT-I7|zOTx?@jviJ{8hO(>$BoF^k>y4`fp{w4U{;v zFXVPW?qNHig5cc4^SFMm*anp11xq0WgA)B)Ygcagzhc9E?%yjm=!<>}xxHcetu|ZH zZ%Yr&9l_mX6Ix&7#F3^GUP=i|k zI=2Fy05nLREakt!FczeW0sC5!%>Hq z|JtvqsED-QPW}_#CZ2dyL)$IV@Kje|SkI&6G!zKdt;Bi|~HZ6w$?NBvO$>WJn0TvTuvpEakt!FczeW0sC5!%>Hq z|JtwlduViROWzRQCZ2dyL)$IV@Kje|SkIM`sZ1+a+yZ39`YDfmHS5lFwHJX@-w)~oiUHjO;s(WdeVhswwof}cyGY~|&`h9A zkPX;K3lRAz`c$BX`$y@pnt*kWnm=g(UG1wW2XgY!`oMLMrmvAmMGlgrDWZ#qn9z!P Y{jL*!CjU=l0TTg(r>mdKI;Vst0NttRVE_OC literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/09Kreuz.png b/src/main/java/solitaer/images/09Kreuz.png new file mode 100644 index 0000000000000000000000000000000000000000..1838a50cbb13577f5a97cd50ea8dcfbf4e3370e8 GIT binary patch literal 584 zcmeAS@N?(olHy`uVBq!ia0vp^o+K)m>noz|QCoWECWTX?IjHsp3d?%_Dm zZ>zQ?{`b4F`c|9ms@xlkq0}L{t7dQJb5)1laBsEM0_v0#-4=R#LqFG5xf||V*}nxQ z%8Pzm@s0Z%R0&k8R>ku9!{4CX!*+*&ZUGv5Rc-}H9BBRGLv<^GHmm^J`g`TAw!b1Er}k$_f13`( zU`0UZ=>rvla3IhGpd<8w2ABbD1l!uW7v!u%|A3|gG01M90ri|f!Eakt!FczeBbTz92dZYl{ZJp5wbq*z8x|j`TYszVZ~vixA#V@dWdQ~ozbZ@NkSZnKV+x%#=F&4 z^xM)y^SFKoCHjNdKyC6IzgKL~2Qz^t0L21x56|PO*2-DEEpfl#w?L5o#kbnB_`ikx z76x+tTeGCU87Inv4B8h`9RL*g>)L92)o#Ol&fhD*_WsrfIbp;86(BbORZAzvugV2V z{a<>ktv2LFd?1PE|O=V7WZEakt!FcyzV3&+1!%>Hq z|JtvqshGH4Un5yB8P_7Zc#TBrQ4MXkNW)WI=1YG}EE4ti`nW{of1hall*JXneNL8L z{7Wl>y6TU2sXx`)r{P|x2}DOH2mP@Q+oO3@93Eakt!FcyzV3&+1!%>Hq z|JtVs3(Z=TUG}j?GOk5*@fwNLqZ-<7k%p(b%$NR{SS0H2^>K;F|31<9DT^zD`iw^IbZN{{@uwO?n6Ie_?vmF8x=jS=y@eo${tEakt!Fcyz;3{o)0oIMd zzvH(sF}E4+`&oA(=tf|od#kKySqP9}uk}X%s@x6l*1aJ&_6vVod#mm5ifs#Twbh2) zaNo-NyZlhxD%%bDSIyo8<{p+4{kCFT;{T8v{anAp67_++4M6pKLson{08%xbt9s=I z_pS0b+z|=_au4qdtxmYVDi^3zUi4c~V*N@W17vM9$jZgH*gOyX8hnU9;w0tR$|GUvv3&_|PdV51YSpQbu>X6$T+*@r|<=${_1v(pSHprNu z+{1M(e^+dfziI|l0dy@;4oG?fJp{x+?}EJM4RWRTR(7D9z+U+u_?G#1*xN>~YM@oM jEzt0R2h+%`2}Vqoxe^>bP0l+XkKWTW{s literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/10Pik.png b/src/main/java/solitaer/images/10Pik.png new file mode 100644 index 0000000000000000000000000000000000000000..fa6024a62ff2f893c71d3f995a76ac9b0fe78663 GIT binary patch literal 507 zcmeAS@N?(olHy`uVBq!ia0vp^oAt>Eakt!FczedZxkXmAEaXODqI>J#xUIau%5h>dgX@cS<>HDY)gy=s=qNiiytIc9ddhvd+Xkn8}voLRVT)4y$J?!z#{Ig zwpwoja}U=kyzy?WUA4hn^xF!E5kUFet7dP^5A6%Nv7DXa`Lmp_rTh`w*L8h;~)n>aY_r~Hw{{n#OrGd=+7NCRmubKg!FrDkSGqQDm zy|=P|TLxCj1$4MPhqcz56&n^G>f;(>jQEakt!Fcze<0>fz5!a2y z-}k==5wKgdb<5&I-fewSR#`7rEL;p^{MzDrKj-3X-Kwpw|Ic5Ty_Wsg+O_Oen_bs$ zd+}egYU@{*`P=5bI4idI)}sIEFD{GKZg$Pz_Tnm#U$rPaddpWA|LFNI-t*MnS_Bk6 zdrke<#;*?1{9lq^cm7Lw-T3d^h2^@x(z@^ETwJYNb*pN@a-i8j%Kk>xg8gP+GQ0QP zTx1^oC98YhHoJ?L#r__=#{9Q?p?~xjpoKSq=6~7p)nWfupaX3$*dx2tew!T7Eq|{8 ymG4GYp7omj?~O$eC&`+YT)7bF?9MyH82Z9T7x+zZkN*gaOa@O^KbLh*2~7Y>W#t9{ literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/11Karo.png b/src/main/java/solitaer/images/11Karo.png new file mode 100644 index 0000000000000000000000000000000000000000..422760bcef3faafc7f96a63829da8cf79b035983 GIT binary patch literal 518 zcmeAS@N?(olHy`uVBq!ia0vp^oA!>Eakt!FcyzVAkUR29|^G ze#`Ir-grPlGw#v)10j)yr@8{edNw6Z5na5dBB;xM$|E<;dzwe@Z+zrt*(I;(Ubt99 z|5V@~S?zn8(;s>66fyTI4D5U4ANg^K$b5~Xy+Jak0`F+N@9GZHnEq&Pk>8BccK$B;Q`g?us47#J? z4%E?GB+?!fGv$#d$PMe^mc&e1TmiIok%;)xiXb2@gCw^{!yV+J0FbnOP@j`!SAGP{ zaeIQh#Gl3%1_Hh1{ZUoh4aK(-sYf-2n9wWvJEakt!Fcze4I)|(X@76Tc-gA(mSZUnd1uGsKj{msf-ZGV^EYO@W!5xtf7 zcl{x|km`f`fOwwP8=&yt@WgnnH|<>2t2V5?)mFPA;4SNKFiw;Q$&0_yedFEwHz3hp zbXD$+;H}~yLhoNZR?vbgthE56xSZyJ8zi zi}zN2h$Kj{$hW13>Q-!6&Q-l~TVlTGH;{9HcyGw<4g5g8-cY?-Z-6e_8*(EaXfP13 z_|~*H^!A4REww8*08Ly8^bpXEakt!Fcze<0@@VF_(=N zzvH)X3CaCA@^)c$!O{(j5A|_bYrR>q;r{AviT~Xb<+a{)b5*bY)@HlPcEj33b^34C z-fH`+f7R^G+C%?BZf|hk%6nVu&G$q90^c^)uK0G~p4JNEfV literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/12Herz.png b/src/main/java/solitaer/images/12Herz.png new file mode 100644 index 0000000000000000000000000000000000000000..cfda3461d174a4f960546b2ad424cfb89ca2d98a GIT binary patch literal 509 zcmeAS@N?(olHy`uVBq!ia0vp^oAr>Eakt!FcyzU{(yLh|9*{ z-|<_XIW}kB=~Vy86_fd5#lppHeNt9gK!$(xm(16)wKo@)M}K+GQ@i==g8XfAUp9SR zFkQE5yX*gR7j~}|{}mtoWs~dsZ7=Ri{@UXDKf60_+l#wmdv8}QERWvu)k!~k{)_WG zwYL_{&$WG#`dYa5X4Qpj&HHlpUf>5BmELBTdlAG)?Y@_L@$|LkIEeZ3IkqqQd4am_ z1C{RvSq3sEwYzS^*9H3xzhrjTWxjU2pK}o?1yrD)d+|L`gFZ-ue>6YP89?U%4Fj63 z5480?NIZX=-Nn;DX92wu|KhY*?X6!f^=Zg{g?oAkF#a*GGg;)9cJIhFV6-xLy85}S Ib4q9e0Q%(v)&Kwi literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/12Karo.png b/src/main/java/solitaer/images/12Karo.png new file mode 100644 index 0000000000000000000000000000000000000000..d9f8a0bdd01cdd01dc5d68843dd77cec9c97dcb0 GIT binary patch literal 525 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FcyzU{;JH!x4v< z|JuXY*ruhwfZ4>!(`(JT>)}0>yrWhS_KywbwklRHPlGt{liX6}l&Q-J|w36+vC^HQfs} zTZ=^Q2X}ez?BYKasNw!m7^K5|%HoQ^xGsH7{i91|jqv*GKbHfqR1c zoGd}AWxNVCk4_HS6WsMb4M^8`0!4vB?jIM)0PUF`WCJqZ{o{R*Rq9VQ=7AmPZQ12) z+2yUdZ;1@hX8S~t#(;T10ibufKdl4$B7e&2ABsSa8lLJ34C_Jh`%n^k#UGxs&Mz`t ROBoo=44$rjF6*2UngFMY+-?8> literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/12Kreuz.png b/src/main/java/solitaer/images/12Kreuz.png new file mode 100644 index 0000000000000000000000000000000000000000..a6356c803084f9df3f5493fccfcf48710b0db892 GIT binary patch literal 552 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FcyzAeS_!nCr&s zZ~HTNMI>^xX8z-`(R{OF!{S4IT-I7Z#&oXgmETx@uh^h3`t5zo-&NZZ_pi#mvG`V- zt=1bL`PVuzewFQp|3QiUT-71BH`HsrS$gQ7cdM;d&gyN6@me9(2_Si(=B0<^uEuTX z2O9VrY=YBP-ru2b8-XS+ywz44aswznIZOJR;J2W}`taPtcB^U=KG!Z)Mkd6Zn?(HwQRC;2|?~ b82=e_eRyJv1X>;eQvidftDnm{r-UW|1-uLh literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/12Pik.png b/src/main/java/solitaer/images/12Pik.png new file mode 100644 index 0000000000000000000000000000000000000000..c57f94c6e7833bc0a408773c8590a376378402f3 GIT binary patch literal 494 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeV-^d$n9ISM z@Af4;A|@VJPQ+~$w^w?zV#DG?eO%UBZ+@@Jy-~06X6d20Reu|5Lw@sChg2s-x7Nnr z$iHg#W_y|QciSR=_Z!}=dx2upxqd?|0%}zNYOP!S rtqEu^NZkgYOPgR`gZpuaFn-Ca3EcGC)fJHrj7J7fS3j3^P6B| literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/13Herz.png b/src/main/java/solitaer/images/13Herz.png new file mode 100644 index 0000000000000000000000000000000000000000..5362efaa30e3fb203258bf8480fa91f838b12f9f GIT binary patch literal 511 zcmeAS@N?(olHy`uVBq!ia0vp^oAv>Eakt!FcyzU{(yLh|9*{ z-|<_PJ#5UpBzgQNS4`%M6$=-)^+{P}0U7?$Uov0I*4|uH9{uG#&)=lit#uo}I`yv= zugbZ&TlZIa+r3=d7ya8_Y;=9U?Zth`Ut3)7->zDCTx{=cpbq}3?XEx~r*_eNkj($| z*N*Yq>@H4UD}JkLp?);~uVdG^|DL(9T=&<#YuvWmUfdP4-4^!(Vm?^z21stPF4!)R zF~`MflV7*~JBA{>_d}7VbCslG%;oyiH%7=5Kqk9cbu#-r8G>{G;E$I1O=H vJdja)>z9kYamkenfzIx{vZh0f@t?7A$r8W5*LRG85zFA|>gTe~DWM4f3ykYk literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/13Karo.png b/src/main/java/solitaer/images/13Karo.png new file mode 100644 index 0000000000000000000000000000000000000000..7945855e66a25d9492ab292f4be330f9849bfef0 GIT binary patch literal 527 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FcyzU{;JH!x4v< z|JuXY*ruh%CmoM(Tem4`is<4s5~)WuwA~^9bbE)tQSvUmpw zJ#w||x}SX1`l;5wr6SXVVonAA(bAqbP~d2Fa06@ zR4Z&7(_WjCrryJ?~mc9ybCpf`YgM=ExZ1w9i1FhEakt!FcyzV3!Q10P9Ba z@Ag~7xTLC9eEfBJLeP!CME6!%(XtRALtpe;&|B_rfr;^2Z|-ycUU{qSZ%FQ8xvOSx z0u$wdBv35qZR20xR$Hw%fw_nOt=ur3>vud@I(jSb@1TXZm_Z6^S8f2BwBlP+ZOh(} z8}cF53G$+=a&P!wl>=h4klP#jxqb&F?q9hrQ66OFexTgqTkPM0fkptWv;}bw?F+f# z4de@b3regHPVCQ;28vGSs$Ti6323)>E681SK<t~eg0#4|?gg5BABf#SPRTtS zcPLKl&GIbiZ!5MX0xg7)zCbx32D${K%J+shP}lFK+7OW0AgBI5P`B!v1JJ;|3G#?= gfd|l#V0@L={=y$y_hZHvU>acXboFyt=akR{0P2hLRsaA1 literal 0 HcmV?d00001 diff --git a/src/main/java/solitaer/images/13Pik.png b/src/main/java/solitaer/images/13Pik.png new file mode 100644 index 0000000000000000000000000000000000000000..605141a81cf00f03aa591e7dc1c2ac5a34fc5f25 GIT binary patch literal 495 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeV^%V!i0j7c zZ~HS$YYdLe2yuINaPpx(E^DnfD>f`Xv~T^bw!i&{>_Tp|XW1v{U%i*upT(cEdc%9} z>hRpd_d;)PaNo*X9dg4PMBd)8_Rv24H|<&cZ}dgKt=J&1^~SliHvUFC*YD+7(hz~b z#C|T2N_~#s0g3xpd^-@Q^=9dmK|sYoW;V$F zc#w+yD}eTiqYLl?)mVen>;~Dg4XEk2Yb(ga+{616Ku%ckjTvYbNOSAnkQ?GHvZ7@n iHv$vgTZb0oO8t|Scl@5-{wfQMNCr<=KbLh*2~7Y(*wmH) literal 0 HcmV?d00001 From 51d1e8c7abe21278bb7d9510f7e607c38bc66bdf Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Wed, 26 Jan 2022 16:41:21 +0100 Subject: [PATCH 008/108] Add Offset for startStack --- src/main/java/solitaer/Card.java | 3 +++ src/main/java/solitaer/StartStack.java | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/solitaer/Card.java b/src/main/java/solitaer/Card.java index a5b7128..63b1d8e 100644 --- a/src/main/java/solitaer/Card.java +++ b/src/main/java/solitaer/Card.java @@ -1,5 +1,6 @@ package solitaer; +import java.awt.Color; import java.awt.Graphics; import java.awt.Image; import java.util.Objects; @@ -113,6 +114,8 @@ public class Card extends JPanel { // TODO Auto-generated method stub super.paintComponent(g); g.drawImage(getImage(), 0, 0, this.getWidth(), this.getHeight(), this); + g.setColor(Color.black); + g.drawRect(0, 0, this.getWidth()-1, this.getHeight()-1); } } diff --git a/src/main/java/solitaer/StartStack.java b/src/main/java/solitaer/StartStack.java index 2ab0504..66a25c1 100644 --- a/src/main/java/solitaer/StartStack.java +++ b/src/main/java/solitaer/StartStack.java @@ -12,21 +12,26 @@ public class StartStack extends JPanel { private static final long serialVersionUID = 1L; private Image im; private ArrayList stack = new ArrayList(); + + private int offset; public StartStack(int _x, int _y) { super.setLocation(_x, _y); super.setSize(72, 450); super.setOpaque(false); super.setLayout(null); + + offset = 0; } public void addCard(Card _card) { + _card.setLocation(0, offset); stack.add(_card); - System.out.println("dfsfdsf"); addtoPanel(); + offset += 20; } - void addtoPanel() { + private void addtoPanel() { this.removeAll(); for(int i = stack.size()-1; i>=0; i-- ) { From 0fccd2aba9b4494f43c66e732623baf9fd195cca Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Wed, 26 Jan 2022 16:57:10 +0100 Subject: [PATCH 009/108] add Image for empty stack --- src/main/java/solitaer/SolitaerGamePanel.java | 3 +++ src/main/java/solitaer/StartStack.java | 3 +-- src/main/java/solitaer/images/empty.png | Bin 0 -> 7063 bytes 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 src/main/java/solitaer/images/empty.png diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 73fc4d0..3577a3a 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -19,6 +19,9 @@ public class SolitaerGamePanel extends JPanel { a.addCard(new Card(13, Symbol.Karo, true)); a.addCard(new Card(1, Symbol.Karo, true)); this.add(a); + + StartStack b = new StartStack(200,25); + this.add(b); } diff --git a/src/main/java/solitaer/StartStack.java b/src/main/java/solitaer/StartStack.java index 66a25c1..e2cf44c 100644 --- a/src/main/java/solitaer/StartStack.java +++ b/src/main/java/solitaer/StartStack.java @@ -35,7 +35,6 @@ public class StartStack extends JPanel { this.removeAll(); for(int i = stack.size()-1; i>=0; i-- ) { - System.out.println("for"); this.add(stack.get(i)); } } @@ -45,7 +44,7 @@ public class StartStack extends JPanel { // TODO Auto-generated method stub super.paintComponent(g); if (stack.size() == 0) { - ImageIcon ii = new ImageIcon(getClass().getResource("images/back.png")); + ImageIcon ii = new ImageIcon(getClass().getResource("images/empty.png")); im = ii.getImage(); g.drawImage(im, 0, 0, this.getWidth(), 96, this); } diff --git a/src/main/java/solitaer/images/empty.png b/src/main/java/solitaer/images/empty.png new file mode 100644 index 0000000000000000000000000000000000000000..f6c6284bb9bb498d64b9fdd3529d47fa7773de0a GIT binary patch literal 7063 zcmeHMc{tQv`=3g(L<%LT##pkAF@qVVL3SgPJ$ss!2{U76tZ8|K$gbU*ElUrwWlK>) zB&86_lBX0Z9$N_Scckt2zSr-%p6hzw|C+hZnS1W#bI$!a_c`-D*F;zxG8W(y=L3O2 z0$39RE8r6gG(69GpcnnP>j?~=lH zJ2buCE4iY+H+1>^wKGxd*Ow<@v-IM3%e7G$r^L#;f;A~h3Ci;5{K>ohwD}PqZ($X| z_{WcQ<6J93*l9x3vI9Ci3B%XKE%&!4UAxI^#gq=m9gsK%Mf&^MNM7`Qc~a-mfm80T zy#qv@rMpsNWc@dC@{!w)rPK4KK^7m(^$gKlr=b@wet6VTbvX4-bfPpV&d%3S(8hnd zrTX@4%ZKrL`IeZmYy5MKWfjA%WA`x516&zNpDjup=`sT@TPzD>M<3mFEHy45yYDEM zIp2%R%QMx=`UG*#y0P5EUtc$=`{Ul%eL*eH-Mq0UmqUI8&s0Z5s^0A zJlE=>P2bqr>#5lA`fN(q+r5%bnc%3mRkOINX331lfu!m`Mn)!Gr*1&DB+@A6e2p>! zTOWoO(8>d|sxw8&YHSHFT;*+Eu&`xM*wGNk7Nx^-QgRdx`4l0NvH5a@bhCA4e1tPN zD*mcm_TlG_$XVkL%%6geT*Kt&95BzrX1BDIHDCa0dKx0r;&K{48L}Wkd&x6mYL;h z+#*Cwz{;eUl{}P5(>teVn`T=?DZk;Q)pfH`skB98UrC$tq6AYZ!@^df`U)XZ@lMD# zMceZH{KD(KqxnVYjY-{Hfu+LcY3;SL*Skq`Hm&byM>5mUD8umWhs>sS2ACbw-Q(A` z!6uzN)$=;EYg?O7o7=&-=L%8Mrq7bk8%~J@SnQC*iJ}HRq}ELBDx=Kf4z;IOedObG z(Icr#v-dnSXTx%zXgyEFtBz*m&RbrW(+b#cn`R^0bye@u4eiEpc1sB$pRdhu|}4TVPgQZ9-fX_3y$+m#g6-t)Ok!|QN- zcZq_63;9@({3c%Uiw)wp^P?k8`8#S}1eD}x=(RaXW7p|gX4*w6ItWFo@f-fpRricA zo!evC(`Asvm*7~*lNDTseEPKWK)R;MdynjQZ(0aR%Od%FyFH3sa37?$s_hb$G@Z$A z?NksMXm^G$i5X13g7s!+m;@a;mpLSe)mSP5SU4hHxpuDWqB&4g}Iy)c-JdG zjTXzcE#%bB&> zOGS@3KI)fRiCT1eo-?rm`S@&tW^fYS2RXH6F-tuAQm2i0w(py=99qO*PwIkh78)!Z z7d+Rad01yWBbwzQJiak{C2+gP(kIPaCxyY%sNg!cog4pXF9~(jZk6K+x@0NzSt%1d z;b5fu!-(KppGLlRx*cHwIBWjjHc^+6OGJ0>9<0*Q=w9nFeR77?_Zi3-rR&nK9J)e} z=7O+GZ!Tekk6RTPLw%^Va+yx+V~I@%Dl?8tZ=TTbU2C&?b;B>MsV;SmuFm698YbGNRqmcMl zXg}}u?6_iHM}D_1ZWpUPPuTj;t&H2tWl*8VxlIq{`R&}4J()WL+dgL0(^9#i&LMc; zT$+qO7a$melK)L$D87CM4t5f#D+m_`y*#I}?iXS3?ylItxH}Kt?XlAro`#q_i#@gF z*;zT<{Y3P=X`Y2o_olaJMa+v`|0L36$yzx-u+0Ug7w1j*yLv{6s80IA7mrLUO>b;Jq7d<*_9Zc$ex*M*(rzKu za!1j$R;Kci_s5M~f=2rXoxP<#zWE`8abm4SL8s+o3%0Sn=@sO8xe&kg7ymk;F z#Z+~#6`|p*?mDt6Vs*fuKgFc8{q1e+~{!x34%81LuwH?duaLjR~ znXKj89W(MGBMX?%CH_ObW}lZaQ*kk8H%Fd3xOCw)&pN>e@ZA#Uq_{LhjCmMxF`=jR zy+c4}U)%GnDTD?szEB}6k7N;cMtM479G@D?F@SFr4A4=bCIkx9`ewlLSg?FuCYb4rdQU0`(8$!o<{yecc?h>ZBKSe(8+ctH}q;}{1&XX{veRg4BQ+IdXoWoV;$f^RHPyDa?5I$SqB4(aiRudXo zy){0g#0ST{fmS+m>(G)G?o7R?T6zUuNJNy~}y%DSdM zsq2DY_iua}v3hegv9 z1uLa>K4wqe6?t(ojUI$DXsDQq{uCDed1$C3NPm8oo0SH8b=~<>KYmYpcWPXGFs=zD==IO`#@&%IvYjxlm`FzxK=d(foboO~vGzl7VL&W4Y%3cET>9E&?@V|B;- zP`7a7ZyN&}P`BiteLp{ZOF*1Vsdt4=A{3X2o zyJnL$ZmafJyq+k9Y412|?z|YG5p=}*mzDLF&nWRMY+}cNlsE{q zE{v+LZ-Ld<|Mo}^Jjf@Xh}SZ?Zy^$DZfzKEx@o_Oce6#xpW)}i&)XF9Y&UgEx7~F9 z^0MyvFzE*mEE!OZ&!zT04DYVadRrl`QwJncl0{sy8Wt1uBE?{s{-%IAiT;``LgJ#= z6J3T+=Q|iF>=7=lvMnAF)ehO(AV!g)j7CfoxKn3*%wO5~S*E^uHRm>?7;t`_cD#Sg z`!K`Xx|mw(`{cO@{XeDU8%7#3xn1Hu$B&h?(vu?v`7x>_lGRj$B%%04J#$lOLi#rI zt;Qm@nL(0cCHDd%OC9ryyR_!{Hw1XewD~ydhZA{ur6u)@1jsf=B~5FL&P9l%G-1Br zo6@8&n-wC&G`CxX@;#h9vr_-5Co%LPFG^l$L$#~tB2nyJ&&EWbzGdxOAKvl~p5iVn zyLGo0MA60;Rg^bx6?)07T-cX*dz14=&>8b;l1a>8IWi)Ab&ESsSPP0(Zd~YkSylen zdjUjpKirC{tCv)<${P2H^_%m3{9z!q>&r>dVgs{ZQYn~o`4Xc7mn?gn8JbAKo}i=2A=3aW`hZ2H!4jF@~P%71WYAqLG09VDmaEd*_~<<$Rt|_9e{$m8o2Dq!jtjH|750gkX^d-~SQa?kGh~MKGK1|Qm zbVx)P*^}%AxUzsz;lB)NjKx`ekKjMge61;>o5`evtLc+&Gribbg))5dIza z7w>PmuQ~%>I2_u5PW0hS4{M+W;f#+a(TP+NdR0_K5fKEq1`>)=Q%6A6P$U9W1CJs= z$?9+-f<#s&tK(5WL1AeuHl9W#bD#ilWh#I}rl_c*Ch8tQG{Jtnx!+;fZHcfB;|*P-!H( zAM1z7hU!JOX5%@0!jWpK2si?+ss=Eks-p43=`fke0&0=8yoJoN>k*fs`#(Z5C6DkYv2;kKGTGd;Vy}y3@x(Pg~ zt0pjbwQ$jR;@3e~cwaJUbs!+_tBL52r@4`V9llml-}Kb~v|LCsu;ta&pz5l?va68^ z1gIuKlK>@=Nfcn|kz@oy{a17rox=9RGs(JcK&C)8Knbm81D0DOQ~pRDHULU ztH7ZMqzxR2R?|SMt3hCE$-+2$`dhXb*uU|CS#|j75CG!7>VU%qIICda534o4I28U5 zUu)~|KO6yo{yoS);`cXQzv=o%4E!VK-_`Y-u7AY9KXU$EUH>(@_$TZ*y$Pc*8 zd?+5m0~aA~!a-vL&KVKCeT*;)~F)2XG9V^ zr#&)5P^fn__+JpCtStZl literal 0 HcmV?d00001 From 8ccbb52a9a443fea1a8eae881684e8a57e4dd449 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Wed, 26 Jan 2022 18:13:42 +0100 Subject: [PATCH 010/108] Add Ruleset for startStack and Tests --- src/main/java/solitaer/StartStack.java | 35 +++++++++++++++--- src/test/java/solitaer/StartStackTest.java | 42 ++++++++++++++++++++++ 2 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 src/test/java/solitaer/StartStackTest.java diff --git a/src/main/java/solitaer/StartStack.java b/src/main/java/solitaer/StartStack.java index e2cf44c..6a001ea 100644 --- a/src/main/java/solitaer/StartStack.java +++ b/src/main/java/solitaer/StartStack.java @@ -12,7 +12,7 @@ public class StartStack extends JPanel { private static final long serialVersionUID = 1L; private Image im; private ArrayList stack = new ArrayList(); - + private int offset; public StartStack(int _x, int _y) { @@ -20,21 +20,44 @@ public class StartStack extends JPanel { super.setSize(72, 450); super.setOpaque(false); super.setLayout(null); - + offset = 0; } + public boolean cardCheck(Card _topStack, Card _playerCard) { + if(_topStack == null && _playerCard == null) { + return false; + } + if (_topStack == null) { + // Nur der König kann auf einen leeren Stapel gelegt werden + return _playerCard.getNr() == 13; + }else { + return (// Nummer nur aufsteigend + _topStack.getNr() == _playerCard.getNr() + 1) + && + // rot auf Schwarz + ( + ((_topStack.getSymbol() == Symbol.Herz || _topStack.getSymbol() == Symbol.Karo) + && (_playerCard.getSymbol() == Symbol.Pik || _playerCard.getSymbol() == Symbol.Kreuz)) + || + // schwarz auf rot + ((_topStack.getSymbol() == Symbol.Pik || _topStack.getSymbol() == Symbol.Kreuz) + && (_playerCard.getSymbol() == Symbol.Herz || _playerCard.getSymbol() == Symbol.Karo)) + ); + } + } + public void addCard(Card _card) { _card.setLocation(0, offset); stack.add(_card); addtoPanel(); offset += 20; } - + private void addtoPanel() { - + this.removeAll(); - for(int i = stack.size()-1; i>=0; i-- ) { + for (int i = stack.size() - 1; i >= 0; i--) { this.add(stack.get(i)); } } @@ -44,7 +67,9 @@ public class StartStack extends JPanel { // TODO Auto-generated method stub super.paintComponent(g); if (stack.size() == 0) { + //Arcade64\src\main\java\solitaer\images ImageIcon ii = new ImageIcon(getClass().getResource("images/empty.png")); + //ImageIcon ii = new ImageIcon("C:/Users/Alexander/eclipse-workspace/Arcade64/src/main/java/solitaer/images/empty.png"); im = ii.getImage(); g.drawImage(im, 0, 0, this.getWidth(), 96, this); } diff --git a/src/test/java/solitaer/StartStackTest.java b/src/test/java/solitaer/StartStackTest.java new file mode 100644 index 0000000..bf65ff1 --- /dev/null +++ b/src/test/java/solitaer/StartStackTest.java @@ -0,0 +1,42 @@ +package solitaer; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +class StartStackTest { + + @ParameterizedTest + @MethodSource("testStartStackTestDaten") + //Jedes Symbol muss einmal vorhand sein + void testRulesetStartStack(String msg, Card _stapel, Card _spieler, boolean _expectedResult) { + StartStack stack = new StartStack(10, 10); + + + assertEquals(_expectedResult, stack.cardCheck(_stapel, _spieler), msg); + } + + + private static Stream testStartStackTestDaten(){ + return Stream.of( + Arguments.of("Ass-Kreuz auf 2-Herz", new Card(2, Symbol.Herz, true), new Card(1, Symbol.Kreuz, true), true), + Arguments.of("Ass-Herz auf 2Herz", new Card(1, Symbol.Herz, true), new Card(2, Symbol.Herz, true), false), + Arguments.of("Ass-Kreuz auf leeres Feld", null, new Card(1, Symbol.Kreuz, true), false), + Arguments.of("König auf leeres Feld", null, new Card(13, Symbol.Kreuz, true), true), + Arguments.of("5-Pik auf 6-Karo", new Card(6, Symbol.Karo, true), new Card(5, Symbol.Pik, true), true), + Arguments.of("König-Karo auf Ass-Kreuz", new Card(1, Symbol.Kreuz, true), new Card(13, Symbol.Karo, true), false), + Arguments.of("5-Karo auf 7-Kreuz", new Card(7, Symbol.Kreuz, true), new Card(5, Symbol.Karo, true), false), + Arguments.of("2-Herz auf Ass-Kreuz", new Card(2, Symbol.Herz, true), new Card(1, Symbol.Kreuz, true), true), + Arguments.of("null auf null", null, null, false) + + ); + + + } + +} From 67d9ada9322950927d06cebb1b6444b48b9527de Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Wed, 26 Jan 2022 21:19:33 +0100 Subject: [PATCH 011/108] Refactor Card and StartStack --- src/main/java/solitaer/Card.java | 10 +++++----- src/main/java/solitaer/StartStack.java | 12 +++++++----- src/test/java/solitaer/StartStackTest.java | 9 ++------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/main/java/solitaer/Card.java b/src/main/java/solitaer/Card.java index 63b1d8e..9eeec05 100644 --- a/src/main/java/solitaer/Card.java +++ b/src/main/java/solitaer/Card.java @@ -14,9 +14,6 @@ enum Symbol { public class Card extends JPanel { - /** - * - */ private static final long serialVersionUID = 1L; private int nr; private Symbol symbol; @@ -25,9 +22,12 @@ public class Card extends JPanel { private Image Up; private Image back; + + private final int IMAGE_WIDTH = 72; + private final int IMAGE_HIGHT = 96; public Card(int nr, Symbol symbol, boolean faceUp) { - this.setSize(72,96); + this.setSize(IMAGE_WIDTH,IMAGE_HIGHT); this.nr = nr; this.symbol = symbol; this.faceUp = faceUp; @@ -75,7 +75,7 @@ public class Card extends JPanel { case Kreuz: return "Kreuz"; default: - return null; + return ""; } } diff --git a/src/main/java/solitaer/StartStack.java b/src/main/java/solitaer/StartStack.java index 6a001ea..a4bd932 100644 --- a/src/main/java/solitaer/StartStack.java +++ b/src/main/java/solitaer/StartStack.java @@ -12,12 +12,16 @@ public class StartStack extends JPanel { private static final long serialVersionUID = 1L; private Image im; private ArrayList stack = new ArrayList(); + private final int OFFSET_VALUE = 20; + + private final int IMAGE_WIDTH = 72; + private final int IMAGE_HIGHT = 450; private int offset; public StartStack(int _x, int _y) { super.setLocation(_x, _y); - super.setSize(72, 450); + super.setSize(IMAGE_WIDTH, IMAGE_HIGHT); super.setOpaque(false); super.setLayout(null); @@ -51,12 +55,12 @@ public class StartStack extends JPanel { _card.setLocation(0, offset); stack.add(_card); addtoPanel(); - offset += 20; + offset += OFFSET_VALUE; } private void addtoPanel() { - this.removeAll(); + //Alles neu Zeichnen for (int i = stack.size() - 1; i >= 0; i--) { this.add(stack.get(i)); } @@ -67,9 +71,7 @@ public class StartStack extends JPanel { // TODO Auto-generated method stub super.paintComponent(g); if (stack.size() == 0) { - //Arcade64\src\main\java\solitaer\images ImageIcon ii = new ImageIcon(getClass().getResource("images/empty.png")); - //ImageIcon ii = new ImageIcon("C:/Users/Alexander/eclipse-workspace/Arcade64/src/main/java/solitaer/images/empty.png"); im = ii.getImage(); g.drawImage(im, 0, 0, this.getWidth(), 96, this); } diff --git a/src/test/java/solitaer/StartStackTest.java b/src/test/java/solitaer/StartStackTest.java index bf65ff1..e9515e8 100644 --- a/src/test/java/solitaer/StartStackTest.java +++ b/src/test/java/solitaer/StartStackTest.java @@ -4,7 +4,6 @@ import static org.junit.jupiter.api.Assertions.*; import java.util.stream.Stream; -import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -16,8 +15,6 @@ class StartStackTest { //Jedes Symbol muss einmal vorhand sein void testRulesetStartStack(String msg, Card _stapel, Card _spieler, boolean _expectedResult) { StartStack stack = new StartStack(10, 10); - - assertEquals(_expectedResult, stack.cardCheck(_stapel, _spieler), msg); } @@ -25,7 +22,8 @@ class StartStackTest { private static Stream testStartStackTestDaten(){ return Stream.of( Arguments.of("Ass-Kreuz auf 2-Herz", new Card(2, Symbol.Herz, true), new Card(1, Symbol.Kreuz, true), true), - Arguments.of("Ass-Herz auf 2Herz", new Card(1, Symbol.Herz, true), new Card(2, Symbol.Herz, true), false), + Arguments.of("Ass-Herz auf 2-Herz", new Card(2, Symbol.Herz, true), new Card(1, Symbol.Herz, true), false), + Arguments.of("Ass-Herz auf 2-Herz", new Card(1, Symbol.Herz, true), new Card(2, Symbol.Herz, true), false), Arguments.of("Ass-Kreuz auf leeres Feld", null, new Card(1, Symbol.Kreuz, true), false), Arguments.of("König auf leeres Feld", null, new Card(13, Symbol.Kreuz, true), true), Arguments.of("5-Pik auf 6-Karo", new Card(6, Symbol.Karo, true), new Card(5, Symbol.Pik, true), true), @@ -33,10 +31,7 @@ class StartStackTest { Arguments.of("5-Karo auf 7-Kreuz", new Card(7, Symbol.Kreuz, true), new Card(5, Symbol.Karo, true), false), Arguments.of("2-Herz auf Ass-Kreuz", new Card(2, Symbol.Herz, true), new Card(1, Symbol.Kreuz, true), true), Arguments.of("null auf null", null, null, false) - ); - - } } From 7d0878431ed5b959c3fa6887396ac1e8773665ad Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Wed, 26 Jan 2022 22:25:26 +0100 Subject: [PATCH 012/108] Fix Card and StartStack DRAW --- src/main/java/solitaer/Card.java | 54 ++++++++++++++------------ src/main/java/solitaer/StartStack.java | 12 +++--- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/src/main/java/solitaer/Card.java b/src/main/java/solitaer/Card.java index 9eeec05..1933d7a 100644 --- a/src/main/java/solitaer/Card.java +++ b/src/main/java/solitaer/Card.java @@ -2,10 +2,8 @@ package solitaer; import java.awt.Color; import java.awt.Graphics; -import java.awt.Image; import java.util.Objects; -import javax.swing.ImageIcon; import javax.swing.JPanel; enum Symbol { @@ -19,9 +17,6 @@ public class Card extends JPanel { private Symbol symbol; private boolean faceUp; - - private Image Up; - private Image back; private final int IMAGE_WIDTH = 72; private final int IMAGE_HIGHT = 96; @@ -31,13 +26,6 @@ public class Card extends JPanel { this.nr = nr; this.symbol = symbol; this.faceUp = faceUp; - - String cardName = "" + getFileNr() + getFileSymbole(); - ImageIcon iiup = new ImageIcon(getClass().getResource("images/" + cardName + ".png")); - Up = iiup.getImage(); - - ImageIcon iiback = new ImageIcon(getClass().getResource("images/back.png")); - back = iiback.getImage(); } public boolean isFaceUp() { @@ -52,7 +40,7 @@ public class Card extends JPanel { return nr; } - private String getFileNr() { + private String getNrText() { if (this.nr < 10) { return "0" + this.nr; } else { @@ -64,7 +52,7 @@ public class Card extends JPanel { return symbol; } - private String getFileSymbole() { + private String getSymboleText() { switch (this.symbol) { case Herz: return "Herz"; @@ -79,14 +67,6 @@ public class Card extends JPanel { } } - public Image getImage() { - if (faceUp) { - return Up; - } else { - return back; - } - } - @Override public String toString() { return "Card [nr=" + nr + ", symbol=" + symbol + ", faceUp=" + faceUp + "]"; @@ -113,9 +93,33 @@ public class Card extends JPanel { protected void paintComponent(Graphics g) { // TODO Auto-generated method stub super.paintComponent(g); - g.drawImage(getImage(), 0, 0, this.getWidth(), this.getHeight(), this); - g.setColor(Color.black); - g.drawRect(0, 0, this.getWidth()-1, this.getHeight()-1); + paintCard(g); + + } + + + private void paintCard(Graphics g) { + if (faceUp) { + g.setColor(Color.white); + g.fillRect(0, 0, this.getWidth(), this.getHeight()); + + g.setColor(Color.black); + g.drawRect(0, 0, this.getWidth() - 1, this.getHeight() - 1); + + if (this.symbol == Symbol.Herz || this.symbol == Symbol.Karo) + g.setColor(Color.red); + else + g.setColor(Color.black); + + String text = "" + this.getNrText() + " " + this.getSymboleText(); + g.drawString(text, 3, 15); + } else { + g.setColor(Color.blue); + g.fillRect(0, 0, this.getWidth(), this.getHeight()); + + g.setColor(Color.black); + g.drawRect(0, 0, this.getWidth() - 1, this.getHeight() - 1); + } } } diff --git a/src/main/java/solitaer/StartStack.java b/src/main/java/solitaer/StartStack.java index a4bd932..7bc782e 100644 --- a/src/main/java/solitaer/StartStack.java +++ b/src/main/java/solitaer/StartStack.java @@ -1,16 +1,14 @@ package solitaer; +import java.awt.Color; import java.awt.Graphics; -import java.awt.Image; import java.util.ArrayList; -import javax.swing.ImageIcon; import javax.swing.JPanel; public class StartStack extends JPanel { private static final long serialVersionUID = 1L; - private Image im; private ArrayList stack = new ArrayList(); private final int OFFSET_VALUE = 20; @@ -71,9 +69,11 @@ public class StartStack extends JPanel { // TODO Auto-generated method stub super.paintComponent(g); if (stack.size() == 0) { - ImageIcon ii = new ImageIcon(getClass().getResource("images/empty.png")); - im = ii.getImage(); - g.drawImage(im, 0, 0, this.getWidth(), 96, this); + g.setColor(Color.gray); + g.fillRect(0, 0, this.getWidth(), 96); + + g.setColor(Color.black); + g.drawRect(0, 0, this.getWidth()-1, 96-1); } } From 7caebafde98f0a0534788cce725aadf29f99395a Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Wed, 26 Jan 2022 23:43:32 +0100 Subject: [PATCH 013/108] Add MouseListener --- src/main/java/solitaer/MyMouseListener.java | 60 +++++++++++++++++++ src/main/java/solitaer/SolitaerGamePanel.java | 19 ++++-- 2 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 src/main/java/solitaer/MyMouseListener.java diff --git a/src/main/java/solitaer/MyMouseListener.java b/src/main/java/solitaer/MyMouseListener.java new file mode 100644 index 0000000..a5db8af --- /dev/null +++ b/src/main/java/solitaer/MyMouseListener.java @@ -0,0 +1,60 @@ +package solitaer; + +import java.awt.Component; +import java.awt.event.MouseEvent; + +import javax.swing.SwingUtilities; +import javax.swing.event.MouseInputListener; + +public class MyMouseListener implements MouseInputListener { + + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + System.out.println("DOWN"); + Component com = SwingUtilities.getDeepestComponentAt( + e.getComponent(), e.getX(), e.getY()); + System.out.println("########"); + System.out.println(com.toString()); + System.out.println(com.getParent().toString()); + System.out.println("########"); + + } + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseDragged(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseMoved(MouseEvent e) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 3577a3a..bfe5a90 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -7,17 +7,26 @@ import javax.swing.JPanel; public class SolitaerGamePanel extends JPanel { - /** - * - */ private static final long serialVersionUID = 1L; + private CardDeck deck; + private MyMouseListener mouseL; public SolitaerGamePanel() { setLayout(null); + + mouseL = new MyMouseListener(); + this.addMouseListener(mouseL); + + + deck = new CardDeck(); + + + StartStack a = new StartStack(25,25); - a.addCard(new Card(13, Symbol.Karo, true)); - a.addCard(new Card(1, Symbol.Karo, true)); + a.addCard(deck.getDeck().get(0)); + deck.getDeck().get(1).setFaceUp(true); + a.addCard((deck.getDeck().get(1))); this.add(a); StartStack b = new StartStack(200,25); From 421cd8903f8d74d48dbad28bd7e969f4382f7a1f Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Thu, 27 Jan 2022 21:28:46 +0100 Subject: [PATCH 014/108] Add BaseStack Refactor StartStack --- src/main/java/solitaer/BaseStack.java | 49 +++++++++++++++++++++ src/main/java/solitaer/MyMouseListener.java | 20 +++++++-- src/main/java/solitaer/StartStack.java | 29 +++--------- 3 files changed, 71 insertions(+), 27 deletions(-) create mode 100644 src/main/java/solitaer/BaseStack.java diff --git a/src/main/java/solitaer/BaseStack.java b/src/main/java/solitaer/BaseStack.java new file mode 100644 index 0000000..7300cb9 --- /dev/null +++ b/src/main/java/solitaer/BaseStack.java @@ -0,0 +1,49 @@ +package solitaer; + +import java.util.ArrayList; + +import javax.swing.JPanel; + +public abstract class BaseStack extends JPanel { + private static final long serialVersionUID = 1L; + private ArrayList stack = new ArrayList(); + private final int OFFSET_VALUE = 20; + int offset; + + public BaseStack() { + // TODO Auto-generated constructor stub + offset = 0; + } + + public boolean stackIsEmpty() { + return stack.isEmpty(); + } + + public void addCard(Card _card) { + _card.setLocation(0, offset); + stack.add(_card); + RenderStackNew(); + offset += OFFSET_VALUE; + } + + private void RenderStackNew() { + this.removeAll(); + // Alles neu Zeichnen + for (int i = stack.size() - 1; i >= 0; i--) { + this.add(stack.get(i)); + } + this.repaint(); + } + + public Card removeLastCard() { + if (stack.size() != 0) { + Card LastCard = stack.remove(stack.size() - 1); + RenderStackNew(); + return LastCard; + } + return null; + + } + + protected abstract boolean cardCheck(Card _topStack, Card _playerCard); +} diff --git a/src/main/java/solitaer/MyMouseListener.java b/src/main/java/solitaer/MyMouseListener.java index a5db8af..7a29a4b 100644 --- a/src/main/java/solitaer/MyMouseListener.java +++ b/src/main/java/solitaer/MyMouseListener.java @@ -20,10 +20,22 @@ public class MyMouseListener implements MouseInputListener { System.out.println("DOWN"); Component com = SwingUtilities.getDeepestComponentAt( e.getComponent(), e.getX(), e.getY()); - System.out.println("########"); - System.out.println(com.toString()); - System.out.println(com.getParent().toString()); - System.out.println("########"); +// System.out.println("########"); +// System.out.println(com.toString()); +// System.out.println(com.getParent().toString()); +// System.out.println("########"); + + //Leeres StartFeld + if (com instanceof StartStack) { + System.out.println("Leer Start"); + + } + //Karte, die in einem StartStack liegt + else if(com instanceof Card && com.getParent() instanceof StartStack) { + System.out.println("Karte in StartStack"+com.toString()); + + ((BaseStack)com.getParent()).removeLastCard(); + } } diff --git a/src/main/java/solitaer/StartStack.java b/src/main/java/solitaer/StartStack.java index 7bc782e..28710e4 100644 --- a/src/main/java/solitaer/StartStack.java +++ b/src/main/java/solitaer/StartStack.java @@ -2,28 +2,22 @@ package solitaer; import java.awt.Color; import java.awt.Graphics; -import java.util.ArrayList; -import javax.swing.JPanel; -public class StartStack extends JPanel { +public class StartStack extends BaseStack { private static final long serialVersionUID = 1L; - private ArrayList stack = new ArrayList(); - private final int OFFSET_VALUE = 20; private final int IMAGE_WIDTH = 72; private final int IMAGE_HIGHT = 450; - private int offset; public StartStack(int _x, int _y) { + super(); super.setLocation(_x, _y); super.setSize(IMAGE_WIDTH, IMAGE_HIGHT); super.setOpaque(false); super.setLayout(null); - - offset = 0; } public boolean cardCheck(Card _topStack, Card _playerCard) { @@ -49,26 +43,13 @@ public class StartStack extends JPanel { } } - public void addCard(Card _card) { - _card.setLocation(0, offset); - stack.add(_card); - addtoPanel(); - offset += OFFSET_VALUE; - } - - private void addtoPanel() { - this.removeAll(); - //Alles neu Zeichnen - for (int i = stack.size() - 1; i >= 0; i--) { - this.add(stack.get(i)); - } - } + @Override protected void paintComponent(Graphics g) { // TODO Auto-generated method stub super.paintComponent(g); - if (stack.size() == 0) { + if (stackIsEmpty()) { g.setColor(Color.gray); g.fillRect(0, 0, this.getWidth(), 96); @@ -77,4 +58,6 @@ public class StartStack extends JPanel { } } + + } From b11a6244b7c46f61a67639808486d63ef9eb07d2 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Thu, 27 Jan 2022 22:00:44 +0100 Subject: [PATCH 015/108] Turn Card with Mouse --- src/main/java/solitaer/BaseStack.java | 9 +++++ src/main/java/solitaer/Card.java | 3 +- src/main/java/solitaer/MyMouseListener.java | 31 ++++++++++++++- src/main/java/solitaer/SaveStack.java | 38 +++++++++++++++++++ src/main/java/solitaer/SolitaerGamePanel.java | 12 +++++- 5 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 src/main/java/solitaer/SaveStack.java diff --git a/src/main/java/solitaer/BaseStack.java b/src/main/java/solitaer/BaseStack.java index 7300cb9..aabbc6f 100644 --- a/src/main/java/solitaer/BaseStack.java +++ b/src/main/java/solitaer/BaseStack.java @@ -18,6 +18,15 @@ public abstract class BaseStack extends JPanel { public boolean stackIsEmpty() { return stack.isEmpty(); } + + public Card peekLastCard() { + if(!stackIsEmpty()) { + return stack.get(stack.size()-1); + } else { + return null; + } + + } public void addCard(Card _card) { _card.setLocation(0, offset); diff --git a/src/main/java/solitaer/Card.java b/src/main/java/solitaer/Card.java index 1933d7a..af55cfc 100644 --- a/src/main/java/solitaer/Card.java +++ b/src/main/java/solitaer/Card.java @@ -69,7 +69,8 @@ public class Card extends JPanel { @Override public String toString() { - return "Card [nr=" + nr + ", symbol=" + symbol + ", faceUp=" + faceUp + "]"; + //return "Card [nr=" + nr + ", symbol=" + symbol + ", faceUp=" + faceUp + "]"; + return "Card NR="+nr+" | Symbole="+symbol+" | Face="+faceUp; } @Override diff --git a/src/main/java/solitaer/MyMouseListener.java b/src/main/java/solitaer/MyMouseListener.java index 7a29a4b..140c2a9 100644 --- a/src/main/java/solitaer/MyMouseListener.java +++ b/src/main/java/solitaer/MyMouseListener.java @@ -7,6 +7,15 @@ import javax.swing.SwingUtilities; import javax.swing.event.MouseInputListener; public class MyMouseListener implements MouseInputListener { + + private SaveStack save; + private BaseStack tempStack; + private Card tempCard; + + public MyMouseListener(SaveStack _save) { + // TODO Auto-generated constructor stub + this.save = _save; + } @Override public void mouseClicked(MouseEvent e) { @@ -32,9 +41,27 @@ public class MyMouseListener implements MouseInputListener { } //Karte, die in einem StartStack liegt else if(com instanceof Card && com.getParent() instanceof StartStack) { - System.out.println("Karte in StartStack"+com.toString()); + tempCard = (Card) com; + tempStack = (StartStack) com.getParent(); + + //Wenn faceDown, schau ob es die oberste Carde ist und dreh diese um + if(!tempCard.isFaceUp()) { + if(tempStack.peekLastCard().equals(tempCard)) { + tempCard.setFaceUp(true); + tempCard.repaint(); + System.out.println("Turn"+tempCard.toString()); + } + + + } + + + //System.out.println("Karte in StartStack"+com.toString()); + + + - ((BaseStack)com.getParent()).removeLastCard(); + //save.addCard(((BaseStack)com.getParent()).removeLastCard());; } } diff --git a/src/main/java/solitaer/SaveStack.java b/src/main/java/solitaer/SaveStack.java new file mode 100644 index 0000000..d95974f --- /dev/null +++ b/src/main/java/solitaer/SaveStack.java @@ -0,0 +1,38 @@ +package solitaer; + +import java.awt.Color; +import java.awt.Graphics; + +public class SaveStack extends BaseStack { + + private static final long serialVersionUID = 1L; + + public SaveStack(int _x, int _y) { + // TODO Auto-generated constructor stub + super(); + super.setLocation(_x, _y); + super.setSize(72, 450); + super.setOpaque(false); + super.setLayout(null); + } + + @Override + protected boolean cardCheck(Card _topStack, Card _playerCard) { + // TODO Auto-generated method stub + return false; + } + + @Override + protected void paintComponent(Graphics g) { + // TODO Auto-generated method stub + super.paintComponent(g); + if (stackIsEmpty()) { + g.setColor(Color.pink); + g.fillRect(0, 0, this.getWidth(), 96); + + g.setColor(Color.black); + g.drawRect(0, 0, this.getWidth() - 1, 96 - 1); + } + } + +} diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index bfe5a90..14ab7cf 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -10,12 +10,14 @@ public class SolitaerGamePanel extends JPanel { private static final long serialVersionUID = 1L; private CardDeck deck; private MyMouseListener mouseL; + + private SaveStack save =new SaveStack(500,250); public SolitaerGamePanel() { setLayout(null); - mouseL = new MyMouseListener(); + mouseL = new MyMouseListener(save); this.addMouseListener(mouseL); @@ -25,12 +27,18 @@ public class SolitaerGamePanel extends JPanel { StartStack a = new StartStack(25,25); a.addCard(deck.getDeck().get(0)); - deck.getDeck().get(1).setFaceUp(true); + deck.getDeck().get(1).setFaceUp(false); a.addCard((deck.getDeck().get(1))); this.add(a); StartStack b = new StartStack(200,25); this.add(b); + + //save = new SaveStack(500,250); + this.add(save); + + + } From cc51b3fa681756768b2a561b4642d8b6fed0d167 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Thu, 27 Jan 2022 22:36:28 +0100 Subject: [PATCH 016/108] Move Cards between StartStack with Mouse --- src/main/java/solitaer/BaseStack.java | 31 +++++--- src/main/java/solitaer/MyMouseListener.java | 73 +++++++++++-------- src/main/java/solitaer/SolitaerGamePanel.java | 26 ++++++- 3 files changed, 89 insertions(+), 41 deletions(-) diff --git a/src/main/java/solitaer/BaseStack.java b/src/main/java/solitaer/BaseStack.java index aabbc6f..e8064d0 100644 --- a/src/main/java/solitaer/BaseStack.java +++ b/src/main/java/solitaer/BaseStack.java @@ -1,5 +1,7 @@ package solitaer; +import java.lang.invoke.TypeDescriptor.OfField; +import java.time.OffsetDateTime; import java.util.ArrayList; import javax.swing.JPanel; @@ -25,7 +27,14 @@ public abstract class BaseStack extends JPanel { } else { return null; } - + } + + public int indexOfCard(Card _card) { + return stack.indexOf(_card); + } + + public int stackSize() { + return stack.size(); } public void addCard(Card _card) { @@ -35,23 +44,23 @@ public abstract class BaseStack extends JPanel { offset += OFFSET_VALUE; } - private void RenderStackNew() { - this.removeAll(); - // Alles neu Zeichnen - for (int i = stack.size() - 1; i >= 0; i--) { - this.add(stack.get(i)); - } - this.repaint(); - } - public Card removeLastCard() { if (stack.size() != 0) { Card LastCard = stack.remove(stack.size() - 1); + offset -= OFFSET_VALUE; RenderStackNew(); return LastCard; } return null; - + } + + private void RenderStackNew() { + this.removeAll(); + // Alles neu Zeichnen + for (int i = stack.size() - 1; i >= 0; i--) { + this.add(stack.get(i)); + } + this.repaint(); } protected abstract boolean cardCheck(Card _topStack, Card _playerCard); diff --git a/src/main/java/solitaer/MyMouseListener.java b/src/main/java/solitaer/MyMouseListener.java index 140c2a9..4ca99b8 100644 --- a/src/main/java/solitaer/MyMouseListener.java +++ b/src/main/java/solitaer/MyMouseListener.java @@ -7,11 +7,12 @@ import javax.swing.SwingUtilities; import javax.swing.event.MouseInputListener; public class MyMouseListener implements MouseInputListener { - + private SaveStack save; private BaseStack tempStack; + private BaseStack selectedStack; private Card tempCard; - + public MyMouseListener(SaveStack _save) { // TODO Auto-generated constructor stub this.save = _save; @@ -27,41 +28,55 @@ public class MyMouseListener implements MouseInputListener { public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub System.out.println("DOWN"); - Component com = SwingUtilities.getDeepestComponentAt( - e.getComponent(), e.getX(), e.getY()); -// System.out.println("########"); -// System.out.println(com.toString()); -// System.out.println(com.getParent().toString()); -// System.out.println("########"); - - //Leeres StartFeld + Component com = SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY()); + + // Leeres StartFeld if (com instanceof StartStack) { System.out.println("Leer Start"); - + } - //Karte, die in einem StartStack liegt - else if(com instanceof Card && com.getParent() instanceof StartStack) { + // Karte, die in einem StartStack liegt + else if (com instanceof Card && com.getParent() instanceof StartStack) { tempCard = (Card) com; tempStack = (StartStack) com.getParent(); - - //Wenn faceDown, schau ob es die oberste Carde ist und dreh diese um - if(!tempCard.isFaceUp()) { - if(tempStack.peekLastCard().equals(tempCard)) { - tempCard.setFaceUp(true); - tempCard.repaint(); - System.out.println("Turn"+tempCard.toString()); + + if (save.stackIsEmpty()) { + // Wenn faceDown, schau ob es die oberste Carde ist und dreh diese um + if (!tempCard.isFaceUp()) { + if (tempStack.peekLastCard().equals(tempCard)) { + tempCard.setFaceUp(true); + tempCard.repaint(); + } + } + // Card faceUp + else { + // move all Cards below the selected Card to Save + int index = tempStack.indexOfCard(tempCard); + while (tempStack.stackSize() - 1 >= index) { + save.addCard(tempStack.removeLastCard()); + } + selectedStack = tempStack; + + } + } + //saveStack is NOT empty + else { + if(selectedStack == null) { + System.out.println("ERROR selectedStack in StartStack"); + } + if(tempStack.cardCheck(tempStack.peekLastCard(), save.peekLastCard())) { + while(!save.stackIsEmpty()) { + tempStack.addCard(save.removeLastCard()); + } + } else { + //Alles wieder auf den Ursprünglichen Stack packen + while(!save.stackIsEmpty()) { + selectedStack.addCard(save.removeLastCard()); + } } - + selectedStack = null; } - - - //System.out.println("Karte in StartStack"+com.toString()); - - - - - //save.addCard(((BaseStack)com.getParent()).removeLastCard());; } } diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 14ab7cf..d94b99c 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -26,14 +26,38 @@ public class SolitaerGamePanel extends JPanel { StartStack a = new StartStack(25,25); + a.addCard(deck.getDeck().get(0)); - deck.getDeck().get(1).setFaceUp(false); + + deck.getDeck().get(5).setFaceUp(true); + a.addCard((deck.getDeck().get(5))); + + deck.getDeck().get(4).setFaceUp(true); + a.addCard((deck.getDeck().get(4))); + + deck.getDeck().get(3).setFaceUp(true); + a.addCard((deck.getDeck().get(3))); + + deck.getDeck().get(2).setFaceUp(true); + a.addCard((deck.getDeck().get(2))); + + deck.getDeck().get(1).setFaceUp(true); a.addCard((deck.getDeck().get(1))); + this.add(a); StartStack b = new StartStack(200,25); + + deck.getDeck().get(32).setFaceUp(true); + b.addCard((deck.getDeck().get(32))); this.add(b); + StartStack c = new StartStack(375,25); + + deck.getDeck().get(33).setFaceUp(true); + c.addCard((deck.getDeck().get(33))); + this.add(c); + //save = new SaveStack(500,250); this.add(save); From 5aab0411798e7bbd41c70e75d0a2bfc51972ce0e Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Thu, 27 Jan 2022 22:51:55 +0100 Subject: [PATCH 017/108] Refactor Start- Save- BaseStack and MyMousListener --- src/main/java/solitaer/BaseStack.java | 6 ++++-- src/main/java/solitaer/MyMouseListener.java | 18 +++++++++--------- src/main/java/solitaer/SaveStack.java | 6 +++--- src/main/java/solitaer/StartStack.java | 10 +++------- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/main/java/solitaer/BaseStack.java b/src/main/java/solitaer/BaseStack.java index e8064d0..84dfab2 100644 --- a/src/main/java/solitaer/BaseStack.java +++ b/src/main/java/solitaer/BaseStack.java @@ -1,12 +1,14 @@ package solitaer; -import java.lang.invoke.TypeDescriptor.OfField; -import java.time.OffsetDateTime; import java.util.ArrayList; import javax.swing.JPanel; public abstract class BaseStack extends JPanel { + public final int IMAGE_WIDTH = 72; + public final int IMAGE_HIGHT = 96; + public final int STACK_HIGHT = 450; + private static final long serialVersionUID = 1L; private ArrayList stack = new ArrayList(); private final int OFFSET_VALUE = 20; diff --git a/src/main/java/solitaer/MyMouseListener.java b/src/main/java/solitaer/MyMouseListener.java index 4ca99b8..4e9a08a 100644 --- a/src/main/java/solitaer/MyMouseListener.java +++ b/src/main/java/solitaer/MyMouseListener.java @@ -8,14 +8,14 @@ import javax.swing.event.MouseInputListener; public class MyMouseListener implements MouseInputListener { - private SaveStack save; + private SaveStack saveStack; private BaseStack tempStack; private BaseStack selectedStack; private Card tempCard; public MyMouseListener(SaveStack _save) { // TODO Auto-generated constructor stub - this.save = _save; + this.saveStack = _save; } @Override @@ -40,7 +40,7 @@ public class MyMouseListener implements MouseInputListener { tempCard = (Card) com; tempStack = (StartStack) com.getParent(); - if (save.stackIsEmpty()) { + if (saveStack.stackIsEmpty()) { // Wenn faceDown, schau ob es die oberste Carde ist und dreh diese um if (!tempCard.isFaceUp()) { if (tempStack.peekLastCard().equals(tempCard)) { @@ -53,7 +53,7 @@ public class MyMouseListener implements MouseInputListener { // move all Cards below the selected Card to Save int index = tempStack.indexOfCard(tempCard); while (tempStack.stackSize() - 1 >= index) { - save.addCard(tempStack.removeLastCard()); + saveStack.addCard(tempStack.removeLastCard()); } selectedStack = tempStack; @@ -64,14 +64,14 @@ public class MyMouseListener implements MouseInputListener { if(selectedStack == null) { System.out.println("ERROR selectedStack in StartStack"); } - if(tempStack.cardCheck(tempStack.peekLastCard(), save.peekLastCard())) { - while(!save.stackIsEmpty()) { - tempStack.addCard(save.removeLastCard()); + if(tempStack.cardCheck(tempStack.peekLastCard(), saveStack.peekLastCard())) { + while(!saveStack.stackIsEmpty()) { + tempStack.addCard(saveStack.removeLastCard()); } } else { //Alles wieder auf den Ursprünglichen Stack packen - while(!save.stackIsEmpty()) { - selectedStack.addCard(save.removeLastCard()); + while(!saveStack.stackIsEmpty()) { + selectedStack.addCard(saveStack.removeLastCard()); } } diff --git a/src/main/java/solitaer/SaveStack.java b/src/main/java/solitaer/SaveStack.java index d95974f..3f423a2 100644 --- a/src/main/java/solitaer/SaveStack.java +++ b/src/main/java/solitaer/SaveStack.java @@ -11,7 +11,7 @@ public class SaveStack extends BaseStack { // TODO Auto-generated constructor stub super(); super.setLocation(_x, _y); - super.setSize(72, 450); + super.setSize(IMAGE_WIDTH, STACK_HIGHT); super.setOpaque(false); super.setLayout(null); } @@ -28,10 +28,10 @@ public class SaveStack extends BaseStack { super.paintComponent(g); if (stackIsEmpty()) { g.setColor(Color.pink); - g.fillRect(0, 0, this.getWidth(), 96); + g.fillRect(0, 0, this.getWidth(), IMAGE_HIGHT); g.setColor(Color.black); - g.drawRect(0, 0, this.getWidth() - 1, 96 - 1); + g.drawRect(0, 0, this.getWidth() - 1, IMAGE_HIGHT - 1); } } diff --git a/src/main/java/solitaer/StartStack.java b/src/main/java/solitaer/StartStack.java index 28710e4..8f14ae6 100644 --- a/src/main/java/solitaer/StartStack.java +++ b/src/main/java/solitaer/StartStack.java @@ -8,14 +8,10 @@ public class StartStack extends BaseStack { private static final long serialVersionUID = 1L; - private final int IMAGE_WIDTH = 72; - private final int IMAGE_HIGHT = 450; - - public StartStack(int _x, int _y) { super(); super.setLocation(_x, _y); - super.setSize(IMAGE_WIDTH, IMAGE_HIGHT); + super.setSize(IMAGE_WIDTH, STACK_HIGHT); super.setOpaque(false); super.setLayout(null); } @@ -51,10 +47,10 @@ public class StartStack extends BaseStack { super.paintComponent(g); if (stackIsEmpty()) { g.setColor(Color.gray); - g.fillRect(0, 0, this.getWidth(), 96); + g.fillRect(0, 0, this.getWidth(), IMAGE_HIGHT); g.setColor(Color.black); - g.drawRect(0, 0, this.getWidth()-1, 96-1); + g.drawRect(0, 0, this.getWidth()-1, IMAGE_HIGHT-1); } } From 65a829fbff195e5445f35bd0c37368a2a828e4de Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sat, 29 Jan 2022 16:37:22 +0100 Subject: [PATCH 018/108] init AblageStack --- src/main/java/solitaer/AblageStack.java | 21 ++++++++++++++++ src/test/java/solitaer/AblageStackTest.java | 28 +++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/main/java/solitaer/AblageStack.java create mode 100644 src/test/java/solitaer/AblageStackTest.java diff --git a/src/main/java/solitaer/AblageStack.java b/src/main/java/solitaer/AblageStack.java new file mode 100644 index 0000000..7cb9fbe --- /dev/null +++ b/src/main/java/solitaer/AblageStack.java @@ -0,0 +1,21 @@ +package solitaer; + +public class AblageStack extends BaseStack { + + private static final long serialVersionUID = 1L; + + public AblageStack(int _x, int _y) { + super(); + super.setLocation(_x, _y); + super.setSize(IMAGE_WIDTH, STACK_HIGHT); + super.setOpaque(false); + super.setLayout(null); + } + + @Override + protected boolean cardCheck(Card _topStack, Card _playerCard) { + // TODO Auto-generated method stub + return true; + } + +} diff --git a/src/test/java/solitaer/AblageStackTest.java b/src/test/java/solitaer/AblageStackTest.java new file mode 100644 index 0000000..4a9283e --- /dev/null +++ b/src/test/java/solitaer/AblageStackTest.java @@ -0,0 +1,28 @@ +package solitaer; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +class AblageStackTest { + + @ParameterizedTest + @MethodSource("testAblageStackTestDaten") + void testRulesetStartStack(String msg, Card _stapel, Card _spieler, boolean _expectedResult) { + AblageStack stack = new AblageStack(0, 0); + assertEquals(_expectedResult, stack.cardCheck(_stapel, _spieler), msg); + } + + private static Stream testAblageStackTestDaten(){ + return Stream.of( + Arguments.of("Ass-Kreuz auf Leeres Feld", + null, + new Card(1, Symbol.Kreuz, true), true) + ); + } + +} From e5fa1c365767fbf9c402e165170aba1d5d564831 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 16:10:00 +0100 Subject: [PATCH 019/108] Add Ruleset for AblageStack and Tests --- src/main/java/solitaer/AblageStack.java | 19 ++++++++++++--- src/test/java/solitaer/AblageStackTest.java | 26 +++++++++++++++++---- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/main/java/solitaer/AblageStack.java b/src/main/java/solitaer/AblageStack.java index 7cb9fbe..0e436b6 100644 --- a/src/main/java/solitaer/AblageStack.java +++ b/src/main/java/solitaer/AblageStack.java @@ -3,19 +3,32 @@ package solitaer; public class AblageStack extends BaseStack { private static final long serialVersionUID = 1L; + private Symbol sym; - public AblageStack(int _x, int _y) { + public AblageStack(int _x, int _y, Symbol _sym) { super(); super.setLocation(_x, _y); super.setSize(IMAGE_WIDTH, STACK_HIGHT); super.setOpaque(false); super.setLayout(null); + + this.sym = _sym; } @Override protected boolean cardCheck(Card _topStack, Card _playerCard) { - // TODO Auto-generated method stub - return true; + if(_topStack == null && _playerCard == null) { + return false; + } + if(_playerCard.getSymbol() != this.sym) { + return false; + } else if(_topStack == null) { + //nur ein Ass darf auf einen Leeren Stabel gelegt werden + return _playerCard.getNr() == 1; + } else { + return _topStack.getNr() == _playerCard.getNr() - 1; + } + } } diff --git a/src/test/java/solitaer/AblageStackTest.java b/src/test/java/solitaer/AblageStackTest.java index 4a9283e..6059ac1 100644 --- a/src/test/java/solitaer/AblageStackTest.java +++ b/src/test/java/solitaer/AblageStackTest.java @@ -12,16 +12,34 @@ class AblageStackTest { @ParameterizedTest @MethodSource("testAblageStackTestDaten") - void testRulesetStartStack(String msg, Card _stapel, Card _spieler, boolean _expectedResult) { - AblageStack stack = new AblageStack(0, 0); + void testRulesetAblageStack(String msg, Card _stapel, Card _spieler, boolean _expectedResult) { + AblageStack stack = new AblageStack(0, 0, Symbol.Kreuz); assertEquals(_expectedResult, stack.cardCheck(_stapel, _spieler), msg); } private static Stream testAblageStackTestDaten(){ return Stream.of( - Arguments.of("Ass-Kreuz auf Leeres Feld", + Arguments.of("Ass-Kreuz auf Leeres Kreuz-Feld", null, - new Card(1, Symbol.Kreuz, true), true) + null, false), + Arguments.of("Ass-Kreuz auf Leeres Kreuz-Feld", + null, + new Card(1, Symbol.Kreuz, true), true), + Arguments.of("02-Kreuz auf Leeres Kreuz-Feld", + null, + new Card(2, Symbol.Kreuz, true), false), + Arguments.of("Ass-Herz auf Leeres Kreuz-Feld", + null, + new Card(1, Symbol.Herz, true), false), + Arguments.of("05-Kreuz auf 04-Kreuz", + new Card(4, Symbol.Kreuz, true), + new Card(5, Symbol.Kreuz, true), true), + Arguments.of("05-Herz auf 04-Kreuz", + new Card(4, Symbol.Kreuz, true), + new Card(5, Symbol.Herz, true), false), + Arguments.of("Ass-Kreuz auf König-Kreuz", + new Card(13, Symbol.Kreuz, true), + new Card(1, Symbol.Kreuz, true), false) ); } From b16c5e74ad3f4673d76c414c9bddd6ac3e2d9d03 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 16:23:55 +0100 Subject: [PATCH 020/108] Add render for AblageStack --- src/main/java/solitaer/AblageStack.java | 29 +++++++++++++++++++ src/main/java/solitaer/SolitaerGamePanel.java | 15 ++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/main/java/solitaer/AblageStack.java b/src/main/java/solitaer/AblageStack.java index 0e436b6..56439a0 100644 --- a/src/main/java/solitaer/AblageStack.java +++ b/src/main/java/solitaer/AblageStack.java @@ -1,5 +1,9 @@ package solitaer; +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; + public class AblageStack extends BaseStack { private static final long serialVersionUID = 1L; @@ -30,5 +34,30 @@ public class AblageStack extends BaseStack { } } + + @Override + protected void paintComponent(Graphics g) { + // TODO Auto-generated method stub + super.paintComponent(g); + if (stackIsEmpty()) { + g.setColor(Color.gray); + g.fillRect(0, 0, this.getWidth(), IMAGE_HIGHT); + + g.setColor(Color.black); + g.drawRect(0, 0, this.getWidth()-1, IMAGE_HIGHT-1); + + if (this.sym == Symbol.Herz || this.sym == Symbol.Karo) + g.setColor(Color.red); + else + g.setColor(Color.black); + + int fontSize = 20; + Font f = new Font(Font.MONOSPACED, Font.BOLD, fontSize); + g.setFont(f); + + String text = this.sym.toString(); + g.drawString(text, 5, this.IMAGE_HIGHT/2); + } + } } diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index d94b99c..a7a56f5 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -25,7 +25,7 @@ public class SolitaerGamePanel extends JPanel { - StartStack a = new StartStack(25,25); + StartStack a = new StartStack(25,125); a.addCard(deck.getDeck().get(0)); @@ -46,13 +46,13 @@ public class SolitaerGamePanel extends JPanel { this.add(a); - StartStack b = new StartStack(200,25); + StartStack b = new StartStack(200,125); deck.getDeck().get(32).setFaceUp(true); b.addCard((deck.getDeck().get(32))); this.add(b); - StartStack c = new StartStack(375,25); + StartStack c = new StartStack(375,125); deck.getDeck().get(33).setFaceUp(true); c.addCard((deck.getDeck().get(33))); @@ -62,6 +62,15 @@ public class SolitaerGamePanel extends JPanel { this.add(save); + AblageStack a1 = new AblageStack(200, 10, Symbol.Herz); + this.add(a1); + AblageStack a2 = new AblageStack(275, 10, Symbol.Kreuz); + this.add(a2); + AblageStack a3 = new AblageStack(350, 10, Symbol.Karo); + this.add(a3); + AblageStack a4 = new AblageStack(425, 10, Symbol.Pik); + this.add(a4); + } From 2cb74cadc9308531abbb85625560bd83c4f10da9 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 16:48:51 +0100 Subject: [PATCH 021/108] add MouseInput for AblageStack --- src/main/java/solitaer/MyMouseListener.java | 51 ++++++++++++++++--- src/main/java/solitaer/SolitaerGamePanel.java | 15 ++++-- 2 files changed, 53 insertions(+), 13 deletions(-) diff --git a/src/main/java/solitaer/MyMouseListener.java b/src/main/java/solitaer/MyMouseListener.java index 4e9a08a..c79d440 100644 --- a/src/main/java/solitaer/MyMouseListener.java +++ b/src/main/java/solitaer/MyMouseListener.java @@ -58,26 +58,61 @@ public class MyMouseListener implements MouseInputListener { selectedStack = tempStack; } - } - //saveStack is NOT empty + } + // saveStack is NOT empty else { - if(selectedStack == null) { + if (selectedStack == null) { System.out.println("ERROR selectedStack in StartStack"); } - if(tempStack.cardCheck(tempStack.peekLastCard(), saveStack.peekLastCard())) { - while(!saveStack.stackIsEmpty()) { + if (tempStack.cardCheck(tempStack.peekLastCard(), saveStack.peekLastCard())) { + while (!saveStack.stackIsEmpty()) { tempStack.addCard(saveStack.removeLastCard()); } } else { - //Alles wieder auf den Ursprünglichen Stack packen - while(!saveStack.stackIsEmpty()) { + // Alles wieder auf den Ursprünglichen Stack packen + while (!saveStack.stackIsEmpty()) { selectedStack.addCard(saveStack.removeLastCard()); } } - + selectedStack = null; } } + // AblageStack + else if (com.getParent() instanceof AblageStack || com instanceof AblageStack) { + + System.out.println("AblageStack"); + + if (com instanceof AblageStack) { + tempStack = (AblageStack) com; + } else { + tempStack = (AblageStack) com.getParent(); + + } + + if (saveStack.stackIsEmpty()) { + // Move Top Card from AblageStack in Save + if (tempStack.stackIsEmpty() == false) { + saveStack.addCard(tempStack.removeLastCard()); + selectedStack = tempStack; + } + + } else { + // Move Card from Save in AblageStack + if (saveStack.stackSize() == 1) { + if (tempStack.cardCheck(tempStack.peekLastCard(), saveStack.peekLastCard())) { + tempStack.addCard(saveStack.removeLastCard()); + } + + } else { + // Alles wieder auf den Ursprünglichen Stack packen + while (!saveStack.stackIsEmpty()) { + selectedStack.addCard(saveStack.removeLastCard()); + } + } + } + + } } diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index a7a56f5..4c16f06 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -26,9 +26,7 @@ public class SolitaerGamePanel extends JPanel { StartStack a = new StartStack(25,125); - - a.addCard(deck.getDeck().get(0)); - + deck.getDeck().get(5).setFaceUp(true); a.addCard((deck.getDeck().get(5))); @@ -44,6 +42,9 @@ public class SolitaerGamePanel extends JPanel { deck.getDeck().get(1).setFaceUp(true); a.addCard((deck.getDeck().get(1))); + deck.getDeck().get(0).setFaceUp(true); + a.addCard(deck.getDeck().get(0)); + this.add(a); StartStack b = new StartStack(200,125); @@ -54,10 +55,14 @@ public class SolitaerGamePanel extends JPanel { StartStack c = new StartStack(375,125); - deck.getDeck().get(33).setFaceUp(true); - c.addCard((deck.getDeck().get(33))); + deck.getDeck().get(13).setFaceUp(true); + c.addCard((deck.getDeck().get(12))); this.add(c); + + StartStack d = new StartStack(475,125); + this.add(d); + //save = new SaveStack(500,250); this.add(save); From 63cdf0a8a799eea750de2171e536ea8379a756cd Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 16:53:19 +0100 Subject: [PATCH 022/108] remove offset for AblageStack --- src/main/java/solitaer/AblageStack.java | 2 +- src/main/java/solitaer/BaseStack.java | 12 +++++++++--- src/main/java/solitaer/SaveStack.java | 2 +- src/main/java/solitaer/StartStack.java | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/solitaer/AblageStack.java b/src/main/java/solitaer/AblageStack.java index 56439a0..c96818b 100644 --- a/src/main/java/solitaer/AblageStack.java +++ b/src/main/java/solitaer/AblageStack.java @@ -10,7 +10,7 @@ public class AblageStack extends BaseStack { private Symbol sym; public AblageStack(int _x, int _y, Symbol _sym) { - super(); + super(false); super.setLocation(_x, _y); super.setSize(IMAGE_WIDTH, STACK_HIGHT); super.setOpaque(false); diff --git a/src/main/java/solitaer/BaseStack.java b/src/main/java/solitaer/BaseStack.java index 84dfab2..a94321d 100644 --- a/src/main/java/solitaer/BaseStack.java +++ b/src/main/java/solitaer/BaseStack.java @@ -13,9 +13,15 @@ public abstract class BaseStack extends JPanel { private ArrayList stack = new ArrayList(); private final int OFFSET_VALUE = 20; int offset; + int addOffset; - public BaseStack() { + public BaseStack(boolean _offset) { // TODO Auto-generated constructor stub + if(_offset) { + addOffset = OFFSET_VALUE; + }else { + addOffset = 0; + } offset = 0; } @@ -43,13 +49,13 @@ public abstract class BaseStack extends JPanel { _card.setLocation(0, offset); stack.add(_card); RenderStackNew(); - offset += OFFSET_VALUE; + offset += addOffset; } public Card removeLastCard() { if (stack.size() != 0) { Card LastCard = stack.remove(stack.size() - 1); - offset -= OFFSET_VALUE; + offset -= addOffset; RenderStackNew(); return LastCard; } diff --git a/src/main/java/solitaer/SaveStack.java b/src/main/java/solitaer/SaveStack.java index 3f423a2..cd4cea0 100644 --- a/src/main/java/solitaer/SaveStack.java +++ b/src/main/java/solitaer/SaveStack.java @@ -9,7 +9,7 @@ public class SaveStack extends BaseStack { public SaveStack(int _x, int _y) { // TODO Auto-generated constructor stub - super(); + super(true); super.setLocation(_x, _y); super.setSize(IMAGE_WIDTH, STACK_HIGHT); super.setOpaque(false); diff --git a/src/main/java/solitaer/StartStack.java b/src/main/java/solitaer/StartStack.java index 8f14ae6..068b88f 100644 --- a/src/main/java/solitaer/StartStack.java +++ b/src/main/java/solitaer/StartStack.java @@ -9,7 +9,7 @@ public class StartStack extends BaseStack { private static final long serialVersionUID = 1L; public StartStack(int _x, int _y) { - super(); + super(true); super.setLocation(_x, _y); super.setSize(IMAGE_WIDTH, STACK_HIGHT); super.setOpaque(false); From 24f874a09d420b4b441b2c610319a6420a35b6bc Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 17:09:23 +0100 Subject: [PATCH 023/108] Refactor MouseInput --- src/main/java/solitaer/MyMouseListener.java | 23 ++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/java/solitaer/MyMouseListener.java b/src/main/java/solitaer/MyMouseListener.java index c79d440..ee54111 100644 --- a/src/main/java/solitaer/MyMouseListener.java +++ b/src/main/java/solitaer/MyMouseListener.java @@ -65,14 +65,9 @@ public class MyMouseListener implements MouseInputListener { System.out.println("ERROR selectedStack in StartStack"); } if (tempStack.cardCheck(tempStack.peekLastCard(), saveStack.peekLastCard())) { - while (!saveStack.stackIsEmpty()) { - tempStack.addCard(saveStack.removeLastCard()); - } + clearSaveStack(tempStack); } else { - // Alles wieder auf den Ursprünglichen Stack packen - while (!saveStack.stackIsEmpty()) { - selectedStack.addCard(saveStack.removeLastCard()); - } + clearSaveStack(selectedStack); } selectedStack = null; @@ -87,7 +82,6 @@ public class MyMouseListener implements MouseInputListener { tempStack = (AblageStack) com; } else { tempStack = (AblageStack) com.getParent(); - } if (saveStack.stackIsEmpty()) { @@ -105,10 +99,8 @@ public class MyMouseListener implements MouseInputListener { } } else { - // Alles wieder auf den Ursprünglichen Stack packen - while (!saveStack.stackIsEmpty()) { - selectedStack.addCard(saveStack.removeLastCard()); - } + //Clear Save + clearSaveStack(selectedStack); } } @@ -116,6 +108,13 @@ public class MyMouseListener implements MouseInputListener { } + private void clearSaveStack(BaseStack _ziel) { + // Alles wieder auf den Ursprünglichen Stack packen + while (!saveStack.stackIsEmpty()) { + _ziel.addCard(saveStack.removeLastCard()); + } + } + @Override public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub From 29b2c1db6776a33abc30d581ba495423f01b2bf3 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 17:50:24 +0100 Subject: [PATCH 024/108] Add GeberStack --- src/main/java/solitaer/GeberStack.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/main/java/solitaer/GeberStack.java diff --git a/src/main/java/solitaer/GeberStack.java b/src/main/java/solitaer/GeberStack.java new file mode 100644 index 0000000..2696e62 --- /dev/null +++ b/src/main/java/solitaer/GeberStack.java @@ -0,0 +1,21 @@ +package solitaer; + +public class GeberStack extends BaseStack { + + private static final long serialVersionUID = 1L; + + public GeberStack(int _x, int _y) { + super(false); + super.setLocation(_x, _y); + super.setSize(IMAGE_WIDTH, STACK_HIGHT); + super.setOpaque(false); + super.setLayout(null); + } + + @Override + protected boolean cardCheck(Card _topStack, Card _playerCard) { + // TODO Auto-generated method stub + return false; + } + +} From e5832eac493f85582d3ae3e722b4690c248a4b32 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 17:53:39 +0100 Subject: [PATCH 025/108] Add WasteStack --- src/main/java/solitaer/GeberStack.java | 6 +++++- src/main/java/solitaer/WasteStack.java | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/main/java/solitaer/WasteStack.java diff --git a/src/main/java/solitaer/GeberStack.java b/src/main/java/solitaer/GeberStack.java index 2696e62..b3c6e58 100644 --- a/src/main/java/solitaer/GeberStack.java +++ b/src/main/java/solitaer/GeberStack.java @@ -3,13 +3,17 @@ package solitaer; public class GeberStack extends BaseStack { private static final long serialVersionUID = 1L; + + private WasteStack wasteStack; - public GeberStack(int _x, int _y) { + public GeberStack(int _x, int _y, WasteStack _waste) { super(false); super.setLocation(_x, _y); super.setSize(IMAGE_WIDTH, STACK_HIGHT); super.setOpaque(false); super.setLayout(null); + + this.wasteStack = _waste; } @Override diff --git a/src/main/java/solitaer/WasteStack.java b/src/main/java/solitaer/WasteStack.java new file mode 100644 index 0000000..554a936 --- /dev/null +++ b/src/main/java/solitaer/WasteStack.java @@ -0,0 +1,21 @@ +package solitaer; + +public class WasteStack extends BaseStack { + + private static final long serialVersionUID = 1L; + + public WasteStack(int _x, int _y) { + super(false); + super.setLocation(_x, _y); + super.setSize(IMAGE_WIDTH, STACK_HIGHT); + super.setOpaque(false); + super.setLayout(null); + } + + @Override + protected boolean cardCheck(Card _topStack, Card _playerCard) { + // TODO Auto-generated method stub + return false; + } + +} From f95187e009424b4fecb31f55a43cc6a72f17d988 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 17:58:22 +0100 Subject: [PATCH 026/108] Add render for GeberStack --- src/main/java/solitaer/GeberStack.java | 19 +++++++++++++++++++ src/main/java/solitaer/SolitaerGamePanel.java | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/src/main/java/solitaer/GeberStack.java b/src/main/java/solitaer/GeberStack.java index b3c6e58..9e10e10 100644 --- a/src/main/java/solitaer/GeberStack.java +++ b/src/main/java/solitaer/GeberStack.java @@ -1,5 +1,8 @@ package solitaer; +import java.awt.Color; +import java.awt.Graphics; + public class GeberStack extends BaseStack { private static final long serialVersionUID = 1L; @@ -21,5 +24,21 @@ public class GeberStack extends BaseStack { // TODO Auto-generated method stub return false; } + + @Override + protected void paintComponent(Graphics g) { + // TODO Auto-generated method stub + super.paintComponent(g); + if (stackIsEmpty()) { + g.setColor(Color.pink); + g.fillRect(0, 0, this.getWidth(), IMAGE_HIGHT); + + g.setColor(Color.black); + g.drawRect(0, 0, this.getWidth() - 1, IMAGE_HIGHT - 1); + + String text = "Start\nAgain"; + g.drawString(text, 5, this.IMAGE_HIGHT/2); + } + } } diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 4c16f06..834e22a 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -77,6 +77,13 @@ public class SolitaerGamePanel extends JPanel { this.add(a4); + WasteStack w = new WasteStack(85, 10); + GeberStack g = new GeberStack(10, 10, w); + + this.add(w); + this.add(g); + + } From 698569ba076d98eeadb6894a593b444f6064db59 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 18:00:49 +0100 Subject: [PATCH 027/108] Add render for WasteStack --- src/main/java/solitaer/WasteStack.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/solitaer/WasteStack.java b/src/main/java/solitaer/WasteStack.java index 554a936..c86d360 100644 --- a/src/main/java/solitaer/WasteStack.java +++ b/src/main/java/solitaer/WasteStack.java @@ -1,5 +1,8 @@ package solitaer; +import java.awt.Color; +import java.awt.Graphics; + public class WasteStack extends BaseStack { private static final long serialVersionUID = 1L; @@ -17,5 +20,19 @@ public class WasteStack extends BaseStack { // TODO Auto-generated method stub return false; } + + @Override + protected void paintComponent(Graphics g) { + // TODO Auto-generated method stub + super.paintComponent(g); + if (stackIsEmpty()) { + g.setColor(Color.lightGray); + g.fillRect(0, 0, this.getWidth(), IMAGE_HIGHT); + + g.setColor(Color.black); + g.drawRect(0, 0, this.getWidth() - 1, IMAGE_HIGHT - 1); + + } + } } From f83db6a3f957e407e93ccc34bc4fb41b01645b48 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 18:38:24 +0100 Subject: [PATCH 028/108] Add swapGeberWaste Funktion and Add Test --- src/main/java/solitaer/GeberStack.java | 11 ++++++++++ src/test/java/solitaer/GeberStackTest.java | 25 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/test/java/solitaer/GeberStackTest.java diff --git a/src/main/java/solitaer/GeberStack.java b/src/main/java/solitaer/GeberStack.java index 9e10e10..1136daa 100644 --- a/src/main/java/solitaer/GeberStack.java +++ b/src/main/java/solitaer/GeberStack.java @@ -19,6 +19,17 @@ public class GeberStack extends BaseStack { this.wasteStack = _waste; } + public WasteStack getWastStack() { + return wasteStack; + } + + public void swapWasteGeber() { + while(wasteStack.stackIsEmpty() == false) { + this.addCard(wasteStack.removeLastCard()); + } + } + + @Override protected boolean cardCheck(Card _topStack, Card _playerCard) { // TODO Auto-generated method stub diff --git a/src/test/java/solitaer/GeberStackTest.java b/src/test/java/solitaer/GeberStackTest.java new file mode 100644 index 0000000..0115389 --- /dev/null +++ b/src/test/java/solitaer/GeberStackTest.java @@ -0,0 +1,25 @@ +package solitaer; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +class GeberStackTest { + + @Test + void testswapGeberWaste001() { + WasteStack waste = new WasteStack(0, 0); + GeberStack geber = new GeberStack(0, 0, waste); + + for (int i = 1; i < 14; i++) { + waste.addCard(new Card(0, Symbol.Pik, false)); + } + + int expectedResult = waste.stackSize(); + + geber.swapWasteGeber(); + + assertEquals(geber.stackSize(), expectedResult, "same Size"); + } + +} From ae20cbcbaefab7e9470b1d9946a3cb159c574add Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 21:20:56 +0100 Subject: [PATCH 029/108] Add MousInput GeberStack --- src/main/java/solitaer/GeberStack.java | 4 ++- src/main/java/solitaer/MyMouseListener.java | 25 ++++++++++++++++++- src/main/java/solitaer/SolitaerGamePanel.java | 13 ++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/main/java/solitaer/GeberStack.java b/src/main/java/solitaer/GeberStack.java index 1136daa..a974883 100644 --- a/src/main/java/solitaer/GeberStack.java +++ b/src/main/java/solitaer/GeberStack.java @@ -25,7 +25,9 @@ public class GeberStack extends BaseStack { public void swapWasteGeber() { while(wasteStack.stackIsEmpty() == false) { - this.addCard(wasteStack.removeLastCard()); + Card card = wasteStack.removeLastCard(); + card.setFaceUp(false); + this.addCard(card); } } diff --git a/src/main/java/solitaer/MyMouseListener.java b/src/main/java/solitaer/MyMouseListener.java index ee54111..2e227a2 100644 --- a/src/main/java/solitaer/MyMouseListener.java +++ b/src/main/java/solitaer/MyMouseListener.java @@ -105,9 +105,32 @@ public class MyMouseListener implements MouseInputListener { } } + // GeberStack + else if (com.getParent() instanceof GeberStack || com instanceof GeberStack) { - } + System.out.println("GeberStack"); + + if (com instanceof GeberStack) { + tempStack = (GeberStack) com; + } else { + tempStack = (GeberStack) com.getParent(); + } + + if (tempStack.stackIsEmpty()) { + // Move all from Waste to Geber + ((GeberStack) this.tempStack).swapWasteGeber(); + } else { + // Move next card to Waste + tempCard = tempStack.removeLastCard(); + tempCard.setFaceUp(true); + ((GeberStack) this.tempStack).getWastStack() + .addCard(tempCard); + + } + } + + } private void clearSaveStack(BaseStack _ziel) { // Alles wieder auf den Ursprünglichen Stack packen while (!saveStack.stackIsEmpty()) { diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 834e22a..837bf33 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -80,6 +80,19 @@ public class SolitaerGamePanel extends JPanel { WasteStack w = new WasteStack(85, 10); GeberStack g = new GeberStack(10, 10, w); + deck.getDeck().get(34).setFaceUp(true); + w.addCard(deck.getDeck().get(34)); + deck.getDeck().get(35).setFaceUp(true); + w.addCard(deck.getDeck().get(35)); + deck.getDeck().get(36).setFaceUp(true); + w.addCard(deck.getDeck().get(36)); + deck.getDeck().get(37).setFaceUp(true); + w.addCard(deck.getDeck().get(37)); + + + g.addCard(deck.getDeck().get(38)); + + this.add(w); this.add(g); From b2be476c381ec84dd50bf186bfb6d68005fc83ea Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 21:28:35 +0100 Subject: [PATCH 030/108] Refactor GeberStack --- src/main/java/solitaer/GeberStack.java | 15 ++++++++++++--- src/main/java/solitaer/MyMouseListener.java | 14 +++----------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/java/solitaer/GeberStack.java b/src/main/java/solitaer/GeberStack.java index a974883..41aa66a 100644 --- a/src/main/java/solitaer/GeberStack.java +++ b/src/main/java/solitaer/GeberStack.java @@ -25,12 +25,21 @@ public class GeberStack extends BaseStack { public void swapWasteGeber() { while(wasteStack.stackIsEmpty() == false) { - Card card = wasteStack.removeLastCard(); - card.setFaceUp(false); - this.addCard(card); + moveCardTurnFace(wasteStack, this, false); } } + public void moveToWaste() { + moveCardTurnFace(this, wasteStack, true); + } + + private void moveCardTurnFace(BaseStack _removeStack, BaseStack _addStack, boolean _face) { + Card card = _removeStack.removeLastCard(); + card.setFaceUp(_face); + _addStack.addCard(card); + + } + @Override protected boolean cardCheck(Card _topStack, Card _playerCard) { diff --git a/src/main/java/solitaer/MyMouseListener.java b/src/main/java/solitaer/MyMouseListener.java index 2e227a2..695a440 100644 --- a/src/main/java/solitaer/MyMouseListener.java +++ b/src/main/java/solitaer/MyMouseListener.java @@ -106,30 +106,22 @@ public class MyMouseListener implements MouseInputListener { } // GeberStack - else if (com.getParent() instanceof GeberStack || com instanceof GeberStack) { - + else if (com.getParent() instanceof GeberStack + || com instanceof GeberStack) { System.out.println("GeberStack"); - if (com instanceof GeberStack) { tempStack = (GeberStack) com; } else { tempStack = (GeberStack) com.getParent(); } - if (tempStack.stackIsEmpty()) { // Move all from Waste to Geber ((GeberStack) this.tempStack).swapWasteGeber(); } else { // Move next card to Waste - tempCard = tempStack.removeLastCard(); - tempCard.setFaceUp(true); - ((GeberStack) this.tempStack).getWastStack() - .addCard(tempCard); - + ((GeberStack) this.tempStack).moveToWaste(); } - } - } private void clearSaveStack(BaseStack _ziel) { // Alles wieder auf den Ursprünglichen Stack packen From 8b93f0414429295fcd4fc0e20a3eb6e1f0cab381 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 21:56:46 +0100 Subject: [PATCH 031/108] Add MouseInput WasteStack --- src/main/java/solitaer/MyMouseListener.java | 26 ++++++++++++++++--- src/main/java/solitaer/SolitaerGamePanel.java | 4 +-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/main/java/solitaer/MyMouseListener.java b/src/main/java/solitaer/MyMouseListener.java index 695a440..4067231 100644 --- a/src/main/java/solitaer/MyMouseListener.java +++ b/src/main/java/solitaer/MyMouseListener.java @@ -99,15 +99,14 @@ public class MyMouseListener implements MouseInputListener { } } else { - //Clear Save + // Clear Save clearSaveStack(selectedStack); } } } // GeberStack - else if (com.getParent() instanceof GeberStack - || com instanceof GeberStack) { + else if (com.getParent() instanceof GeberStack || com instanceof GeberStack) { System.out.println("GeberStack"); if (com instanceof GeberStack) { tempStack = (GeberStack) com; @@ -122,7 +121,28 @@ public class MyMouseListener implements MouseInputListener { ((GeberStack) this.tempStack).moveToWaste(); } } + // WasteStack + else if (com.getParent() instanceof WasteStack || com instanceof WasteStack) { + System.out.println("WasteStack"); + if (com instanceof WasteStack) { + tempStack = (WasteStack) com; + } else { + tempStack = (WasteStack) com.getParent(); + } + + if (saveStack.stackIsEmpty()) { + // Move Top Card from AblageStack in Save + if (tempStack.stackIsEmpty() == false) { + saveStack.addCard(tempStack.removeLastCard()); + selectedStack = tempStack; + } + + } else { + clearSaveStack(selectedStack); + } + } } + private void clearSaveStack(BaseStack _ziel) { // Alles wieder auf den Ursprünglichen Stack packen while (!saveStack.stackIsEmpty()) { diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 837bf33..f3f757d 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -55,8 +55,8 @@ public class SolitaerGamePanel extends JPanel { StartStack c = new StartStack(375,125); - deck.getDeck().get(13).setFaceUp(true); - c.addCard((deck.getDeck().get(12))); + deck.getDeck().get(10).setFaceUp(true); + c.addCard((deck.getDeck().get(10))); this.add(c); From 5f6b3bbfffe27232e42c450887e493bbe355087c Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 22:26:22 +0100 Subject: [PATCH 032/108] Fix MouseInput StartStack --- src/main/java/solitaer/MyMouseListener.java | 58 +++++++++++-------- src/main/java/solitaer/SolitaerGamePanel.java | 4 +- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/main/java/solitaer/MyMouseListener.java b/src/main/java/solitaer/MyMouseListener.java index 4067231..70aec81 100644 --- a/src/main/java/solitaer/MyMouseListener.java +++ b/src/main/java/solitaer/MyMouseListener.java @@ -30,37 +30,49 @@ public class MyMouseListener implements MouseInputListener { System.out.println("DOWN"); Component com = SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY()); - // Leeres StartFeld - if (com instanceof StartStack) { - System.out.println("Leer Start"); - - } - // Karte, die in einem StartStack liegt - else if (com instanceof Card && com.getParent() instanceof StartStack) { - tempCard = (Card) com; - tempStack = (StartStack) com.getParent(); +// // Leeres StartFeld +// if (com instanceof StartStack) { +// System.out.println("Leer Start"); +// +// } +// // Karte, die in einem StartStack liegt +// else + if ((com instanceof Card && com.getParent() instanceof StartStack) + || (com instanceof StartStack && ((StartStack) com).stackIsEmpty())) { if (saveStack.stackIsEmpty()) { - // Wenn faceDown, schau ob es die oberste Carde ist und dreh diese um - if (!tempCard.isFaceUp()) { - if (tempStack.peekLastCard().equals(tempCard)) { - tempCard.setFaceUp(true); - tempCard.repaint(); - } - } - // Card faceUp - else { - // move all Cards below the selected Card to Save - int index = tempStack.indexOfCard(tempCard); - while (tempStack.stackSize() - 1 >= index) { - saveStack.addCard(tempStack.removeLastCard()); + + if (com instanceof Card && com.getParent() instanceof StartStack) { + tempCard = (Card) com; + tempStack = (StartStack) com.getParent(); + + // Wenn faceDown, schau ob es die oberste Carde ist und dreh diese um + if (!tempCard.isFaceUp()) { + if (tempStack.peekLastCard().equals(tempCard)) { + tempCard.setFaceUp(true); + tempCard.repaint(); + } } - selectedStack = tempStack; + // Card faceUp + else { + // move all Cards below the selected Card to Save + int index = tempStack.indexOfCard(tempCard); + while (tempStack.stackSize() - 1 >= index) { + saveStack.addCard(tempStack.removeLastCard()); + } + selectedStack = tempStack; + } } } // saveStack is NOT empty else { + if(com instanceof StartStack) { + tempStack = (StartStack) com; + } else { + tempStack = (StartStack) com.getParent(); + } + if (selectedStack == null) { System.out.println("ERROR selectedStack in StartStack"); } diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index f3f757d..7eaf634 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -55,8 +55,8 @@ public class SolitaerGamePanel extends JPanel { StartStack c = new StartStack(375,125); - deck.getDeck().get(10).setFaceUp(true); - c.addCard((deck.getDeck().get(10))); + //deck.getDeck().get(20).setFaceUp(true); + c.addCard((deck.getDeck().get(20))); this.add(c); From d89b2a0c02bfbc0b999b84158c4e419b2980d944 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 22:35:24 +0100 Subject: [PATCH 033/108] Update check and test from StartStack --- src/main/java/solitaer/StartStack.java | 36 +++++++++------------- src/test/java/solitaer/StartStackTest.java | 5 +-- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/main/java/solitaer/StartStack.java b/src/main/java/solitaer/StartStack.java index 068b88f..0dd2f8f 100644 --- a/src/main/java/solitaer/StartStack.java +++ b/src/main/java/solitaer/StartStack.java @@ -3,11 +3,10 @@ package solitaer; import java.awt.Color; import java.awt.Graphics; - public class StartStack extends BaseStack { private static final long serialVersionUID = 1L; - + public StartStack(int _x, int _y) { super(true); super.setLocation(_x, _y); @@ -17,30 +16,27 @@ public class StartStack extends BaseStack { } public boolean cardCheck(Card _topStack, Card _playerCard) { - if(_topStack == null && _playerCard == null) { + if (_topStack == null && _playerCard == null) { return false; - } + } if (_topStack == null) { // Nur der König kann auf einen leeren Stapel gelegt werden return _playerCard.getNr() == 13; - }else { + } else if (!_topStack.isFaceUp()) { + return false; + } else { return (// Nummer nur aufsteigend - _topStack.getNr() == _playerCard.getNr() + 1) - && - // rot auf Schwarz - ( - ((_topStack.getSymbol() == Symbol.Herz || _topStack.getSymbol() == Symbol.Karo) - && (_playerCard.getSymbol() == Symbol.Pik || _playerCard.getSymbol() == Symbol.Kreuz)) - || + _topStack.getNr() == _playerCard.getNr() + 1) && + // rot auf Schwarz + (((_topStack.getSymbol() == Symbol.Herz || _topStack.getSymbol() == Symbol.Karo) + && (_playerCard.getSymbol() == Symbol.Pik || _playerCard.getSymbol() == Symbol.Kreuz)) || // schwarz auf rot - ((_topStack.getSymbol() == Symbol.Pik || _topStack.getSymbol() == Symbol.Kreuz) - && (_playerCard.getSymbol() == Symbol.Herz || _playerCard.getSymbol() == Symbol.Karo)) - ); + ((_topStack.getSymbol() == Symbol.Pik || _topStack.getSymbol() == Symbol.Kreuz) + && (_playerCard.getSymbol() == Symbol.Herz + || _playerCard.getSymbol() == Symbol.Karo))); } } - - @Override protected void paintComponent(Graphics g) { // TODO Auto-generated method stub @@ -48,12 +44,10 @@ public class StartStack extends BaseStack { if (stackIsEmpty()) { g.setColor(Color.gray); g.fillRect(0, 0, this.getWidth(), IMAGE_HIGHT); - + g.setColor(Color.black); - g.drawRect(0, 0, this.getWidth()-1, IMAGE_HIGHT-1); + g.drawRect(0, 0, this.getWidth() - 1, IMAGE_HIGHT - 1); } } - - } diff --git a/src/test/java/solitaer/StartStackTest.java b/src/test/java/solitaer/StartStackTest.java index e9515e8..d033e45 100644 --- a/src/test/java/solitaer/StartStackTest.java +++ b/src/test/java/solitaer/StartStackTest.java @@ -29,8 +29,9 @@ class StartStackTest { Arguments.of("5-Pik auf 6-Karo", new Card(6, Symbol.Karo, true), new Card(5, Symbol.Pik, true), true), Arguments.of("König-Karo auf Ass-Kreuz", new Card(1, Symbol.Kreuz, true), new Card(13, Symbol.Karo, true), false), Arguments.of("5-Karo auf 7-Kreuz", new Card(7, Symbol.Kreuz, true), new Card(5, Symbol.Karo, true), false), - Arguments.of("2-Herz auf Ass-Kreuz", new Card(2, Symbol.Herz, true), new Card(1, Symbol.Kreuz, true), true), - Arguments.of("null auf null", null, null, false) + Arguments.of("Ass-Herz auf 2-Kreuz", new Card(2, Symbol.Herz, true), new Card(1, Symbol.Kreuz, true), true), + Arguments.of("null auf null", null, null, false), + Arguments.of("Ass-Herz auf face-Down-2-Kreuz", new Card(2, Symbol.Herz, false), new Card(1, Symbol.Kreuz, true), false) ); } From 3ad5083c354c4999ba1c9b2ae4595f7c2a45d9f3 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 22:43:43 +0100 Subject: [PATCH 034/108] Refactor Card and StartStack --- src/main/java/solitaer/Card.java | 12 +++++++++++- src/main/java/solitaer/StartStack.java | 9 +++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/solitaer/Card.java b/src/main/java/solitaer/Card.java index af55cfc..5cad36d 100644 --- a/src/main/java/solitaer/Card.java +++ b/src/main/java/solitaer/Card.java @@ -39,6 +39,16 @@ public class Card extends JPanel { public int getNr() { return nr; } + + public boolean isred() { + return this.symbol == Symbol.Herz + || this.symbol == Symbol.Karo; + } + + public boolean isblack() { + return this.symbol == Symbol.Kreuz + || this.symbol == Symbol.Pik; + } private String getNrText() { if (this.nr < 10) { @@ -107,7 +117,7 @@ public class Card extends JPanel { g.setColor(Color.black); g.drawRect(0, 0, this.getWidth() - 1, this.getHeight() - 1); - if (this.symbol == Symbol.Herz || this.symbol == Symbol.Karo) + if (this.isred()) g.setColor(Color.red); else g.setColor(Color.black); diff --git a/src/main/java/solitaer/StartStack.java b/src/main/java/solitaer/StartStack.java index 0dd2f8f..9c66b1d 100644 --- a/src/main/java/solitaer/StartStack.java +++ b/src/main/java/solitaer/StartStack.java @@ -26,14 +26,11 @@ public class StartStack extends BaseStack { return false; } else { return (// Nummer nur aufsteigend - _topStack.getNr() == _playerCard.getNr() + 1) && + (_topStack.getNr() == _playerCard.getNr() + 1) && // rot auf Schwarz - (((_topStack.getSymbol() == Symbol.Herz || _topStack.getSymbol() == Symbol.Karo) - && (_playerCard.getSymbol() == Symbol.Pik || _playerCard.getSymbol() == Symbol.Kreuz)) || + ((_topStack.isred() && _playerCard.isblack()) || // schwarz auf rot - ((_topStack.getSymbol() == Symbol.Pik || _topStack.getSymbol() == Symbol.Kreuz) - && (_playerCard.getSymbol() == Symbol.Herz - || _playerCard.getSymbol() == Symbol.Karo))); + (_topStack.isblack() && _playerCard.isred()))); } } From 02ad893dea6a4e153b8040d5fd1c8e402ff5949f Mon Sep 17 00:00:00 2001 From: kfkama Date: Wed, 2 Feb 2022 10:29:28 +0100 Subject: [PATCH 035/108] Init Base UI --- .gitignore | 22 +++++++++ src/main/java/TicTacToe/TicTacToeGame.java | 48 +++++++++++++++++++ .../java/TicTacToe/TicTacToeGameTest.java | 10 ++++ 3 files changed, 80 insertions(+) create mode 100644 src/main/java/TicTacToe/TicTacToeGame.java create mode 100644 src/test/java/TicTacToe/TicTacToeGameTest.java diff --git a/.gitignore b/.gitignore index 84adb3f..c837958 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,25 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +.mvn/wrapper/maven-wrapper.jar + +# Eclipse m2e generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# End of https://www.toptal.com/developers/gitignore/api/maven + diff --git a/src/main/java/TicTacToe/TicTacToeGame.java b/src/main/java/TicTacToe/TicTacToeGame.java new file mode 100644 index 0000000..f958273 --- /dev/null +++ b/src/main/java/TicTacToe/TicTacToeGame.java @@ -0,0 +1,48 @@ +package TicTacToe; + +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.geom.Line2D; + +import javax.swing.JFrame; +import javax.swing.JPanel; + + +public class TicTacToeGame extends JPanel { + + private static final long serialVersionUID = 1L; + private static int width = 600, height = 600; + + public TicTacToeGame() { + this.setSize(width, height); + } + + public static void main(String[] args) { + + JFrame f = new JFrame(); + TicTacToeGame ttt = new TicTacToeGame(); + + f.add(ttt); + f.setSize(width,height); + f.setLayout(null); + f.setVisible(true); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + Graphics2D g2 = (Graphics2D) g; + + Line2D lin = new Line2D.Float(250, 150, 250, 450); + Line2D lin2 = new Line2D.Float(350, 150, 350, 450); + Line2D lin3 = new Line2D.Float(150, 250, 450, 250); + Line2D lin4 = new Line2D.Float(150, 350, 450, 350); + + g2.draw(lin); + g2.draw(lin2); + g2.draw(lin3); + g2.draw(lin4); + } + + +} \ No newline at end of file diff --git a/src/test/java/TicTacToe/TicTacToeGameTest.java b/src/test/java/TicTacToe/TicTacToeGameTest.java new file mode 100644 index 0000000..08742dd --- /dev/null +++ b/src/test/java/TicTacToe/TicTacToeGameTest.java @@ -0,0 +1,10 @@ +package TicTacToe; + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; + +class TicTacToeGameTest { + + + +} From a0409b6b94e6f5b8c73008b54fd644bae2898e7f Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Fri, 4 Feb 2022 16:04:03 +0100 Subject: [PATCH 036/108] Set Layout StartStacks --- src/main/java/solitaer/SolitaerGamePanel.java | 92 +++++++++++-------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 7eaf634..374b937 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -8,10 +8,19 @@ import javax.swing.JPanel; public class SolitaerGamePanel extends JPanel { private static final long serialVersionUID = 1L; + + private final int OFFSET_STACKS = 5; + public final int IMAGE_WIDTH = 72; + public final int IMAGE_HIGHT = 96; + private CardDeck deck; private MyMouseListener mouseL; private SaveStack save =new SaveStack(500,250); + private StartStack[] start = new StartStack[7] ; + + + public SolitaerGamePanel() { @@ -20,48 +29,53 @@ public class SolitaerGamePanel extends JPanel { mouseL = new MyMouseListener(save); this.addMouseListener(mouseL); - deck = new CardDeck(); - - - StartStack a = new StartStack(25,125); - - deck.getDeck().get(5).setFaceUp(true); - a.addCard((deck.getDeck().get(5))); - - deck.getDeck().get(4).setFaceUp(true); - a.addCard((deck.getDeck().get(4))); - - deck.getDeck().get(3).setFaceUp(true); - a.addCard((deck.getDeck().get(3))); - deck.getDeck().get(2).setFaceUp(true); - a.addCard((deck.getDeck().get(2))); - - deck.getDeck().get(1).setFaceUp(true); - a.addCard((deck.getDeck().get(1))); - - deck.getDeck().get(0).setFaceUp(true); - a.addCard(deck.getDeck().get(0)); - - this.add(a); - - StartStack b = new StartStack(200,125); - - deck.getDeck().get(32).setFaceUp(true); - b.addCard((deck.getDeck().get(32))); - this.add(b); - - StartStack c = new StartStack(375,125); - - //deck.getDeck().get(20).setFaceUp(true); - c.addCard((deck.getDeck().get(20))); - this.add(c); - - - StartStack d = new StartStack(475,125); - this.add(d); + for(int i = 0; i<7; i++) { + int x = (((IMAGE_WIDTH+OFFSET_STACKS)*i)+OFFSET_STACKS); + System.out.println(x); + start[i] = new StartStack(x, 125); + this.add(start[i]); + } + +// StartStack a = new StartStack(25,125); +// +// deck.getDeck().get(5).setFaceUp(true); +// a.addCard((deck.getDeck().get(5))); +// +// deck.getDeck().get(4).setFaceUp(true); +// a.addCard((deck.getDeck().get(4))); +// +// deck.getDeck().get(3).setFaceUp(true); +// a.addCard((deck.getDeck().get(3))); +// +// deck.getDeck().get(2).setFaceUp(true); +// a.addCard((deck.getDeck().get(2))); +// +// deck.getDeck().get(1).setFaceUp(true); +// a.addCard((deck.getDeck().get(1))); +// +// deck.getDeck().get(0).setFaceUp(true); +// a.addCard(deck.getDeck().get(0)); +// +// this.add(a); +// +// StartStack b = new StartStack(200,125); +// +// deck.getDeck().get(32).setFaceUp(true); +// b.addCard((deck.getDeck().get(32))); +// this.add(b); +// +// StartStack c = new StartStack(375,125); +// +// //deck.getDeck().get(20).setFaceUp(true); +// c.addCard((deck.getDeck().get(20))); +// this.add(c); +// +// +// StartStack d = new StartStack(475,125); +// this.add(d); //save = new SaveStack(500,250); this.add(save); From d79fd583f551c6faca906d4230b8b2cd0f7cd818 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Fri, 4 Feb 2022 16:13:05 +0100 Subject: [PATCH 037/108] Set Layout AblageStacks --- src/main/java/solitaer/SolitaerGamePanel.java | 72 +++++++------------ 1 file changed, 25 insertions(+), 47 deletions(-) diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 374b937..7e867a7 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -18,6 +18,7 @@ public class SolitaerGamePanel extends JPanel { private SaveStack save =new SaveStack(500,250); private StartStack[] start = new StartStack[7] ; + private AblageStack[] ablage = new AblageStack[4]; @@ -39,56 +40,33 @@ public class SolitaerGamePanel extends JPanel { this.add(start[i]); } -// StartStack a = new StartStack(25,125); -// -// deck.getDeck().get(5).setFaceUp(true); -// a.addCard((deck.getDeck().get(5))); -// -// deck.getDeck().get(4).setFaceUp(true); -// a.addCard((deck.getDeck().get(4))); -// -// deck.getDeck().get(3).setFaceUp(true); -// a.addCard((deck.getDeck().get(3))); -// -// deck.getDeck().get(2).setFaceUp(true); -// a.addCard((deck.getDeck().get(2))); -// -// deck.getDeck().get(1).setFaceUp(true); -// a.addCard((deck.getDeck().get(1))); -// -// deck.getDeck().get(0).setFaceUp(true); -// a.addCard(deck.getDeck().get(0)); -// -// this.add(a); -// -// StartStack b = new StartStack(200,125); -// -// deck.getDeck().get(32).setFaceUp(true); -// b.addCard((deck.getDeck().get(32))); -// this.add(b); -// -// StartStack c = new StartStack(375,125); -// -// //deck.getDeck().get(20).setFaceUp(true); -// c.addCard((deck.getDeck().get(20))); -// this.add(c); -// -// -// StartStack d = new StartStack(475,125); -// this.add(d); + - //save = new SaveStack(500,250); - this.add(save); + for(int i = 0; i<4; i++) { + int x = (((IMAGE_WIDTH+OFFSET_STACKS)*(3+i))+OFFSET_STACKS); + switch (i) { + case 0: + ablage[i] = new AblageStack(x, 10, Symbol.Herz); + break; + case 1: + ablage[i] = new AblageStack(x, 10, Symbol.Kreuz); + break; + case 2: + ablage[i] = new AblageStack(x, 10, Symbol.Karo); + break; + case 3: + ablage[i] = new AblageStack(x, 10, Symbol.Pik); + break; + + default: + break; + } + this.add(ablage[i]); + } - AblageStack a1 = new AblageStack(200, 10, Symbol.Herz); - this.add(a1); - AblageStack a2 = new AblageStack(275, 10, Symbol.Kreuz); - this.add(a2); - AblageStack a3 = new AblageStack(350, 10, Symbol.Karo); - this.add(a3); - AblageStack a4 = new AblageStack(425, 10, Symbol.Pik); - this.add(a4); + //save = new SaveStack(500,250); + this.add(save); WasteStack w = new WasteStack(85, 10); From 8be8a7096b9d9b3a76492a6386488c49b95e4478 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Fri, 4 Feb 2022 16:19:21 +0100 Subject: [PATCH 038/108] Set Layout Geber- WasteStack --- src/main/java/solitaer/SolitaerGamePanel.java | 37 +++++++------------ 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 7e867a7..84454cd 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -9,7 +9,9 @@ public class SolitaerGamePanel extends JPanel { private static final long serialVersionUID = 1L; - private final int OFFSET_STACKS = 5; + private final int OFFSET_STACKS_X = 5; + private final int OFFSET_STACKS_Y = 10; + public final int IMAGE_WIDTH = 72; public final int IMAGE_HIGHT = 96; @@ -20,6 +22,9 @@ public class SolitaerGamePanel extends JPanel { private StartStack[] start = new StartStack[7] ; private AblageStack[] ablage = new AblageStack[4]; + private WasteStack w;// = new WasteStack(85, 10); + private GeberStack g;// = new GeberStack(10, 10, w); + @@ -34,7 +39,7 @@ public class SolitaerGamePanel extends JPanel { for(int i = 0; i<7; i++) { - int x = (((IMAGE_WIDTH+OFFSET_STACKS)*i)+OFFSET_STACKS); + int x = (((IMAGE_WIDTH+OFFSET_STACKS_X)*i)+OFFSET_STACKS_X); System.out.println(x); start[i] = new StartStack(x, 125); this.add(start[i]); @@ -43,19 +48,19 @@ public class SolitaerGamePanel extends JPanel { for(int i = 0; i<4; i++) { - int x = (((IMAGE_WIDTH+OFFSET_STACKS)*(3+i))+OFFSET_STACKS); + int x = (((IMAGE_WIDTH+OFFSET_STACKS_X)*(3+i))+OFFSET_STACKS_X); switch (i) { case 0: - ablage[i] = new AblageStack(x, 10, Symbol.Herz); + ablage[i] = new AblageStack(x, OFFSET_STACKS_Y, Symbol.Herz); break; case 1: - ablage[i] = new AblageStack(x, 10, Symbol.Kreuz); + ablage[i] = new AblageStack(x, OFFSET_STACKS_Y, Symbol.Kreuz); break; case 2: - ablage[i] = new AblageStack(x, 10, Symbol.Karo); + ablage[i] = new AblageStack(x, OFFSET_STACKS_Y, Symbol.Karo); break; case 3: - ablage[i] = new AblageStack(x, 10, Symbol.Pik); + ablage[i] = new AblageStack(x, OFFSET_STACKS_Y, Symbol.Pik); break; default: @@ -69,22 +74,8 @@ public class SolitaerGamePanel extends JPanel { this.add(save); - WasteStack w = new WasteStack(85, 10); - GeberStack g = new GeberStack(10, 10, w); - - deck.getDeck().get(34).setFaceUp(true); - w.addCard(deck.getDeck().get(34)); - deck.getDeck().get(35).setFaceUp(true); - w.addCard(deck.getDeck().get(35)); - deck.getDeck().get(36).setFaceUp(true); - w.addCard(deck.getDeck().get(36)); - deck.getDeck().get(37).setFaceUp(true); - w.addCard(deck.getDeck().get(37)); - - - g.addCard(deck.getDeck().get(38)); - - + w = new WasteStack((IMAGE_WIDTH+(OFFSET_STACKS_X)*2), OFFSET_STACKS_Y); + g = new GeberStack(OFFSET_STACKS_X, OFFSET_STACKS_Y, w); this.add(w); this.add(g); From c5a31c3991a952a682b5f007299c6766d71e4476 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Fri, 4 Feb 2022 16:28:19 +0100 Subject: [PATCH 039/108] Set Layout SaveStack --- src/main/java/solitaer/SolitaerGamePanel.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 84454cd..3aa618b 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -1,8 +1,10 @@ package solitaer; import java.awt.Color; +import java.awt.Font; import java.awt.Graphics; +import javax.swing.JLabel; import javax.swing.JPanel; public class SolitaerGamePanel extends JPanel { @@ -18,7 +20,7 @@ public class SolitaerGamePanel extends JPanel { private CardDeck deck; private MyMouseListener mouseL; - private SaveStack save =new SaveStack(500,250); + private SaveStack save;// =new SaveStack(500,250); private StartStack[] start = new StartStack[7] ; private AblageStack[] ablage = new AblageStack[4]; @@ -70,7 +72,13 @@ public class SolitaerGamePanel extends JPanel { } - //save = new SaveStack(500,250); + int Offset_x_Save = (((IMAGE_WIDTH+OFFSET_STACKS_X)*8)+OFFSET_STACKS_X); + JLabel label = new JLabel(); + label.setText("selected Cards"); + label.setBounds(Offset_x_Save, 100, 200,25); + this.add(label); + + save = new SaveStack(Offset_x_Save,125); this.add(save); From d477a4f2e3062579a5782656e54b522dc546f4f3 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Fri, 4 Feb 2022 16:45:55 +0100 Subject: [PATCH 040/108] Refactor SolitaerGamePanel --- src/main/java/solitaer/SolitaerGamePanel.java | 97 ++++++++++--------- 1 file changed, 51 insertions(+), 46 deletions(-) diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 3aa618b..2c22ba6 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -10,59 +10,55 @@ import javax.swing.JPanel; public class SolitaerGamePanel extends JPanel { private static final long serialVersionUID = 1L; - + private final int OFFSET_STACKS_X = 5; - private final int OFFSET_STACKS_Y = 10; + private final int OFFSET_STACKS_Y = 15; public final int IMAGE_WIDTH = 72; public final int IMAGE_HIGHT = 96; - + + public final int STARTSTACK_SIZE = 7; + public final int ABLAGESTACK_SIZE = 4; + private CardDeck deck; private MyMouseListener mouseL; - - private SaveStack save;// =new SaveStack(500,250); - private StartStack[] start = new StartStack[7] ; + + private SaveStack save; + private StartStack[] start = new StartStack[7]; private AblageStack[] ablage = new AblageStack[4]; - - private WasteStack w;// = new WasteStack(85, 10); - private GeberStack g;// = new GeberStack(10, 10, w); - - - - - + + private WasteStack waste; + private GeberStack geber; + public SolitaerGamePanel() { setLayout(null); - + mouseL = new MyMouseListener(save); this.addMouseListener(mouseL); - deck = new CardDeck(); - + deck = new CardDeck(); - for(int i = 0; i<7; i++) { - int x = (((IMAGE_WIDTH+OFFSET_STACKS_X)*i)+OFFSET_STACKS_X); - System.out.println(x); - start[i] = new StartStack(x, 125); + for (int i = 0; i < STARTSTACK_SIZE; i++) { + int y = setLayouty(1); + start[i] = new StartStack(setLayoutX(i), y); this.add(start[i]); } - - - - for(int i = 0; i<4; i++) { - int x = (((IMAGE_WIDTH+OFFSET_STACKS_X)*(3+i))+OFFSET_STACKS_X); + + for (int i = 0; i < ABLAGESTACK_SIZE; i++) { + int x = setLayoutX(((STARTSTACK_SIZE - ABLAGESTACK_SIZE) + i)); + int y = setLayouty(0); switch (i) { case 0: - ablage[i] = new AblageStack(x, OFFSET_STACKS_Y, Symbol.Herz); + ablage[i] = new AblageStack(x, y, Symbol.Herz); break; case 1: - ablage[i] = new AblageStack(x, OFFSET_STACKS_Y, Symbol.Kreuz); + ablage[i] = new AblageStack(x, y, Symbol.Kreuz); break; case 2: - ablage[i] = new AblageStack(x, OFFSET_STACKS_Y, Symbol.Karo); + ablage[i] = new AblageStack(x, y, Symbol.Karo); break; case 3: - ablage[i] = new AblageStack(x, OFFSET_STACKS_Y, Symbol.Pik); + ablage[i] = new AblageStack(x, y, Symbol.Pik); break; default: @@ -70,32 +66,41 @@ public class SolitaerGamePanel extends JPanel { } this.add(ablage[i]); } + + int Offset_x_Save = setLayoutX(STARTSTACK_SIZE + 1); + int Offset_y_Save = setLayouty(1); - - int Offset_x_Save = (((IMAGE_WIDTH+OFFSET_STACKS_X)*8)+OFFSET_STACKS_X); JLabel label = new JLabel(); label.setText("selected Cards"); - label.setBounds(Offset_x_Save, 100, 200,25); + label.setBounds(Offset_x_Save, Offset_y_Save - 25, 200, 25); this.add(label); - - save = new SaveStack(Offset_x_Save,125); + + save = new SaveStack(Offset_x_Save, Offset_y_Save); this.add(save); - - - w = new WasteStack((IMAGE_WIDTH+(OFFSET_STACKS_X)*2), OFFSET_STACKS_Y); - g = new GeberStack(OFFSET_STACKS_X, OFFSET_STACKS_Y, w); - this.add(w); - this.add(g); - - + + waste = new WasteStack(setLayoutX(1), OFFSET_STACKS_Y); + geber = new GeberStack(setLayoutX(0), OFFSET_STACKS_Y, waste); + this.add(waste); + this.add(geber); + + } + + private int setLayoutX(int _spalte) { + return (((IMAGE_WIDTH + OFFSET_STACKS_X) * _spalte) + OFFSET_STACKS_X); } - - + + private int setLayouty(int _row) { + if(_row == 1) + return IMAGE_HIGHT + (OFFSET_STACKS_Y * 3); + else + return OFFSET_STACKS_Y; + } + @Override protected void paintComponent(Graphics g) { // TODO Auto-generated method stub super.paintComponent(g); - g.setColor(Color.green); + g.setColor(new Color(0, 135, 62)); g.fillRect(0, 0, this.getWidth(), this.getHeight()); } } From 3576bf037069015f5d98bd87e725aad77c43f71c Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Fri, 4 Feb 2022 16:57:15 +0100 Subject: [PATCH 041/108] ADD Cards to StartStacks --- src/main/java/solitaer/SolitaerGamePanel.java | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 2c22ba6..5d1165f 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -32,17 +32,40 @@ public class SolitaerGamePanel extends JPanel { public SolitaerGamePanel() { setLayout(null); + + + int Offset_x_Save = setLayoutX(STARTSTACK_SIZE + 1); + int Offset_y_Save = setLayouty(1); + + JLabel label = new JLabel(); + label.setText("selected Cards"); + label.setBounds(Offset_x_Save, Offset_y_Save - 25, 200, 25); + this.add(label); + + save = new SaveStack(Offset_x_Save, Offset_y_Save); + this.add(save); + mouseL = new MyMouseListener(save); this.addMouseListener(mouseL); deck = new CardDeck(); + System.out.println(deck.getDeck().size()); for (int i = 0; i < STARTSTACK_SIZE; i++) { int y = setLayouty(1); start[i] = new StartStack(setLayoutX(i), y); + int tmp = i; + while(tmp != 0) { + start[i].addCard(deck.getDeck().remove(0)); + tmp -= 1; + } + Card card = deck.getDeck().remove(0); + card.setFaceUp(true); + start[i].addCard(card); this.add(start[i]); } + System.out.println(deck.getDeck().size()); for (int i = 0; i < ABLAGESTACK_SIZE; i++) { int x = setLayoutX(((STARTSTACK_SIZE - ABLAGESTACK_SIZE) + i)); @@ -67,17 +90,6 @@ public class SolitaerGamePanel extends JPanel { this.add(ablage[i]); } - int Offset_x_Save = setLayoutX(STARTSTACK_SIZE + 1); - int Offset_y_Save = setLayouty(1); - - JLabel label = new JLabel(); - label.setText("selected Cards"); - label.setBounds(Offset_x_Save, Offset_y_Save - 25, 200, 25); - this.add(label); - - save = new SaveStack(Offset_x_Save, Offset_y_Save); - this.add(save); - waste = new WasteStack(setLayoutX(1), OFFSET_STACKS_Y); geber = new GeberStack(setLayoutX(0), OFFSET_STACKS_Y, waste); this.add(waste); From abecb9f8be2acd55af87ca423db6d2fda7eaab28 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Fri, 4 Feb 2022 17:02:57 +0100 Subject: [PATCH 042/108] ADD all remaining Cards to GeberStack --- src/main/java/solitaer/SolitaerGamePanel.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 5d1165f..86b40c8 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -33,7 +33,6 @@ public class SolitaerGamePanel extends JPanel { public SolitaerGamePanel() { setLayout(null); - int Offset_x_Save = setLayoutX(STARTSTACK_SIZE + 1); int Offset_y_Save = setLayouty(1); @@ -45,12 +44,10 @@ public class SolitaerGamePanel extends JPanel { save = new SaveStack(Offset_x_Save, Offset_y_Save); this.add(save); - mouseL = new MyMouseListener(save); this.addMouseListener(mouseL); deck = new CardDeck(); - System.out.println(deck.getDeck().size()); for (int i = 0; i < STARTSTACK_SIZE; i++) { int y = setLayouty(1); @@ -65,7 +62,6 @@ public class SolitaerGamePanel extends JPanel { start[i].addCard(card); this.add(start[i]); } - System.out.println(deck.getDeck().size()); for (int i = 0; i < ABLAGESTACK_SIZE; i++) { int x = setLayoutX(((STARTSTACK_SIZE - ABLAGESTACK_SIZE) + i)); @@ -92,6 +88,11 @@ public class SolitaerGamePanel extends JPanel { waste = new WasteStack(setLayoutX(1), OFFSET_STACKS_Y); geber = new GeberStack(setLayoutX(0), OFFSET_STACKS_Y, waste); + + while(deck.getDeck().size() != 0) { + geber.addCard(deck.getDeck().remove(0)); + } + this.add(waste); this.add(geber); From 337594435a88245425e47e1cc5aa5cafa8e76cd4 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Fri, 4 Feb 2022 17:11:22 +0100 Subject: [PATCH 043/108] ADD last card to WasteStack --- src/main/java/solitaer/SolitaerGamePanel.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 86b40c8..0edca74 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -89,10 +89,14 @@ public class SolitaerGamePanel extends JPanel { waste = new WasteStack(setLayoutX(1), OFFSET_STACKS_Y); geber = new GeberStack(setLayoutX(0), OFFSET_STACKS_Y, waste); - while(deck.getDeck().size() != 0) { + while(deck.getDeck().size() != 1) { geber.addCard(deck.getDeck().remove(0)); } + Card card = deck.getDeck().remove(0); + card.setFaceUp(true); + waste.addCard(card); + this.add(waste); this.add(geber); From f6a2f009da39d5ed07355eaac95a499cc77d6821 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Fri, 4 Feb 2022 21:55:24 +0100 Subject: [PATCH 044/108] Add Shuffel for CardDeck --- src/main/java/solitaer/CardDeck.java | 6 ++++++ src/main/java/solitaer/SolitaerGamePanel.java | 1 + 2 files changed, 7 insertions(+) diff --git a/src/main/java/solitaer/CardDeck.java b/src/main/java/solitaer/CardDeck.java index 41a6518..3b49bdf 100644 --- a/src/main/java/solitaer/CardDeck.java +++ b/src/main/java/solitaer/CardDeck.java @@ -1,6 +1,7 @@ package solitaer; import java.util.ArrayList; +import java.util.Collections; public class CardDeck { @@ -33,4 +34,9 @@ public class CardDeck { return deck; } + + public void shuffelDeck() { + Collections.shuffle(deck); + } + } diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 0edca74..26b1e18 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -48,6 +48,7 @@ public class SolitaerGamePanel extends JPanel { this.addMouseListener(mouseL); deck = new CardDeck(); + deck.shuffelDeck(); for (int i = 0; i < STARTSTACK_SIZE; i++) { int y = setLayouty(1); From 6c2aaeb146d57f157f6b27933c27ca66c487ebfe Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Fri, 4 Feb 2022 22:08:17 +0100 Subject: [PATCH 045/108] Fix MouseListener --- src/main/java/solitaer/MyMouseListener.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/solitaer/MyMouseListener.java b/src/main/java/solitaer/MyMouseListener.java index 70aec81..d222ac6 100644 --- a/src/main/java/solitaer/MyMouseListener.java +++ b/src/main/java/solitaer/MyMouseListener.java @@ -29,14 +29,7 @@ public class MyMouseListener implements MouseInputListener { // TODO Auto-generated method stub System.out.println("DOWN"); Component com = SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY()); - -// // Leeres StartFeld -// if (com instanceof StartStack) { -// System.out.println("Leer Start"); -// -// } -// // Karte, die in einem StartStack liegt -// else + if ((com instanceof Card && com.getParent() instanceof StartStack) || (com instanceof StartStack && ((StartStack) com).stackIsEmpty())) { @@ -152,6 +145,12 @@ public class MyMouseListener implements MouseInputListener { } else { clearSaveStack(selectedStack); } + //Clear SaveStack click on SolitaerGamePanel + }else if(com instanceof SolitaerGamePanel || + com.getParent() instanceof SolitaerGamePanel && com instanceof StartStack ){ + if(saveStack.stackIsEmpty() == false) { + clearSaveStack(selectedStack); + } } } From b8ad7aca0676b7a6343ca8953003cf3eaa27b098 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 6 Feb 2022 15:30:15 +0100 Subject: [PATCH 046/108] Add SolitaerMenue --- src/main/java/hauptmenue/GameWindow.java | 7 +++--- src/main/java/solitaer/SolitaerMenue.java | 30 +++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 src/main/java/solitaer/SolitaerMenue.java diff --git a/src/main/java/hauptmenue/GameWindow.java b/src/main/java/hauptmenue/GameWindow.java index a2c7479..7fe612d 100644 --- a/src/main/java/hauptmenue/GameWindow.java +++ b/src/main/java/hauptmenue/GameWindow.java @@ -5,18 +5,19 @@ import java.awt.Dimension; import javax.swing.JFrame; import solitaer.SolitaerGamePanel; +import solitaer.SolitaerMenue; public class GameWindow extends JFrame { - /** - * - */ private static final long serialVersionUID = 1L; private final SolitaerGamePanel gamePanel = new SolitaerGamePanel(); + + private SolitaerMenue smenue = new SolitaerMenue(); public GameWindow() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); gamePanel.setPreferredSize(new Dimension(1180, 780)); + this.setJMenuBar(smenue.getMenue()); add(gamePanel); pack(); diff --git a/src/main/java/solitaer/SolitaerMenue.java b/src/main/java/solitaer/SolitaerMenue.java new file mode 100644 index 0000000..e2c854b --- /dev/null +++ b/src/main/java/solitaer/SolitaerMenue.java @@ -0,0 +1,30 @@ +package solitaer; + +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; + +public class SolitaerMenue { + + JMenuBar menuBar = new JMenuBar(); + + JMenu menu = new JMenu("options"); + + JMenuItem restart = new JMenuItem("restart"); + JMenuItem quit = new JMenuItem("quit"); + + public SolitaerMenue() { + + this.menu.add(restart); + this.menu.addSeparator(); + this.menu.add(quit); + + this.menuBar.add(menu); + + } + + public JMenuBar getMenue() { + return menuBar; + } + +} From e902f029cebc1b7f86981d2b0a707772c20b108f Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 6 Feb 2022 15:37:30 +0100 Subject: [PATCH 047/108] Add MouseInput MenueQuit-Button --- src/main/java/solitaer/SolitaerMenue.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/solitaer/SolitaerMenue.java b/src/main/java/solitaer/SolitaerMenue.java index e2c854b..76a86ef 100644 --- a/src/main/java/solitaer/SolitaerMenue.java +++ b/src/main/java/solitaer/SolitaerMenue.java @@ -1,10 +1,13 @@ package solitaer; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; -public class SolitaerMenue { +public class SolitaerMenue implements ActionListener{ JMenuBar menuBar = new JMenuBar(); @@ -15,10 +18,13 @@ public class SolitaerMenue { public SolitaerMenue() { + this.restart.addActionListener(this); this.menu.add(restart); this.menu.addSeparator(); + this.quit.addActionListener(this); this.menu.add(quit); + this.menuBar.add(menu); } @@ -27,4 +33,14 @@ public class SolitaerMenue { return menuBar; } + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if(e.getSource() == this.quit) { + System.out.println("quit"); + System.exit(0); + } + + } + } From 2f4e989b9bedbece9ff9fab593fdb61a00767e61 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 6 Feb 2022 15:50:21 +0100 Subject: [PATCH 048/108] Add methode restart --- src/main/java/solitaer/SolitaerGamePanel.java | 98 ++++++++++++++----- 1 file changed, 72 insertions(+), 26 deletions(-) diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 26b1e18..7c9e70a 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -32,10 +32,10 @@ public class SolitaerGamePanel extends JPanel { public SolitaerGamePanel() { setLayout(null); - + int Offset_x_Save = setLayoutX(STARTSTACK_SIZE + 1); int Offset_y_Save = setLayouty(1); - + JLabel label = new JLabel(); label.setText("selected Cards"); label.setBounds(Offset_x_Save, Offset_y_Save - 25, 200, 25); @@ -43,25 +43,25 @@ public class SolitaerGamePanel extends JPanel { save = new SaveStack(Offset_x_Save, Offset_y_Save); this.add(save); - + mouseL = new MyMouseListener(save); this.addMouseListener(mouseL); - deck = new CardDeck(); - deck.shuffelDeck(); +// deck = new CardDeck(); +// deck.shuffelDeck(); for (int i = 0; i < STARTSTACK_SIZE; i++) { int y = setLayouty(1); start[i] = new StartStack(setLayoutX(i), y); - int tmp = i; - while(tmp != 0) { - start[i].addCard(deck.getDeck().remove(0)); - tmp -= 1; - } - Card card = deck.getDeck().remove(0); - card.setFaceUp(true); - start[i].addCard(card); - this.add(start[i]); +// int tmp = i; +// while (tmp != 0) { +// start[i].addCard(deck.getDeck().remove(0)); +// tmp -= 1; +// } +// Card card = deck.getDeck().remove(0); +// card.setFaceUp(true); +// start[i].addCard(card); +// this.add(start[i]); } for (int i = 0; i < ABLAGESTACK_SIZE; i++) { @@ -84,22 +84,24 @@ public class SolitaerGamePanel extends JPanel { default: break; } - this.add(ablage[i]); +// this.add(ablage[i]); } waste = new WasteStack(setLayoutX(1), OFFSET_STACKS_Y); geber = new GeberStack(setLayoutX(0), OFFSET_STACKS_Y, waste); + +// while (deck.getDeck().size() != 1) { +// geber.addCard(deck.getDeck().remove(0)); +// } +// +// Card card = deck.getDeck().remove(0); +// card.setFaceUp(true); +// waste.addCard(card); +// +// this.add(waste); +// this.add(geber); - while(deck.getDeck().size() != 1) { - geber.addCard(deck.getDeck().remove(0)); - } - - Card card = deck.getDeck().remove(0); - card.setFaceUp(true); - waste.addCard(card); - - this.add(waste); - this.add(geber); + restartGame(); } @@ -108,10 +110,54 @@ public class SolitaerGamePanel extends JPanel { } private int setLayouty(int _row) { - if(_row == 1) + if (_row == 1) return IMAGE_HIGHT + (OFFSET_STACKS_Y * 3); else return OFFSET_STACKS_Y; + } + + public void restartGame() { + deck = new CardDeck(); + deck.shuffelDeck(); + + for (int i = 0; i < STARTSTACK_SIZE; i++) { + int tmp = i; + while (tmp != 0) { + start[i].addCard(deck.getDeck().remove(0)); + tmp -= 1; + } + Card card = deck.getDeck().remove(0); + card.setFaceUp(true); + start[i].addCard(card); + this.add(start[i]); + + } + + + + for (int i = 0; i < ABLAGESTACK_SIZE; i++) { + this.add(ablage[i]); + } + + + while (deck.getDeck().size() != 1) { + geber.addCard(deck.getDeck().remove(0)); + } + + Card card = deck.getDeck().remove(0); + card.setFaceUp(true); + waste.addCard(card); + + this.add(waste); + this.add(geber); + + + + + + + + } @Override From c57f31ac025346a9f0ad5671871ffbd96eb8de57 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 6 Feb 2022 15:54:29 +0100 Subject: [PATCH 049/108] Add clearStack methode to BaseStack --- src/main/java/solitaer/BaseStack.java | 4 ++++ src/main/java/solitaer/SolitaerGamePanel.java | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/solitaer/BaseStack.java b/src/main/java/solitaer/BaseStack.java index a94321d..5e78f37 100644 --- a/src/main/java/solitaer/BaseStack.java +++ b/src/main/java/solitaer/BaseStack.java @@ -24,6 +24,10 @@ public abstract class BaseStack extends JPanel { } offset = 0; } + + public void clearStack() { + stack.clear(); + } public boolean stackIsEmpty() { return stack.isEmpty(); diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 7c9e70a..9a4bc87 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -42,7 +42,7 @@ public class SolitaerGamePanel extends JPanel { this.add(label); save = new SaveStack(Offset_x_Save, Offset_y_Save); - this.add(save); + mouseL = new MyMouseListener(save); this.addMouseListener(mouseL); @@ -121,6 +121,7 @@ public class SolitaerGamePanel extends JPanel { deck.shuffelDeck(); for (int i = 0; i < STARTSTACK_SIZE; i++) { + start[i].clearStack(); int tmp = i; while (tmp != 0) { start[i].addCard(deck.getDeck().remove(0)); @@ -136,10 +137,12 @@ public class SolitaerGamePanel extends JPanel { for (int i = 0; i < ABLAGESTACK_SIZE; i++) { + ablage[i].clearStack(); this.add(ablage[i]); } - + geber.clearStack(); + waste.clearStack(); while (deck.getDeck().size() != 1) { geber.addCard(deck.getDeck().remove(0)); } @@ -150,6 +153,10 @@ public class SolitaerGamePanel extends JPanel { this.add(waste); this.add(geber); + + + save.clearStack(); + this.add(save); From d478ae0cc636aeca585e8a080c88fa03c3f1f04b Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 6 Feb 2022 15:56:55 +0100 Subject: [PATCH 050/108] Add MouseInput MenueRestart-Button --- src/main/java/hauptmenue/GameWindow.java | 2 +- src/main/java/solitaer/SolitaerMenue.java | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/hauptmenue/GameWindow.java b/src/main/java/hauptmenue/GameWindow.java index 7fe612d..9230044 100644 --- a/src/main/java/hauptmenue/GameWindow.java +++ b/src/main/java/hauptmenue/GameWindow.java @@ -12,7 +12,7 @@ public class GameWindow extends JFrame { private static final long serialVersionUID = 1L; private final SolitaerGamePanel gamePanel = new SolitaerGamePanel(); - private SolitaerMenue smenue = new SolitaerMenue(); + private SolitaerMenue smenue = new SolitaerMenue(gamePanel); public GameWindow() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); diff --git a/src/main/java/solitaer/SolitaerMenue.java b/src/main/java/solitaer/SolitaerMenue.java index 76a86ef..e3dbcb8 100644 --- a/src/main/java/solitaer/SolitaerMenue.java +++ b/src/main/java/solitaer/SolitaerMenue.java @@ -9,6 +9,8 @@ import javax.swing.JMenuItem; public class SolitaerMenue implements ActionListener{ + SolitaerGamePanel solitaerpanel; + JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("options"); @@ -16,7 +18,9 @@ public class SolitaerMenue implements ActionListener{ JMenuItem restart = new JMenuItem("restart"); JMenuItem quit = new JMenuItem("quit"); - public SolitaerMenue() { + public SolitaerMenue(SolitaerGamePanel _panel) { + + solitaerpanel = _panel; this.restart.addActionListener(this); this.menu.add(restart); @@ -41,6 +45,10 @@ public class SolitaerMenue implements ActionListener{ System.exit(0); } + if(e.getSource() == this.restart) { + solitaerpanel.restartGame(); + } + } } From 8a594b8918a445d087cb3198f92ce4efd1d704f3 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 6 Feb 2022 16:13:55 +0100 Subject: [PATCH 051/108] Fix render when restart --- src/main/java/solitaer/BaseStack.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/solitaer/BaseStack.java b/src/main/java/solitaer/BaseStack.java index 5e78f37..686b60f 100644 --- a/src/main/java/solitaer/BaseStack.java +++ b/src/main/java/solitaer/BaseStack.java @@ -27,6 +27,8 @@ public abstract class BaseStack extends JPanel { public void clearStack() { stack.clear(); + offset = 0; + RenderStackNew(); } public boolean stackIsEmpty() { From 6722a62792900ca9e5a7f5650aab2c3c1a8f1c5f Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 6 Feb 2022 16:20:39 +0100 Subject: [PATCH 052/108] Refactor --- src/main/java/solitaer/BaseStack.java | 4 +- src/main/java/solitaer/SolitaerGamePanel.java | 45 ++----------------- src/main/java/solitaer/SolitaerMenue.java | 3 +- 3 files changed, 7 insertions(+), 45 deletions(-) diff --git a/src/main/java/solitaer/BaseStack.java b/src/main/java/solitaer/BaseStack.java index 686b60f..2b17330 100644 --- a/src/main/java/solitaer/BaseStack.java +++ b/src/main/java/solitaer/BaseStack.java @@ -12,8 +12,8 @@ public abstract class BaseStack extends JPanel { private static final long serialVersionUID = 1L; private ArrayList stack = new ArrayList(); private final int OFFSET_VALUE = 20; - int offset; - int addOffset; + private int offset; + private int addOffset; public BaseStack(boolean _offset) { // TODO Auto-generated constructor stub diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 9a4bc87..4df5655 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -1,7 +1,6 @@ package solitaer; import java.awt.Color; -import java.awt.Font; import java.awt.Graphics; import javax.swing.JLabel; @@ -19,6 +18,8 @@ public class SolitaerGamePanel extends JPanel { public final int STARTSTACK_SIZE = 7; public final int ABLAGESTACK_SIZE = 4; + + private Color backgroundColor = new Color(0, 135, 62); private CardDeck deck; private MyMouseListener mouseL; @@ -42,26 +43,13 @@ public class SolitaerGamePanel extends JPanel { this.add(label); save = new SaveStack(Offset_x_Save, Offset_y_Save); - mouseL = new MyMouseListener(save); this.addMouseListener(mouseL); -// deck = new CardDeck(); -// deck.shuffelDeck(); - for (int i = 0; i < STARTSTACK_SIZE; i++) { int y = setLayouty(1); start[i] = new StartStack(setLayoutX(i), y); -// int tmp = i; -// while (tmp != 0) { -// start[i].addCard(deck.getDeck().remove(0)); -// tmp -= 1; -// } -// Card card = deck.getDeck().remove(0); -// card.setFaceUp(true); -// start[i].addCard(card); -// this.add(start[i]); } for (int i = 0; i < ABLAGESTACK_SIZE; i++) { @@ -84,22 +72,10 @@ public class SolitaerGamePanel extends JPanel { default: break; } -// this.add(ablage[i]); } waste = new WasteStack(setLayoutX(1), OFFSET_STACKS_Y); geber = new GeberStack(setLayoutX(0), OFFSET_STACKS_Y, waste); - -// while (deck.getDeck().size() != 1) { -// geber.addCard(deck.getDeck().remove(0)); -// } -// -// Card card = deck.getDeck().remove(0); -// card.setFaceUp(true); -// waste.addCard(card); -// -// this.add(waste); -// this.add(geber); restartGame(); @@ -131,11 +107,8 @@ public class SolitaerGamePanel extends JPanel { card.setFaceUp(true); start[i].addCard(card); this.add(start[i]); - } - - for (int i = 0; i < ABLAGESTACK_SIZE; i++) { ablage[i].clearStack(); this.add(ablage[i]); @@ -146,7 +119,6 @@ public class SolitaerGamePanel extends JPanel { while (deck.getDeck().size() != 1) { geber.addCard(deck.getDeck().remove(0)); } - Card card = deck.getDeck().remove(0); card.setFaceUp(true); waste.addCard(card); @@ -154,24 +126,15 @@ public class SolitaerGamePanel extends JPanel { this.add(waste); this.add(geber); - save.clearStack(); - this.add(save); - - - - - - - - + this.add(save); } @Override protected void paintComponent(Graphics g) { // TODO Auto-generated method stub super.paintComponent(g); - g.setColor(new Color(0, 135, 62)); + g.setColor(backgroundColor); g.fillRect(0, 0, this.getWidth(), this.getHeight()); } } diff --git a/src/main/java/solitaer/SolitaerMenue.java b/src/main/java/solitaer/SolitaerMenue.java index e3dbcb8..9845702 100644 --- a/src/main/java/solitaer/SolitaerMenue.java +++ b/src/main/java/solitaer/SolitaerMenue.java @@ -18,7 +18,7 @@ public class SolitaerMenue implements ActionListener{ JMenuItem restart = new JMenuItem("restart"); JMenuItem quit = new JMenuItem("quit"); - public SolitaerMenue(SolitaerGamePanel _panel) { + public SolitaerMenue(SolitaerGamePanel _panel) { solitaerpanel = _panel; @@ -28,7 +28,6 @@ public class SolitaerMenue implements ActionListener{ this.quit.addActionListener(this); this.menu.add(quit); - this.menuBar.add(menu); } From 788cf4762f39e4256ddc5b03a7221507c771defc Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 6 Feb 2022 22:55:05 +0100 Subject: [PATCH 053/108] Fix MouseInput GeberStack --- src/main/java/solitaer/MyMouseListener.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/solitaer/MyMouseListener.java b/src/main/java/solitaer/MyMouseListener.java index d222ac6..0ad21bb 100644 --- a/src/main/java/solitaer/MyMouseListener.java +++ b/src/main/java/solitaer/MyMouseListener.java @@ -118,6 +118,11 @@ public class MyMouseListener implements MouseInputListener { } else { tempStack = (GeberStack) com.getParent(); } + + if(this.saveStack.stackIsEmpty() == false) { + clearSaveStack(selectedStack); + } + if (tempStack.stackIsEmpty()) { // Move all from Waste to Geber ((GeberStack) this.tempStack).swapWasteGeber(); From bb5e31ff9f826afae19ca7253647ad8147cb8f36 Mon Sep 17 00:00:00 2001 From: kfkama Date: Mon, 14 Feb 2022 23:19:33 +0100 Subject: [PATCH 054/108] Add cell class --- src/main/java/TicTacToe/TicTacToeGame.java | 5 +++-- src/main/java/TicTacToe/cell.java | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 src/main/java/TicTacToe/cell.java diff --git a/src/main/java/TicTacToe/TicTacToeGame.java b/src/main/java/TicTacToe/TicTacToeGame.java index f958273..db769ff 100644 --- a/src/main/java/TicTacToe/TicTacToeGame.java +++ b/src/main/java/TicTacToe/TicTacToeGame.java @@ -4,6 +4,7 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Line2D; +import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; @@ -12,13 +13,13 @@ public class TicTacToeGame extends JPanel { private static final long serialVersionUID = 1L; private static int width = 600, height = 600; - + + public TicTacToeGame() { this.setSize(width, height); } public static void main(String[] args) { - JFrame f = new JFrame(); TicTacToeGame ttt = new TicTacToeGame(); diff --git a/src/main/java/TicTacToe/cell.java b/src/main/java/TicTacToe/cell.java new file mode 100644 index 0000000..ea76245 --- /dev/null +++ b/src/main/java/TicTacToe/cell.java @@ -0,0 +1,13 @@ +package TicTacToe; +import javax.swing.JButton; + +public class cell extends JButton { + + int value = 0; + + public cell() { + + } + + +} From 597dffcc6067df7ffd60e54fc5068a368b2e618f Mon Sep 17 00:00:00 2001 From: kfkama Date: Tue, 15 Feb 2022 00:05:50 +0100 Subject: [PATCH 055/108] Made cell change color on click/Player turns --- src/main/java/TicTacToe/TicTacToeGame.java | 35 ++++++++++++++++++++-- src/main/java/TicTacToe/cell.java | 31 +++++++++++++++++-- 2 files changed, 61 insertions(+), 5 deletions(-) diff --git a/src/main/java/TicTacToe/TicTacToeGame.java b/src/main/java/TicTacToe/TicTacToeGame.java index db769ff..89fa969 100644 --- a/src/main/java/TicTacToe/TicTacToeGame.java +++ b/src/main/java/TicTacToe/TicTacToeGame.java @@ -4,7 +4,6 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Line2D; -import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; @@ -13,22 +12,44 @@ public class TicTacToeGame extends JPanel { private static final long serialVersionUID = 1L; private static int width = 600, height = 600; - + public cell[] field; + public int player = 1; public TicTacToeGame() { this.setSize(width, height); + setLayout(null); + initField(); } public static void main(String[] args) { JFrame f = new JFrame(); TicTacToeGame ttt = new TicTacToeGame(); - + f.add(ttt); f.setSize(width,height); f.setLayout(null); f.setVisible(true); } + public void initField() { + field = new cell[9]; + + for(int i = 0; i < field.length; i++) { + field[i] = new cell(this); + add(field[i]); + } + + for(int i = 0; i < field.length; i++) { + if(i < 3) { + field[i].setBounds(150 + i*100, 150 , 100, 100); + } else if (i < 6) { + field[i].setBounds(150 + i%3*100, 250 , 100, 100); + } else { + field[i].setBounds(150 + i%3*100, 350 , 100, 100); + } + } + } + @Override protected void paintComponent(Graphics g) { super.paintComponent(g); @@ -45,5 +66,13 @@ public class TicTacToeGame extends JPanel { g2.draw(lin4); } + public void endTurn() { + player++; + if(player >= 3) { + player = 1; + } + + } + } \ No newline at end of file diff --git a/src/main/java/TicTacToe/cell.java b/src/main/java/TicTacToe/cell.java index ea76245..b8c4351 100644 --- a/src/main/java/TicTacToe/cell.java +++ b/src/main/java/TicTacToe/cell.java @@ -1,13 +1,40 @@ package TicTacToe; +import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + import javax.swing.JButton; public class cell extends JButton { int value = 0; + private TicTacToeGame ttt; - public cell() { + public cell(TicTacToeGame _ttt) { + ttt = _ttt; + addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + OnMouseClick(); + } + }); } - + protected void OnMouseClick() { + value = ttt.player; + ttt.endTurn(); + switch (value) { + case 1: setBackground(new Color(255,0,0)); + break; + case 2: setBackground(new Color(0,0,255)); + break; + default: ; + break; + } + } + + + + } From fee8ede7991fc58ba9f7c0150e967ab70b36b9cc Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Tue, 15 Feb 2022 11:48:01 +0100 Subject: [PATCH 056/108] remove unused pictures --- src/main/java/solitaer/images/01Herz.png | Bin 523 -> 0 bytes src/main/java/solitaer/images/01Karo.png | Bin 539 -> 0 bytes src/main/java/solitaer/images/01Kreuz.png | Bin 564 -> 0 bytes src/main/java/solitaer/images/01Pik.png | Bin 506 -> 0 bytes src/main/java/solitaer/images/02Herz.png | Bin 530 -> 0 bytes src/main/java/solitaer/images/02Karo.png | Bin 546 -> 0 bytes src/main/java/solitaer/images/02Kreuz.png | Bin 574 -> 0 bytes src/main/java/solitaer/images/02Pik.png | Bin 517 -> 0 bytes src/main/java/solitaer/images/03Herz.png | Bin 532 -> 0 bytes src/main/java/solitaer/images/03Karo.png | Bin 547 -> 0 bytes src/main/java/solitaer/images/03Kreuz.png | Bin 576 -> 0 bytes src/main/java/solitaer/images/03Pik.png | Bin 518 -> 0 bytes src/main/java/solitaer/images/04Herz.png | Bin 530 -> 0 bytes src/main/java/solitaer/images/04Karo.png | Bin 547 -> 0 bytes src/main/java/solitaer/images/04Kreuz.png | Bin 574 -> 0 bytes src/main/java/solitaer/images/04Pik.png | Bin 516 -> 0 bytes src/main/java/solitaer/images/05Herz.png | Bin 531 -> 0 bytes src/main/java/solitaer/images/05Karo.png | Bin 548 -> 0 bytes src/main/java/solitaer/images/05Kreuz.png | Bin 575 -> 0 bytes src/main/java/solitaer/images/05Pik.png | Bin 519 -> 0 bytes src/main/java/solitaer/images/06Herz.png | Bin 540 -> 0 bytes src/main/java/solitaer/images/06Karo.png | Bin 555 -> 0 bytes src/main/java/solitaer/images/06Kreuz.png | Bin 584 -> 0 bytes src/main/java/solitaer/images/06Pik.png | Bin 527 -> 0 bytes src/main/java/solitaer/images/07Herz.png | Bin 525 -> 0 bytes src/main/java/solitaer/images/07Karo.png | Bin 542 -> 0 bytes src/main/java/solitaer/images/07Kreuz.png | Bin 567 -> 0 bytes src/main/java/solitaer/images/07Pik.png | Bin 510 -> 0 bytes src/main/java/solitaer/images/08Herz.png | Bin 543 -> 0 bytes src/main/java/solitaer/images/08Karo.png | Bin 557 -> 0 bytes src/main/java/solitaer/images/08Kreuz.png | Bin 588 -> 0 bytes src/main/java/solitaer/images/08Pik.png | Bin 530 -> 0 bytes src/main/java/solitaer/images/09Herz.png | Bin 540 -> 0 bytes src/main/java/solitaer/images/09Karo.png | Bin 555 -> 0 bytes src/main/java/solitaer/images/09Kreuz.png | Bin 584 -> 0 bytes src/main/java/solitaer/images/09Pik.png | Bin 527 -> 0 bytes src/main/java/solitaer/images/10Herz.png | Bin 523 -> 0 bytes src/main/java/solitaer/images/10Karo.png | Bin 539 -> 0 bytes src/main/java/solitaer/images/10Kreuz.png | Bin 563 -> 0 bytes src/main/java/solitaer/images/10Pik.png | Bin 507 -> 0 bytes src/main/java/solitaer/images/11Herz.png | Bin 499 -> 0 bytes src/main/java/solitaer/images/11Karo.png | Bin 518 -> 0 bytes src/main/java/solitaer/images/11Kreuz.png | Bin 540 -> 0 bytes src/main/java/solitaer/images/11Pik.png | Bin 483 -> 0 bytes src/main/java/solitaer/images/12Herz.png | Bin 509 -> 0 bytes src/main/java/solitaer/images/12Karo.png | Bin 525 -> 0 bytes src/main/java/solitaer/images/12Kreuz.png | Bin 552 -> 0 bytes src/main/java/solitaer/images/12Pik.png | Bin 494 -> 0 bytes src/main/java/solitaer/images/13Herz.png | Bin 511 -> 0 bytes src/main/java/solitaer/images/13Karo.png | Bin 527 -> 0 bytes src/main/java/solitaer/images/13Kreuz.png | Bin 554 -> 0 bytes src/main/java/solitaer/images/13Pik.png | Bin 495 -> 0 bytes src/main/java/solitaer/images/back.png | Bin 1361 -> 0 bytes src/main/java/solitaer/images/empty.png | Bin 7063 -> 0 bytes 54 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/main/java/solitaer/images/01Herz.png delete mode 100644 src/main/java/solitaer/images/01Karo.png delete mode 100644 src/main/java/solitaer/images/01Kreuz.png delete mode 100644 src/main/java/solitaer/images/01Pik.png delete mode 100644 src/main/java/solitaer/images/02Herz.png delete mode 100644 src/main/java/solitaer/images/02Karo.png delete mode 100644 src/main/java/solitaer/images/02Kreuz.png delete mode 100644 src/main/java/solitaer/images/02Pik.png delete mode 100644 src/main/java/solitaer/images/03Herz.png delete mode 100644 src/main/java/solitaer/images/03Karo.png delete mode 100644 src/main/java/solitaer/images/03Kreuz.png delete mode 100644 src/main/java/solitaer/images/03Pik.png delete mode 100644 src/main/java/solitaer/images/04Herz.png delete mode 100644 src/main/java/solitaer/images/04Karo.png delete mode 100644 src/main/java/solitaer/images/04Kreuz.png delete mode 100644 src/main/java/solitaer/images/04Pik.png delete mode 100644 src/main/java/solitaer/images/05Herz.png delete mode 100644 src/main/java/solitaer/images/05Karo.png delete mode 100644 src/main/java/solitaer/images/05Kreuz.png delete mode 100644 src/main/java/solitaer/images/05Pik.png delete mode 100644 src/main/java/solitaer/images/06Herz.png delete mode 100644 src/main/java/solitaer/images/06Karo.png delete mode 100644 src/main/java/solitaer/images/06Kreuz.png delete mode 100644 src/main/java/solitaer/images/06Pik.png delete mode 100644 src/main/java/solitaer/images/07Herz.png delete mode 100644 src/main/java/solitaer/images/07Karo.png delete mode 100644 src/main/java/solitaer/images/07Kreuz.png delete mode 100644 src/main/java/solitaer/images/07Pik.png delete mode 100644 src/main/java/solitaer/images/08Herz.png delete mode 100644 src/main/java/solitaer/images/08Karo.png delete mode 100644 src/main/java/solitaer/images/08Kreuz.png delete mode 100644 src/main/java/solitaer/images/08Pik.png delete mode 100644 src/main/java/solitaer/images/09Herz.png delete mode 100644 src/main/java/solitaer/images/09Karo.png delete mode 100644 src/main/java/solitaer/images/09Kreuz.png delete mode 100644 src/main/java/solitaer/images/09Pik.png delete mode 100644 src/main/java/solitaer/images/10Herz.png delete mode 100644 src/main/java/solitaer/images/10Karo.png delete mode 100644 src/main/java/solitaer/images/10Kreuz.png delete mode 100644 src/main/java/solitaer/images/10Pik.png delete mode 100644 src/main/java/solitaer/images/11Herz.png delete mode 100644 src/main/java/solitaer/images/11Karo.png delete mode 100644 src/main/java/solitaer/images/11Kreuz.png delete mode 100644 src/main/java/solitaer/images/11Pik.png delete mode 100644 src/main/java/solitaer/images/12Herz.png delete mode 100644 src/main/java/solitaer/images/12Karo.png delete mode 100644 src/main/java/solitaer/images/12Kreuz.png delete mode 100644 src/main/java/solitaer/images/12Pik.png delete mode 100644 src/main/java/solitaer/images/13Herz.png delete mode 100644 src/main/java/solitaer/images/13Karo.png delete mode 100644 src/main/java/solitaer/images/13Kreuz.png delete mode 100644 src/main/java/solitaer/images/13Pik.png delete mode 100644 src/main/java/solitaer/images/back.png delete mode 100644 src/main/java/solitaer/images/empty.png diff --git a/src/main/java/solitaer/images/01Herz.png b/src/main/java/solitaer/images/01Herz.png deleted file mode 100644 index 62d0956036088f5c44006ad1f8e3bcc22060673e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 523 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FcyzVAc}{hNBKI z|FvH;lj!-F;`~XpA~dXLQ_>XC#cL!|k7{VgP4WJyy0jv&OMU4N>o6Nl_k}V?yNg8h zy*@4xsXyK|yGTU*sYc!@xQaVd9(iiUO?l+1ISm4Eakt!FczeW0sC5!%>Hq z|JtwlYiP{clD;9lO+4|ahPGRz;i;~`u%1ni7TI*=YaVsgw9`C#f8(RcMIxsHW2P+L zp>fpPvTJ`bh-@zs(SHgQe6&#J==@EOmWs@u@@SEW_)-gyviV)@K^py!CV$eXJJ~fo zs3xeZJ1Ay~lV#WcjxTDUNUEM`Md5yX=2u&cB zi)4;26yaa`!wck|{>YC(eIQ$1HTAqc0%e!V9Cg-|^ZGayrq};epoaU$sX!aSa+X~{ zgWH2@ye+waMj!6#{-m*QDbS@qmH>Sa{4t>GKhU@Fo06u8E?y&%iX03>Oz0nD_^v&E U`5oE^fRWDN>FVdQ&MBb@0DH9N+W-In diff --git a/src/main/java/solitaer/images/01Kreuz.png b/src/main/java/solitaer/images/01Kreuz.png deleted file mode 100644 index a202c885615d14cccd85cbfeb05b50a1036c08b3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 564 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!Fcyz;3{o)0oIMd zzvH(sF|+aS`&oA(=tf|od#kKySqPAke^u^Ayw;nwhxUcs*f0ET>8-Xb>2G1Vhwo{< zS$wPQuXUpQRkJsNxrgmm*>2d*RULABLp@Liq&m8FZ|Du6%6%a#z8%;XQk?)a#=F&a z)!zelhwMO1pmcOA$h5bOdqZyr0L=i2{smf5+fo~HV>(y$>J8ho|nPEWpnE~wti}Jq-OawXgR@>gzTA-jiNFUTu{an9+j{Fytdsq(W zUhl2EzXhRwS$qiM6L*7UHx3vIVCg!0ES=`5dZ)H diff --git a/src/main/java/solitaer/images/01Pik.png b/src/main/java/solitaer/images/01Pik.png deleted file mode 100644 index faa496eae00ca694295a9816f5cb18d65c464a15..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 506 zcmeAS@N?(olHy`uVBq!ia0vp^oAx>Eakt!FczeBbPL%h|9*R z@Ag~RqDYGbx5|o^h1>{CbZ`9|x0Uy|eCyuO>V*2>#QdxGHn?wP-xhk~eQWK? zZ3}O;?G3%XVLR9F726W~v!o&7A-92Qcz>_>cHo}Y8}HV?3lG)lzgc`}U&xJUpgA|D zb5)1jSbRwCs@WU%Lv|n)K*8wNT9CF@Tdkbc+Y2ds r66D}^kSl=Ra{&7i?%koo_{(l6_|9+QuMdxaamwK7>gTe~DWM4f_yye^ diff --git a/src/main/java/solitaer/images/02Herz.png b/src/main/java/solitaer/images/02Herz.png deleted file mode 100644 index 559fbbebcda0b7e008345bf5cb0327b40ea46200..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 530 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FcyzV3w>S!x4v< z|JuXY#HJn8H#--;VD%b_)T0{OZjpwkx&p&$7TR>_Pl^5*)HOTkkA2vkDT@R89xatQ z>TKE79&~5QqyHPBy!RSMoi+2kKK_pYtF3X@l=CVK?wb8cBhL$HM*F9gKV-GzKtlV2 z`W`K;(TY12sNw!GNbV^Al*KS9|5Jf`raW3E!v9o5?o^-+P@=I&WPjRGZ;;8YMIz=) zcW54U{uyF3BJ_&ilVg)#%N6CDz_@1c MboFyt=akR{03n{`wEzGB diff --git a/src/main/java/solitaer/images/02Karo.png b/src/main/java/solitaer/images/02Karo.png deleted file mode 100644 index 028c2762d7bd5cc0f5cb08fcb3ce50cc3dc7e4ef..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 546 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeW0sC5!%>Hq z|JtvqsED}UmfIKJCZ2dyL)$IV@Kje|SkIv3yNMaG#T9S9_7j zbRY_{nX>qYbr_J`0c3Or#dsBJx_?~0rb6TB?4Um`ntDqufZ_}Gh)xgE2>-Y&=BR$; z$AB*Lr9Y;DG;6qj{6FPU&^n+EBBuiXw2AUBtqAT~KV@-+M*pMeQ(!X}$Q)fNbJTt_ z#Ck`|F7u}vAR}dtE(DrTvlQg0^FaIDK^8BQIm*5i=n^pZ=u(k*O|URf9_(nK)_p-x zr-M8YRO4;Q^;Dzoa2Nln&^?;*Kv(Y3JnCGjt+(_?XOZas6y#t?nj*S*jYR4Y6Z*^k YNpqjy_Je*$fN{^@>FVdQ&MBb@04|v6<^TWy diff --git a/src/main/java/solitaer/images/02Kreuz.png b/src/main/java/solitaer/images/02Kreuz.png deleted file mode 100644 index 8a0fd4621f952f65b945028e960b8785ba6395c7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 574 zcmeAS@N?(olHy`uVBq!ia0vp^o6H~ja%;k}jjs@a>xx7uu1 z<=$9)$PP&USBLTKLx4hZK>2#nZ-I&WqTl#MzpdD?_Ey{8kQLt!!~u<(4l>4ltNac3 z8}6-pLvF-_OmW)E`#bDyW9{l~3vad6hTQOO{ks&%Xn`kgw>RW>qpjAPrHABz-U7Qv mZUxjQNWldUw;{mz%l@!hC6@j9?H9mw!QkoY=d#Wzp$PzocmZbs diff --git a/src/main/java/solitaer/images/02Pik.png b/src/main/java/solitaer/images/02Pik.png deleted file mode 100644 index 0a1e2742c2958a1adc8208604cbec9d62793e615..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 517 zcmeAS@N?(olHy`uVBq!ia0vp^oAs>Eakt!FczeW0nr50P9Ba z@Ag~lL`1fHthl+^L-Wmw4T}%;aan7<`MoOl#(#}B%d_}_SbjtJ*7+OUx3X^wz45)Z zcEz@Zx7zjs6)e8hW~=okH21LFRkNJc8{TtQhu#J%vAO+<;kHx9ZygyO7_kKs!NZB(CTB-30S8-0wq#@r!+y{YSs<-U+LL(aYfJ>gTe~ HDWM4f5~%(% diff --git a/src/main/java/solitaer/images/03Herz.png b/src/main/java/solitaer/images/03Herz.png deleted file mode 100644 index 05c7794ded6624585c53161a173f95268e28fc8a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 532 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeXO@B^!x4v< z|NF0rh?w-6+o(IcMHrsy3JmMnlr%+j@tPkFJG=O&Y=5*+B;V^}`I?I0J}1kr_9Bt# zKoqn`^XUDJj~2=tT`F_5e9EJsF7u^7tix=kJo44tw*)8((z7h)=;f4BQmy(_LvLwCaF@3w6v=D2f6Rs&xfo*Q z(weXsuaC@6HU71W@&naB)z}Areceq+SCR+U~DsZ My85}Sb4q9e08{(q1ONa4 diff --git a/src/main/java/solitaer/images/03Karo.png b/src/main/java/solitaer/images/03Karo.png deleted file mode 100644 index da7c45d468da5f8ee534c8eb10823f26b53153d5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 547 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeW0sC5!%>Hq z|JtvqsED}MS8oV!6Hh#0Z z20!vX6{z9m7T#*hlK!@8TVg+u zTCpK~EAQ|6LvdHl-UQ|z{uhwg&s80Ad&7UNH=&90T5rrj;)&5fH3186G5-#D+gQ6| z1Hb6E72lY@aaD)jXy^JJ_O@}a7Enw6RXLzt(yMYIHsu2u+DL}HZLM9sE%823bn&e= zTdgA!>Eakt!Fcze<0@u$0oIM- z-|e?BF*BQ;jJN8ZcBqfbTI~-+Ywd~+ z|ATT5%ZYwlcnC^sD36yy?w}y#fSa{0Ikt~lMd0BdlEakt!FcyzV3w>S!x4v< z|JuXY#HK0gn|%vkuzHO|>QN1Cw@AZNU4dbLTq{N51G{Di-I?;}|HenlWLk?v=1*C? zL-VMw=0ADuxKn{PAYT8YWg_NFf7Gw307(EvHGou}S7ERmke=fHF~CmLKKZCOQ0QYo z-=l!8*`HQcXu2R6`D^31}VA)CvutzP?A&rvm@X5Y=A_v~pq1 zQi~}-oA{pwe+=l#2g*x_?SUxt1l!itUL^8=3DCiPkEXBL0k*&%XC#VFn%T0&Rkc`~>8-4|GA0gP(~Pgg&e IbxsLQ0J_58k^lez diff --git a/src/main/java/solitaer/images/04Karo.png b/src/main/java/solitaer/images/04Karo.png deleted file mode 100644 index 4c37a84176457f1d57be15be14e0b4bc114837a3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 547 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeW0sC5!%>Hq z|JtvqsED}UmfIKJCZ2dyL)$IV@Kje|SkIk amHMq+hx}BP^v!^g&*16m=d#Wzp$P!+MCMxn diff --git a/src/main/java/solitaer/images/04Kreuz.png b/src/main/java/solitaer/images/04Kreuz.png deleted file mode 100644 index acbfba91d74e04b725ef4ca882230a8490378765..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 574 zcmeAS@N?(olHy`uVBq!ia0vp^oZ^%!S2bvU^d$&sE=!iG5#}fPSJ{;F~2w*m@XJRUHx3vIVCg!0Fe$E`2YX_ diff --git a/src/main/java/solitaer/images/04Pik.png b/src/main/java/solitaer/images/04Pik.png deleted file mode 100644 index d33a44881739141cd42462d9b4baa08a42f8b188..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 516 zcmeAS@N?(olHy`uVBq!ia0vp^oA$>Eakt!Fcze<0@@VF_(=N zzvH)X3Gw{=@pfT#!O{(j5A|_bYrR>q;r{AviT~Xb>qDy(;zMqDZ{5GaeJlI6&>Qbt z_lDdK$UXcoF!ykr)|?=5zjDu`RJbOZrEakt!FcyzpqGLp!_fmz z{P<;gL>I4-NIj~d?H2j5@soyKK;BVr%{;G<Z`eL ziHP~qAJ$=erYx?|aQ_(8rLPGT{nsa|zjTM@QRkha<{;X)5~wOb?x^$6H9sV^Bwf#%N+`qLj| zGv(1Tpy=jD3q|e+^gS|PQ=#ep5yPebp3%rk!)x@XEGW1y+&Fi#tv>Iw|&K?#Q;BDA93!+49|9&?2U Qz{qCsboFyt=akR{0HPP;4FCWD diff --git a/src/main/java/solitaer/images/05Karo.png b/src/main/java/solitaer/images/05Karo.png deleted file mode 100644 index 45d75cae6bd3abd070b5d525dcbf2727d1f4a127..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 548 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FcyzV3&+1!%>Hq z|Jtvqsff7l-dnMcEv`j$@fwNLqZ-<7k%p(b_)mq_1l;Rt589)7^!>(1zLs21HSSG$ zq`kC4!~J9R8X#Gy>HaaGYyFf*L4A+HBY{lwr8}lKe)?#C(wpKpi#mQ*?mAmg5-{dpIW?Q%HkgjWR5PCIcmT8 z(L#}YuaD+lK&yb-*nuVht$5_`^>LZV|1(|fMIzISMB+7pE&(Zbw(RoO)LZ&vGFTWW zZ~jzc%3_d1fz|{-RfF^d)hv~1EfTR$1e&O2r_m2|9MESA_lQmp`qNt^YM%lNgTSz! jO-WNwf@O#Z{bm0ca=_2&XlXhy_8B}~{an^LB{Ts5b-L%O diff --git a/src/main/java/solitaer/images/05Kreuz.png b/src/main/java/solitaer/images/05Kreuz.png deleted file mode 100644 index 7ab055a1da5c0b484637a7de6bde9666e635e393..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 575 zcmeAS@N?(olHy`uVBq!ia0vp^orH6x z;eT^Cgm2}o4!OM{y!G$WLvmNm-puE!4!z;tYP+g7L0)uQ=c1J%{R6ZA-KV8s-kN z4QTw|pxncDhvGzmhW=j+vKOeepX>M1TlzN^gIu~Cs4e)$>RWBLK%+p$ffWIb+z(U; z!a#$7eo5TlQX6tR0O*RVW;v_3C9VfL4JZfn%dIvL26`UkOQCPUK=%i46^Hs^!~ejy xt$#z_HgZ*m{AR6gl@%=uxe=J?KExPT>JtyE$KKsi)Cx=(44$rjF6*2UngE1f{>uOW diff --git a/src/main/java/solitaer/images/05Pik.png b/src/main/java/solitaer/images/05Pik.png deleted file mode 100644 index 6bbfab9ab0cc9d3dd2965c4bc39c19da4c70ae18..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 519 zcmeAS@N?(olHy`uVBq!ia0vp^oAw>Eakt!FczeW0nr50P9Ba z@Ag~RxVUcBRNvg}q4{RThQ){axU99_{9cuN--JwTiLgT-uT{H zyJFkITWz%~Hrx-nvHDhN zaRzGJ;NEJh^(HX)@IHk%p^5Tf<~Fd7@U6VnKy`;eJlVwcT)zVn_pbyQXAk65hpgC^ z7%vPom|yf;JCJ(=r1foUtuM^_e4rB+ANm&nvLDDSZ-F>*FUV!NhvT5S76Tpac*Fmy z91zEWT<8pPPH1AhKv~F*z(n^}SAUiO5sFc1T%QL`njxgN@xNA-NoVb diff --git a/src/main/java/solitaer/images/06Herz.png b/src/main/java/solitaer/images/06Herz.png deleted file mode 100644 index 04e7477972180d16619eeb2ee187d5f5113db8c1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 540 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeW0sC5!%>Hq z|JtvqsE8cR@81~SCZ2dyL)$IV@Kje|SkI3h47K-G16>7E?iROEKTn1Dcx(CFW{%Pe8No_fh z(DWkFQ-L;9{Es?Yay`|M1Dfw_*)<=g(Y;U;h>p$?GfjZ2A+CZMP)0_`Eakt!FczeW0sC5!%>Hq z|JtwlduViROWzRQCZ2dyL)$IV@Kje|SkIwTXxx}9(C5dH|0?f*HbMZ70~yn`BPYo*TR^ivx`Lcr$8mw z0S##n(s2LyAEGPfq&XW`IlA%gA4(oN|F0Paz~fS9A$s1q4!jy?hH`F9?hdm zf$k{ObYBP-=UcjC$|G%%Ci%^efI>jkPy})lKTsoB0n7lPv!^VE_@F(=X3F9nQx;o* z$Vbtq0)cLk4yy@R_edM;ZeLBgQ_+Q*N9zOEJ(|8oA{9AElBS3*9%4c(>L2-^@H1>| Ro(oI_44$rjF6*2UngBT#?-c+5 diff --git a/src/main/java/solitaer/images/06Kreuz.png b/src/main/java/solitaer/images/06Kreuz.png deleted file mode 100644 index c79e6727f4bbe41ea1f7faf32a8f222191b92cb7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 584 zcmeAS@N?(olHy`uVBq!ia0vp^o+S^9566Xiv}y>F=vxgC&u*ltzs4SmsX ztF|Tn_q(zBR+}x5zxY<$-=&A-uA04>&s80I!@bp3E2KI>UUXaN?G620SLJTFZ)N`$ z2r^~GH|}pxC97(xxFF0wKn8NJWxm*V(E%)iTzp9KwXFGfEL;V zjdS11TO9(l;cpPoDTm@jfyVZ8{ayhQ2U@@QP~A$P4J&}Q{$2@mlnBV3U=yGeSbyjZ zeV|$p4utwAQ66kPP$kgr)raChQi=5|w}J4&Tg=r!i}$zu4SC!6H|T96(1{=)zNrtX w20E#F0np=h2jddmTV+MdLT&^OF~(QmdKI;Vst0021u$N&HU diff --git a/src/main/java/solitaer/images/06Pik.png b/src/main/java/solitaer/images/06Pik.png deleted file mode 100644 index 35e3403c443db87800f4c90e66db2ee282171b15..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 527 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeBbRi9nCr&s zZ~HSuYYZ%w7?<$R6DbS15t!)SDl7V}`l{KR{~B-nugbmAziPLkKdb)Gye$50p*P;Q z)~?*P@Kzg;OsroCl#u=wa(lztLv{LZ7T;>K1!@CI{PzZ`+OR(aq&norbgpWxkm?Qk zqTiMtng?WqRM-oA3rvg$GQTYVniX=xeJd|WV#C^7ZGYWvxP!DWhZ^@y{mo*aKA_3z zhwQZ8c(>X@4Eo*9RlTYzopr03FK&s{jB1 diff --git a/src/main/java/solitaer/images/07Herz.png b/src/main/java/solitaer/images/07Herz.png deleted file mode 100644 index b16d6637329b15ee268ef5dd4e3df5d40c96b6da..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 525 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FcyzVAc}{hNBKI z|FvH;ljxC5cm5<=5gOLBDQSx6;x!VfM>VwVG^RiDtkl-?`nW`-{&<)AQ;jK$f3yX~ zOnKy~`L9pZ{HccCslXaf%dYMq8_lElH$GY>;_vlQb?FYxqmzLmK+T#{ybA;Gb5E zF8*N)_K&aTJ&^FcDba<&UFJ{M0v+HMX?UtD5XI+1OX!t+)Rql?JLAh;fYHq0>FVdQ I&MBb@0FB<>+yDRo diff --git a/src/main/java/solitaer/images/07Karo.png b/src/main/java/solitaer/images/07Karo.png deleted file mode 100644 index 854f4f072eb4e64329009bb1627dd82253d3c8d1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 542 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FcyzV3&+1!%>Hq z|Jtvqsff6KU-Pj>GOk5*@fwNLqZ-<7k%p(b_)mrI(Y)W~t$Arn%kAnIhxt|J*@ha4G|L7n2F`&zQ>5qv)Hd7t}<(fZ*#ds}@IXb&Y zbbrcGXOJngi$wUB0;SGRc@(tnQFD>VslY#NqWnuMg1hp)J}$HAlGp49nF*AcUL;a~ zwyQm8kLFSKryBRBEC!iaB+?!fnt~DtfnhyE cP3Rvp^OHS(f=*(uf$`4Z>FVdQ&MBb@0QEakt!Fcyz;3{o)0oIMd zzvH(sF}E4+`&oA(=tf|od#kKySqPAEf0gZq=~?z0+*|jC+}JPtEhyJ{EAQ`m(Qhj@ z^k+$bd*4zUa(jb2P{?~LZ*|Cx#kbo21}DmkehW&hU%8>5>-MVL8{Vy1{BM@tVy<4f zVLDfJ$nVBlpeCT`-xb?{DuD{N1LdQ)@?JH2v-nV))*F2wLm9#Z+4}pyzR=qn@_~YZ zxrgOICfkDyy#aR7cAy);P68S(f3+^5p9{zUsg1q?bW}CaZTX_#)*g}rn_UOw?uR(H zdgZo6`$KW7a)EBR4{`$6Zy>9m3*-$DzA6XO|JxhvHg}*?!A`&Nf5o@P+ST72T5VVT pJz#gJkIP!?&58|+hZy6P{jXZZ*n_r#Yk&!Y!PC{xWt~$(69A(@7Lfn| diff --git a/src/main/java/solitaer/images/07Pik.png b/src/main/java/solitaer/images/07Pik.png deleted file mode 100644 index 9391d2aa16195660d813fd540438e04da4647c6a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 510 zcmeAS@N?(olHy`uVBq!ia0vp^oAz>Eakt!FczedZxkXmAEaXODqI>J#xUIau`gjEd+n-iiTPS@_(i|1_}28-2WGjy=(m-J{sn*x23nurvUlaSg}2&3iswTVZ*T|t zrE!Bl(EZc7eg`GiuK+nPEakt!FczeW0sC5!%>Hq z|JtvqsED-w?%x>RCZ2dyL)$IV@Kje|SkIEau589)7^!~<2zLs21HRMhO z#sHDm$7Le*$Gh5#M5Y4~NWoH(e6Nq?YbrF3&JF^pfGWyA6}m^WwMcaOrwdFwi z_@Az=(3lU>dn(Xo%IY6&MI!deN1ZkAO?ed52S#1yOLt6J3_)P&G^jLK;*qbW-qYYh z&7npHIM!e?0YnQO+|2@lO?h%oh`fky*~P%3j8xqG+rb8W9z3d zn<+p8?@e+47|`W^YWbt|H4>@Fp^!91bny@qTJfKua^gO}?Ocv?ff3K(>FVdQ&MBb@ E0Mriby#N3J diff --git a/src/main/java/solitaer/images/08Karo.png b/src/main/java/solitaer/images/08Karo.png deleted file mode 100644 index 064e2349b1574d44e467959dcf1e8c1b688ecee5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 557 zcmeAS@N?(olHy`uVBq!ia0vp^o>Eakt!FcyzV3w>S!x4v< z|JuXY*rq+Tl?CYrS_2Ue z=j9%P8kl*K!y0G+uWL@x#^xCgdnA=F*`Pc`(OYVZNcr9g`` zfGRk(?KHwaI#$A62-F@Ab}}?HdNw6Z5nYTDKtn|66~EHKQ+`P^)~^I60|rl5KbLh* G2~7Z3R`Fo~ diff --git a/src/main/java/solitaer/images/08Kreuz.png b/src/main/java/solitaer/images/08Kreuz.png deleted file mode 100644 index 3ed11e711022282641ec081ed3b971e7e6ffc9f0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 588 zcmeAS@N?(olHy`uVBq!ia0vp^oT<5L4)uBMef4zYWhzdENHG#Q@<*vrvSPxbQwcbwa z4af$;Z>u0SySD<`(2HG^ybngR4m=xv}8AZPrZ4)nI|hHwyTL;O`aprP_NRv!Xd4-6Fdt>Pe; s1I_)${*B98>&=P{ix2e;HO7C&%>iby4+9eTfT@JR)78&qol`;+0PV3K!2kdN diff --git a/src/main/java/solitaer/images/08Pik.png b/src/main/java/solitaer/images/08Pik.png deleted file mode 100644 index 65191129baf87ebdebad122c05e7a85391a935e7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 530 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeW0!V>kn6_k zZ~HS$Z44|l|6Q=<(0sFE!{S4IT-I7|zOTx?@jviJ{8hO(>$BoF^k>y4`fp{w4U{;v zFXVPW?qNHig5cc4^SFMm*anp11xq0WgA)B)Ygcagzhc9E?%yjm=!<>}xxHcetu|ZH zZ%Yr&9l_mX6Ix&7#F3^GUP=i|k zI=2Fy05nLREakt!FczeW0sC5!%>Hq z|JtvqsED-QPW}_#CZ2dyL)$IV@Kje|SkI&6G!zKdt;Bi|~HZ6w$?NBvO$>WJn0TvTuvpEakt!FczeW0sC5!%>Hq z|JtwlduViROWzRQCZ2dyL)$IV@Kje|SkIM`sZ1+a+yZ39`YDfmHS5lFwHJX@-w)~oiUHjO;s(WdeVhswwof}cyGY~|&`h9A zkPX;K3lRAz`c$BX`$y@pnt*kWnm=g(UG1wW2XgY!`oMLMrmvAmMGlgrDWZ#qn9z!P Y{jL*!CjU=l0TTg(r>mdKI;Vst0NttRVE_OC diff --git a/src/main/java/solitaer/images/09Kreuz.png b/src/main/java/solitaer/images/09Kreuz.png deleted file mode 100644 index 1838a50cbb13577f5a97cd50ea8dcfbf4e3370e8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 584 zcmeAS@N?(olHy`uVBq!ia0vp^o+K)m>noz|QCoWECWTX?IjHsp3d?%_Dm zZ>zQ?{`b4F`c|9ms@xlkq0}L{t7dQJb5)1laBsEM0_v0#-4=R#LqFG5xf||V*}nxQ z%8Pzm@s0Z%R0&k8R>ku9!{4CX!*+*&ZUGv5Rc-}H9BBRGLv<^GHmm^J`g`TAw!b1Er}k$_f13`( zU`0UZ=>rvla3IhGpd<8w2ABbD1l!uW7v!u%|A3|gG01M90ri|f!Eakt!FczeBbTz92dZYl{ZJp5wbq*z8x|j`TYszVZ~vixA#V@dWdQ~ozbZ@NkSZnKV+x%#=F&4 z^xM)y^SFKoCHjNdKyC6IzgKL~2Qz^t0L21x56|PO*2-DEEpfl#w?L5o#kbnB_`ikx z76x+tTeGCU87Inv4B8h`9RL*g>)L92)o#Ol&fhD*_WsrfIbp;86(BbORZAzvugV2V z{a<>ktv2LFd?1PE|O=V7WZEakt!FcyzV3&+1!%>Hq z|JtvqshGH4Un5yB8P_7Zc#TBrQ4MXkNW)WI=1YG}EE4ti`nW{of1hall*JXneNL8L z{7Wl>y6TU2sXx`)r{P|x2}DOH2mP@Q+oO3@93Eakt!FcyzV3&+1!%>Hq z|JtVs3(Z=TUG}j?GOk5*@fwNLqZ-<7k%p(b%$NR{SS0H2^>K;F|31<9DT^zD`iw^IbZN{{@uwO?n6Ie_?vmF8x=jS=y@eo${tEakt!Fcyz;3{o)0oIMd zzvH(sF}E4+`&oA(=tf|od#kKySqP9}uk}X%s@x6l*1aJ&_6vVod#mm5ifs#Twbh2) zaNo-NyZlhxD%%bDSIyo8<{p+4{kCFT;{T8v{anAp67_++4M6pKLson{08%xbt9s=I z_pS0b+z|=_au4qdtxmYVDi^3zUi4c~V*N@W17vM9$jZgH*gOyX8hnU9;w0tR$|GUvv3&_|PdV51YSpQbu>X6$T+*@r|<=${_1v(pSHprNu z+{1M(e^+dfziI|l0dy@;4oG?fJp{x+?}EJM4RWRTR(7D9z+U+u_?G#1*xN>~YM@oM jEzt0R2h+%`2}Vqoxe^>bP0l+XkKWTW{s diff --git a/src/main/java/solitaer/images/10Pik.png b/src/main/java/solitaer/images/10Pik.png deleted file mode 100644 index fa6024a62ff2f893c71d3f995a76ac9b0fe78663..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 507 zcmeAS@N?(olHy`uVBq!ia0vp^oAt>Eakt!FczedZxkXmAEaXODqI>J#xUIau%5h>dgX@cS<>HDY)gy=s=qNiiytIc9ddhvd+Xkn8}voLRVT)4y$J?!z#{Ig zwpwoja}U=kyzy?WUA4hn^xF!E5kUFet7dP^5A6%Nv7DXa`Lmp_rTh`w*L8h;~)n>aY_r~Hw{{n#OrGd=+7NCRmubKg!FrDkSGqQDm zy|=P|TLxCj1$4MPhqcz56&n^G>f;(>jQEakt!Fcze<0>fz5!a2y z-}k==5wKgdb<5&I-fewSR#`7rEL;p^{MzDrKj-3X-Kwpw|Ic5Ty_Wsg+O_Oen_bs$ zd+}egYU@{*`P=5bI4idI)}sIEFD{GKZg$Pz_Tnm#U$rPaddpWA|LFNI-t*MnS_Bk6 zdrke<#;*?1{9lq^cm7Lw-T3d^h2^@x(z@^ETwJYNb*pN@a-i8j%Kk>xg8gP+GQ0QP zTx1^oC98YhHoJ?L#r__=#{9Q?p?~xjpoKSq=6~7p)nWfupaX3$*dx2tew!T7Eq|{8 ymG4GYp7omj?~O$eC&`+YT)7bF?9MyH82Z9T7x+zZkN*gaOa@O^KbLh*2~7Y>W#t9{ diff --git a/src/main/java/solitaer/images/11Karo.png b/src/main/java/solitaer/images/11Karo.png deleted file mode 100644 index 422760bcef3faafc7f96a63829da8cf79b035983..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 518 zcmeAS@N?(olHy`uVBq!ia0vp^oA!>Eakt!FcyzVAkUR29|^G ze#`Ir-grPlGw#v)10j)yr@8{edNw6Z5na5dBB;xM$|E<;dzwe@Z+zrt*(I;(Ubt99 z|5V@~S?zn8(;s>66fyTI4D5U4ANg^K$b5~Xy+Jak0`F+N@9GZHnEq&Pk>8BccK$B;Q`g?us47#J? z4%E?GB+?!fGv$#d$PMe^mc&e1TmiIok%;)xiXb2@gCw^{!yV+J0FbnOP@j`!SAGP{ zaeIQh#Gl3%1_Hh1{ZUoh4aK(-sYf-2n9wWvJEakt!Fcze4I)|(X@76Tc-gA(mSZUnd1uGsKj{msf-ZGV^EYO@W!5xtf7 zcl{x|km`f`fOwwP8=&yt@WgnnH|<>2t2V5?)mFPA;4SNKFiw;Q$&0_yedFEwHz3hp zbXD$+;H}~yLhoNZR?vbgthE56xSZyJ8zi zi}zN2h$Kj{$hW13>Q-!6&Q-l~TVlTGH;{9HcyGw<4g5g8-cY?-Z-6e_8*(EaXfP13 z_|~*H^!A4REww8*08Ly8^bpXEakt!Fcze<0@@VF_(=N zzvH)X3CaCA@^)c$!O{(j5A|_bYrR>q;r{AviT~Xb<+a{)b5*bY)@HlPcEj33b^34C z-fH`+f7R^G+C%?BZf|hk%6nVu&G$q90^c^)uK0G~p4JNEfV diff --git a/src/main/java/solitaer/images/12Herz.png b/src/main/java/solitaer/images/12Herz.png deleted file mode 100644 index cfda3461d174a4f960546b2ad424cfb89ca2d98a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 509 zcmeAS@N?(olHy`uVBq!ia0vp^oAr>Eakt!FcyzU{(yLh|9*{ z-|<_XIW}kB=~Vy86_fd5#lppHeNt9gK!$(xm(16)wKo@)M}K+GQ@i==g8XfAUp9SR zFkQE5yX*gR7j~}|{}mtoWs~dsZ7=Ri{@UXDKf60_+l#wmdv8}QERWvu)k!~k{)_WG zwYL_{&$WG#`dYa5X4Qpj&HHlpUf>5BmELBTdlAG)?Y@_L@$|LkIEeZ3IkqqQd4am_ z1C{RvSq3sEwYzS^*9H3xzhrjTWxjU2pK}o?1yrD)d+|L`gFZ-ue>6YP89?U%4Fj63 z5480?NIZX=-Nn;DX92wu|KhY*?X6!f^=Zg{g?oAkF#a*GGg;)9cJIhFV6-xLy85}S Ib4q9e0Q%(v)&Kwi diff --git a/src/main/java/solitaer/images/12Karo.png b/src/main/java/solitaer/images/12Karo.png deleted file mode 100644 index d9f8a0bdd01cdd01dc5d68843dd77cec9c97dcb0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 525 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FcyzU{;JH!x4v< z|JuXY*ruhwfZ4>!(`(JT>)}0>yrWhS_KywbwklRHPlGt{liX6}l&Q-J|w36+vC^HQfs} zTZ=^Q2X}ez?BYKasNw!m7^K5|%HoQ^xGsH7{i91|jqv*GKbHfqR1c zoGd}AWxNVCk4_HS6WsMb4M^8`0!4vB?jIM)0PUF`WCJqZ{o{R*Rq9VQ=7AmPZQ12) z+2yUdZ;1@hX8S~t#(;T10ibufKdl4$B7e&2ABsSa8lLJ34C_Jh`%n^k#UGxs&Mz`t ROBoo=44$rjF6*2UngFMY+-?8> diff --git a/src/main/java/solitaer/images/12Kreuz.png b/src/main/java/solitaer/images/12Kreuz.png deleted file mode 100644 index a6356c803084f9df3f5493fccfcf48710b0db892..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 552 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FcyzAeS_!nCr&s zZ~HTNMI>^xX8z-`(R{OF!{S4IT-I7Z#&oXgmETx@uh^h3`t5zo-&NZZ_pi#mvG`V- zt=1bL`PVuzewFQp|3QiUT-71BH`HsrS$gQ7cdM;d&gyN6@me9(2_Si(=B0<^uEuTX z2O9VrY=YBP-ru2b8-XS+ywz44aswznIZOJR;J2W}`taPtcB^U=KG!Z)Mkd6Zn?(HwQRC;2|?~ b82=e_eRyJv1X>;eQvidftDnm{r-UW|1-uLh diff --git a/src/main/java/solitaer/images/12Pik.png b/src/main/java/solitaer/images/12Pik.png deleted file mode 100644 index c57f94c6e7833bc0a408773c8590a376378402f3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 494 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeV-^d$n9ISM z@Af4;A|@VJPQ+~$w^w?zV#DG?eO%UBZ+@@Jy-~06X6d20Reu|5Lw@sChg2s-x7Nnr z$iHg#W_y|QciSR=_Z!}=dx2upxqd?|0%}zNYOP!S rtqEu^NZkgYOPgR`gZpuaFn-Ca3EcGC)fJHrj7J7fS3j3^P6B| diff --git a/src/main/java/solitaer/images/13Herz.png b/src/main/java/solitaer/images/13Herz.png deleted file mode 100644 index 5362efaa30e3fb203258bf8480fa91f838b12f9f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 511 zcmeAS@N?(olHy`uVBq!ia0vp^oAv>Eakt!FcyzU{(yLh|9*{ z-|<_PJ#5UpBzgQNS4`%M6$=-)^+{P}0U7?$Uov0I*4|uH9{uG#&)=lit#uo}I`yv= zugbZ&TlZIa+r3=d7ya8_Y;=9U?Zth`Ut3)7->zDCTx{=cpbq}3?XEx~r*_eNkj($| z*N*Yq>@H4UD}JkLp?);~uVdG^|DL(9T=&<#YuvWmUfdP4-4^!(Vm?^z21stPF4!)R zF~`MflV7*~JBA{>_d}7VbCslG%;oyiH%7=5Kqk9cbu#-r8G>{G;E$I1O=H vJdja)>z9kYamkenfzIx{vZh0f@t?7A$r8W5*LRG85zFA|>gTe~DWM4f3ykYk diff --git a/src/main/java/solitaer/images/13Karo.png b/src/main/java/solitaer/images/13Karo.png deleted file mode 100644 index 7945855e66a25d9492ab292f4be330f9849bfef0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 527 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FcyzU{;JH!x4v< z|JuXY*ruh%CmoM(Tem4`is<4s5~)WuwA~^9bbE)tQSvUmpw zJ#w||x}SX1`l;5wr6SXVVonAA(bAqbP~d2Fa06@ zR4Z&7(_WjCrryJ?~mc9ybCpf`YgM=ExZ1w9i1FhEakt!FcyzV3!Q10P9Ba z@Ag~7xTLC9eEfBJLeP!CME6!%(XtRALtpe;&|B_rfr;^2Z|-ycUU{qSZ%FQ8xvOSx z0u$wdBv35qZR20xR$Hw%fw_nOt=ur3>vud@I(jSb@1TXZm_Z6^S8f2BwBlP+ZOh(} z8}cF53G$+=a&P!wl>=h4klP#jxqb&F?q9hrQ66OFexTgqTkPM0fkptWv;}bw?F+f# z4de@b3regHPVCQ;28vGSs$Ti6323)>E681SK<t~eg0#4|?gg5BABf#SPRTtS zcPLKl&GIbiZ!5MX0xg7)zCbx32D${K%J+shP}lFK+7OW0AgBI5P`B!v1JJ;|3G#?= gfd|l#V0@L={=y$y_hZHvU>acXboFyt=akR{0P2hLRsaA1 diff --git a/src/main/java/solitaer/images/13Pik.png b/src/main/java/solitaer/images/13Pik.png deleted file mode 100644 index 605141a81cf00f03aa591e7dc1c2ac5a34fc5f25..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 495 zcmeAS@N?(olHy`uVBq!ia0vp^oEakt!FczeV^%V!i0j7c zZ~HS$YYdLe2yuINaPpx(E^DnfD>f`Xv~T^bw!i&{>_Tp|XW1v{U%i*upT(cEdc%9} z>hRpd_d;)PaNo*X9dg4PMBd)8_Rv24H|<&cZ}dgKt=J&1^~SliHvUFC*YD+7(hz~b z#C|T2N_~#s0g3xpd^-@Q^=9dmK|sYoW;V$F zc#w+yD}eTiqYLl?)mVen>;~Dg4XEk2Yb(ga+{616Ku%ckjTvYbNOSAnkQ?GHvZ7@n iHv$vgTZb0oO8t|Scl@5-{wfQMNCr<=KbLh*2~7Y(*wmH) diff --git a/src/main/java/solitaer/images/back.png b/src/main/java/solitaer/images/back.png deleted file mode 100644 index 9457b3025989f05a6724f9688f0e4b4007b5030b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1361 zcmV-X1+MyuP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1m;OZK~#8N?V7DZ zD?1Q?E0M@bB#(eZRw8+X%1RuPN2o;d2uLIn$s-_+9>))fLA0 z$9B8L%K^{N&*aY7f4|@3wF7LNEJRG&Wdd~rvCGR#jFH?PvS@f7UI+krAC0|1Lnx+6 zmuKWg#1h*RE*fC(B=Y(-g_y;Fkz3dpiQ*v@B0WzTEkTVKaC8d;>BXcw!`u32%z6(^n-mZD)2z~B}pt#ZZT$`Yf9<@@`4x7*=| z50pkAtistS)sJ$;y6gFLCx)_#Knea66Tc`teAO9q^P31fULNVA{2#6Qz z040db=E^UUo&gSh6Q-GHa*zsl#PO+{RJf&LBu*1CX>IUBwj9JWz*AX=K)o2-RFaYh z-B>Y05yo3<*ct*`fts-B_Vo0GAF5bQ!*ofbq9`UmOG;^*E;dow3XG|BiyO5vUD9D? zh-r6=a|PHI!G z<*Kv@rLo>HQ3TPgl@idQ{8*@4+m|n()nR3Ty0yv`5YNCqN*?OgHX{4CKU zO^YdJU>Y12__u0K*jEl_XYon}abE#FtuRY5c-=%C^u&n@fMH>DV{_H5ucSngoh^2A zyG2^7Pr4)}fF0>&Zt=kAkgG)PrT0|j#%|cuxyrUvc26^IY+p@kRj=d`-J};w^UF$_ zw32N%c{d2up|8?DfKACm-QsjrJ|JdlCC||f!o|-s{9}PcHzm*D#kDcYUq3h z8W^@57pq{-KFml9|HF;tgg&<8RQLVZYx)%e6A8S!*fO4aUaX+Z&{1v)No+T;Ph-tk>)9b_)?O+({YSzP`R*US6P2 zZfI%~G`T2==Efe&)y}f;Sc!2jW zn1Og@`7}P?X2qY|GWm0x4P~!;?lbNiD&S6J^B2~6;oQ!_B*wXAzoE_tUtC#^{TAyr z{Ez&Tu&`ND#Gl(T8M&Rw==Y%3K`j17lVyWuXL-b-S#Sm{ee`?&H?!od`2GD4F1)}x Tv1aIi00000NkvXXu0mjfOWB0! diff --git a/src/main/java/solitaer/images/empty.png b/src/main/java/solitaer/images/empty.png deleted file mode 100644 index f6c6284bb9bb498d64b9fdd3529d47fa7773de0a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7063 zcmeHMc{tQv`=3g(L<%LT##pkAF@qVVL3SgPJ$ss!2{U76tZ8|K$gbU*ElUrwWlK>) zB&86_lBX0Z9$N_Scckt2zSr-%p6hzw|C+hZnS1W#bI$!a_c`-D*F;zxG8W(y=L3O2 z0$39RE8r6gG(69GpcnnP>j?~=lH zJ2buCE4iY+H+1>^wKGxd*Ow<@v-IM3%e7G$r^L#;f;A~h3Ci;5{K>ohwD}PqZ($X| z_{WcQ<6J93*l9x3vI9Ci3B%XKE%&!4UAxI^#gq=m9gsK%Mf&^MNM7`Qc~a-mfm80T zy#qv@rMpsNWc@dC@{!w)rPK4KK^7m(^$gKlr=b@wet6VTbvX4-bfPpV&d%3S(8hnd zrTX@4%ZKrL`IeZmYy5MKWfjA%WA`x516&zNpDjup=`sT@TPzD>M<3mFEHy45yYDEM zIp2%R%QMx=`UG*#y0P5EUtc$=`{Ul%eL*eH-Mq0UmqUI8&s0Z5s^0A zJlE=>P2bqr>#5lA`fN(q+r5%bnc%3mRkOINX331lfu!m`Mn)!Gr*1&DB+@A6e2p>! zTOWoO(8>d|sxw8&YHSHFT;*+Eu&`xM*wGNk7Nx^-QgRdx`4l0NvH5a@bhCA4e1tPN zD*mcm_TlG_$XVkL%%6geT*Kt&95BzrX1BDIHDCa0dKx0r;&K{48L}Wkd&x6mYL;h z+#*Cwz{;eUl{}P5(>teVn`T=?DZk;Q)pfH`skB98UrC$tq6AYZ!@^df`U)XZ@lMD# zMceZH{KD(KqxnVYjY-{Hfu+LcY3;SL*Skq`Hm&byM>5mUD8umWhs>sS2ACbw-Q(A` z!6uzN)$=;EYg?O7o7=&-=L%8Mrq7bk8%~J@SnQC*iJ}HRq}ELBDx=Kf4z;IOedObG z(Icr#v-dnSXTx%zXgyEFtBz*m&RbrW(+b#cn`R^0bye@u4eiEpc1sB$pRdhu|}4TVPgQZ9-fX_3y$+m#g6-t)Ok!|QN- zcZq_63;9@({3c%Uiw)wp^P?k8`8#S}1eD}x=(RaXW7p|gX4*w6ItWFo@f-fpRricA zo!evC(`Asvm*7~*lNDTseEPKWK)R;MdynjQZ(0aR%Od%FyFH3sa37?$s_hb$G@Z$A z?NksMXm^G$i5X13g7s!+m;@a;mpLSe)mSP5SU4hHxpuDWqB&4g}Iy)c-JdG zjTXzcE#%bB&> zOGS@3KI)fRiCT1eo-?rm`S@&tW^fYS2RXH6F-tuAQm2i0w(py=99qO*PwIkh78)!Z z7d+Rad01yWBbwzQJiak{C2+gP(kIPaCxyY%sNg!cog4pXF9~(jZk6K+x@0NzSt%1d z;b5fu!-(KppGLlRx*cHwIBWjjHc^+6OGJ0>9<0*Q=w9nFeR77?_Zi3-rR&nK9J)e} z=7O+GZ!Tekk6RTPLw%^Va+yx+V~I@%Dl?8tZ=TTbU2C&?b;B>MsV;SmuFm698YbGNRqmcMl zXg}}u?6_iHM}D_1ZWpUPPuTj;t&H2tWl*8VxlIq{`R&}4J()WL+dgL0(^9#i&LMc; zT$+qO7a$melK)L$D87CM4t5f#D+m_`y*#I}?iXS3?ylItxH}Kt?XlAro`#q_i#@gF z*;zT<{Y3P=X`Y2o_olaJMa+v`|0L36$yzx-u+0Ug7w1j*yLv{6s80IA7mrLUO>b;Jq7d<*_9Zc$ex*M*(rzKu za!1j$R;Kci_s5M~f=2rXoxP<#zWE`8abm4SL8s+o3%0Sn=@sO8xe&kg7ymk;F z#Z+~#6`|p*?mDt6Vs*fuKgFc8{q1e+~{!x34%81LuwH?duaLjR~ znXKj89W(MGBMX?%CH_ObW}lZaQ*kk8H%Fd3xOCw)&pN>e@ZA#Uq_{LhjCmMxF`=jR zy+c4}U)%GnDTD?szEB}6k7N;cMtM479G@D?F@SFr4A4=bCIkx9`ewlLSg?FuCYb4rdQU0`(8$!o<{yecc?h>ZBKSe(8+ctH}q;}{1&XX{veRg4BQ+IdXoWoV;$f^RHPyDa?5I$SqB4(aiRudXo zy){0g#0ST{fmS+m>(G)G?o7R?T6zUuNJNy~}y%DSdM zsq2DY_iua}v3hegv9 z1uLa>K4wqe6?t(ojUI$DXsDQq{uCDed1$C3NPm8oo0SH8b=~<>KYmYpcWPXGFs=zD==IO`#@&%IvYjxlm`FzxK=d(foboO~vGzl7VL&W4Y%3cET>9E&?@V|B;- zP`7a7ZyN&}P`BiteLp{ZOF*1Vsdt4=A{3X2o zyJnL$ZmafJyq+k9Y412|?z|YG5p=}*mzDLF&nWRMY+}cNlsE{q zE{v+LZ-Ld<|Mo}^Jjf@Xh}SZ?Zy^$DZfzKEx@o_Oce6#xpW)}i&)XF9Y&UgEx7~F9 z^0MyvFzE*mEE!OZ&!zT04DYVadRrl`QwJncl0{sy8Wt1uBE?{s{-%IAiT;``LgJ#= z6J3T+=Q|iF>=7=lvMnAF)ehO(AV!g)j7CfoxKn3*%wO5~S*E^uHRm>?7;t`_cD#Sg z`!K`Xx|mw(`{cO@{XeDU8%7#3xn1Hu$B&h?(vu?v`7x>_lGRj$B%%04J#$lOLi#rI zt;Qm@nL(0cCHDd%OC9ryyR_!{Hw1XewD~ydhZA{ur6u)@1jsf=B~5FL&P9l%G-1Br zo6@8&n-wC&G`CxX@;#h9vr_-5Co%LPFG^l$L$#~tB2nyJ&&EWbzGdxOAKvl~p5iVn zyLGo0MA60;Rg^bx6?)07T-cX*dz14=&>8b;l1a>8IWi)Ab&ESsSPP0(Zd~YkSylen zdjUjpKirC{tCv)<${P2H^_%m3{9z!q>&r>dVgs{ZQYn~o`4Xc7mn?gn8JbAKo}i=2A=3aW`hZ2H!4jF@~P%71WYAqLG09VDmaEd*_~<<$Rt|_9e{$m8o2Dq!jtjH|750gkX^d-~SQa?kGh~MKGK1|Qm zbVx)P*^}%AxUzsz;lB)NjKx`ekKjMge61;>o5`evtLc+&Gribbg))5dIza z7w>PmuQ~%>I2_u5PW0hS4{M+W;f#+a(TP+NdR0_K5fKEq1`>)=Q%6A6P$U9W1CJs= z$?9+-f<#s&tK(5WL1AeuHl9W#bD#ilWh#I}rl_c*Ch8tQG{Jtnx!+;fZHcfB;|*P-!H( zAM1z7hU!JOX5%@0!jWpK2si?+ss=Eks-p43=`fke0&0=8yoJoN>k*fs`#(Z5C6DkYv2;kKGTGd;Vy}y3@x(Pg~ zt0pjbwQ$jR;@3e~cwaJUbs!+_tBL52r@4`V9llml-}Kb~v|LCsu;ta&pz5l?va68^ z1gIuKlK>@=Nfcn|kz@oy{a17rox=9RGs(JcK&C)8Knbm81D0DOQ~pRDHULU ztH7ZMqzxR2R?|SMt3hCE$-+2$`dhXb*uU|CS#|j75CG!7>VU%qIICda534o4I28U5 zUu)~|KO6yo{yoS);`cXQzv=o%4E!VK-_`Y-u7AY9KXU$EUH>(@_$TZ*y$Pc*8 zd?+5m0~aA~!a-vL&KVKCeT*;)~F)2XG9V^ zr#&)5P^fn__+JpCtStZl From e684a87d66335b9cdf1ce814f8721d1fca056ca6 Mon Sep 17 00:00:00 2001 From: kfkama Date: Tue, 15 Feb 2022 12:49:03 +0100 Subject: [PATCH 057/108] Expanded cell click logic --- src/main/java/TicTacToe/cell.java | 22 +++++++++++-------- .../java/TicTacToe/TicTacToeGameTest.java | 2 -- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/TicTacToe/cell.java b/src/main/java/TicTacToe/cell.java index b8c4351..65e0db5 100644 --- a/src/main/java/TicTacToe/cell.java +++ b/src/main/java/TicTacToe/cell.java @@ -22,15 +22,19 @@ public class cell extends JButton { } protected void OnMouseClick() { - value = ttt.player; - ttt.endTurn(); - switch (value) { - case 1: setBackground(new Color(255,0,0)); - break; - case 2: setBackground(new Color(0,0,255)); - break; - default: ; - break; + if(value == 0) { + value = ttt.player; + ttt.endTurn(); + setEnabled(false); + + switch (value) { + case 1: setBackground(new Color(255,0,0)); + break; + case 2: setBackground(new Color(0,0,255)); + break; + default: ; + break; + } } } diff --git a/src/test/java/TicTacToe/TicTacToeGameTest.java b/src/test/java/TicTacToe/TicTacToeGameTest.java index 08742dd..a02accb 100644 --- a/src/test/java/TicTacToe/TicTacToeGameTest.java +++ b/src/test/java/TicTacToe/TicTacToeGameTest.java @@ -4,7 +4,5 @@ import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; class TicTacToeGameTest { - - } From 1b5b0777046741e0b6c76cbe5e074ae4647a5faf Mon Sep 17 00:00:00 2001 From: kfkama Date: Tue, 15 Feb 2022 13:52:50 +0100 Subject: [PATCH 058/108] Game end: Player wins, with Test --- src/main/java/TicTacToe/TicTacToeGame.java | 25 +++++++++++- src/main/java/TicTacToe/cell.java | 2 +- .../java/TicTacToe/TicTacToeGameTest.java | 40 +++++++++++++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/src/main/java/TicTacToe/TicTacToeGame.java b/src/main/java/TicTacToe/TicTacToeGame.java index 89fa969..3cde289 100644 --- a/src/main/java/TicTacToe/TicTacToeGame.java +++ b/src/main/java/TicTacToe/TicTacToeGame.java @@ -5,6 +5,7 @@ import java.awt.Graphics2D; import java.awt.geom.Line2D; import javax.swing.JFrame; +import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -67,11 +68,33 @@ public class TicTacToeGame extends JPanel { } public void endTurn() { + + if(checkPlayfield() != 0) { + JOptionPane.showMessageDialog(getParent(),"Player: " + player + " Wins!"); + System.exit(0); + } + player++; if(player >= 3) { player = 1; } - + } + + public int checkPlayfield() { + if ((field[0].value == player && field[1].value == player && field[2].value == player) + || (field[0].value == player && field[3].value == player && field[6].value == player) + || (field[8].value == player && field[5].value == player && field[2].value == player) + || (field[8].value == player && field[7].value == player && field[6].value == player) + || (field[0].value == player && field[4].value == player && field[8].value == player) + || (field[0].value == player && field[4].value == player && field[8].value == player) + || (field[2].value == player && field[4].value == player && field[6].value == player) + || (field[3].value == player && field[4].value == player && field[5].value == player) + || (field[1].value == player && field[4].value == player && field[7].value == player)) { + + return player; + } + + return 0; } diff --git a/src/main/java/TicTacToe/cell.java b/src/main/java/TicTacToe/cell.java index 65e0db5..b4cff42 100644 --- a/src/main/java/TicTacToe/cell.java +++ b/src/main/java/TicTacToe/cell.java @@ -7,7 +7,7 @@ import javax.swing.JButton; public class cell extends JButton { - int value = 0; + public int value = 0; private TicTacToeGame ttt; public cell(TicTacToeGame _ttt) { diff --git a/src/test/java/TicTacToe/TicTacToeGameTest.java b/src/test/java/TicTacToe/TicTacToeGameTest.java index a02accb..4111603 100644 --- a/src/test/java/TicTacToe/TicTacToeGameTest.java +++ b/src/test/java/TicTacToe/TicTacToeGameTest.java @@ -1,8 +1,48 @@ package TicTacToe; import static org.junit.jupiter.api.Assertions.*; + +import java.util.stream.Stream; + import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import Arcade64.Arcade64.Code; class TicTacToeGameTest { + @ParameterizedTest + @MethodSource("testFieldsWinning") + void testGameEndWin(int[] _field, int _winner) { + TicTacToeGame ttt = new TicTacToeGame(); + + for(int i = 0; i < ttt.field.length; i++) { + ttt.field[i].value = _field[i]; + } + ttt.player = _winner; + int realWinner = ttt.checkPlayfield(); + + assertEquals(_winner, realWinner); + } + + private static Stream testFieldsWinning(){ + return Stream.of( + Arguments.of(new int[]{ 1,2,1, + 2,2,2, + 1,2,1}, 2), + Arguments.of(new int[]{ 2,1,2, + 2,2,1, + 1,1,1}, 1), + Arguments.of(new int[]{ 1,1,2, + 1,2,2, + 1,2,1}, 1), + Arguments.of(new int[]{ 2,1,1, + 1,2,1, + 1,1,2}, 2) + ); + + + } } From aad8ef8cf9d610da47396bb73f2cdcbed9825b72 Mon Sep 17 00:00:00 2001 From: kfkama Date: Tue, 15 Feb 2022 14:04:25 +0100 Subject: [PATCH 059/108] Refactore: TicTacToe, cell --- src/main/java/TicTacToe/TicTacToeGame.java | 38 ++++++++++--------- src/main/java/TicTacToe/cell.java | 8 ++-- .../java/TicTacToe/TicTacToeGameTest.java | 7 +--- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/main/java/TicTacToe/TicTacToeGame.java b/src/main/java/TicTacToe/TicTacToeGame.java index 3cde289..9784f8b 100644 --- a/src/main/java/TicTacToe/TicTacToeGame.java +++ b/src/main/java/TicTacToe/TicTacToeGame.java @@ -12,9 +12,12 @@ import javax.swing.JPanel; public class TicTacToeGame extends JPanel { private static final long serialVersionUID = 1L; - private static int width = 600, height = 600; + private static final int width = 600, height = 600; + private static final int maxPlayers = 3; + private static final int playFieldSize = 9; + public cell[] field; - public int player = 1; + public int playerID = 1; public TicTacToeGame() { this.setSize(width, height); @@ -33,7 +36,7 @@ public class TicTacToeGame extends JPanel { } public void initField() { - field = new cell[9]; + field = new cell[playFieldSize]; for(int i = 0; i < field.length; i++) { field[i] = new cell(this); @@ -68,30 +71,29 @@ public class TicTacToeGame extends JPanel { } public void endTurn() { - if(checkPlayfield() != 0) { - JOptionPane.showMessageDialog(getParent(),"Player: " + player + " Wins!"); + JOptionPane.showMessageDialog(getParent(),"Player: " + playerID + " Wins!"); System.exit(0); } - player++; - if(player >= 3) { - player = 1; + playerID++; + if(playerID >= maxPlayers) { + playerID = 1; } } public int checkPlayfield() { - if ((field[0].value == player && field[1].value == player && field[2].value == player) - || (field[0].value == player && field[3].value == player && field[6].value == player) - || (field[8].value == player && field[5].value == player && field[2].value == player) - || (field[8].value == player && field[7].value == player && field[6].value == player) - || (field[0].value == player && field[4].value == player && field[8].value == player) - || (field[0].value == player && field[4].value == player && field[8].value == player) - || (field[2].value == player && field[4].value == player && field[6].value == player) - || (field[3].value == player && field[4].value == player && field[5].value == player) - || (field[1].value == player && field[4].value == player && field[7].value == player)) { + if ((field[0].playerID == playerID && field[1].playerID == playerID && field[2].playerID == playerID) + || (field[0].playerID == playerID && field[3].playerID == playerID && field[6].playerID == playerID) + || (field[8].playerID == playerID && field[5].playerID == playerID && field[2].playerID == playerID) + || (field[8].playerID == playerID && field[7].playerID == playerID && field[6].playerID == playerID) + || (field[0].playerID == playerID && field[4].playerID == playerID && field[8].playerID == playerID) + || (field[0].playerID == playerID && field[4].playerID == playerID && field[8].playerID == playerID) + || (field[2].playerID == playerID && field[4].playerID == playerID && field[6].playerID == playerID) + || (field[3].playerID == playerID && field[4].playerID == playerID && field[5].playerID == playerID) + || (field[1].playerID == playerID && field[4].playerID == playerID && field[7].playerID == playerID)) { - return player; + return playerID; } return 0; diff --git a/src/main/java/TicTacToe/cell.java b/src/main/java/TicTacToe/cell.java index b4cff42..249ff4b 100644 --- a/src/main/java/TicTacToe/cell.java +++ b/src/main/java/TicTacToe/cell.java @@ -7,7 +7,7 @@ import javax.swing.JButton; public class cell extends JButton { - public int value = 0; + public int playerID = 0; private TicTacToeGame ttt; public cell(TicTacToeGame _ttt) { @@ -22,12 +22,12 @@ public class cell extends JButton { } protected void OnMouseClick() { - if(value == 0) { - value = ttt.player; + if(playerID == 0) { + playerID = ttt.playerID; ttt.endTurn(); setEnabled(false); - switch (value) { + switch (playerID) { case 1: setBackground(new Color(255,0,0)); break; case 2: setBackground(new Color(0,0,255)); diff --git a/src/test/java/TicTacToe/TicTacToeGameTest.java b/src/test/java/TicTacToe/TicTacToeGameTest.java index 4111603..1211ca3 100644 --- a/src/test/java/TicTacToe/TicTacToeGameTest.java +++ b/src/test/java/TicTacToe/TicTacToeGameTest.java @@ -1,15 +1,12 @@ package TicTacToe; import static org.junit.jupiter.api.Assertions.*; - import java.util.stream.Stream; -import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import Arcade64.Arcade64.Code; class TicTacToeGameTest { @@ -19,9 +16,9 @@ class TicTacToeGameTest { TicTacToeGame ttt = new TicTacToeGame(); for(int i = 0; i < ttt.field.length; i++) { - ttt.field[i].value = _field[i]; + ttt.field[i].playerID = _field[i]; } - ttt.player = _winner; + ttt.playerID = _winner; int realWinner = ttt.checkPlayfield(); assertEquals(_winner, realWinner); From 072610ab1b7612ce6f0317bcceb2339697874fff Mon Sep 17 00:00:00 2001 From: kfkama Date: Tue, 15 Feb 2022 14:12:52 +0100 Subject: [PATCH 060/108] Game end: Draw, with Test --- src/main/java/TicTacToe/TicTacToeGame.java | 9 +++++- .../java/TicTacToe/TicTacToeGameTest.java | 32 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/main/java/TicTacToe/TicTacToeGame.java b/src/main/java/TicTacToe/TicTacToeGame.java index 9784f8b..c551abf 100644 --- a/src/main/java/TicTacToe/TicTacToeGame.java +++ b/src/main/java/TicTacToe/TicTacToeGame.java @@ -18,6 +18,7 @@ public class TicTacToeGame extends JPanel { public cell[] field; public int playerID = 1; + public int turns = 0; public TicTacToeGame() { this.setSize(width, height); @@ -75,7 +76,13 @@ public class TicTacToeGame extends JPanel { JOptionPane.showMessageDialog(getParent(),"Player: " + playerID + " Wins!"); System.exit(0); } - + + turns++; + if(turns >= playFieldSize) { + JOptionPane.showMessageDialog(getParent(),"Draw!"); + System.exit(0); + } + playerID++; if(playerID >= maxPlayers) { playerID = 1; diff --git a/src/test/java/TicTacToe/TicTacToeGameTest.java b/src/test/java/TicTacToe/TicTacToeGameTest.java index 1211ca3..beaabde 100644 --- a/src/test/java/TicTacToe/TicTacToeGameTest.java +++ b/src/test/java/TicTacToe/TicTacToeGameTest.java @@ -24,6 +24,21 @@ class TicTacToeGameTest { assertEquals(_winner, realWinner); } + @ParameterizedTest + @MethodSource("testFieldsDraw") + void testGameEndDraw(int[] _field) { + TicTacToeGame ttt = new TicTacToeGame(); + + for(int i = 0; i < ttt.field.length; i++) { + ttt.field[i].playerID = _field[i]; + } + + int noWinner = ttt.checkPlayfield(); + + assertEquals(0, noWinner); + } + + private static Stream testFieldsWinning(){ return Stream.of( Arguments.of(new int[]{ 1,2,1, @@ -39,6 +54,23 @@ class TicTacToeGameTest { 1,2,1, 1,1,2}, 2) ); + } + + private static Stream testFieldsDraw(){ + return Stream.of( + Arguments.of(new int[]{ 2,1,1, + 2,2,2, + 1,2,1}), + Arguments.of(new int[]{ 2,1,2, + 2,2,1, + 1,2,1}), + Arguments.of(new int[]{ 2,1,2, + 1,2,2, + 1,2,1}), + Arguments.of(new int[]{ 2,1,1, + 1,2,2, + 2,1,1}) + ); } From e5690a005d319fc71ce5b192ffa44440c4f0be1f Mon Sep 17 00:00:00 2001 From: kfkama Date: Tue, 15 Feb 2022 14:24:20 +0100 Subject: [PATCH 061/108] Reset game on game end --- src/main/java/TicTacToe/TicTacToeGame.java | 12 ++++++-- src/main/java/TicTacToe/cell.java | 35 ++++++++++++---------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/main/java/TicTacToe/TicTacToeGame.java b/src/main/java/TicTacToe/TicTacToeGame.java index c551abf..acef34d 100644 --- a/src/main/java/TicTacToe/TicTacToeGame.java +++ b/src/main/java/TicTacToe/TicTacToeGame.java @@ -74,13 +74,13 @@ public class TicTacToeGame extends JPanel { public void endTurn() { if(checkPlayfield() != 0) { JOptionPane.showMessageDialog(getParent(),"Player: " + playerID + " Wins!"); - System.exit(0); + resetGame(); } turns++; if(turns >= playFieldSize) { JOptionPane.showMessageDialog(getParent(),"Draw!"); - System.exit(0); + resetGame(); } playerID++; @@ -105,6 +105,14 @@ public class TicTacToeGame extends JPanel { return 0; } + + public void resetGame() { + for (cell c : field) { + c.reset(); + } + playerID = 1; + turns = 0; + } } \ No newline at end of file diff --git a/src/main/java/TicTacToe/cell.java b/src/main/java/TicTacToe/cell.java index 249ff4b..27a3158 100644 --- a/src/main/java/TicTacToe/cell.java +++ b/src/main/java/TicTacToe/cell.java @@ -1,4 +1,5 @@ package TicTacToe; + import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -9,10 +10,11 @@ public class cell extends JButton { public int playerID = 0; private TicTacToeGame ttt; - + public cell(TicTacToeGame _ttt) { ttt = _ttt; - + setBackground(new Color(255,255,255)); + addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -22,23 +24,26 @@ public class cell extends JButton { } protected void OnMouseClick() { - if(playerID == 0) { - playerID = ttt.playerID; + if (playerID == 0) { + playerID = ttt.playerID; ttt.endTurn(); setEnabled(false); - + switch (playerID) { - case 1: setBackground(new Color(255,0,0)); - break; - case 2: setBackground(new Color(0,0,255)); - break; - default: ; - break; + case 1: + setBackground(new Color(255, 0, 0)); + break; + case 2: + setBackground(new Color(0, 0, 255)); + break; + } } - } } - - - + protected void reset() { + playerID = 0; + setEnabled(true); + setBackground(new Color(255,255,255)); + } + } From 462b2e0a5f912868170a9b19781aba1d9247cb3c Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Tue, 15 Feb 2022 20:38:16 +0100 Subject: [PATCH 062/108] Refactor --- src/main/java/solitaer/Card.java | 12 ++++++------ src/test/java/solitaer/AblageStackTest.java | 4 ++-- src/test/java/solitaer/CardDeckTest.java | 4 ++-- src/test/java/solitaer/StartStackTest.java | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/solitaer/Card.java b/src/main/java/solitaer/Card.java index 5cad36d..e905f90 100644 --- a/src/main/java/solitaer/Card.java +++ b/src/main/java/solitaer/Card.java @@ -21,19 +21,19 @@ public class Card extends JPanel { private final int IMAGE_WIDTH = 72; private final int IMAGE_HIGHT = 96; - public Card(int nr, Symbol symbol, boolean faceUp) { + public Card(int _nr, Symbol _symbol, boolean _faceUp) { this.setSize(IMAGE_WIDTH,IMAGE_HIGHT); - this.nr = nr; - this.symbol = symbol; - this.faceUp = faceUp; + this.nr = _nr; + this.symbol = _symbol; + this.faceUp = _faceUp; } public boolean isFaceUp() { return faceUp; } - public void setFaceUp(boolean faceUp) { - this.faceUp = faceUp; + public void setFaceUp(boolean _faceUp) { + this.faceUp = _faceUp; } public int getNr() { diff --git a/src/test/java/solitaer/AblageStackTest.java b/src/test/java/solitaer/AblageStackTest.java index 6059ac1..94ebe9d 100644 --- a/src/test/java/solitaer/AblageStackTest.java +++ b/src/test/java/solitaer/AblageStackTest.java @@ -12,9 +12,9 @@ class AblageStackTest { @ParameterizedTest @MethodSource("testAblageStackTestDaten") - void testRulesetAblageStack(String msg, Card _stapel, Card _spieler, boolean _expectedResult) { + void testRulesetAblageStack(String _msg, Card _stapel, Card _spieler, boolean _expectedResult) { AblageStack stack = new AblageStack(0, 0, Symbol.Kreuz); - assertEquals(_expectedResult, stack.cardCheck(_stapel, _spieler), msg); + assertEquals(_expectedResult, stack.cardCheck(_stapel, _spieler), _msg); } private static Stream testAblageStackTestDaten(){ diff --git a/src/test/java/solitaer/CardDeckTest.java b/src/test/java/solitaer/CardDeckTest.java index 48776f9..0576f3c 100644 --- a/src/test/java/solitaer/CardDeckTest.java +++ b/src/test/java/solitaer/CardDeckTest.java @@ -25,7 +25,7 @@ class CardDeckTest { @ParameterizedTest @MethodSource("testSymbole") //Jedes Symbol muss einmal vorhand sein - void testCardDeckSymbole(String msg, Symbol _sym) { + void testCardDeckSymbole(String _msg, Symbol _sym) { boolean result = false; @@ -36,7 +36,7 @@ class CardDeckTest { } } - assertTrue(result, msg); + assertTrue(result, _msg); } diff --git a/src/test/java/solitaer/StartStackTest.java b/src/test/java/solitaer/StartStackTest.java index d033e45..a618a19 100644 --- a/src/test/java/solitaer/StartStackTest.java +++ b/src/test/java/solitaer/StartStackTest.java @@ -13,9 +13,9 @@ class StartStackTest { @ParameterizedTest @MethodSource("testStartStackTestDaten") //Jedes Symbol muss einmal vorhand sein - void testRulesetStartStack(String msg, Card _stapel, Card _spieler, boolean _expectedResult) { + void testRulesetStartStack(String _msg, Card _stapel, Card _spieler, boolean _expectedResult) { StartStack stack = new StartStack(10, 10); - assertEquals(_expectedResult, stack.cardCheck(_stapel, _spieler), msg); + assertEquals(_expectedResult, stack.cardCheck(_stapel, _spieler), _msg); } From 30f5312440b82d75e7d2ea77dbffd062ed9c3cf1 Mon Sep 17 00:00:00 2001 From: kfkama Date: Tue, 15 Feb 2022 23:31:20 +0100 Subject: [PATCH 063/108] Add Scoreboard class with basic functions --- src/main/java/TicTacToe/Scoreboard.java | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/TicTacToe/Scoreboard.java diff --git a/src/main/java/TicTacToe/Scoreboard.java b/src/main/java/TicTacToe/Scoreboard.java new file mode 100644 index 0000000..b2f4483 --- /dev/null +++ b/src/main/java/TicTacToe/Scoreboard.java @@ -0,0 +1,36 @@ +package TicTacToe; + +import javax.swing.JLabel; + +public class Scoreboard extends JLabel{ + + private static final long serialVersionUID = 1L; + + public int[] playerPoints; + + public Scoreboard(int _playerCount) { + playerPoints = new int[_playerCount]; + } + + public void addPoint(int playerID) { + playerPoints[playerID]++; + updateScores(); + } + + public void subPoint(int playerID) { + playerPoints[playerID]--; + updateScores(); + } + + public void updateScores() { + for(int i = 0; i < playerPoints.length; i++){ + if(i == 0) { + setText("Draws: " + playerPoints[0]); + } else { + setText(getText() + " Player " + i + ": " + playerPoints[i]); + } + } + } + + +} From ca9ca4446a2bce6c5338bc4b864da1651fdfbc42 Mon Sep 17 00:00:00 2001 From: kfkama Date: Tue, 15 Feb 2022 23:38:26 +0100 Subject: [PATCH 064/108] Show Scoreboard in TicTacToe game --- src/main/java/TicTacToe/Scoreboard.java | 3 ++- src/main/java/TicTacToe/TicTacToeGame.java | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/TicTacToe/Scoreboard.java b/src/main/java/TicTacToe/Scoreboard.java index b2f4483..a9799a5 100644 --- a/src/main/java/TicTacToe/Scoreboard.java +++ b/src/main/java/TicTacToe/Scoreboard.java @@ -10,6 +10,7 @@ public class Scoreboard extends JLabel{ public Scoreboard(int _playerCount) { playerPoints = new int[_playerCount]; + updateScores(); } public void addPoint(int playerID) { @@ -27,7 +28,7 @@ public class Scoreboard extends JLabel{ if(i == 0) { setText("Draws: " + playerPoints[0]); } else { - setText(getText() + " Player " + i + ": " + playerPoints[i]); + setText(getText() + " Player " + i + ": " + playerPoints[i]); } } } diff --git a/src/main/java/TicTacToe/TicTacToeGame.java b/src/main/java/TicTacToe/TicTacToeGame.java index acef34d..6d363a9 100644 --- a/src/main/java/TicTacToe/TicTacToeGame.java +++ b/src/main/java/TicTacToe/TicTacToeGame.java @@ -19,11 +19,15 @@ public class TicTacToeGame extends JPanel { public cell[] field; public int playerID = 1; public int turns = 0; + public Scoreboard scoreboard; public TicTacToeGame() { this.setSize(width, height); setLayout(null); initField(); + scoreboard = new Scoreboard(maxPlayers); + scoreboard.setBounds(200, 100, 200, 50); + add(scoreboard); } public static void main(String[] args) { @@ -74,12 +78,14 @@ public class TicTacToeGame extends JPanel { public void endTurn() { if(checkPlayfield() != 0) { JOptionPane.showMessageDialog(getParent(),"Player: " + playerID + " Wins!"); + scoreboard.addPoint(playerID); resetGame(); } turns++; if(turns >= playFieldSize) { JOptionPane.showMessageDialog(getParent(),"Draw!"); + scoreboard.addPoint(playerID); resetGame(); } From e7468f149851e5a57e95e624880425d2086b7209 Mon Sep 17 00:00:00 2001 From: kfkama Date: Tue, 15 Feb 2022 23:45:38 +0100 Subject: [PATCH 065/108] Refactor cell, TicTacToe --- .../java/TicTacToe/{cell.java => Cell.java} | 4 ++-- src/main/java/TicTacToe/TicTacToeGame.java | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) rename src/main/java/TicTacToe/{cell.java => Cell.java} (91%) diff --git a/src/main/java/TicTacToe/cell.java b/src/main/java/TicTacToe/Cell.java similarity index 91% rename from src/main/java/TicTacToe/cell.java rename to src/main/java/TicTacToe/Cell.java index 27a3158..2c53223 100644 --- a/src/main/java/TicTacToe/cell.java +++ b/src/main/java/TicTacToe/Cell.java @@ -6,12 +6,12 @@ import java.awt.event.ActionListener; import javax.swing.JButton; -public class cell extends JButton { +public class Cell extends JButton { public int playerID = 0; private TicTacToeGame ttt; - public cell(TicTacToeGame _ttt) { + public Cell(TicTacToeGame _ttt) { ttt = _ttt; setBackground(new Color(255,255,255)); diff --git a/src/main/java/TicTacToe/TicTacToeGame.java b/src/main/java/TicTacToe/TicTacToeGame.java index 6d363a9..44aa358 100644 --- a/src/main/java/TicTacToe/TicTacToeGame.java +++ b/src/main/java/TicTacToe/TicTacToeGame.java @@ -16,7 +16,7 @@ public class TicTacToeGame extends JPanel { private static final int maxPlayers = 3; private static final int playFieldSize = 9; - public cell[] field; + public Cell[] field; public int playerID = 1; public int turns = 0; public Scoreboard scoreboard; @@ -25,10 +25,9 @@ public class TicTacToeGame extends JPanel { this.setSize(width, height); setLayout(null); initField(); - scoreboard = new Scoreboard(maxPlayers); - scoreboard.setBounds(200, 100, 200, 50); - add(scoreboard); + initScoreboard(); } + public static void main(String[] args) { JFrame f = new JFrame(); @@ -41,10 +40,10 @@ public class TicTacToeGame extends JPanel { } public void initField() { - field = new cell[playFieldSize]; + field = new Cell[playFieldSize]; for(int i = 0; i < field.length; i++) { - field[i] = new cell(this); + field[i] = new Cell(this); add(field[i]); } @@ -59,6 +58,12 @@ public class TicTacToeGame extends JPanel { } } + private void initScoreboard() { + scoreboard = new Scoreboard(maxPlayers); + scoreboard.setBounds(200, 100, 200, 50); + add(scoreboard); + } + @Override protected void paintComponent(Graphics g) { super.paintComponent(g); @@ -85,7 +90,7 @@ public class TicTacToeGame extends JPanel { turns++; if(turns >= playFieldSize) { JOptionPane.showMessageDialog(getParent(),"Draw!"); - scoreboard.addPoint(playerID); + scoreboard.addPoint(0); resetGame(); } @@ -113,7 +118,7 @@ public class TicTacToeGame extends JPanel { } public void resetGame() { - for (cell c : field) { + for (Cell c : field) { c.reset(); } playerID = 1; From 41b70d270045d59b2ac072081ad35bd9d4b7463c Mon Sep 17 00:00:00 2001 From: kfkama Date: Wed, 16 Feb 2022 10:54:30 +0100 Subject: [PATCH 066/108] Add Games played to Scoreboard --- src/main/java/TicTacToe/Scoreboard.java | 5 +++++ src/main/java/TicTacToe/TicTacToeGame.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/TicTacToe/Scoreboard.java b/src/main/java/TicTacToe/Scoreboard.java index a9799a5..a903129 100644 --- a/src/main/java/TicTacToe/Scoreboard.java +++ b/src/main/java/TicTacToe/Scoreboard.java @@ -24,13 +24,18 @@ public class Scoreboard extends JLabel{ } public void updateScores() { + int gamesPlayed = 0; for(int i = 0; i < playerPoints.length; i++){ if(i == 0) { setText("Draws: " + playerPoints[0]); } else { setText(getText() + " Player " + i + ": " + playerPoints[i]); } + + gamesPlayed += playerPoints[i]; } + setText(getText() + " Games played: " + gamesPlayed); + } diff --git a/src/main/java/TicTacToe/TicTacToeGame.java b/src/main/java/TicTacToe/TicTacToeGame.java index 44aa358..7b8fb5a 100644 --- a/src/main/java/TicTacToe/TicTacToeGame.java +++ b/src/main/java/TicTacToe/TicTacToeGame.java @@ -60,7 +60,7 @@ public class TicTacToeGame extends JPanel { private void initScoreboard() { scoreboard = new Scoreboard(maxPlayers); - scoreboard.setBounds(200, 100, 200, 50); + scoreboard.setBounds(150, 100, 300, 50); add(scoreboard); } From 003119fc27d64e0c94a15190cb093a64fb9887f0 Mon Sep 17 00:00:00 2001 From: kfkama Date: Wed, 16 Feb 2022 15:31:22 +0100 Subject: [PATCH 067/108] Changed Colors to cross and circle --- src/main/java/TicTacToe/Cell.java | 33 ++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/main/java/TicTacToe/Cell.java b/src/main/java/TicTacToe/Cell.java index 2c53223..a254735 100644 --- a/src/main/java/TicTacToe/Cell.java +++ b/src/main/java/TicTacToe/Cell.java @@ -1,6 +1,8 @@ package TicTacToe; import java.awt.Color; +import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -13,7 +15,7 @@ public class Cell extends JButton { public Cell(TicTacToeGame _ttt) { ttt = _ttt; - setBackground(new Color(255,255,255)); + setBackground(new Color(255, 255, 255)); addActionListener(new ActionListener() { @Override @@ -28,22 +30,31 @@ public class Cell extends JButton { playerID = ttt.playerID; ttt.endTurn(); setEnabled(false); + repaint(); + } + } - switch (playerID) { - case 1: - setBackground(new Color(255, 0, 0)); - break; - case 2: - setBackground(new Color(0, 0, 255)); - break; - } + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + Graphics2D g2 = (Graphics2D) g; + + switch (playerID) { + case 1: + g2.drawOval(5, 5, 90, 90); + break; + case 2: + g2.drawLine(5, 5, 90, 90); + g2.drawLine(90, 5, 5, 90); + break; } } - + + protected void reset() { playerID = 0; setEnabled(true); - setBackground(new Color(255,255,255)); + repaint(); } } From 3efe0a8d3eb440f62259509427a14d646f9850cd Mon Sep 17 00:00:00 2001 From: kfkama Date: Wed, 16 Feb 2022 15:33:48 +0100 Subject: [PATCH 068/108] Bugfix unclickable cell --- src/main/java/TicTacToe/Cell.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/TicTacToe/Cell.java b/src/main/java/TicTacToe/Cell.java index a254735..01fd7ab 100644 --- a/src/main/java/TicTacToe/Cell.java +++ b/src/main/java/TicTacToe/Cell.java @@ -28,8 +28,8 @@ public class Cell extends JButton { protected void OnMouseClick() { if (playerID == 0) { playerID = ttt.playerID; - ttt.endTurn(); setEnabled(false); + ttt.endTurn(); repaint(); } } From 3ca691f2a24ba0b81b4645eaf7498e495050f0d6 Mon Sep 17 00:00:00 2001 From: kfkama Date: Wed, 16 Feb 2022 15:35:29 +0100 Subject: [PATCH 069/108] Bugfix turn 8 draw --- src/main/java/TicTacToe/TicTacToeGame.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/TicTacToe/TicTacToeGame.java b/src/main/java/TicTacToe/TicTacToeGame.java index 7b8fb5a..56f9dc9 100644 --- a/src/main/java/TicTacToe/TicTacToeGame.java +++ b/src/main/java/TicTacToe/TicTacToeGame.java @@ -88,7 +88,7 @@ public class TicTacToeGame extends JPanel { } turns++; - if(turns >= playFieldSize) { + if(turns > playFieldSize) { JOptionPane.showMessageDialog(getParent(),"Draw!"); scoreboard.addPoint(0); resetGame(); From 899ba9bbc4087b344b6204f1c400ff9b57ebb5c5 Mon Sep 17 00:00:00 2001 From: kfkama Date: Wed, 16 Feb 2022 15:46:55 +0100 Subject: [PATCH 070/108] Requested change to darker colors --- src/main/java/TicTacToe/Cell.java | 4 ++-- src/main/java/TicTacToe/Scoreboard.java | 3 +++ src/main/java/TicTacToe/TicTacToeGame.java | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/TicTacToe/Cell.java b/src/main/java/TicTacToe/Cell.java index 01fd7ab..81b8a0f 100644 --- a/src/main/java/TicTacToe/Cell.java +++ b/src/main/java/TicTacToe/Cell.java @@ -15,7 +15,7 @@ public class Cell extends JButton { public Cell(TicTacToeGame _ttt) { ttt = _ttt; - setBackground(new Color(255, 255, 255)); + setBackground(new Color(0)); addActionListener(new ActionListener() { @Override @@ -38,7 +38,7 @@ public class Cell extends JButton { protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; - + g2.setPaint(Color.white); switch (playerID) { case 1: g2.drawOval(5, 5, 90, 90); diff --git a/src/main/java/TicTacToe/Scoreboard.java b/src/main/java/TicTacToe/Scoreboard.java index a903129..cbca4a2 100644 --- a/src/main/java/TicTacToe/Scoreboard.java +++ b/src/main/java/TicTacToe/Scoreboard.java @@ -1,5 +1,7 @@ package TicTacToe; +import java.awt.Color; + import javax.swing.JLabel; public class Scoreboard extends JLabel{ @@ -10,6 +12,7 @@ public class Scoreboard extends JLabel{ public Scoreboard(int _playerCount) { playerPoints = new int[_playerCount]; + setForeground(Color.white); updateScores(); } diff --git a/src/main/java/TicTacToe/TicTacToeGame.java b/src/main/java/TicTacToe/TicTacToeGame.java index 56f9dc9..92338f1 100644 --- a/src/main/java/TicTacToe/TicTacToeGame.java +++ b/src/main/java/TicTacToe/TicTacToeGame.java @@ -1,5 +1,6 @@ package TicTacToe; +import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Line2D; @@ -23,6 +24,7 @@ public class TicTacToeGame extends JPanel { public TicTacToeGame() { this.setSize(width, height); + setBackground(Color.black); setLayout(null); initField(); initScoreboard(); @@ -68,6 +70,7 @@ public class TicTacToeGame extends JPanel { protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; + g2.setColor(Color.white); Line2D lin = new Line2D.Float(250, 150, 250, 450); Line2D lin2 = new Line2D.Float(350, 150, 350, 450); From 848a5ba499d335d70de776f8626c65a10942e230 Mon Sep 17 00:00:00 2001 From: kfkama Date: Wed, 16 Feb 2022 15:51:57 +0100 Subject: [PATCH 071/108] Bugfix draw order --- src/main/java/TicTacToe/Cell.java | 6 +++--- src/main/java/TicTacToe/TicTacToeGame.java | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/TicTacToe/Cell.java b/src/main/java/TicTacToe/Cell.java index 81b8a0f..b6c4e6b 100644 --- a/src/main/java/TicTacToe/Cell.java +++ b/src/main/java/TicTacToe/Cell.java @@ -41,12 +41,12 @@ public class Cell extends JButton { g2.setPaint(Color.white); switch (playerID) { case 1: - g2.drawOval(5, 5, 90, 90); - break; - case 2: g2.drawLine(5, 5, 90, 90); g2.drawLine(90, 5, 5, 90); break; + case 2: + g2.drawOval(5, 5, 90, 90); + break; } } diff --git a/src/main/java/TicTacToe/TicTacToeGame.java b/src/main/java/TicTacToe/TicTacToeGame.java index 92338f1..642f6e5 100644 --- a/src/main/java/TicTacToe/TicTacToeGame.java +++ b/src/main/java/TicTacToe/TicTacToeGame.java @@ -88,19 +88,21 @@ public class TicTacToeGame extends JPanel { JOptionPane.showMessageDialog(getParent(),"Player: " + playerID + " Wins!"); scoreboard.addPoint(playerID); resetGame(); + } else { + turns++; + if(turns >= playFieldSize) { + JOptionPane.showMessageDialog(getParent(),"Draw!"); + scoreboard.addPoint(0); + resetGame(); + } + + playerID++; + if(playerID >= maxPlayers) { + playerID = 1; + } } - turns++; - if(turns > playFieldSize) { - JOptionPane.showMessageDialog(getParent(),"Draw!"); - scoreboard.addPoint(0); - resetGame(); - } - playerID++; - if(playerID >= maxPlayers) { - playerID = 1; - } } public int checkPlayfield() { From 88de22364d8695e95d25d628e30184fd3c4a3dac Mon Sep 17 00:00:00 2001 From: kfkama Date: Wed, 16 Feb 2022 16:49:01 +0100 Subject: [PATCH 072/108] Add class MinesweeperGame with basic playfield gen. --- .gitignore | 21 +++++++++++ .../java/Minesweeper/MinesweeperGame.java | 36 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/test/java/Minesweeper/MinesweeperGame.java diff --git a/.gitignore b/.gitignore index 84adb3f..cfcc9bc 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,24 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +.mvn/wrapper/maven-wrapper.jar + +# Eclipse m2e generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# End of https://www.toptal.com/developers/gitignore/api/maven \ No newline at end of file diff --git a/src/test/java/Minesweeper/MinesweeperGame.java b/src/test/java/Minesweeper/MinesweeperGame.java new file mode 100644 index 0000000..8285a98 --- /dev/null +++ b/src/test/java/Minesweeper/MinesweeperGame.java @@ -0,0 +1,36 @@ +package Minesweeper; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; + +public class MinesweeperGame extends JPanel { + + public MinesweeperGame(int _playfieldSize) { + this.setSize(600, 600); + setLayout(null); + initPlayfield(_playfieldSize); + } + + private void initPlayfield(int _playfieldSize) { + for (int i = 0; i < _playfieldSize; i++) { + for (int j = 0; j < _playfieldSize; j++) { + JButton b = new JButton(); + b.setBounds(j * 40, i * 40, 40, 40); + add(b); + } + } + } + + public static void main(String[] args) { + JFrame f = new JFrame(); + MinesweeperGame ttt = new MinesweeperGame(8); + + f.add(ttt); + f.setSize(600, 600); + f.setLayout(null); + f.setVisible(true); + + } + +} From 00b6ab308c03c679c1154db02099f91fe58ddc6e Mon Sep 17 00:00:00 2001 From: kfkama Date: Wed, 16 Feb 2022 16:56:45 +0100 Subject: [PATCH 073/108] Refactore MinesweeperGame --- .../java/Minesweeper/MinesweeperGame.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/test/java/Minesweeper/MinesweeperGame.java b/src/test/java/Minesweeper/MinesweeperGame.java index 8285a98..a7764e3 100644 --- a/src/test/java/Minesweeper/MinesweeperGame.java +++ b/src/test/java/Minesweeper/MinesweeperGame.java @@ -6,17 +6,24 @@ import javax.swing.JPanel; public class MinesweeperGame extends JPanel { + private static final long serialVersionUID = 1L; + private static final int WIDTH = 600, HEIGTH = 600; + private static final int CELLSIZE = 40; + private int playfieldSize; + public MinesweeperGame(int _playfieldSize) { - this.setSize(600, 600); + this.setSize(WIDTH, HEIGTH); + playfieldSize = _playfieldSize; setLayout(null); - initPlayfield(_playfieldSize); + + initPlayfield(); } - private void initPlayfield(int _playfieldSize) { - for (int i = 0; i < _playfieldSize; i++) { - for (int j = 0; j < _playfieldSize; j++) { + private void initPlayfield() { + for (int i = 0; i < playfieldSize; i++) { + for (int j = 0; j < playfieldSize; j++) { JButton b = new JButton(); - b.setBounds(j * 40, i * 40, 40, 40); + b.setBounds(j * CELLSIZE, i * CELLSIZE, CELLSIZE, CELLSIZE); add(b); } } @@ -27,7 +34,7 @@ public class MinesweeperGame extends JPanel { MinesweeperGame ttt = new MinesweeperGame(8); f.add(ttt); - f.setSize(600, 600); + f.setSize(WIDTH, HEIGTH); f.setLayout(null); f.setVisible(true); From 44a39db750e8dc5499aa13f884c0476594daef15 Mon Sep 17 00:00:00 2001 From: kfkama Date: Wed, 16 Feb 2022 18:17:21 +0100 Subject: [PATCH 074/108] Add class Cell --- src/main/java/Minesweeper/Cell.java | 15 +++++++++++++++ .../java/Minesweeper/MinesweeperGame.java | 0 2 files changed, 15 insertions(+) create mode 100644 src/main/java/Minesweeper/Cell.java rename src/{test => main}/java/Minesweeper/MinesweeperGame.java (100%) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java new file mode 100644 index 0000000..594c53d --- /dev/null +++ b/src/main/java/Minesweeper/Cell.java @@ -0,0 +1,15 @@ +package Minesweeper; + +enum CellType{Number, Bomb} +public class Cell { + public CellType type; + public boolean flagged = false; + public int value = -1; + + public Cell(CellType _type) { + type = _type; + } + + + +} diff --git a/src/test/java/Minesweeper/MinesweeperGame.java b/src/main/java/Minesweeper/MinesweeperGame.java similarity index 100% rename from src/test/java/Minesweeper/MinesweeperGame.java rename to src/main/java/Minesweeper/MinesweeperGame.java From 665d7c123240023c3e7117b7b5034c3620477464 Mon Sep 17 00:00:00 2001 From: kfkama Date: Wed, 16 Feb 2022 18:27:51 +0100 Subject: [PATCH 075/108] Add Cell to Minesweeper, replacing JButtons / Move playfield to center --- src/main/java/Minesweeper/Cell.java | 9 +++++---- src/main/java/Minesweeper/MinesweeperGame.java | 14 ++++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index 594c53d..12a1935 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -1,7 +1,11 @@ package Minesweeper; +import javax.swing.JButton; + enum CellType{Number, Bomb} -public class Cell { +public class Cell extends JButton { + + private static final long serialVersionUID = 1L; public CellType type; public boolean flagged = false; public int value = -1; @@ -9,7 +13,4 @@ public class Cell { public Cell(CellType _type) { type = _type; } - - - } diff --git a/src/main/java/Minesweeper/MinesweeperGame.java b/src/main/java/Minesweeper/MinesweeperGame.java index a7764e3..8be5353 100644 --- a/src/main/java/Minesweeper/MinesweeperGame.java +++ b/src/main/java/Minesweeper/MinesweeperGame.java @@ -11,20 +11,26 @@ public class MinesweeperGame extends JPanel { private static final int CELLSIZE = 40; private int playfieldSize; + public Cell[][] playfield; + public MinesweeperGame(int _playfieldSize) { this.setSize(WIDTH, HEIGTH); playfieldSize = _playfieldSize; setLayout(null); - + initPlayfield(); } private void initPlayfield() { + + playfield = new Cell[playfieldSize][playfieldSize]; + for (int i = 0; i < playfieldSize; i++) { for (int j = 0; j < playfieldSize; j++) { - JButton b = new JButton(); - b.setBounds(j * CELLSIZE, i * CELLSIZE, CELLSIZE, CELLSIZE); - add(b); + Cell c = new Cell(CellType.Number); + c.setBounds(j * CELLSIZE + (WIDTH / 2 - playfieldSize * CELLSIZE / 2), i * CELLSIZE + (HEIGTH / 2 - playfieldSize * CELLSIZE / 2), CELLSIZE, + CELLSIZE); + add(c); } } } From 1dc0576f7b3eb855928953e168697f36f4d0905e Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 11:13:53 +0100 Subject: [PATCH 076/108] Add bomb placement --- .../java/Minesweeper/MinesweeperGame.java | 34 ++++++++++++--- .../java/Minesweeper/MinesweeperGameTest.java | 41 +++++++++++++++++++ 2 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 src/test/java/Minesweeper/MinesweeperGameTest.java diff --git a/src/main/java/Minesweeper/MinesweeperGame.java b/src/main/java/Minesweeper/MinesweeperGame.java index 8be5353..ffb4a10 100644 --- a/src/main/java/Minesweeper/MinesweeperGame.java +++ b/src/main/java/Minesweeper/MinesweeperGame.java @@ -10,12 +10,14 @@ public class MinesweeperGame extends JPanel { private static final int WIDTH = 600, HEIGTH = 600; private static final int CELLSIZE = 40; private int playfieldSize; + private int bombAmount; public Cell[][] playfield; - public MinesweeperGame(int _playfieldSize) { + public MinesweeperGame(int _playfieldSize, int _bombAmount) { this.setSize(WIDTH, HEIGTH); playfieldSize = _playfieldSize; + bombAmount = _bombAmount; setLayout(null); initPlayfield(); @@ -25,19 +27,39 @@ public class MinesweeperGame extends JPanel { playfield = new Cell[playfieldSize][playfieldSize]; + int[] bPlacment = new int[bombAmount]; + for (int i = 0; i < bPlacment.length; i++) { + bPlacment[i] = (int) (Math.random() * playfieldSize * playfieldSize); + + for (int j = 0; j < i; j++) { + if (bPlacment[i] == bPlacment[j]) { + i--; + break; + } + } + } + for (int i = 0; i < playfieldSize; i++) { for (int j = 0; j < playfieldSize; j++) { - Cell c = new Cell(CellType.Number); - c.setBounds(j * CELLSIZE + (WIDTH / 2 - playfieldSize * CELLSIZE / 2), i * CELLSIZE + (HEIGTH / 2 - playfieldSize * CELLSIZE / 2), CELLSIZE, - CELLSIZE); - add(c); + playfield[i][j] = new Cell(CellType.Number); + + playfield[i][j].setBounds(j * CELLSIZE + (WIDTH / 2 - playfieldSize * CELLSIZE / 2), + i * CELLSIZE + (HEIGTH / 2 - playfieldSize * CELLSIZE / 2), CELLSIZE, CELLSIZE); + add(playfield[i][j]); + + for (int k = 0; k < bPlacment.length; k++) { + if (bPlacment[k] == i * playfieldSize + j) { + playfield[i][j].type = CellType.Bomb; + break; + } + } } } } public static void main(String[] args) { JFrame f = new JFrame(); - MinesweeperGame ttt = new MinesweeperGame(8); + MinesweeperGame ttt = new MinesweeperGame(8, 10); f.add(ttt); f.setSize(WIDTH, HEIGTH); diff --git a/src/test/java/Minesweeper/MinesweeperGameTest.java b/src/test/java/Minesweeper/MinesweeperGameTest.java new file mode 100644 index 0000000..fe10af4 --- /dev/null +++ b/src/test/java/Minesweeper/MinesweeperGameTest.java @@ -0,0 +1,41 @@ +package Minesweeper; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +class MinesweeperGameTest { + + @ParameterizedTest + @MethodSource("testBombs") + void testBombPlacement(int _playfieldSize, int _bombAmount) { + MinesweeperGame m = new MinesweeperGame(_playfieldSize, _bombAmount); + + int bombCounter = 0; + + for(Cell[] row : m.playfield){ + for (Cell c : row) { + if(c.type == CellType.Bomb) { + bombCounter++; + } + } + } + assertEquals(_bombAmount, bombCounter); + } + + + private static Stream testBombs(){ + return Stream.of( + Arguments.of(8, 10), + Arguments.of(8, 0), + Arguments.of(4, 12), + Arguments.of(10, 100), + Arguments.of(5, 1) + ); + } + +} From aa04d679bd0d4f92df6725c2883db57372601dd8 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 11:36:45 +0100 Subject: [PATCH 077/108] Moved playfield logic to new class --- .../java/Minesweeper/MinesweeperGame.java | 46 ++----------------- src/main/java/Minesweeper/Playfield.java | 46 +++++++++++++++++++ .../java/Minesweeper/MinesweeperGameTest.java | 2 +- 3 files changed, 50 insertions(+), 44 deletions(-) create mode 100644 src/main/java/Minesweeper/Playfield.java diff --git a/src/main/java/Minesweeper/MinesweeperGame.java b/src/main/java/Minesweeper/MinesweeperGame.java index ffb4a10..df5d33c 100644 --- a/src/main/java/Minesweeper/MinesweeperGame.java +++ b/src/main/java/Minesweeper/MinesweeperGame.java @@ -7,54 +7,14 @@ import javax.swing.JPanel; public class MinesweeperGame extends JPanel { private static final long serialVersionUID = 1L; - private static final int WIDTH = 600, HEIGTH = 600; - private static final int CELLSIZE = 40; - private int playfieldSize; - private int bombAmount; + public static final int WIDTH = 600, HEIGTH = 600; - public Cell[][] playfield; + public Playfield playfield; public MinesweeperGame(int _playfieldSize, int _bombAmount) { this.setSize(WIDTH, HEIGTH); - playfieldSize = _playfieldSize; - bombAmount = _bombAmount; setLayout(null); - - initPlayfield(); - } - - private void initPlayfield() { - - playfield = new Cell[playfieldSize][playfieldSize]; - - int[] bPlacment = new int[bombAmount]; - for (int i = 0; i < bPlacment.length; i++) { - bPlacment[i] = (int) (Math.random() * playfieldSize * playfieldSize); - - for (int j = 0; j < i; j++) { - if (bPlacment[i] == bPlacment[j]) { - i--; - break; - } - } - } - - for (int i = 0; i < playfieldSize; i++) { - for (int j = 0; j < playfieldSize; j++) { - playfield[i][j] = new Cell(CellType.Number); - - playfield[i][j].setBounds(j * CELLSIZE + (WIDTH / 2 - playfieldSize * CELLSIZE / 2), - i * CELLSIZE + (HEIGTH / 2 - playfieldSize * CELLSIZE / 2), CELLSIZE, CELLSIZE); - add(playfield[i][j]); - - for (int k = 0; k < bPlacment.length; k++) { - if (bPlacment[k] == i * playfieldSize + j) { - playfield[i][j].type = CellType.Bomb; - break; - } - } - } - } + playfield = new Playfield(this, _playfieldSize, _bombAmount ); } public static void main(String[] args) { diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java new file mode 100644 index 0000000..013a0bb --- /dev/null +++ b/src/main/java/Minesweeper/Playfield.java @@ -0,0 +1,46 @@ +package Minesweeper; + +public class Playfield { + + private static final int CELLSIZE = 40; + private int playfieldSize; + private MinesweeperGame MsG; + public Cell[][] playfield; + + public Playfield(MinesweeperGame _MsG, int _playfieldSize, int _bombAmount) { + MsG = _MsG; + playfieldSize = _playfieldSize; + + playfield = new Cell[playfieldSize][playfieldSize]; + + int[] bPlacement = new int[_bombAmount]; + for (int i = 0; i < bPlacement.length; i++) { + bPlacement[i] = (int) (Math.random() * playfieldSize * playfieldSize); + + for (int j = 0; j < i; j++) { + if (bPlacement[i] == bPlacement[j]) { + i--; + break; + } + } + } + + for (int i = 0; i < playfieldSize; i++) { + for (int j = 0; j < playfieldSize; j++) { + playfield[i][j] = new Cell(CellType.Number); + + playfield[i][j].setBounds(j * CELLSIZE + (MsG.WIDTH / 2 - playfieldSize * CELLSIZE / 2), + i * CELLSIZE + (MsG.HEIGTH / 2 - playfieldSize * CELLSIZE / 2), CELLSIZE, CELLSIZE); + MsG.add(playfield[i][j]); + + for (int k = 0; k < bPlacement.length; k++) { + if (bPlacement[k] == i * playfieldSize + j) { + playfield[i][j].type = CellType.Bomb; + break; + } + } + } + } + } + +} diff --git a/src/test/java/Minesweeper/MinesweeperGameTest.java b/src/test/java/Minesweeper/MinesweeperGameTest.java index fe10af4..2564d00 100644 --- a/src/test/java/Minesweeper/MinesweeperGameTest.java +++ b/src/test/java/Minesweeper/MinesweeperGameTest.java @@ -17,7 +17,7 @@ class MinesweeperGameTest { int bombCounter = 0; - for(Cell[] row : m.playfield){ + for(Cell[] row : m.playfield.playfield){ for (Cell c : row) { if(c.type == CellType.Bomb) { bombCounter++; From 380e848e38450c1af397f44392242ba7db982dd8 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 11:40:31 +0100 Subject: [PATCH 078/108] Refactore Playfield --- src/main/java/Minesweeper/Playfield.java | 28 +++++++++---------- .../java/Minesweeper/MinesweeperGameTest.java | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index 013a0bb..aa843a6 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -3,19 +3,19 @@ package Minesweeper; public class Playfield { private static final int CELLSIZE = 40; - private int playfieldSize; + private int Size; private MinesweeperGame MsG; - public Cell[][] playfield; + public Cell[][] cells; - public Playfield(MinesweeperGame _MsG, int _playfieldSize, int _bombAmount) { + public Playfield(MinesweeperGame _MsG, int _Size, int _bombAmount) { MsG = _MsG; - playfieldSize = _playfieldSize; + Size = _Size; - playfield = new Cell[playfieldSize][playfieldSize]; + cells = new Cell[Size][Size]; int[] bPlacement = new int[_bombAmount]; for (int i = 0; i < bPlacement.length; i++) { - bPlacement[i] = (int) (Math.random() * playfieldSize * playfieldSize); + bPlacement[i] = (int) (Math.random() * Size * Size); for (int j = 0; j < i; j++) { if (bPlacement[i] == bPlacement[j]) { @@ -25,17 +25,17 @@ public class Playfield { } } - for (int i = 0; i < playfieldSize; i++) { - for (int j = 0; j < playfieldSize; j++) { - playfield[i][j] = new Cell(CellType.Number); + for (int i = 0; i < Size; i++) { + for (int j = 0; j < Size; j++) { + cells[i][j] = new Cell(CellType.Number); - playfield[i][j].setBounds(j * CELLSIZE + (MsG.WIDTH / 2 - playfieldSize * CELLSIZE / 2), - i * CELLSIZE + (MsG.HEIGTH / 2 - playfieldSize * CELLSIZE / 2), CELLSIZE, CELLSIZE); - MsG.add(playfield[i][j]); + cells[i][j].setBounds(j * CELLSIZE + (MsG.WIDTH / 2 - Size * CELLSIZE / 2), + i * CELLSIZE + (MsG.HEIGTH / 2 - Size * CELLSIZE / 2), CELLSIZE, CELLSIZE); + MsG.add(cells[i][j]); for (int k = 0; k < bPlacement.length; k++) { - if (bPlacement[k] == i * playfieldSize + j) { - playfield[i][j].type = CellType.Bomb; + if (bPlacement[k] == i * Size + j) { + cells[i][j].type = CellType.Bomb; break; } } diff --git a/src/test/java/Minesweeper/MinesweeperGameTest.java b/src/test/java/Minesweeper/MinesweeperGameTest.java index 2564d00..2dce81d 100644 --- a/src/test/java/Minesweeper/MinesweeperGameTest.java +++ b/src/test/java/Minesweeper/MinesweeperGameTest.java @@ -17,7 +17,7 @@ class MinesweeperGameTest { int bombCounter = 0; - for(Cell[] row : m.playfield.playfield){ + for(Cell[] row : m.playfield.cells){ for (Cell c : row) { if(c.type == CellType.Bomb) { bombCounter++; From 0e2ea58e5721989641caa2f74419a3a8390c86c2 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 12:56:43 +0100 Subject: [PATCH 079/108] Add bomb proximity with test --- src/main/java/Minesweeper/Cell.java | 2 +- .../java/Minesweeper/MinesweeperGame.java | 3 +- src/main/java/Minesweeper/Playfield.java | 62 ++++++++++++++++++- .../java/Minesweeper/MinesweeperGameTest.java | 12 ++++ 4 files changed, 74 insertions(+), 5 deletions(-) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index 12a1935..36946f8 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -8,7 +8,7 @@ public class Cell extends JButton { private static final long serialVersionUID = 1L; public CellType type; public boolean flagged = false; - public int value = -1; + public int value = 0; public Cell(CellType _type) { type = _type; diff --git a/src/main/java/Minesweeper/MinesweeperGame.java b/src/main/java/Minesweeper/MinesweeperGame.java index df5d33c..fde06cd 100644 --- a/src/main/java/Minesweeper/MinesweeperGame.java +++ b/src/main/java/Minesweeper/MinesweeperGame.java @@ -8,7 +8,6 @@ public class MinesweeperGame extends JPanel { private static final long serialVersionUID = 1L; public static final int WIDTH = 600, HEIGTH = 600; - public Playfield playfield; public MinesweeperGame(int _playfieldSize, int _bombAmount) { @@ -19,7 +18,7 @@ public class MinesweeperGame extends JPanel { public static void main(String[] args) { JFrame f = new JFrame(); - MinesweeperGame ttt = new MinesweeperGame(8, 10); + MinesweeperGame ttt = new MinesweeperGame(3, 0); f.add(ttt); f.setSize(WIDTH, HEIGTH); diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index aa843a6..a56dbc6 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -2,7 +2,7 @@ package Minesweeper; public class Playfield { - private static final int CELLSIZE = 40; + private static final int CELLSIZE = 50; private int Size; private MinesweeperGame MsG; public Cell[][] cells; @@ -10,7 +10,7 @@ public class Playfield { public Playfield(MinesweeperGame _MsG, int _Size, int _bombAmount) { MsG = _MsG; Size = _Size; - + cells = new Cell[Size][Size]; int[] bPlacement = new int[_bombAmount]; @@ -41,6 +41,64 @@ public class Playfield { } } } + + for (int i = 0; i < Size; i++) { + for (int j = 0; j < Size; j++) { + if (cells[i][j].type == CellType.Number) { + calculateBombProximity(i, j); + } + } + } + } + + public void calculateBombProximity(int row, int column) { + + if (row > 0) { + if (column > 0) { + if (cells[row - 1][column - 1].type == CellType.Bomb) { + cells[row][column].value++; + } + } + + if (cells[row - 1][column].type == CellType.Bomb) { + cells[row][column].value++; + } + + if (column < cells.length - 1) { + if (cells[row - 1][column + 1].type == CellType.Bomb) { + cells[row][column].value++; + } + } + } + + if (row < cells.length - 1) { + if (column > 0) { + if (cells[row + 1][column - 1].type == CellType.Bomb) { + cells[row][column].value++; + } + } + + if (cells[row + 1][column].type == CellType.Bomb) { + cells[row][column].value++; + } + + if (column < cells.length - 1) { + if (cells[row + 1][column + 1].type == CellType.Bomb) { + cells[row][column].value++; + } + } + } + + if (column > 0) { + if (cells[row][column - 1].type == CellType.Bomb) { + cells[row][column].value++; + } + } + if (column < cells.length - 1) { + if (cells[row][column + 1].type == CellType.Bomb) { + cells[row][column].value++; + } + } } } diff --git a/src/test/java/Minesweeper/MinesweeperGameTest.java b/src/test/java/Minesweeper/MinesweeperGameTest.java index 2dce81d..4b61967 100644 --- a/src/test/java/Minesweeper/MinesweeperGameTest.java +++ b/src/test/java/Minesweeper/MinesweeperGameTest.java @@ -4,6 +4,7 @@ import static org.junit.jupiter.api.Assertions.*; import java.util.stream.Stream; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -27,6 +28,15 @@ class MinesweeperGameTest { assertEquals(_bombAmount, bombCounter); } + @Test + void testProximityPoints() { + MinesweeperGame m = new MinesweeperGame(3, 0); + m.playfield.cells[0][0].type = CellType.Bomb; + m.playfield.calculateBombProximity(1, 1); + + assertEquals(1, m.playfield.cells[1][1].value); + } + private static Stream testBombs(){ return Stream.of( @@ -38,4 +48,6 @@ class MinesweeperGameTest { ); } + + } From cc10c4fdde4576d56b5ae1957c7619fe8813fb36 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 13:47:23 +0100 Subject: [PATCH 080/108] Show proximity values on cells --- src/main/java/Minesweeper/Cell.java | 8 ++++++++ src/main/java/Minesweeper/MinesweeperGame.java | 2 +- src/main/java/Minesweeper/Playfield.java | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index 36946f8..a455e88 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -13,4 +13,12 @@ public class Cell extends JButton { public Cell(CellType _type) { type = _type; } + + public void update() { + if(type == CellType.Number) { + setText(String.valueOf(value)); + } else { + + } + } } diff --git a/src/main/java/Minesweeper/MinesweeperGame.java b/src/main/java/Minesweeper/MinesweeperGame.java index fde06cd..231c674 100644 --- a/src/main/java/Minesweeper/MinesweeperGame.java +++ b/src/main/java/Minesweeper/MinesweeperGame.java @@ -18,7 +18,7 @@ public class MinesweeperGame extends JPanel { public static void main(String[] args) { JFrame f = new JFrame(); - MinesweeperGame ttt = new MinesweeperGame(3, 0); + MinesweeperGame ttt = new MinesweeperGame(8, 10); f.add(ttt); f.setSize(WIDTH, HEIGTH); diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index a56dbc6..9f52d84 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -99,6 +99,8 @@ public class Playfield { cells[row][column].value++; } } + + cells[row][column].update(); } } From 4d97b75dbae0cc782d06b6061d65c46d4db80ce8 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 14:40:07 +0100 Subject: [PATCH 081/108] Add floodfill on click --- src/main/java/Minesweeper/Cell.java | 81 +++++++++++++++++++++--- src/main/java/Minesweeper/Playfield.java | 8 ++- 2 files changed, 78 insertions(+), 11 deletions(-) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index a455e88..c2a3f33 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -1,24 +1,89 @@ package Minesweeper; +import java.awt.Color; +import java.awt.Point; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + import javax.swing.JButton; -enum CellType{Number, Bomb} +enum CellType { + Number, Bomb +} + public class Cell extends JButton { - + private static final long serialVersionUID = 1L; + private Playfield playfield; + public CellType type; + public Point cord; public boolean flagged = false; public int value = 0; - - public Cell(CellType _type) { + + public Cell(CellType _type, Playfield _playfield, Point _cord) { type = _type; + cord = _cord; + playfield = _playfield; + + addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + OnMouseClick(); + } + }); } - + + protected void OnMouseClick() { + if (type != CellType.Bomb) { + flood(); + } + } + public void update() { - if(type == CellType.Number) { + if (type == CellType.Number) { setText(String.valueOf(value)); - } else { - } } + + public void flood() { + if (type == CellType.Bomb) { + return; + } + setBackground(Color.LIGHT_GRAY); + setEnabled(false); + + if (value == 0) { + if (cord.y > 0) { + if (playfield.cells[cord.y - 1][cord.x].type == CellType.Number + && playfield.cells[cord.y - 1][cord.x].isEnabled()) { + playfield.cells[cord.y - 1][cord.x].flood(); + } + } + + if (cord.x < playfield.Size - 1) { + if (playfield.cells[cord.y][cord.x + 1].type == CellType.Number + && playfield.cells[cord.y][cord.x + 1].isEnabled()) { + playfield.cells[cord.y][cord.x + 1].flood(); + } + } + + if (cord.y < playfield.Size - 1) { + if (playfield.cells[cord.y + 1][cord.x].type == CellType.Number + && playfield.cells[cord.y + 1][cord.x].isEnabled()) { + playfield.cells[cord.y + 1][cord.x].flood(); + } + } + + if (cord.x > 0) { + if (playfield.cells[cord.y][cord.x - 1].type == CellType.Number + && playfield.cells[cord.y][cord.x - 1].isEnabled()) { + playfield.cells[cord.y][cord.x - 1].flood(); + } + } + + } + + } + } diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index 9f52d84..1cefcbf 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -1,9 +1,11 @@ package Minesweeper; +import java.awt.Point; + public class Playfield { private static final int CELLSIZE = 50; - private int Size; + public int Size; private MinesweeperGame MsG; public Cell[][] cells; @@ -27,7 +29,7 @@ public class Playfield { for (int i = 0; i < Size; i++) { for (int j = 0; j < Size; j++) { - cells[i][j] = new Cell(CellType.Number); + cells[i][j] = new Cell(CellType.Number, this, new Point(j, i)); cells[i][j].setBounds(j * CELLSIZE + (MsG.WIDTH / 2 - Size * CELLSIZE / 2), i * CELLSIZE + (MsG.HEIGTH / 2 - Size * CELLSIZE / 2), CELLSIZE, CELLSIZE); @@ -99,7 +101,7 @@ public class Playfield { cells[row][column].value++; } } - + cells[row][column].update(); } From b51cfb67323aa4f1441ec2f4b4a255a72a340753 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 14:48:48 +0100 Subject: [PATCH 082/108] Change update for celltype bomb --- src/main/java/Minesweeper/Cell.java | 2 ++ src/main/java/Minesweeper/Playfield.java | 1 + 2 files changed, 3 insertions(+) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index c2a3f33..7b5e0de 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -43,6 +43,8 @@ public class Cell extends JButton { public void update() { if (type == CellType.Number) { setText(String.valueOf(value)); + } else { + setBackground(Color.RED); } } diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index 1cefcbf..14f0a81 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -38,6 +38,7 @@ public class Playfield { for (int k = 0; k < bPlacement.length; k++) { if (bPlacement[k] == i * Size + j) { cells[i][j].type = CellType.Bomb; + cells[i][j].update(); break; } } From 30903220e9ecc89c297f1add1b0fe707e0af7f9c Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 14:53:51 +0100 Subject: [PATCH 083/108] Refactore Playfield --- src/main/java/Minesweeper/MinesweeperGame.java | 3 ++- src/main/java/Minesweeper/Playfield.java | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/Minesweeper/MinesweeperGame.java b/src/main/java/Minesweeper/MinesweeperGame.java index 231c674..c3b9af4 100644 --- a/src/main/java/Minesweeper/MinesweeperGame.java +++ b/src/main/java/Minesweeper/MinesweeperGame.java @@ -24,7 +24,8 @@ public class MinesweeperGame extends JPanel { f.setSize(WIDTH, HEIGTH); f.setLayout(null); f.setVisible(true); - } + + } diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index 14f0a81..3fc9006 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -12,6 +12,10 @@ public class Playfield { public Playfield(MinesweeperGame _MsG, int _Size, int _bombAmount) { MsG = _MsG; Size = _Size; + generatePlayfield(_bombAmount); + } + + public void generatePlayfield(int _bombAmount) { cells = new Cell[Size][Size]; @@ -53,7 +57,7 @@ public class Playfield { } } } - + public void calculateBombProximity(int row, int column) { if (row > 0) { From d718f86c52e7de7c05d24980d9c10bfeb16c7229 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 14:58:58 +0100 Subject: [PATCH 084/108] Made playfield resetable --- src/main/java/Minesweeper/Playfield.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index 3fc9006..eed046b 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -8,18 +8,20 @@ public class Playfield { public int Size; private MinesweeperGame MsG; public Cell[][] cells; + private int bombAmount; public Playfield(MinesweeperGame _MsG, int _Size, int _bombAmount) { MsG = _MsG; Size = _Size; - generatePlayfield(_bombAmount); + bombAmount = _bombAmount; + generatePlayfield(); } - public void generatePlayfield(int _bombAmount) { + public void generatePlayfield() { cells = new Cell[Size][Size]; - int[] bPlacement = new int[_bombAmount]; + int[] bPlacement = new int[bombAmount]; for (int i = 0; i < bPlacement.length; i++) { bPlacement[i] = (int) (Math.random() * Size * Size); @@ -57,7 +59,16 @@ public class Playfield { } } } - + + public void reset() { + for (int i = 0; i < Size; i++) { + for (int j = 0; j < Size; j++) { + MsG.remove(cells[i][j]); + } + } + generatePlayfield(); + } + public void calculateBombProximity(int row, int column) { if (row > 0) { From 4cbfc45a3de3a47c7f78663b11aa993c009e353c Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 15:02:28 +0100 Subject: [PATCH 085/108] Game End: Clicked on Mine --- src/main/java/Minesweeper/Cell.java | 2 ++ src/main/java/Minesweeper/Playfield.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index 7b5e0de..93f8799 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -37,6 +37,8 @@ public class Cell extends JButton { protected void OnMouseClick() { if (type != CellType.Bomb) { flood(); + } else { + playfield.reset(); } } diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index eed046b..38f61cc 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -2,6 +2,8 @@ package Minesweeper; import java.awt.Point; +import javax.swing.JOptionPane; + public class Playfield { private static final int CELLSIZE = 50; @@ -61,6 +63,7 @@ public class Playfield { } public void reset() { + JOptionPane.showMessageDialog(MsG,"KABOOM! Try again!"); for (int i = 0; i < Size; i++) { for (int j = 0; j < Size; j++) { MsG.remove(cells[i][j]); From b635c64d4f88c7e25074ab31e0272da5e341ccc8 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 15:12:36 +0100 Subject: [PATCH 086/108] Game End: Victory --- src/main/java/Minesweeper/Cell.java | 2 +- src/main/java/Minesweeper/Playfield.java | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index 93f8799..fc7d393 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -56,7 +56,7 @@ public class Cell extends JButton { } setBackground(Color.LIGHT_GRAY); setEnabled(false); - + playfield.cellFlooded(); if (value == 0) { if (cord.y > 0) { if (playfield.cells[cord.y - 1][cord.x].type == CellType.Number diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index 38f61cc..c67c570 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -11,7 +11,9 @@ public class Playfield { private MinesweeperGame MsG; public Cell[][] cells; private int bombAmount; - + private int cellsFlooded = 0; + + public Playfield(MinesweeperGame _MsG, int _Size, int _bombAmount) { MsG = _MsG; Size = _Size; @@ -123,5 +125,12 @@ public class Playfield { cells[row][column].update(); } - + + public void cellFlooded() { + cellsFlooded++; + if(cellsFlooded >= Size * Size - bombAmount) { + JOptionPane.showMessageDialog(MsG, "You won, congratulations!"); + System.exit(0); + } + } } From d0594cba7ed93ca3c1805643c5e53b752cfbf5bd Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 15:55:18 +0100 Subject: [PATCH 087/108] Flagging on right click --- src/main/java/Minesweeper/Cell.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index fc7d393..80e9aac 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -4,6 +4,8 @@ import java.awt.Color; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import javax.swing.JButton; @@ -32,6 +34,17 @@ public class Cell extends JButton { OnMouseClick(); } }); + + addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + super.mousePressed(e); + if (e.getButton() == 3) { + OnMouseRightClick(); + } + } + }); } protected void OnMouseClick() { @@ -42,6 +55,14 @@ public class Cell extends JButton { } } + protected void OnMouseRightClick() { + if (flagged) { + flagged = false; + } else { + flagged = true; + } + } + public void update() { if (type == CellType.Number) { setText(String.valueOf(value)); From 3c6f092049c6cb45420b50c9b660e5731234c1e4 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 16:03:42 +0100 Subject: [PATCH 088/108] Add flagging logic to cell --- src/main/java/Minesweeper/Cell.java | 33 +++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index 80e9aac..9f6cc0c 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -27,7 +27,8 @@ public class Cell extends JButton { type = _type; cord = _cord; playfield = _playfield; - + + setBackground(Color.white); addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -48,18 +49,30 @@ public class Cell extends JButton { } protected void OnMouseClick() { - if (type != CellType.Bomb) { - flood(); - } else { - playfield.reset(); + if (!flagged) { + if (type != CellType.Bomb) { + flood(); + } else { + playfield.reset(); + } } } protected void OnMouseRightClick() { - if (flagged) { - flagged = false; - } else { - flagged = true; + if (isEnabled()) { + if (flagged) { + flagged = false; + + if (type == CellType.Number) { + setBackground(Color.gray); + } else { + setBackground(Color.red); + } + + } else { + flagged = true; + setBackground(Color.cyan); + } } } @@ -75,9 +88,11 @@ public class Cell extends JButton { if (type == CellType.Bomb) { return; } + setBackground(Color.LIGHT_GRAY); setEnabled(false); playfield.cellFlooded(); + if (value == 0) { if (cord.y > 0) { if (playfield.cells[cord.y - 1][cord.x].type == CellType.Number From d6178355ded68961cde36c2aa2244483d1b61fa1 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 16:06:34 +0100 Subject: [PATCH 089/108] Bugfix early victory --- src/main/java/Minesweeper/Playfield.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index c67c570..2a1806e 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -65,7 +65,8 @@ public class Playfield { } public void reset() { - JOptionPane.showMessageDialog(MsG,"KABOOM! Try again!"); + JOptionPane.showMessageDialog(MsG,"KABOOM! Try again!"); + cellsFlooded = 0; for (int i = 0; i < Size; i++) { for (int j = 0; j < Size; j++) { MsG.remove(cells[i][j]); From 7de023fa3e0e4bcca4258ca62b056841e34de105 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 16:30:00 +0100 Subject: [PATCH 090/108] Flagged cells will not be flooded --- src/main/java/Minesweeper/Cell.java | 2 +- src/main/java/Minesweeper/MinesweeperGame.java | 5 +---- src/main/java/Minesweeper/Playfield.java | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index 9f6cc0c..d67ba5b 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -85,7 +85,7 @@ public class Cell extends JButton { } public void flood() { - if (type == CellType.Bomb) { + if (type == CellType.Bomb || flagged) { return; } diff --git a/src/main/java/Minesweeper/MinesweeperGame.java b/src/main/java/Minesweeper/MinesweeperGame.java index c3b9af4..9570e80 100644 --- a/src/main/java/Minesweeper/MinesweeperGame.java +++ b/src/main/java/Minesweeper/MinesweeperGame.java @@ -25,7 +25,4 @@ public class MinesweeperGame extends JPanel { f.setLayout(null); f.setVisible(true); } - - - -} +} \ No newline at end of file diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index 2a1806e..754dd52 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -134,4 +134,4 @@ public class Playfield { System.exit(0); } } -} +} \ No newline at end of file From 5d1aba44082f7911b0dd17ab58ac4669e9721551 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 16:38:16 +0100 Subject: [PATCH 091/108] Flagged number cells count as flooded --- src/main/java/Minesweeper/Cell.java | 8 ++++++-- src/main/java/Minesweeper/Playfield.java | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index d67ba5b..8b05e78 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -62,16 +62,20 @@ public class Cell extends JButton { if (isEnabled()) { if (flagged) { flagged = false; - + if (type == CellType.Number) { setBackground(Color.gray); + playfield.cellDried(); } else { setBackground(Color.red); } - + } else { flagged = true; setBackground(Color.cyan); + if (type == CellType.Number) { + playfield.cellFlooded(); + } } } } diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index 754dd52..86d14fb 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -134,4 +134,8 @@ public class Playfield { System.exit(0); } } + + public void cellDried() { + cellsFlooded--; + } } \ No newline at end of file From c6c2328e4ac5f8a1082b6d3f735be23d6e309772 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 18:32:48 +0100 Subject: [PATCH 092/108] Changed victory end to reset --- src/main/java/Minesweeper/Cell.java | 2 ++ src/main/java/Minesweeper/Playfield.java | 12 +++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index 8b05e78..8311365 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -8,6 +8,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JButton; +import javax.swing.JOptionPane; enum CellType { Number, Bomb @@ -53,6 +54,7 @@ public class Cell extends JButton { if (type != CellType.Bomb) { flood(); } else { + JOptionPane.showMessageDialog(getParent(),"KABOOM! Try again!"); playfield.reset(); } } diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index 86d14fb..f757df8 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -12,8 +12,7 @@ public class Playfield { public Cell[][] cells; private int bombAmount; private int cellsFlooded = 0; - - + public Playfield(MinesweeperGame _MsG, int _Size, int _bombAmount) { MsG = _MsG; Size = _Size; @@ -65,7 +64,6 @@ public class Playfield { } public void reset() { - JOptionPane.showMessageDialog(MsG,"KABOOM! Try again!"); cellsFlooded = 0; for (int i = 0; i < Size; i++) { for (int j = 0; j < Size; j++) { @@ -126,15 +124,15 @@ public class Playfield { cells[row][column].update(); } - + public void cellFlooded() { cellsFlooded++; - if(cellsFlooded >= Size * Size - bombAmount) { + if (cellsFlooded >= Size * Size - bombAmount) { JOptionPane.showMessageDialog(MsG, "You won, congratulations!"); - System.exit(0); + reset(); } } - + public void cellDried() { cellsFlooded--; } From 430ff0922847aeba9019d8da62d9315a70a6cad3 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 18:49:51 +0100 Subject: [PATCH 093/108] Add reveal cell function --- src/main/java/Minesweeper/Cell.java | 4 +++- src/main/java/Minesweeper/Playfield.java | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index 8311365..31c0e7b 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -51,12 +51,14 @@ public class Cell extends JButton { protected void OnMouseClick() { if (!flagged) { + reveal(); if (type != CellType.Bomb) { flood(); } else { JOptionPane.showMessageDialog(getParent(),"KABOOM! Try again!"); playfield.reset(); } + } } @@ -82,7 +84,7 @@ public class Cell extends JButton { } } - public void update() { + public void reveal() { if (type == CellType.Number) { setText(String.valueOf(value)); } else { diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index f757df8..f2036df 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -1,5 +1,6 @@ package Minesweeper; +import java.awt.Color; import java.awt.Point; import javax.swing.JOptionPane; @@ -43,11 +44,9 @@ public class Playfield { cells[i][j].setBounds(j * CELLSIZE + (MsG.WIDTH / 2 - Size * CELLSIZE / 2), i * CELLSIZE + (MsG.HEIGTH / 2 - Size * CELLSIZE / 2), CELLSIZE, CELLSIZE); MsG.add(cells[i][j]); - for (int k = 0; k < bPlacement.length; k++) { if (bPlacement[k] == i * Size + j) { cells[i][j].type = CellType.Bomb; - cells[i][j].update(); break; } } @@ -61,6 +60,7 @@ public class Playfield { } } } + MsG.repaint(); } public void reset() { @@ -122,7 +122,6 @@ public class Playfield { } } - cells[row][column].update(); } public void cellFlooded() { From 7c6706bc2021cf331232402e90e61a829cad8477 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 18:59:03 +0100 Subject: [PATCH 094/108] Changed Colors --- src/main/java/Minesweeper/Cell.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index 31c0e7b..2252b7d 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -16,6 +16,10 @@ enum CellType { public class Cell extends JButton { + private static final Color FLAGCOLOR = Color.RED; + private static final Color FLOODEDCOLOR = Color.LIGHT_GRAY; + private static final Color HIDDENCOLOR = Color.GRAY; + private static final Color MINECOLOR = Color.BLACK; private static final long serialVersionUID = 1L; private Playfield playfield; @@ -68,15 +72,15 @@ public class Cell extends JButton { flagged = false; if (type == CellType.Number) { - setBackground(Color.gray); + setBackground(HIDDENCOLOR); playfield.cellDried(); } else { - setBackground(Color.red); + setBackground(MINECOLOR); } } else { flagged = true; - setBackground(Color.cyan); + setBackground(FLAGCOLOR); if (type == CellType.Number) { playfield.cellFlooded(); } @@ -88,7 +92,7 @@ public class Cell extends JButton { if (type == CellType.Number) { setText(String.valueOf(value)); } else { - setBackground(Color.RED); + setBackground(MINECOLOR); } } @@ -97,7 +101,7 @@ public class Cell extends JButton { return; } - setBackground(Color.LIGHT_GRAY); + setBackground(FLOODEDCOLOR); setEnabled(false); playfield.cellFlooded(); From 02c2b01d95728a768c63d6a87f08795f76009ddf Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 19:01:56 +0100 Subject: [PATCH 095/108] Reveal all bombs on game end --- src/main/java/Minesweeper/Cell.java | 1 + src/main/java/Minesweeper/Playfield.java | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index 2252b7d..4991e9e 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -59,6 +59,7 @@ public class Cell extends JButton { if (type != CellType.Bomb) { flood(); } else { + playfield.revealAllBombs(); JOptionPane.showMessageDialog(getParent(),"KABOOM! Try again!"); playfield.reset(); } diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index f2036df..372b715 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -127,11 +127,23 @@ public class Playfield { public void cellFlooded() { cellsFlooded++; if (cellsFlooded >= Size * Size - bombAmount) { + revealAllBombs(); JOptionPane.showMessageDialog(MsG, "You won, congratulations!"); reset(); } } + public void revealAllBombs() { + for (int i = 0; i < Size; i++) { + for (int j = 0; j < Size; j++) { + if(cells[i][j].type == CellType.Bomb) { + cells[i][j].reveal(); + } + } + } + MsG.repaint(); + } + public void cellDried() { cellsFlooded--; } From 968c93804d6a04b6ccafdecac4122c21c468bc11 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 19:05:16 +0100 Subject: [PATCH 096/108] Refactore Minesweeper, Playfield --- src/main/java/Minesweeper/MinesweeperGame.java | 5 ++--- src/main/java/Minesweeper/Playfield.java | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/Minesweeper/MinesweeperGame.java b/src/main/java/Minesweeper/MinesweeperGame.java index 9570e80..8293a18 100644 --- a/src/main/java/Minesweeper/MinesweeperGame.java +++ b/src/main/java/Minesweeper/MinesweeperGame.java @@ -1,6 +1,5 @@ package Minesweeper; -import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; @@ -18,9 +17,9 @@ public class MinesweeperGame extends JPanel { public static void main(String[] args) { JFrame f = new JFrame(); - MinesweeperGame ttt = new MinesweeperGame(8, 10); + MinesweeperGame MsG = new MinesweeperGame(8, 10); - f.add(ttt); + f.add(MsG); f.setSize(WIDTH, HEIGTH); f.setLayout(null); f.setVisible(true); diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index 372b715..9e73cb8 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -1,6 +1,5 @@ package Minesweeper; -import java.awt.Color; import java.awt.Point; import javax.swing.JOptionPane; From 5c365de0d2eba3af035a38bfa2ca7210cb4b64c5 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 19:17:40 +0100 Subject: [PATCH 097/108] .gitignore fix --- .gitignore | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.gitignore b/.gitignore index 84adb3f..cfcc9bc 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,24 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +.mvn/wrapper/maven-wrapper.jar + +# Eclipse m2e generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# End of https://www.toptal.com/developers/gitignore/api/maven \ No newline at end of file From 9c2de1f2f7ef7c6630a2bf9cfe10fde1dfdeb24b Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 19:44:48 +0100 Subject: [PATCH 098/108] Bugfix numbers not showen --- src/main/java/Minesweeper/Cell.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index 4991e9e..f8535eb 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -91,7 +91,9 @@ public class Cell extends JButton { public void reveal() { if (type == CellType.Number) { - setText(String.valueOf(value)); + if(value > 0) { + setText(String.valueOf(value)); + } } else { setBackground(MINECOLOR); } @@ -104,6 +106,7 @@ public class Cell extends JButton { setBackground(FLOODEDCOLOR); setEnabled(false); + reveal(); playfield.cellFlooded(); if (value == 0) { From 896413211c40fcb697d435dca1435d5e0709e27f Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 19:47:31 +0100 Subject: [PATCH 099/108] Bugfix worng colors on unflag --- src/main/java/Minesweeper/Cell.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index f8535eb..aa1a65f 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -18,7 +18,7 @@ public class Cell extends JButton { private static final Color FLAGCOLOR = Color.RED; private static final Color FLOODEDCOLOR = Color.LIGHT_GRAY; - private static final Color HIDDENCOLOR = Color.GRAY; + private static final Color HIDDENCOLOR = Color.WHITE; private static final Color MINECOLOR = Color.BLACK; private static final long serialVersionUID = 1L; private Playfield playfield; @@ -33,7 +33,7 @@ public class Cell extends JButton { cord = _cord; playfield = _playfield; - setBackground(Color.white); + setBackground(HIDDENCOLOR); addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -72,11 +72,9 @@ public class Cell extends JButton { if (flagged) { flagged = false; + setBackground(HIDDENCOLOR); if (type == CellType.Number) { - setBackground(HIDDENCOLOR); playfield.cellDried(); - } else { - setBackground(MINECOLOR); } } else { From f902c3550b2ab4c37492b10a89dc97a195d98b7a Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 20:02:43 +0100 Subject: [PATCH 100/108] Add TimerLable class with basic logic --- .../java/Minesweeper/MinesweeperGame.java | 2 +- src/main/java/Minesweeper/TimerLable.java | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/main/java/Minesweeper/TimerLable.java diff --git a/src/main/java/Minesweeper/MinesweeperGame.java b/src/main/java/Minesweeper/MinesweeperGame.java index 8293a18..f31d319 100644 --- a/src/main/java/Minesweeper/MinesweeperGame.java +++ b/src/main/java/Minesweeper/MinesweeperGame.java @@ -12,7 +12,7 @@ public class MinesweeperGame extends JPanel { public MinesweeperGame(int _playfieldSize, int _bombAmount) { this.setSize(WIDTH, HEIGTH); setLayout(null); - playfield = new Playfield(this, _playfieldSize, _bombAmount ); + playfield = new Playfield(this, _playfieldSize, _bombAmount); } public static void main(String[] args) { diff --git a/src/main/java/Minesweeper/TimerLable.java b/src/main/java/Minesweeper/TimerLable.java new file mode 100644 index 0000000..a194bbf --- /dev/null +++ b/src/main/java/Minesweeper/TimerLable.java @@ -0,0 +1,38 @@ +package Minesweeper; + +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.JLabel; + +public class TimerLable extends JLabel { + + private static final long serialVersionUID = 1L; + private int counter = 0; + + public void start() { + Timer timer = new Timer(); + TimerTask task = new Helper(this); + + timer.schedule(task, 0, 1000); + } + + public void update() { + setText(String.valueOf(++counter)); + } +} + + +class Helper extends TimerTask +{ + public static int i = 0; + private TimerLable timerLable; + + public Helper(TimerLable _timerLable) { + timerLable = _timerLable; + } + public void run() + { + timerLable.update(); + } +} \ No newline at end of file From 1a8df9a1a9c3b145d5b618d763a50afa49b3f011 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 20:03:24 +0100 Subject: [PATCH 101/108] Display TimerLable --- src/main/java/Minesweeper/MinesweeperGame.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/Minesweeper/MinesweeperGame.java b/src/main/java/Minesweeper/MinesweeperGame.java index f31d319..1741988 100644 --- a/src/main/java/Minesweeper/MinesweeperGame.java +++ b/src/main/java/Minesweeper/MinesweeperGame.java @@ -13,6 +13,10 @@ public class MinesweeperGame extends JPanel { this.setSize(WIDTH, HEIGTH); setLayout(null); playfield = new Playfield(this, _playfieldSize, _bombAmount); + TimerLable tl = new TimerLable(); + tl.setBounds((WIDTH / 2 - 5), HEIGTH / 2 - 240, 20, 20); + add(tl); + tl.start(); } public static void main(String[] args) { From 8128061c09986773d9a3c684ef4e9c77dca2f236 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 20:07:22 +0100 Subject: [PATCH 102/108] Add reset to TimerLable --- src/main/java/Minesweeper/TimerLable.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/Minesweeper/TimerLable.java b/src/main/java/Minesweeper/TimerLable.java index a194bbf..ae08055 100644 --- a/src/main/java/Minesweeper/TimerLable.java +++ b/src/main/java/Minesweeper/TimerLable.java @@ -8,11 +8,12 @@ import javax.swing.JLabel; public class TimerLable extends JLabel { private static final long serialVersionUID = 1L; - private int counter = 0; + protected int counter = 0; + private Helper task; public void start() { Timer timer = new Timer(); - TimerTask task = new Helper(this); + task = new Helper(this); timer.schedule(task, 0, 1000); } @@ -20,12 +21,18 @@ public class TimerLable extends JLabel { public void update() { setText(String.valueOf(++counter)); } + + public void reset() { + task.reset = true; + } + } class Helper extends TimerTask { - public static int i = 0; + public boolean reset; + public static int i = 0; private TimerLable timerLable; public Helper(TimerLable _timerLable) { @@ -33,6 +40,10 @@ class Helper extends TimerTask } public void run() { + if(reset) { + reset = false; + timerLable.counter = 0; + } timerLable.update(); } } \ No newline at end of file From 1a7908fa2a0b1e43882cdbb9f0eeee0530a5328e Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 20:09:28 +0100 Subject: [PATCH 103/108] Reset timer on game end --- src/main/java/Minesweeper/MinesweeperGame.java | 4 +++- src/main/java/Minesweeper/Playfield.java | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/Minesweeper/MinesweeperGame.java b/src/main/java/Minesweeper/MinesweeperGame.java index 1741988..cf07347 100644 --- a/src/main/java/Minesweeper/MinesweeperGame.java +++ b/src/main/java/Minesweeper/MinesweeperGame.java @@ -8,12 +8,14 @@ public class MinesweeperGame extends JPanel { private static final long serialVersionUID = 1L; public static final int WIDTH = 600, HEIGTH = 600; public Playfield playfield; + public TimerLable tl; public MinesweeperGame(int _playfieldSize, int _bombAmount) { this.setSize(WIDTH, HEIGTH); setLayout(null); playfield = new Playfield(this, _playfieldSize, _bombAmount); - TimerLable tl = new TimerLable(); + + tl = new TimerLable(); tl.setBounds((WIDTH / 2 - 5), HEIGTH / 2 - 240, 20, 20); add(tl); tl.start(); diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index 9e73cb8..425f4f2 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -69,6 +69,7 @@ public class Playfield { MsG.remove(cells[i][j]); } } + MsG.tl.reset(); generatePlayfield(); } From d6f1baffe9cc878be102568f9f0f9e038cafc0b1 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 20:18:46 +0100 Subject: [PATCH 104/108] Timer stops while game end dialog is open --- src/main/java/Minesweeper/Playfield.java | 1 + src/main/java/Minesweeper/TimerLable.java | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index 425f4f2..29dde34 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -141,6 +141,7 @@ public class Playfield { } } } + MsG.tl.stop(); MsG.repaint(); } diff --git a/src/main/java/Minesweeper/TimerLable.java b/src/main/java/Minesweeper/TimerLable.java index ae08055..750e417 100644 --- a/src/main/java/Minesweeper/TimerLable.java +++ b/src/main/java/Minesweeper/TimerLable.java @@ -24,14 +24,19 @@ public class TimerLable extends JLabel { public void reset() { task.reset = true; + task.stop = false; } + public void stop() { + task.stop = true; + } } class Helper extends TimerTask { public boolean reset; + public boolean stop; public static int i = 0; private TimerLable timerLable; @@ -40,6 +45,9 @@ class Helper extends TimerTask } public void run() { + if(stop) { + return; + } if(reset) { reset = false; timerLable.counter = 0; From 520c5dc3a0a5320891b6b01374ee9101ca02c4bd Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 20:19:19 +0100 Subject: [PATCH 105/108] Bugfix timer reset --- src/main/java/Minesweeper/TimerLable.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/Minesweeper/TimerLable.java b/src/main/java/Minesweeper/TimerLable.java index 750e417..68a1ea9 100644 --- a/src/main/java/Minesweeper/TimerLable.java +++ b/src/main/java/Minesweeper/TimerLable.java @@ -24,6 +24,9 @@ public class TimerLable extends JLabel { public void reset() { task.reset = true; + counter = 0; + setText(String.valueOf(counter)); + repaint(); task.stop = false; } From 7738993b29e092bd7af2db10075d7407c4869e64 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 20:54:55 +0100 Subject: [PATCH 106/108] fix .gitignore, again --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cfcc9bc..c52aba5 100644 --- a/.gitignore +++ b/.gitignore @@ -43,4 +43,4 @@ buildNumber.properties # JDT-specific (Eclipse Java Development Tools) .classpath -# End of https://www.toptal.com/developers/gitignore/api/maven \ No newline at end of file +# End of https://www.toptal.com/developers/gitignore/api/maven From b1e7a31280623d87f9c6012c5ddf5cad6fdf0fa1 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 21:16:31 +0100 Subject: [PATCH 107/108] fix .gitignore, again...again --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c52aba5..c837958 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ buildNumber.properties .classpath # End of https://www.toptal.com/developers/gitignore/api/maven + From 8bbad65768b6c487421bcc043329efd6eb29c844 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 22:08:44 +0100 Subject: [PATCH 108/108] Add Main Menu --- src/main/java/TicTacToe/TicTacToeGame.java | 2 +- src/main/java/hauptmenue/GameWindow.java | 86 ++++++++++++++++++++-- 2 files changed, 80 insertions(+), 8 deletions(-) diff --git a/src/main/java/TicTacToe/TicTacToeGame.java b/src/main/java/TicTacToe/TicTacToeGame.java index 642f6e5..33a8ee0 100644 --- a/src/main/java/TicTacToe/TicTacToeGame.java +++ b/src/main/java/TicTacToe/TicTacToeGame.java @@ -13,7 +13,7 @@ import javax.swing.JPanel; public class TicTacToeGame extends JPanel { private static final long serialVersionUID = 1L; - private static final int width = 600, height = 600; + public static final int width = 600, height = 600; private static final int maxPlayers = 3; private static final int playFieldSize = 9; diff --git a/src/main/java/hauptmenue/GameWindow.java b/src/main/java/hauptmenue/GameWindow.java index 9230044..6972a9e 100644 --- a/src/main/java/hauptmenue/GameWindow.java +++ b/src/main/java/hauptmenue/GameWindow.java @@ -1,28 +1,100 @@ package hauptmenue; import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.JButton; import javax.swing.JFrame; +import Minesweeper.MinesweeperGame; +import TicTacToe.TicTacToeGame; import solitaer.SolitaerGamePanel; import solitaer.SolitaerMenue; public class GameWindow extends JFrame { private static final long serialVersionUID = 1L; - private final SolitaerGamePanel gamePanel = new SolitaerGamePanel(); - - private SolitaerMenue smenue = new SolitaerMenue(gamePanel); public GameWindow() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - gamePanel.setPreferredSize(new Dimension(1180, 780)); - this.setJMenuBar(smenue.getMenue()); + setSize(new Dimension(200, 125)); + setLayout(null); - add(gamePanel); - pack(); + + + JButton soli = new JButton("Solitaer"); + JButton Tic = new JButton("TicTacToe"); + JButton Mine = new JButton("Minesweeper"); + + soli.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + soli.setVisible(false); + Tic.setVisible(false); + Mine.setVisible(false); + initSoli(); + } + }); + + Tic.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + soli.setVisible(false); + Tic.setVisible(false); + Mine.setVisible(false); + initTicTacToe(); + } + + }); + + Mine.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + soli.setVisible(false); + Tic.setVisible(false); + Mine.setVisible(false); + initMinesweeper(); + } + + + }); + soli.setBounds(0, 0, 200, 30); + Tic.setBounds(0, 30, 200, 30); + Mine.setBounds(0, 60, 200, 30); + add(soli); + add(Tic); + add(Mine); setVisible(true); } + private void initSoli() { + SolitaerGamePanel gamePanel = new SolitaerGamePanel(); + SolitaerMenue smenue = new SolitaerMenue(gamePanel); + gamePanel.setVisible(true); + gamePanel.setSize(new Dimension(1180, 780)); + setSize(new Dimension(1180, 780)); + //gamePanel.setPreferredSize(new Dimension(1180, 780)); + setJMenuBar(smenue.getMenue()); + add(gamePanel); + repaint(); + } + + public void initTicTacToe() { + TicTacToeGame ttt = new TicTacToeGame(); + setSize(ttt.width, ttt.height); + setLayout(null); + add(ttt); + } + + public void initMinesweeper() { + MinesweeperGame MsG = new MinesweeperGame(8,10); + setSize(MsG.WIDTH, MsG.HEIGTH); + setLayout(null); + add(MsG); + } + }