package extend.mj.player.rulestate;

import java.util.Map.Entry;

import com.game.Global;
import com.game.state.StateBase;

import extend.mj.*;

/**
 * 
 */
public class PROtherWinState extends StateBase<EXPlayer>{

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

		room.addPiaoNiaoScore(owner, activePlayer);
		Global.logger.info(owner + " otherWin:" + owner.winMap.toString());
		
		
		activePlayer.settleLog.add(owner.winMap.containsKey(WinCardType.XIAOHU)?Config.SETTLE_XIAO_DIAN_PAO:Config.SETTLE_DA_DIAN_PAO);
		activePlayer.winer = 2;
		activePlayer.win_count = 0;
		
		room.winCount += 1;
		owner.winer = 1;
		
		owner.winCard = room.activeCard;
		
		owner.settleLog.add(owner.winMap.containsKey(WinCardType.XIAOHU)?Config.SETTLE_XIAO_JIE_PAO:Config.SETTLE_DA_JIE_PAO);
		EXMainServer.gameCtr.winEvent(owner,activePlayer.seat);
		
		room.winCallback( owner);
	}

}
