package extend.zp.player.state;

import java.util.Map.Entry;

import com.game.ActionEvent;
import com.taurus.core.entity.ITArray;
import com.taurus.core.entity.ITObject;

import extend.zp.EXActionEvent;
import extend.zp.EXPlayer;
import extend.zp.RuleWeight;
import extend.zp.tip.Tip;


public class EXPlayerDisCardTipState extends EXPlayerTipState {
	@Override
	public void enter(EXPlayer owner) {
		// TODO Auto-generated method stub
		super.enter(owner);
		owner.getRoom().tipMap.put(owner.playerid, owner.tipMgr);

	}

	@Override
	public void exit(EXPlayer owner) {
		// TODO Auto-generated method stub
		super.exit(owner);
		owner.getRoom().tipMap.remove(owner.playerid);
	}

	@Override
	public void execute(EXPlayer owner, String cmd, int gid, Object param) {
		super.execute(owner, cmd, gid, param);
		if (cmd.equals(EXActionEvent.EVENT_ACTION)) {
			ITObject netParam = (ITObject) param;
			int id = netParam.getInt("id");
			ITArray biid = netParam.containsKey("biid")?netParam.getTArray("biid"):null;
			owner.tipMgr.choicAction(id,biid);

			// Global.logger.error("EXPlayerDisCardTipState" + id);
		}else if(cmd.equals(ActionEvent.EVENT_TIMER_AUTO)){
			int id = owner.tipMgr.getUid();
			for (Entry<Integer, Tip> entry : owner.tipMgr.tipMap.entrySet()) {
				Tip tip = entry.getValue();
				//if (tip.type == RuleWeight.TYPE_WIN) {
				//	id = tip.id;
				//	break;
				//}
			}
			owner.tipMgr.choicAction(id,null);
		}
	}
}
