Clover Coverage Report - HeartsSkyThread Coverage Report
Coverage timestamp: gio dic 18 2014 15:52:24 EST
../../../../img/srcFileCovDistChart8.png 23% of files have more coverage
406   807   99   15,62
110   575   0,24   13
26     3,81  
2    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  GameThread       Line # 16 406 99 74,4% 0.74354243
  GameThread.State       Line # 20 0 0 - -1.0
 
No Tests
 
1    package game.shad.tempus.hearts;
2   
3    import java.text.DecimalFormat;
4    import java.util.ArrayList;
5    import java.util.concurrent.atomic.AtomicReference;
6   
7   
8    import android.content.Context;
9    import android.graphics.Canvas;
10    import android.graphics.Color;
11    import android.util.Log;
12    import android.view.SurfaceHolder;
13    import android.view.View;
14    import android.widget.Toast;
15   
 
16    public class GameThread extends Thread
17    {
18    public static final String TAG = "Hearts--GameThread";
19   
 
20    public enum State {
21    RUNNING(), PAUSED(), DEAD();
22    }
23    public volatile AtomicReference<State> state = new AtomicReference<GameThread.State>(State.PAUSED);
24    public String eol = System.getProperty("line.separator");
25   
26    private final static int MAX_FPS = 50;
27    private final static int MAX_FRAME_SKIPS = 5;
28    private final static int FRAME_PERIOD = 1000 / MAX_FPS;
29   
30    private DecimalFormat df = new DecimalFormat("0.##");
31    private final static int STAT_INTERVAL = 1000;
32    private final static int FPS_HISTORY_NR = 10;
33    private long statusIntervalTimer = 0l;
34    private long totalFramesSkipped = 0l;
35    private long framesSkippedPerStatCycle = 0l;
36   
37    private int frameCountPerStatCycle = 0;
38    private long totalFrameCount = 0l;
39    private double fpsStore[];
40    private long statsCount = 0;
41    private double averageFps = 0.0;
42   
43    private SurfaceHolder surfaceHolder;
44    private Game game;
45    private MainActivity main;
46    private Canvas canvas;
47    private Context context;
48    public GameView gameView;
49    private boolean running;
50    private boolean firstStart = false;
51    private boolean justPickedUpPile = false;
52   
 
53  0 toggle public void setRunning(boolean running){
54  0 this.running = running;
55    }
56   
 
57  8 toggle public GameThread(Context context, MainActivity main, Game game, GameView gameView){
58  8 super();
59  8 this.gameView = gameView;
60  8 this.context = context;
61  8 this.main = main;
62  8 this.game = game;
63    }
 
64  8 toggle public void firstInit(){
65  8 heartsMe();
66  8 main.gt.start();
67   
68    }
 
69  8 toggle public void run(){
70  8 Thread.currentThread().setName("Craps Game Thread");
71   
72  256 while (state.get() != State.DEAD) {
73  248 try{
74  248 if(state.get() == State.PAUSED) {
75  12 sleep(5000);
76    }
77  236 pause(420);
78    //TODO if trading swap cards
79    //Detect when the table has 4 cards
80    //Deals with selected Card
81    //Depending on How user selects card deselecting last card could be tricky.
82    //
83   
84   
85  224 main.gameView.update();
86   
87    } catch(InterruptedException e){
88  24 Log.d(TAG, "Interrupted Exception!!! state=" + state.get(), e);
89    }
90    }
91    }
92   
 
93  8 toggle public void heartsMe(){
94  8 Log.d(TAG, "start()");
95   
96    //should not need to make deck, just shuffle the old one.
97  8 if(game.restart){
98    //TODO reset all points
99  8 Log.d(TAG, "Game first start");
100  8 makeDeck();
101  8 shuffle();
102  8 deal();
103    //This needs to be done later trade(); //ha ha more like set who to trade too.
104    //TODO let play select cards and trade.
105  8 voidCheck();
106    //NOW IN THREAD
107    //createViews();
108    //TODO trade two
109  8 checkForTwoMethod();//This more or less starts the game.
110  8 displayCards(game.p1);
111    }
112   
113    else{
114  0 Log.d(TAG, "New round delt");
115    //New round keep playing
116  0 makeDeck();
117  0 shuffle();
118  0 deal();
119    //TODO trade()
120  0 voidCheck();
121    //createViews();
122   
123  0 checkForTwoMethod();//This more or less starts the game.
124  0 displayCards(game.p1);
125    }
126    //thread.setRunning(true);
127   
128    // thread.run();
129    //DECKHOLDER
130   
131    }
132   
133    /**
134    * creates 52 cards 13 of each suit.
135    */
 
136  8 toggle public void makeDeck() {
137  8 Log.d(TAG, "make Deck");
138  8 game.deck.clearALL();
139  40 for(int suit=0;suit<4;suit++){
140  448 for(int value=1;value<14;value++){
141  416 Card cd = new Card(value, suit, context);
142  416 game.deck.addCard(cd);
143    }
144   
145    }
146   
147    }
148    /**
149    * WOULD NOT BET LIFE ON THIS SHUFFLE!!!
150    * Probably a very uneven shuffle.
151    */
 
152  8 toggle public void shuffle(){
153  8 Log.d(TAG, "shuffle");
154  8 if(game.shuffleType==1){
155  3 Log.d(TAG, "shuffle type 1");
156   
157    //New shuffle going in 8/16
158  3 int x = 0;
159  3 int z = 50;
160  3 int total =0;
161   
162  3 Deck deck2 = new Deck();
163  3 Deck deck3 = new Deck();
164  3 Deck deck4 = new Deck();
165  3 deck2.addAllCards(game.deck);
166  3 int j=0;
167  3 int a=(int) (Math.random()*7)+1;
168  3 int dLength=0;;
169  3 boolean stop = false;
170  153 while(x<z&&!stop){
171  150 x++;
172  150 dLength=deck2.getSize();
173  1776 while(dLength>0){
174  1626 if(dLength<=a){
175  122 Log.d(TAG, "STOP, too Small. "+dLength);
176  122 deck3.addAllCards(deck2);
177  122 deck2.clearALL();
178  122 a=-1; //must be negative or it will go into the while loop
179  122 stop=true;
180    //maybe just break and drop all cards.
181    }
182    //print ("a="+a, 449);
183  9073 while(a>=0){
184  7447 deck3.addCard(deck2.getCard(a));
185  7447 deck2.removeCardAtIndex(a);
186  7447 a--; //goes to -1, but thats ok
187  7447 j++; //seemed like it adds an extra but a>=0 is why.
188    }
189   
190  1626 deck4.addAllCards(deck3);
191  1626 deck3.clearALL();
192   
193  1626 a=(int) (Math.random()*7)+1;
194  1626 dLength=deck2.getSize();
195    //Log.d(TAG, "deck2= "+dLength, 461);
196    //Log.d(TAG, "deck3= "+deck3.getSize(), 462);
197    //Log.d(TAG, "deck4= "+deck4.getSize(), 463);
198    }
199    //deck2.clearALL(); should be empty
200  150 stop=false;
201  150 deck2.addAllCards(deck4); //dont use = it makes them clones of each other
202  150 deck4.clearALL();
203  150 Log.d(TAG, "x="+x+" z="+z);
204   
205    }
206  3 Log.d(TAG, "j is "+j);
207  3 game.deck.clearALL();
208  3 game.deck.addAllCards(deck2);
209    }
210  5 else if(game.shuffleType==2){ //this shuffle may not work after changing everything to Deck...
211  1 Log.d(TAG, "shuffle type 2");
212  1 int x=0;
213  1 int z=50;//times to loop the deck and 'randomly' switch cards.
214  1 int r = 51;
215  1 boolean stop=false;
216  1 Deck deck2 = new Deck();
217   
218  51 while(x<z){
219  50 x++;
220  50 int j=0;
221  50 int a=(int) (Math.random()*r);
222  51 for(int i=52; i>0&&!stop; i--){
223  1 int loop=0;
224  17 while(game.deck.getCard(a)!=null&&!stop){
225  16 loop++;
226  16 a=(int) (Math.random()*r);
227  16 if(loop>15&&!stop){ //careful on this Set loop to 15 from 10.
228  1 r = 0;
229  53 for(int q=0; q<game.deck.getSize();q++){//Random math not finding cards, Empty rest and start again.
230  52 if(game.deck.getCard(q)!=null){
231  52 deck2.addCardAtIndex(q, game.deck.getCard(q));
232  52 r++;
233  52 j++;
234    }
235   
236   
237    }
238  1 stop=true;
239   
240   
241    }
242    }
243  1 if(!stop){
244  0 deck2.addCardAtIndex(a, game.deck.getCard(a));
245  0 game.deck.addCardAtIndex(a, null);
246  0 j++;
247    }
248    }
249   
250  50 game.deck=deck2;
251   
252   
253   
254    }
255    }
256    else{
257    //TODO finish.
258  4 Log.d(TAG, "shuffle type 3");
259  4 int x = 0;
260  4 int z = 50;
261  4 int total =0;
262  4 ArrayList<Deck> decks= new ArrayList<Deck>();
263  4 Deck deck2 = new Deck();
264  4 deck2.addAllCards(game.deck);
265  204 while(x<z){
266  200 decks.addAll(splitDeck(deck2));
267  200 Log.d(TAG, "the deck is "+decks.size());
268  200 deck2.clearALL();
269  200 deck2.addAllCards(mixOutIn(decks));
270  200 decks.clear();
271  200 x++;
272    }
273   
274   
275   
276   
277   
278    }
279    }
280   
281    /**
282    * Takes a Deck and returns an array of decks, 11 of them 5 per array and 2 in the last one.
283    * @param a The Deck to be split
284    * @return ArrayList<Deck>(size = 11)
285    */
 
286  200 toggle private ArrayList<Deck> splitDeck(Deck a) {
287  200 ArrayList<Deck> decks = new ArrayList<Deck>();
288  2200 for(int i =0; i<10;i++){
289  2000 Deck deck2 = new Deck();
290   
291  2000 int t=0;
292  12000 while(t<5){
293  10000 deck2.addCard(a.getCard(t));
294  10000 t++;
295    }
296  2000 t--;
297  12000 while(t>=0){
298  10000 a.removeCardAtIndex(t);
299  10000 t--;
300    }
301  2000 decks.add(deck2);
302    }
303  200 decks.add(a);
304  200 return decks;
305    }
306   
307    /**
308    * Mix an ArrayList<Deck> into
309    * @param a
310    * @return
311    */
312   
313   
 
314  200 toggle private Deck mixOutIn(ArrayList<Deck> a){
315  200 int size = a.size();
316  200 boolean extra=false;
317  200 if(size%2==1){
318  200 size--;
319  200 extra=true;
320    }
321  200 Deck d= new Deck();
322  1200 for(int i =0;i<size/2;i++){
323  1000 d.addAllCards(mixDecks(a.get(i), a.get(size-i-1)));
324    }
325  200 d.addAllCards(a.get(size/2));
326   
327  200 return d;
328    }
329   
 
330  1000 toggle public Deck mixDecks(Deck a, Deck b){
331  6000 for(int i=0; i<a.getSize();i++){
332  5000 b.addCardAtIndex(i+i, a.getCard(i));
333    }
334  1000 return b;
335    }
336   
 
337  0 toggle public ArrayList<Card> addLowHigh(ArrayList<Card> fromDeck){
338  0 ArrayList<Card> toDeck= new ArrayList<Card>();
339  0 for(int i=0;i<fromDeck.size();i++){
340  0 toDeck.add(fromDeck.get(i));
341    }
342  0 return toDeck;
343    }
344   
 
345  0 toggle public ArrayList<Card> addHighLow(ArrayList<Card> fromDeck){
346  0 ArrayList<Card> toDeck= new ArrayList<Card>();
347  0 for(int i=fromDeck.size()-1;i>=0;i--){
348  0 toDeck.add(fromDeck.get(i));
349    }
350  0 return toDeck;
351    }
352   
353   
354    /**
355    * Create the and deals them out and then finds the two
356    * NEEDS SHUFFLE.
357    * */
 
358  8 toggle public void deal() {
359  8 Log.d(TAG, "dealing");
360  8 Deck hand1 = new Deck();
361  8 Deck hand2 = new Deck();
362  8 Deck hand3 = new Deck();
363  8 Deck hand4 = new Deck();
364  112 for(int i=0;i<game.deck.getSize();i+=4){
365  104 int d1=i;
366  104 int d2=i+1;
367  104 int d3=i+2;
368  104 int d4=i+3;
369  104 hand1.addCard(game.deck.getCard(d1));
370  104 hand2.addCard(game.deck.getCard(d2));
371  104 hand3.addCard(game.deck.getCard(d3));
372  104 hand4.addCard(game.deck.getCard(d4));
373   
374   
375    }
376  8 if(game.p1==null||game.restart){//first Start or restart called
377  8 Log.d(TAG, "New hands dealt.");
378  8 int b = Color.rgb(0, 50 , 200);
379  8 game.p1 = new Player(game, hand1, 0, 1, game.name, Color.WHITE);
380  8 game.p2 = new Player(game, hand2, 0, 2, "Chuck (P2)", Color.RED);
381  8 game.p3 = new Player(game, hand3, 0, 3, "Skippy (P3)", b);
382  8 game.p4 = new Player(game, hand4, 0, 4, "Jeff (P4)", Color.YELLOW);
383  8 gameView.deckHolder.addDeck(hand1);
384    //p2.setColor(Color.RED);
385    }
386    else {//else new round and New cards are dealt
387  0 Log.d(TAG, "new round being delt");
388  0 game.p1.sethand(hand1);
389  0 game.p2.sethand(hand2);
390  0 game.p3.sethand(hand3);
391  0 game.p4.sethand(hand4);
392    }
393   
394    //TODO if resume code
395    /* New Deal to work the proper way.
396    ArrayList<card> hand1 = new ArrayList<card>();
397    ArrayList<card> hand2 = new ArrayList<card>();
398    ArrayList<card> hand3 = new ArrayList<card>();
399    ArrayList<card> hand4 = new ArrayList<card>();
400   
401    for(int i=0;i<13;i++){//could be buggy; also could be shot for shuffling like this.
402    int d1=i;
403    int d2=13+i;
404    int d3=26+i;
405    int d4=39+i;
406    hand1.add(deck[d1]);
407    hand2.add(deck[d2]);
408    hand3.add(deck[d3]);
409    hand4.add(deck[d4]);
410    }
411    if(p1==null||restart){//first Start or restart called
412    Log.d(TAG, "New hands dealt.", 483);
413    int b = Color.rgb(0, 50 , 200);
414    p1 = new Player(hand1, 0, 1, name, Color.WHITE);
415    p2 = new Player(hand2, 0, 2, "Chuck (P2)", Color.RED);
416    p3 = new Player(hand3, 0, 3, "Skippy (P3)", b);
417    p4 = new Player(hand4, 0, 4, "Jeff (P4)", Color.YELLOW);
418    //p2.setColor(Color.RED);
419    }
420    else if(count==0){//else new round and New cards are dealt
421    Log.d(TAG, "new round being delt", 492);
422    p1.sethand(hand1);
423    p2.sethand(hand2);
424    p3.sethand(hand3);
425    p4.sethand(hand4);
426    }
427    else{
428    Log.d(TAG, "IMPORTANT STUFF", 494);
429    //we are loading an old game.....
430    //TODO more code for setting it up right?
431   
432    }
433    */
434   
435    }
436   
437   
438    /**
439    * Call on round 0;
440    * Finds who has the 2 of clubs and forces them to play it
441    * Sets the states for the next round
442    * Then advances the curPlayer
443    */
 
444  8 toggle public void checkForTwoMethod(){
445  8 Log.d(TAG, "checkForTwoMethod() called");
446  8 if(game.p1.checkForTwo()){
447  0 Log.d(TAG, "p1 played the 2 of clubs");
448  0 game.curPlayer=game.p1;
449    //tableCard1.setText(selectedCardSuit+"-"+selectedCard); //TODO remove this line
450    //playing=true;
451    //New code to set up each round play state then not modify till next round.
452  0 game.p1.setState(1);
453  0 game.p2.setState(2);
454  0 game.p3.setState(3);
455  0 game.p4.setState(4);
456  0 playTwoOfClubs();
457  0 gameView.displayCards(game.p1);
458   
459   
460    }
461  8 else if(game.p2.checkForTwo()){
462  6 Log.d(TAG, "p2 plays 2 of clubs");
463  6 game.curPlayer=game.p2;
464  6 game.p1.setState(4);
465  6 game.p2.setState(1);
466  6 game.p3.setState(2);
467  6 game.p4.setState(3);
468  6 playTwoOfClubs();
469    }
470  2 else if(game.p3.checkForTwo()){
471  1 Log.d(TAG, "p3 plays 2 of clubs");
472  1 game.curPlayer=game.p3;
473  1 game.p1.setState(3);
474  1 game.p2.setState(4);
475  1 game.p3.setState(1);
476  1 game.p4.setState(2);
477  1 playTwoOfClubs();
478    }
479  1 else if(game.p4.checkForTwo()){
480  1 Log.d(TAG, "p4 plays 2 of clubs");
481  1 game.curPlayer=game.p4;
482  1 game.p1.setState(2);
483  1 game.p2.setState(3);
484  1 game.p3.setState(4);
485  1 game.p4.setState(1);
486  1 playTwoOfClubs();
487    }
488    else{
489  0 Log.d(TAG, "The game has already started.");
490    }
491  8 Log.d(TAG, " 2 check done--curPlayer="+game.curPlayer.getRealName());
492    }
493   
 
494  8 toggle public void voidCheck(){
495  8 game.p1.checkForVoids();
496  8 game.p2.checkForVoids();
497  8 game.p3.checkForVoids();
498  8 game.p4.checkForVoids();
499    }
500   
 
501  8 toggle public void displayCards(Player p){
502  8 Deck c = p.getClubs();
503  8 Deck d = p.getDiamonds();
504  8 Deck s = p.getSpades();
505  8 Deck h = p.getHearts();
506  8 String clubs = "";
507  8 String diamonds = "";
508  8 String spades = "";
509  8 String hearts = "";
510  36 for(int i=0; i<c.getSize();i++){
511  28 clubs+=c.getCard(i).getValue()+", ";
512    }
513  32 for(int i=0; i<d.getSize();i++){
514  24 diamonds+=d.getCard(i).getValue()+", ";
515    }
516  34 for(int i=0; i<s.getSize();i++){
517  26 spades+=s.getCard(i).getValue()+", ";
518    }
519  34 for(int i=0; i<h.getSize();i++){
520  26 hearts+=h.getCard(i).getValue()+", ";
521    }
522   
523  8 switch(p.getSeat()){
524  8 case 1:
525  8 gameView.p1tvScore.setText("P1:"+game.p1.getScore());
526  8 break;
527  0 case 2:
528  0 gameView.p2tvScore.setText("P2:"+game.p2.getScore());
529  0 break;
530    //TODO
531  0 case 3:
532  0 gameView.p3tvScore.setText("P3:"+game.p3.getScore());
533  0 break;
534    //TODO
535  0 case 4:
536  0 gameView.p4tvScore.setText("P4:"+game.p4.getScore());
537  0 break;
538    //TODO
539    }
540   
541   
542    }
543   
544   
545    /**
546    * Plays the selected card and advances the curPlayer
547    * @param p seat of person who is playing a card
548    * @param rs the string to be set to the layout.
549    */
550   
551    /**
552    * Sets the first round of the game going
553    * Plays two and then sets next CurPlayer
554    */
 
555  8 toggle public void playTwoOfClubs(){
556    // Card nextCard=(game.curPlayer.clubs.getCard(0));
557    // if(nextCard.getValue()!=2){ //has the one and the two of clubs
558    // nextCard=(game.curPlayer.clubs.getCard(1));
559    // game.curPlayer.clubs.removeCardAtIndex(1);//Thus only remove 2
560    // }
561    // else{
562    // game.curPlayer.clubs.removeCardAtIndex(0); //Does not have Ace thus remove place one.
563    // }
564  8 Card nextCard = game.curPlayer.twoOfClubs;
565  8 game.curPlayer.deck.removeCard(nextCard);
566  8 game.curPlayer.updateSuits();
567  8 Log.d(TAG, "game started by "+game.curPlayer.getRealName());
568  8 game.pile.add(nextCard);
569  8 gameView.bottomText2.setText(game.curPlayer.getRealName()+" played the 2 of Clubs. ");
570  8 playCard(nextCard);
571   
572  8 Log.d(TAG, "0101010");
573    }
574   
575   
576   
 
577  0 toggle public void showHand(Player p){
578  0 Deck hand = p.gethand();
579  0 String wholeHand=p.getRealName()+" ";
580  0 for(int i=0;i<hand.getSize();i++){
581  0 wholeHand+=hand.getCard(i).name+", ";
582    }
583  0 Log.d(TAG, wholeHand);
584  0 Log.d(TAG, "total="+hand.getSize());
585    }
586   
 
587  31 toggle public void GO(){
588  31 Log.d(TAG, "GO()");
589  31 gameView.roundView.setText("Round="+game.round);
590  31 Card nextCard=(game.curPlayer.go(game.round, game.pile, game.curPlayer));
591  31 game.pile.add(nextCard);
592  31 Log.d(TAG, "###"+game.curPlayer.realName+" played a "+nextCard.name+". Pile size="+game.pile.size() );
593   
594  31 gameView.bottomText2.setText(game.curPlayer.getRealName()+" played the "+ nextCard.name);
595  31 game.curPlayer.updateDeck();
596   
597  31 playCard(nextCard);
598   
599    }
600   
 
601  49 toggle public void playCard(Card nextCard){
602  49 if(justPickedUpPile){
603  8 gameView.clearTableCards();
604  8 this.justPickedUpPile=false;
605    }
606  49 this.gameView.addTableCard(nextCard);
607  49 if(game.pile.size()>=4){
608  10 Log.d(TAG, "picking up hand");
609  10 pickUpHand();
610    }
611    else{
612  39 this.game.curPlayer=nextPlayer(game.curPlayer); //this is the error line
613    }
614  49 gameView.bottomText.setText("Current player is "+game.curPlayer.getRealName());
615   
616    }
617   
 
618  39 toggle public Player nextPlayer(Player p){
619  39 switch(p.getSeat()){
620  10 case 1:
621  10 game.playing=false;
622  10 return game.p2;
623  12 case 2:
624  12 return game.p3;
625  9 case 3:
626  9 return game.p4;
627  8 case 4:
628  8 game.playing=true;
629  8 return game.p1;
630    }
631  0 return null;
632    }
633   
 
634  10 toggle public void setCurPlayer(Player p){
635  10 game.curPlayer = p;
636    }
637   
 
638  10 toggle public void pickUpHand(){
639  10 game.roundHands.add(game.pile);
640  10 this.justPickedUpPile=true;
641  10 int high = 0;
642  10 int highSeat = 0;
643  10 int points = 0;
644  10 int firstSuit=game.pile.get(0).getSuit();
645  50 for(int i=0;i<game.pile.size();i++){ // maybe start at the back of the pile...yet it does not really matter
646  40 game.pile.get(i).setPlayed(true); //just added Not sdfused yet but could be used to check what cards have been played on crash.
647  40 int curSuit=game.pile.get(i).getSuit();
648  40 int curCard =game.pile.get(i).getValue();
649  40 if(firstSuit==curSuit){
650  39 if(high<=curCard){ //equals so that p1 can take the lead.
651  33 high=curCard;
652  33 highSeat=game.pile.get(i).getOwner().getSeat();//Seats are 1-4
653    }
654    }
655  40 if(curSuit==0){
656  39 game.clubsPlayedInt++;
657    }
658   
659  1 else if(curSuit==1){ //Diamonds check for jack.
660  1 game.diamondsPlayedInt++;
661  1 if(curCard==11){
662  1 points-=10;
663  1 Toast.makeText(context, "Jack - 10", Toast.LENGTH_SHORT).show();
664   
665    }
666    }
667  0 else if(curSuit==2){//Spades check for queen
668  0 game.spadesPlayedInt++;
669   
670  0 if(curCard==12){
671  0 game.heartsBroken=true;
672  0 points+=13;
673  0 Toast.makeText(context, "Queen + 13", Toast.LENGTH_SHORT).show();
674   
675    }
676    }
677  0 else if(curSuit==3){//heart--add points
678  0 game.heartsPlayedInt++;
679  0 game.heartsBroken=true;
680  0 points++;
681    }
682   
683    }
684  10 gameView.clubsPlayed.setText("C="+game.clubsPlayedInt);
685  10 gameView.diamondsPlayed.setText("D="+game.diamondsPlayedInt);
686  10 gameView.spadesPlayed.setText("S="+game.spadesPlayedInt);
687  10 gameView.heartsPlayed.setText("H="+game.heartsPlayedInt);
688  10 int total=game.clubsPlayedInt+game.diamondsPlayedInt+game.spadesPlayedInt+game.heartsPlayedInt;
689  10 gameView.totalPlayed.setText("total= "+total);
690  10 switch(highSeat){
691  8 case 1:
692  8 game.curPlayer=game.p1;
693  8 game.p1.addToScore(points);
694  8 gameView. p1tvScore.setText("P1:"+game.p1.getScore());
695  8 game.playing=true;
696  8 gameView.bottomText2.setText("You won, points="+points);
697  8 gameView.bottomText2.append(eol+"Pick a Start Card");
698   
699  8 break;
700  1 case 2:
701  1 game.curPlayer=game.p2;
702  1 game.p2.addToScore(points);
703  1 gameView.p2tvScore.setText("P2:"+game.p2.getScore());
704  1 gameView.bottomText2.append(eol+"P2 won, points="+points);
705   
706  1 break;
707  1 case 3:
708  1 game.curPlayer=game.p3;
709  1 game.p3.addToScore(points);
710  1 gameView.p3tvScore.setText("P3:"+game.p3.getScore());
711  1 gameView.bottomText2.append(eol+"P3 won, points="+points);
712   
713  1 break;
714  0 case 4:
715  0 game.curPlayer=game.p4;
716  0 game.p4.addToScore(points);
717  0 gameView.p4tvScore.setText("P4:"+game.p4.getScore());
718  0 gameView.bottomText2.append(eol+"P4 won, taking="+points+" points");
719  0 break;
720    }
721  10 Log.d(TAG, "pickUpHand() for "+game.curPlayer.getRealName());
722  10 game.curPlayer.addDeckItem(game.pile);
723  10 game.pile.clear();
724  10 setCurPlayer(game.curPlayer); //for next round.
725   
726   
727  10 game.round++; //cards left counter
728  10 if(game.round==14){//Done playing need new cards.'
729  0 game.count++;
730  0 game.round=1; //ROUND RESET!!!
731  0 if(game.endGameCheck()){
732  0 game.curPlayer =game.winnerCheck();
733  0 gameView.bottomText.setText(game.curPlayer.getRealName()+" won the game!");
734  0 gameView.bottomText2.setText("Press menu, then restart to play again");
735   
736    }
737    else{
738  0 game.newRound=true;
739  0 Log.d(TAG, "New round");
740  0 game.restart=false;
741  0 game.clubsPlayedInt=0;
742  0 game.diamondsPlayedInt=0;
743  0 game.spadesPlayedInt=0;
744  0 game.heartsPlayedInt=0;
745  0 Toast.makeText(context, "New Round Dealt", Toast.LENGTH_LONG).show();
746   
747  0 heartsMe();
748    }
749   
750    }
751   
752   
753    }
754   
755   
756   
757   
758    private long lastUpdate = System.currentTimeMillis();
759    private long timeElapsed = 1;
 
760  236 toggle private void pause(long ms) throws InterruptedException{
761    //System.out.println(ms - System.currentTimeMillis() + lastUpdate);
762  236 Thread.sleep(Math.max(0, ms - System.currentTimeMillis() + lastUpdate));
763   
764  224 timeElapsed = System.currentTimeMillis() - lastUpdate;
765  224 lastUpdate = System.currentTimeMillis();
766    }
767   
 
768  0 toggle private void storeStats() {
769  0 frameCountPerStatCycle++;
770  0 totalFrameCount++;
771  0 statusIntervalTimer += FRAME_PERIOD;
772   
773  0 if(statusIntervalTimer >= STAT_INTERVAL){
774  0 double actualFps = (double)(frameCountPerStatCycle / (STAT_INTERVAL / 1000));
775  0 fpsStore[(int)statsCount % FPS_HISTORY_NR] = actualFps;
776  0 statsCount++;
777  0 double totalFps = 0.0;
778   
779  0 for(int i =0; i < FPS_HISTORY_NR; i++) {
780  0 totalFps += fpsStore[i];
781    }
782   
783  0 if(statsCount < FPS_HISTORY_NR){
784  0 averageFps = totalFps / statsCount;
785    }else {
786  0 averageFps = totalFps / FPS_HISTORY_NR;
787    }
788   
789  0 totalFramesSkipped += framesSkippedPerStatCycle;
790  0 framesSkippedPerStatCycle = 0;
791  0 statusIntervalTimer = 0;
792  0 frameCountPerStatCycle = 0;
793    //game.setAvgFps("FPS: " + df.format(averageFps));
794   
795    }
796    }
797   
 
798  0 toggle private void initTimingElements(){
799  0 fpsStore = new double[FPS_HISTORY_NR];
800  0 for(int i = 0; i < FPS_HISTORY_NR; i++){
801  0 fpsStore[i] = 0.0;
802    }
803  0 Log.d(TAG + ".initTimingElements()","Timing elements for stats intialized");
804    }
805   
806   
807    }