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

Commit

Permalink
fix victory/loss detection - match result can now be submitted !
Browse files Browse the repository at this point in the history
  • Loading branch information
tyrcho committed Oct 18, 2014
1 parent 8dbd734 commit 92b87b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,21 @@ class ImageToEvent(
case Some(screen) =>
iterationsSinceScreenMatched = 0
val e = eventFromScreen(screen, bi)
debug(e)
info(s"screen $screen => event $e")
e
case None =>
debug(s"no screen match on image, last match was $lastScreen $iterationsSinceScreenMatched iterations ago")
info(s"no screen match on image, last match was $lastScreen $iterationsSinceScreenMatched iterations ago")
iterationsSinceScreenMatched += 1
None
}
}

def canRepeatEvent(screen: Screen) =
(Seq(PLAY_LOBBY, PRACTICE_LOBBY, VERSUS_LOBBY) contains screen) ||
screen.group == ScreenGroup.MATCH_END

private def eventFromScreen(newScreen: Screen, image: BufferedImage): Option[GameEvent] =
if (lastScreen.isEmpty || lastScreen.get != newScreen || newScreen == Screen.PLAY_LOBBY || newScreen == Screen.PRACTICE_LOBBY) {
if (lastScreen.isEmpty || lastScreen.get != newScreen || canRepeatEvent(newScreen)) {
if (lastScreen != Some(newScreen)) {
debug(s"Screen : $lastScreen => $newScreen")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ object MockedMain extends TesseractSetup with App with Logging {
players -> 1,
"starting_hand_4_cards" -> 1,
"orgrimmar_with_coin" -> 20,
result -> 15)
"match_end" -> 5,
result -> 10,
"play_lobby" -> 1)

val firstGame = game("Druid_VS_Hunter", "defeat")
val secondGame = game("Priest_VS_Warlock", "victory_pandaria")
Expand All @@ -35,7 +37,7 @@ object MockedMain extends TesseractSetup with App with Logging {
main.start()

class MockProgramHelper(var files: List[(String, Int)]) extends ProgramHelper {
def foundProgram = true
def foundProgram = files.nonEmpty

def getScreenCapture = {
val (f, c) :: t = files
Expand Down

0 comments on commit 92b87b4

Please sign in to comment.