package extend.zp.room.state;

import com.game.Global;
import com.game.data.Player;
import com.game.state.StateBase;
import extend.zp.EXActionEvent;
import extend.zp.EXRoom;
import extend.zp.player.state.EXPlayerPiaoNiaoTipState;

import java.util.Map.Entry;

public class EXRoomPiaoState extends StateBase<EXRoom>{

	@Override
	public void enter(EXRoom owner) {
		owner.piaoCount = owner.maxPlayers;
		for (Entry<Integer, Player> entry : owner.playerMapById.entrySet()) {
			Player player = entry.getValue();
			player.stateMachine.changeState(Global.getState(EXPlayerPiaoNiaoTipState.class));
		}
	}
	
	public void execute(EXRoom owner, String cmd, int gid, Object param) {
		if(cmd.equals(EXActionEvent.EVENT_PIAO)) {
			if(owner.piaoCount==0) {
				owner.stateMachine.changeState(Global.getState(EXRoomDealState.class));
			}
		}
	}
}
