public void checkQuestAfterGame(Match match, boolean win)
{
Logable D = Configuration.getConfiguration().getDebugEntity();
MatchPlayable p = match.getPlayer(1);
MatchComputerPlayer cplayer = null;
if (p instanceof MatchComputerPlayer) cplayer = (MatchComputerPlayer)p; else return;
QuestDefinitionDataPool mQuestDefinitionDataPool = new QuestDefinitionDataPool();
for (int i = 0; i < mData.mQuestsActive.size(); i++)
{
String qname = mData.mQuestsActive.elementAt(i);
QuestDefinitionData quest = mQuestDefinitionDataPool.get(qname);
if (quest == null) continue; // only possible by renaming quests or the like
if (win)
{
D.addLog("Quest type was("+i+"): "+quest.getTaskType(), 3);
if ((quest.getTaskType().equals(Q_DEFEAT_OPPONENT))
|| (quest.getTaskType().equals(Q_DEFEAT_OPPONENT_ONCE))
|| (quest.getTaskType().equals(Q_DEFEAT_OPPONENT_TIMES))
|| (quest.getTaskType().equals(Q_DEFEAT_OPPONENT_TIMES_IN_ROW))
)
{
// OPPONENT CORRECT DEFEATED
if (quest.getNeededOponent().equals(cplayer.getAIPlayer().mNamedAI.mName))
{
QuestData data = getQuestData(quest);
data.opponentName = cplayer.getAIPlayer().mNamedAI.mName;
data.count++;
replaceNewQuestDataStorage(quest, data);
}
}
if (quest.getTaskType().equals(Q_DONT_LOSE_MORE_X_CREATURES))
{
D.addLog("Q_DONT_LOSE_MORE_X_CREATURES creaturesWereDestroyed"+match.mResults.creaturesWereDestroyed[0], 3);
D.addLog("Q_DONT_LOSE_MORE_X_CREATURES quest.getCount()"+quest.getCount(), 3);
if (match.mResults.creaturesWereDestroyed[0] <= quest.getCount())
{
QuestData data = getQuestData(quest);
data.count = match.mResults.creaturesWereDestroyed[0];
replaceNewQuestDataStorage(quest, data);
}
}
if (quest.getTaskType().equals(Q_KILL_X_OPPONENT_CREATURES))
{
D.addLog("Q_KILL_X_OPPONENT_CREATURES creaturesWereDestroyed"+match.mResults.creaturesWereDestroyed[1], 3);
D.addLog("Q_KILL_X_OPPONENT_CREATURES quest.getCount()"+quest.getCount(), 3);
if (match.mResults.creaturesWereDestroyed[1] >= quest.getCount())
{
QuestData data = getQuestData(quest);
data.count = match.mResults.creaturesWereDestroyed[1];
replaceNewQuestDataStorage(quest, data);
}
}
if (quest.getTaskType().equals(Q_WIN_IN_X_TURNS))
{
D.addLog("Q_WIN_IN_X_TURNS match.getRound()"+match.getRound(), 3);
D.addLog("Q_WIN_IN_X_TURNS quest.getCount()"+quest.getCount(), 3);
// Rounds played AT GAME END
if (match.getRound() <= quest.getCount())
{
QuestData data = getQuestData(quest);
data.count = match.getRound();
replaceNewQuestDataStorage(quest, data);
}
}
if ((quest.getTaskType().equals(Q_LIFE_WHEN_QUIT))
)
{
// LIFE AT GAME END
if (match.getLife(match.getPlayer(0)) >= quest.getCount())
{
QuestData data = getQuestData(quest);
data.count = match.getLife(match.getPlayer(0));
replaceNewQuestDataStorage(quest, data);
}
}
if ((quest.getTaskType().equals(Q_DEFEAT_OPPONENT_WITH_DECK))
)
{
// OPPONENT CORRECT DEFEATED
if (quest.getNeededOponent().equals(cplayer.getAIPlayer().mNamedAI.mName))
{
if (quest.getPossibleDecks().elementAt(0).equals(getSelectedDeckName()))
{
QuestData data = getQuestData(quest);
data.opponentName = cplayer.getAIPlayer().mNamedAI.mName;
data.opponentDeck = getSelectedDeckName();
data.count++;
replaceNewQuestDataStorage(quest, data);
}
}
}
/*
// OPPONENT DECK CORRECT DEFEATED
if (quest.getOpponentDeck().equals(cplayer.getAIPlayer().getSelectedDeckName()))
{
QuestData data = getQuestData(quest);
data.opponentDeck = cplayer.getAIPlayer().getSelectedDeckName();
replaceNewQuestDataStorage(quest, data);
}
*/
}
else
{
if ( (quest.getTaskType().equals(Q_DEFEAT_OPPONENT_TIMES_IN_ROW))
)
{
// OPPONENT CORRECT DEFEATED
if (quest.getNeededOponent().equals(cplayer.getAIPlayer().mNamedAI.mName))
{
QuestData data = getQuestData(quest);
data.opponentName = cplayer.getAIPlayer().mNamedAI.mName;
data.count = 0;
replaceNewQuestDataStorage(quest, data);
}
}