001    /**
002     * 
003     */
004    package jagafa.stats;
005    
006    import jagafa.JassRound;
007    import jagafa.object.CardList;
008    import jagafa.object.Hand;
009    
010    import javax.swing.JComponent;
011    
012    /**
013     * GameStats takes a Game object and collects some statistics about it
014     * Mainly from the view of the active Player!
015     * 
016     */
017    public class RoundStats {
018            private static final int COLORS = 4;
019    
020            private int scoreTeam1_;
021    
022            private int scoreTeam2_;
023    
024            private CardList goneList_[];
025    
026            private JassRound round_;
027    
028            public RoundStats(JassRound round) {
029                    this.round_ = round;
030    
031                    this.update();
032            }
033    
034            /**
035             * Update the stats
036             */
037            public void update() {
038                    this.createGoneStats();
039                    this.createScoreStats();
040            }
041    
042            /**
043             * Create two int variables with the teams scores
044             */
045            private void createScoreStats() {
046                    int sum1 = round_.getPlayer(0).getScore() + round_.getPlayer(2).getScore();
047                    int sum2 = round_.getPlayer(1).getScore() + round_.getPlayer(3).getScore();
048                    scoreTeam1_ = sum1;
049                    scoreTeam2_ = sum2;
050            }
051    
052            private void createGoneStats() {
053                    this.goneList_ = new CardList[COLORS];
054                    for (int i = 0; i < COLORS; i++) {
055                            this.goneList_[i] = new CardList();
056                            CardList goneofcol = round_.getGoneHeap().getGoneOfColor(i);
057                            Hand h = new Hand(goneofcol);
058                            h.sort(this.round_.getRules());
059                            goneList_[i].addAll(h);
060                    }
061            }
062    
063            /**
064             * @return Returns the goneList in the form CardList[color].
065             */
066            public CardList[] getGoneList() {
067                    return this.goneList_;
068            }
069    
070            /**
071             * @return Returns the scoreTeam1.
072             */
073            public int getScoreTeam1() {
074                    return this.scoreTeam1_;
075            }
076    
077            /**
078             * @return Returns the scoreTeam2.
079             */
080            public int getScoreTeam2() {
081                    return this.scoreTeam2_;
082            }
083    
084            public int turnsPlayed() {
085                    return this.round_.getGoneHeap().turns();
086            }
087            
088            public void setRound(JassRound round) {
089                    this.round_ = round;
090            }
091    
092            public JComponent getView() {
093    
094                    return null;
095            }
096    }