package extend.mj.player.rulestate;

import com.game.state.StateBase;
import extend.mj.*;

import java.util.Map;

/**
 * ��Ӧ���ƴ���״̬
 * 
 *
 * 2017��8��30��
 * PROtherWinState.java
 */
public class PROtherWinState extends StateBase<EXPlayer>{

	@Override
	public void enter(EXPlayer owner) {
		EXRoom room = (EXRoom) owner.room;
		owner.winer = 1;
		int score = 1;
		EXPlayer activePlayer =  (EXPlayer)room.playerMapBySeat.get(owner.room.activeSeat);
		for (Map.Entry<Integer, WinCardType> entry : owner.winMap.entrySet()) {
			WinCardType wct = entry.getValue();
			for(int i = 0;i<wct.value; ++i) {
				score = wct.score * score;
			}
		}
		if (score>1){
			room.addScore(owner,activePlayer,score,EXScore.WIN);
		}


		activePlayer.winer = 2;
		activePlayer.last_winer = 2;


		if (room.lastBankerSeat == 0)
		{
			room.lastBankerSeat = room.bankerSeat;
		}
		room.bankerSeat = owner.seat;
		room.winCount += 1;

		owner.winCard = room.activeCard;

		room.winCallback( owner ,owner.winCard);
	}

}
