package extend.zp.player.rule;

import com.game.Global;

import com.taurus.core.plugin.redis.Redis;
import extend.zp.EXMainServer;
import extend.zp.EXPlayer;
import extend.zp.EXRoom;
import extend.zp.player.rulestate.PRCheck;
import extend.zp.player.rulestate.PRChi;
import extend.zp.player.rulestate.PRDrawChiState;
import extend.zp.tip.IRuleBase;
import redis.clients.jedis.Jedis;


public class RuleDrawChi implements IRuleBase {
	@Override
	public boolean condition(EXPlayer player) {
		boolean c =  PRCheck.check(player);
		if (!c){
			return false;
		}
		EXPlayer activePlayer = (EXPlayer) player.room.playerMapBySeat.get(player.room.activeSeat);
		int eventCard = activePlayer.drawCard;
		return player.chi(eventCard, this);
	}

	@Override
	public void action(EXPlayer player) {
		EXRoom room = (EXRoom) player.room;
		EXPlayer activePlayer = (EXPlayer) room.playerMapBySeat.get(player.room.activeSeat);
		int activeCard = activePlayer.drawCard;
		PRChi.prChi(activeCard, player);
		activePlayer.drawCard = 0;
		EXMainServer.gameCtr.changeActiveSeat(room, player.seat);

		player.stateMachine.changeState(Global.getState(PRDrawChiState.class));
	}
}
