Skip to content
This repository has been archived by the owner on Jun 10, 2020. It is now read-only.

Commit

Permalink
fix wrong popup when cancelled "finding opponent"
Browse files Browse the repository at this point in the history
  • Loading branch information
tyrcho committed Oct 18, 2014
1 parent 92b87b4 commit 824be99
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class GameMonitor(
case FirstTurn(image) =>
testForCoin(image)
testForOpponentName(image)
matchState.started = true

case StartingHand(image) =>
testForCoin(image)
Expand Down Expand Up @@ -173,14 +174,9 @@ class GameMonitor(
inGameAnalyser.imageShowsVictoryOrDefeat(image) match {
case Some(outcome) =>
uiLog.info(s"Result detected by screen capture : $outcome")
if (matchState.currentMatch.isEmpty) {
uiLog.warn("Result detected but match start was not detected")
matchState.nextMatch(companionState)
}
hsMatch.result = Some(outcome)
matchUtils.submitMatchResult()
case _ =>
BackgroundImageSave.savePngImage(image, "match_end" + Random.nextInt)
debug("Result not detected on screen capture")
}
}
Expand Down Expand Up @@ -248,7 +244,7 @@ class GameMonitor(
}

private def handlePlayLobby(evt: ScreenEvent): Unit = {
if (matchState.lastMatch.isDefined && !matchState.submitted) {
if (matchState.lastMatch.isDefined && !matchState.submitted && matchState.started) {
matchUtils.submitMatchResult()
}
mode(evt.image) match {
Expand Down Expand Up @@ -308,5 +304,11 @@ class GameMonitor(
}
}

def hsMatch = matchState.currentMatch.get
def hsMatch = {
if (matchState.currentMatch.isEmpty) {
uiLog.warn("Match start was not detected")
matchState.nextMatch(companionState)
}
matchState.currentMatch.get
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class MatchState {
var lastMatch: Option[HearthstoneMatch] = None
var startTime: Long = _
var submitted = false
var started = false

def setOpponentName(n: String) = currentMatch.get.opponentName = n
def setNotes(n: String) = currentMatch.get.notes = n
Expand All @@ -27,6 +28,7 @@ class MatchState {
mode = companionState.mode,
rankLevel = companionState.rank))
submitted = false
started = false
}

}

0 comments on commit 824be99

Please sign in to comment.