Android Open Source - ScoponeDaPolso Deck






From Project

Back to project page ScoponeDaPolso.

License

The source code is released under:

GNU General Public License

If you think the Android project ScoponeDaPolso listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.gdg.bari.entities;
// w w w  . j  a v  a  2 s. c om


import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

/**
 * Created by tiziano on 09/11/14.
 */
public class Deck {

    private HashMap<Integer, Card> cardMap;
    //private Set<Card> cardsOnTable;

    private static final String TAG = Deck.class.getSimpleName();

    public List<Card> getPlayerCardList(String playerId){
        List<Card> cardList = new ArrayList<Card>();
        Set<Integer> cardMapKeySet = cardMap.keySet();
        for(int key : cardMapKeySet){
            Card card = cardMap.get(key);
            if(card.getOwner().equals(playerId) && card.getStatus() == Constants.STATUS_IN_HAND){
                cardList.add(card);
            }
        }
        return cardList;
    }


    public Deck(List<String> players){

        cardMap = new HashMap<Integer, Card>();
        List<Card> cardList = new ArrayList<Card>();

        for(String seed : Constants.SEEDS){
            for(int i = 1; i <=10; i++){
                cardList.add(new Card(seed, i));
            }
        }
        Collections.shuffle(cardList);
        for(int i = 0; i < players.size(); i++){
            for(int j = i * 10; j < 10 + (i * 10); j++){
                cardList.get(j).setOwner(players.get(i));
                cardList.get(j).setStatus(Constants.STATUS_IN_HAND);
                cardMap.put(cardList.get(j).hashCode(), cardList.get(j));
            }
        }
    }

    public HashMap<Integer, Card> getCardMap() {
        return cardMap;
    }

    public void update(Card card){
        Card cardToUpd = cardMap.get(card.hashCode());
        cardToUpd.setOwner(card.getOwner());
        cardToUpd.setStatus(card.getStatus());
    }

    public int getNumberOfCardsOwnedByPlayer(String playerId){

        int sum = 0;
        Set<Integer> cardMapKeyList = cardMap.keySet();
        for(Integer cardMapKey: cardMapKeyList){
            if(cardMap.get(cardMapKey).getOwner().equals(playerId))
               sum++;
        }
        return sum;
    }

    public int getNumberOfDenariCardsOwnedByPlayer(String playerId){

        int sum = 0;
        Set<Integer> cardMapKeyList = cardMap.keySet();
        for(Integer cardMapKey: cardMapKeyList){
            Card card = cardMap.get(cardMapKey);
            if(card.getOwner().equals(playerId) &&
                    card.getSeed().equals(Constants.SEED_DENARI))
                sum++;
        }
        return sum;
    }
}




Java Source Code List

com.google.example.games.basegameutils.BaseGameActivity.java
com.google.example.games.basegameutils.BaseGameUtils.java
com.google.example.games.basegameutils.GameHelperUtils.java
com.google.example.games.basegameutils.GameHelper.java
com.mariux.teleport.lib.ApplicationTest.java
com.mariux.teleport.lib.TeleportClient.java
com.mariux.teleport.lib.TeleportService.java
org.gdg.bari.entities.ApplicationTest.java
org.gdg.bari.entities.Card.java
org.gdg.bari.entities.Constants.java
org.gdg.bari.entities.Deck.java
org.gdg.bari.entities.Score.java
org.gdg.bari.entities.TableTurn.java
org.gdg.bari.entities.Table.java
org.gdg.bari.entities.TeleportClientManager.java
org.gdg.bari.scopone.ApplicationTest.java
org.gdg.bari.scopone.activity.MobileGameActivity.java
org.gdg.bari.scopone.activity.MobileMainActivity.java
org.gdg.bari.scopone.activity.WearConfirmationActivity.java
org.gdg.bari.scopone.activity.WearMainActivity.java
org.gdg.bari.scopone.fragment.CardListFragment.java
org.gdg.bari.scopone.fragment.GameFragment.java
org.gdg.bari.scopone.fragment.LoginFragment.java
org.gdg.bari.scopone.fragment.MenuFragment.java
org.gdg.bari.scopone.service.MobileTeleportService.java
org.gdg.bari.scopone.services.WearTeleportService.java
org.gdg.bari.scopone.util.GoogleApiClientManager.java
org.gdg.bari.scopone.util.LogUtil.java