diff --git a/Cribbage/.idea/vcs.xml b/Cribbage/.idea/vcs.xml deleted file mode 100644 index 6c0b8635858dc7ad44b93df54b762707ce49eefc..0000000000000000000000000000000000000000 --- a/Cribbage/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="VcsDirectoryMappings"> - <mapping directory="$PROJECT_DIR$/.." vcs="Git" /> - </component> -</project> \ No newline at end of file diff --git a/Cribbage/out/production/Cribbage/observer/Activity.class b/Cribbage/out/production/Cribbage/observer/Activity.class deleted file mode 100644 index 92854f2cf543f1c0ab12a2961adeeaf0c5663830..0000000000000000000000000000000000000000 Binary files a/Cribbage/out/production/Cribbage/observer/Activity.class and /dev/null differ diff --git a/Cribbage/out/production/Cribbage/observer/CribbageHandCards.class b/Cribbage/out/production/Cribbage/observer/CribbageHandCards.class deleted file mode 100644 index bc8c2aa9c134967199547313e9c91007dace4f50..0000000000000000000000000000000000000000 Binary files a/Cribbage/out/production/Cribbage/observer/CribbageHandCards.class and /dev/null differ diff --git a/Cribbage/out/production/Cribbage/observer/Fifteens.class b/Cribbage/out/production/Cribbage/observer/Fifteens.class deleted file mode 100644 index 51db39eb40ecfe53207c37eb235cbdf3ae292b0c..0000000000000000000000000000000000000000 Binary files a/Cribbage/out/production/Cribbage/observer/Fifteens.class and /dev/null differ diff --git a/Cribbage/out/production/Cribbage/observer/Flush.class b/Cribbage/out/production/Cribbage/observer/Flush.class deleted file mode 100644 index 6ea2ed63dbdd3ef890751c4a674f2f931d3e053f..0000000000000000000000000000000000000000 Binary files a/Cribbage/out/production/Cribbage/observer/Flush.class and /dev/null differ diff --git a/Cribbage/out/production/Cribbage/observer/HandCards.class b/Cribbage/out/production/Cribbage/observer/HandCards.class deleted file mode 100644 index 2e8a71982d23dbe35b3c8a5535c1f3534486a1dd..0000000000000000000000000000000000000000 Binary files a/Cribbage/out/production/Cribbage/observer/HandCards.class and /dev/null differ diff --git a/Cribbage/out/production/Cribbage/observer/Jack.class b/Cribbage/out/production/Cribbage/observer/Jack.class deleted file mode 100644 index aee9e0d83fc8d0035fe6d1a1ec88a5c5950f0b70..0000000000000000000000000000000000000000 Binary files a/Cribbage/out/production/Cribbage/observer/Jack.class and /dev/null differ diff --git a/Cribbage/out/production/Cribbage/observer/Pairs.class b/Cribbage/out/production/Cribbage/observer/Pairs.class deleted file mode 100644 index f2cc2ee7a40434ffbc765e14d63906ad15aa125b..0000000000000000000000000000000000000000 Binary files a/Cribbage/out/production/Cribbage/observer/Pairs.class and /dev/null differ diff --git a/Cribbage/out/production/Cribbage/observer/Rule.class b/Cribbage/out/production/Cribbage/observer/Rule.class deleted file mode 100644 index 9060168db4c48be16f3c57ce88119cc99ea1f392..0000000000000000000000000000000000000000 Binary files a/Cribbage/out/production/Cribbage/observer/Rule.class and /dev/null differ diff --git a/Cribbage/out/production/Cribbage/observer/Runs.class b/Cribbage/out/production/Cribbage/observer/Runs.class deleted file mode 100644 index 4c85fd984ecb2564a6ab05cdf35f0515c9f8c668..0000000000000000000000000000000000000000 Binary files a/Cribbage/out/production/Cribbage/observer/Runs.class and /dev/null differ diff --git a/Cribbage/src/observer/CribbageHandCards.java b/Cribbage/src/observer/CribbageHandCards.java deleted file mode 100644 index c6eec3980c2640eba4ad479e61e54c93ce39ff12..0000000000000000000000000000000000000000 --- a/Cribbage/src/observer/CribbageHandCards.java +++ /dev/null @@ -1,38 +0,0 @@ -package observer; - -import ch.aplu.jcardgame.Hand; -import java.util.ArrayList; - -public class CribbageHandCards implements HandCards{ - - private ArrayList<Rule> rules; - - public CribbageHandCards(){ - rules = new ArrayList<Rule>(); - } - - @Override - public void addRule(Rule rule){ - rules.add(rule); - } - - @Override - public void removeRule(Rule rule){ - rules.remove(rule); - } - - @Override - public void sendHandCards(Hand hand, Hand starter){ - hand.insert(starter, false); - rules.forEach((rule) -> rule.receiveHandCards(hand, starter)); - } - - @Override - public int scoreHandCards() { - int score = 0; - for(Rule r : rules){ - score += r.getScore(); - } - return score; - } -} diff --git a/Cribbage/src/observer/Fifteens.java b/Cribbage/src/observer/Fifteens.java deleted file mode 100644 index 2a30ba6d42576f4950a1bfe40c7833264c44cb5c..0000000000000000000000000000000000000000 --- a/Cribbage/src/observer/Fifteens.java +++ /dev/null @@ -1,53 +0,0 @@ -package observer; - -import ch.aplu.jcardgame.Card; -import ch.aplu.jcardgame.Hand; - -import java.util.ArrayList; - -public class Fifteens implements Rule{ - - Hand hand = null; - int score = 0; - - - public Fifteens(){} - - @Override - public void receiveHandCards(Hand hand, Hand starter){ - this.hand = hand; - this.hand.insert(starter, false); - calculateScore(); - } - - @Override - public int getScore() { - return score; - } - - private void calculateScore(){ - ArrayList<Integer> cardValues = new ArrayList<>(); //An array list that contains all card values. - //Add values to the array list. - for (Card c: hand.getCardList()){ - cardValues.add(Math.min(c.getValue(), 10)); - } - //Choose N numbers from a list, the sum of them should be 15. - score = search(cardValues); - } - - private int search(ArrayList<Integer> cardValues){ - int len = cardValues.size(), bit = 1 << len, score = 0, goal = 15; - for(int i=1; i<bit; i++){ - int sum = 0; - for (int j=0; j < len; j++){ - if((i & 1 << j) != 0){ - sum += cardValues.get(j); - } - } - if (sum == goal){ - score += 2; - } - } - return score; - } -} diff --git a/Cribbage/src/observer/Flush.java b/Cribbage/src/observer/Flush.java deleted file mode 100644 index 8307c7038fbdca5ad152dbbe3946642b78ddec83..0000000000000000000000000000000000000000 --- a/Cribbage/src/observer/Flush.java +++ /dev/null @@ -1,54 +0,0 @@ -package observer; - -import ch.aplu.jcardgame.Card; -import ch.aplu.jcardgame.Hand; - -import cribbage.Cribbage; - -public class Flush implements Rule{ - - Hand hand; - Card starter; - int score = 0; - - public Flush(){} - - @Override - public void receiveHandCards(Hand hand, Hand starter){ - this.hand = hand; - this.starter = starter.get(0); - flushPoint(); - } - - @Override - public int getScore() { - return score; - } - - - private void flushPoint(){ - int nClubs = hand.getNumberOfCardsWithSuit(Cribbage.Suit.CLUBS); - if (nClubs == 4){ - score += (4 + isSameSuit(Cribbage.Suit.CLUBS, starter)); - } - int nDiamonds = hand.getNumberOfCardsWithSuit(Cribbage.Suit.DIAMONDS); - if (nDiamonds == 4){ - score += (4 + isSameSuit(Cribbage.Suit.DIAMONDS, starter)); - } - int nSpades = hand.getNumberOfCardsWithSuit(Cribbage.Suit.SPADES); - if (nSpades == 4){ - score += (4 + isSameSuit(Cribbage.Suit.SPADES, starter)); - } - int nHearts = hand.getNumberOfCardsWithSuit(Cribbage.Suit.HEARTS); - if (nHearts == 4){ - score += (4 + isSameSuit(Cribbage.Suit.HEARTS, starter)); - } - } - - private int isSameSuit(Cribbage.Suit suit, Card starter){ - if (starter.getSuit() == suit){ - return 1; - } - return 0; - } -} diff --git a/Cribbage/src/observer/HandCards.java b/Cribbage/src/observer/HandCards.java deleted file mode 100644 index 0815b94d06a1fb2f7de532050c6a1950a1718782..0000000000000000000000000000000000000000 --- a/Cribbage/src/observer/HandCards.java +++ /dev/null @@ -1,14 +0,0 @@ -package observer; - -import ch.aplu.jcardgame.Hand; - -public interface HandCards { - - void addRule(Rule rule); - - void removeRule(Rule rule); - - void sendHandCards(Hand hand, Hand starter); - - int scoreHandCards(); -} diff --git a/Cribbage/src/observer/Jack.java b/Cribbage/src/observer/Jack.java deleted file mode 100644 index d8123d323e38861e5483bb83e04e20d2e37d05e3..0000000000000000000000000000000000000000 --- a/Cribbage/src/observer/Jack.java +++ /dev/null @@ -1,32 +0,0 @@ -package observer; - -import ch.aplu.jcardgame.Card; -import ch.aplu.jcardgame.Hand; - -import static cribbage.Cribbage.Rank.JACK; - -public class Jack implements Rule{ - - Hand hand; - Card starter; - int score = 0; - - public Jack(){} - - @Override - public void receiveHandCards(Hand hand, Hand starter){ - this.hand = hand; - this.starter = starter.get(0); - } - - @Override - public int getScore() { - return score; - } - - private void calculateScore(){ - if (hand.getCard(starter.getSuit(), JACK) != null){ - score ++; - } - } -} diff --git a/Cribbage/src/observer/Pairs.java b/Cribbage/src/observer/Pairs.java deleted file mode 100644 index daae509b624ea37b975875018009b06ab359b598..0000000000000000000000000000000000000000 --- a/Cribbage/src/observer/Pairs.java +++ /dev/null @@ -1,66 +0,0 @@ -package observer; - -import ch.aplu.jcardgame.Card; -import ch.aplu.jcardgame.Hand; - -import java.util.ArrayList; -import java.util.Collections; - -public class Pairs implements Rule{ - - Hand hand = null; - int score = 0; - - public Pairs(){} - - @Override - public void receiveHandCards(Hand hand, Hand starter){ - this.hand = hand; - this.hand.insert(starter, false); - calculateScore(); - } - - @Override - public int getScore() { - return score; - } - - private void calculateScore(){ - ArrayList<Integer> cardValues = new ArrayList<>(); - for (Card c: hand.getCardList()){ - cardValues.add(c.getValue()); - } - Collections.sort(cardValues); - // 1,1,2,2,2,3,3,3,4,4,4,4,4,5,5 - int count = 1, preValue = cardValues.get(0); - for (int i=1; i<cardValues.size(); i++){ - if (cardValues.get(i) == preValue){ - count ++; - } else{ - score += pairScore(count); - count = 1; - preValue = cardValues.get(i); - } - } - } - - private int pairScore(int count){ - int score; - switch (count){ - case 1: - case 2: - score = 2; - break; - case 3: - score = 6; - break; - case 4: - score = 12; - break; - default: - return 0; - } - return score; - } - -} diff --git a/Cribbage/src/observer/Rule.java b/Cribbage/src/observer/Rule.java deleted file mode 100644 index 4a700680775b8dc836065a56770cde11903e443d..0000000000000000000000000000000000000000 --- a/Cribbage/src/observer/Rule.java +++ /dev/null @@ -1,10 +0,0 @@ -package observer; - -import ch.aplu.jcardgame.Card; -import ch.aplu.jcardgame.Hand; - -public interface Rule { - - void receiveHandCards(Hand hand, Hand starter); - int getScore(); -} diff --git a/Cribbage/src/observer/Runs.java b/Cribbage/src/observer/Runs.java deleted file mode 100644 index faca545bfc2a14ec1c7f1b151a50f913a1fb45db..0000000000000000000000000000000000000000 --- a/Cribbage/src/observer/Runs.java +++ /dev/null @@ -1,26 +0,0 @@ -package observer; - -import ch.aplu.jcardgame.Hand; - -public class Runs implements Rule{ - - Hand hand = null; - int score = 0; - - public Runs(){} - - @Override - public void receiveHandCards(Hand hand, Hand starter){ - this.hand = hand; - this.hand.insert(starter, false); - calculateScore(); - } - - @Override - public int getScore() { - return score; - } - - private void calculateScore(){ - } -}