package extend.mj.uitl;

import java.util.List;
import java.util.Map;

import com.taurus.core.entity.ITArray;
import com.taurus.core.entity.TArray;
import extend.mj.OpCard;
import extend.mj.WinCardType;

import java.util.Random;

public class CardUtil {


	static public void removeGroup(List<int[]> group, int card) {
		for (int i = 0; i < group.size(); i++) {
			int[] cardArray = group.get(i);
			if (cardArray[0] == card) {
				group.remove(cardArray);
				return;
			}

		}
	}

	final static Random random	= new Random();
	static {
		random.setSeed(System.currentTimeMillis());
	}
	static public int randomDiceNum() {
		int result = random.nextInt(5);
		return result + 1;
	}

	static public void removeOpcard(List<OpCard> opcards, OpCard param) {
		for (int i = 0; i < opcards.size(); i++) {
			if (param.card == opcards.get(i).card) {
				opcards.remove(i);
				return;
			}

		}

	}

	static public ITArray toMPData_WinMap(Map<Integer, WinCardType> map) {
		return toMPData_WinMap(map,false);
	}

	static public ITArray toMPData_WinMap(Map<Integer, WinCardType> map,boolean is_opcard) {
		if (map != null && map.size() > 0) {
			ITArray array = TArray.newInstance();
			for (Map.Entry<Integer, WinCardType> entry : map.entrySet()) {
				WinCardType wct = entry.getValue();
				array.addTObject(wct.toTObject(is_opcard));
			}
			return array;
		}
		return null;
	}
}
