if (mPlayerTurn == 0)
{
if (mPlayers[0].getPlayerType() == TYPE_HUMAN)
{
MatchHumanPlayer hp = (MatchHumanPlayer) mPlayers[0];
Player player = hp.getPlayer();
int c = getBattlefield(mPlayers[0]).getSubListByType("Creature").size();
if (c > player.getData().getCreatureMax())
player.getData().setCreatureMax(c);
c = getLife(mPlayers[0]);
if (c > player.getData().getMaxHPInGame())
player.getData().setMaxHPInGame(c);
if (combatDamageDealt > player.getData().getMaxDamageDealtToOtherPlayer())
player.getData().setMaxDamageDealtToOtherPlayer(combatDamageDealt);
// check Achievments
Achievement achievement = player.getNextSuccessfullAchievment("Sets");
while (achievement != null)
{
player.addDoneAchievment(achievement);
player.save();
mDisplay[0].setAchievmentInfo(achievement);
achievement = player.getNextSuccessfullAchievment();
}
combatDamageDealt = 0;
}
}
else
{
if (mPlayers[0].getPlayerType() == TYPE_HUMAN)
{
MatchHumanPlayer hp = (MatchHumanPlayer) mPlayers[0];
Player player = hp.getPlayer();
if (combatDamageDealt > player.getData().getMaxDamageSurvived())
player.getData().setMaxDamageSurvived(combatDamageDealt);
int c = getLife(mPlayers[0]);
if (c > player.getData().getMaxHPInGame())
player.getData().setMaxHPInGame(c);
// check Achievments
Achievement achievement = player.getNextSuccessfullAchievment("Sets");
while (achievement != null)
{
player.addDoneAchievment(achievement);
player.save();
mDisplay[0].setAchievmentInfo(achievement);
achievement = player.getNextSuccessfullAchievment();
}
combatDamageDealt = 0;
}
}
}
mCurrentPhase = PHASES[PHASE_BEGINNING_UNTAP];
Weighting weightingUsed = Weighting.DEFAULT;
if (mPlayerTurn == 0)
{
if (mPlayers[0] instanceof MatchComputerPlayer)
{
MatchComputerPlayer cp = (MatchComputerPlayer) mPlayers[0];
AIPlayer aip = cp.getAIPlayer();
if (!aip.isScriptedAI())
{
EAIConfigurationData eaiConfig = aip.getEAIConfig();
if (eaiConfig != null)
{
String wName = eaiConfig.getActiveWeightingCollection();
weightingUsed = Weighting.buildWeighting(wName);
}
}
}
}
else // if(mPlayerTurn == 1)
{
if (mPlayers[1] instanceof MatchComputerPlayer)
{
MatchComputerPlayer cp = (MatchComputerPlayer) mPlayers[1];
AIPlayer aip = cp.getAIPlayer();
if (!aip.isScriptedAI())
{
EAIConfigurationData eaiConfig = aip.getEAIConfig();
if (eaiConfig != null)
{
String wName = eaiConfig.getActiveWeightingCollection();
weightingUsed = Weighting.buildWeighting(wName);
}
}
}
}
weightingUsed.buildScore(this, mPlayerTurn, true);
weightingUsed.buildScore(this, mPlayerNotTurn, true);
if (!isInTestMode()) if (Configuration.getConfiguration().isShowScoreAndPauseEachRound())
{
setPause(true);
WeightingPanel panel = new WeightingPanel(mPlayerTurn, weightingUsed);
mMainDisplay.showPanelModal(panel, "Weighting player: " +mPlayerTurn);
panel=null;
setPause(false);
}
mPlayerNotTurn = mPlayerTurn;
mPlayerTurn = (mPlayerTurn+1) % PLAYER_COUNT;
mPlayerActive = mPlayerTurn;
D.addLog("M:\n-------\nNew Turn " +getPhaseString(mPlayers[mPlayerTurn])+"\n-------"+mPlayers[mPlayerTurn], 3);
mRound++;
triggerCheck=true;
checkAndEnqueueTriggers(mPlayers[mPlayerTurn], CardTrigger.TRIGGER_PHASE_START_TARGET_PLAYER, 0, null);
checkRemoveTempEffectsTurnCount();
checkEvents(0, AIEffect.AI_EFFECT_TRIGGER_ROUND_NO, null);
checkEvents(1, AIEffect.AI_EFFECT_TRIGGER_ROUND_NO, null);
checkEvents(0, AIEffect.AI_EFFECT_TRIGGER_EVERY_ROUND, null);
checkEvents(1, AIEffect.AI_EFFECT_TRIGGER_EVERY_ROUND, null);
combatDamageDealt = 0;
initNewRound();
if (deinitDone) return false;
}
checkAndEnqueueTriggers(mPlayers[mPlayerTurn], CardTrigger.TRIGGER_PHASE_START_GENERAL, 0, null);
checkAndEnqueueTriggers(mPlayers[mPlayerNotTurn], CardTrigger.TRIGGER_PHASE_START_GENERAL, 0, null);
if (PHASE_COMBAT_DECLARE_BLOCKERS != mCurrentPhase)
if (!triggerCheck)
checkAndEnqueueTriggers(mPlayers[mPlayerTurn], CardTrigger.TRIGGER_PHASE_START_TARGET_PLAYER, 0, null);
initStackCheck(mPlayers[mPlayerTurn]);
switch (mCurrentPhase)
{
case PHASE_BEGINNING_UNTAP:
{
// todo auto untap
break;
}
case PHASE_BEGINNING_UPKEEP:
{
break;
}
case PHASE_BEGINNING_DRAW:
{
// if (mCurrentPhase == PHASE_BEGINNING_DRAW)
{
if (getLibrary(mPlayers[mPlayerTurn]).size()==0)
{
mPd[mPlayerTurn].mLife=0;
loser = mPlayers[mPlayerTurn];
mResults.winner[mPlayerTurn] = false;
mResults.winner[(mPlayerTurn+1)%2] = true;
mResults.lifeLeft[0] = getLife(mPlayers[0]);
mResults.lifeLeft[1] = getLife(mPlayers[1]);
}
}
break;
}
case PHASE_MAIN1:
{
break;
}
case PHASE_COMBAT_BEGIN:
{
break;
}
case PHASE_COMBAT_DECLARE_ATTACKERS:
{
initAttackPhase();
break;
}
case PHASE_COMBAT_DECLARE_BLOCKERS:
{
checkEvents(mPlayerTurn, AIEffect.AI_EFFECT_TRIGGER_ATTACKING_WITH, null);
checkEvents(mPlayerTurn, AIEffect.AI_EFFECT_TRIGGER_ATTACKING_WITH_HIGHER, null);
mPlayerActive = mPlayerNotTurn;
checkAndEnqueueTriggers(mPlayers[mPlayerActive], CardTrigger.TRIGGER_PHASE_START_TARGET_PLAYER, 0, null);
initStackCheck(mPlayers[mPlayerActive]);
break;
}
case PHASE_COMBAT_DAMAGE:
{
checkEvents(mPlayerNotTurn, AIEffect.AI_EFFECT_TRIGGER_BLOCKING_WITH, null);
checkEvents(mPlayerNotTurn, AIEffect.AI_EFFECT_TRIGGER_BLOCKING_WITH_HIGHER, null);
mAttackInitiated = false;
break;
}
case PHASE_COMBAT_END:
{
cleanupCombat();
break;
}
case PHASE_MAIN2:
{
break;
}
case PHASE_END_END:
{
break;
}
case PHASE_END_CLEANUP:
{
break;
}
default:
{
break;
}
}
if (loser!=null)
{
playSound(null, SoundEffect.FX_EFFECT_GAME_END);
mDisplay[0].setGameOver(loser);
mDisplay[1].setGameOver(loser);
if (mOptions.isQuestMode())
{
Player player = ((MatchHumanPlayer)mPlayers[0]).getPlayer();
AIPlayer aiplayer = ((MatchComputerPlayer)mPlayers[1]).getAIPlayer();
player.incPlayed();
if ((mPd[0].mLife <= 0) && (mPd[1].mLife<=0))
{
player.restoreQuestState();
player.incDraw();
player.addDollar((aiplayer.getWinMoney()+1)/2);
player.checkQuestAfterGame(match, false);
}
else if (mPd[0].mLife <= 0)
{
player.restoreQuestState();
player.incLose();
player.addDollar((aiplayer.getWinMoney()+9)/10);
player.checkQuestAfterGame(match, false);
}
else
{
player.incWin();
player.addDollar(aiplayer.getWinMoney());
player.checkQuestAfterGame(match, true);
}
player.save();
// check Achievments
Achievement achievement = player.getNextSuccessfullAchievment("Sets");
while (achievement != null)
{
player.addDoneAchievment(achievement);
player.save();
mDisplay[0].setAchievmentInfo(achievement);
achievement = player.getNextSuccessfullAchievment();
}
}
for (int i = 0; i < mPlayers.length; i++)
if (mPlayers[i] != null)