Delete row when a player loses their win streak

This commit is contained in:
Sam 2017-11-08 11:56:28 +00:00 committed by Alexander Meech
parent 43867a7018
commit 0b7e5d15e0
2 changed files with 10 additions and 1 deletions

View File

@ -74,7 +74,7 @@ public class WinStreakManager extends MiniDbClientPlugin<Map<Integer, Integer>>
if (map.containsKey(game.getGameId()))
{
runAsync(() -> _repository.setWinStreak(ClientManager.getAccountId(player), game.getGameId(), 0));
runAsync(() -> _repository.removeWinStreak(ClientManager.getAccountId(player), game.getGameId()));
}
}
}

View File

@ -8,6 +8,7 @@ class WinStreakRepository extends RepositoryBase
{
private static final String UPDATE_OR_INSERT = "REPLACE INTO accountWinStreak VALUES(?,?,?)";
private static final String DELETE = "DELETE FROM accountWinStreak WHERE accountId=? AND gameId=?";
WinStreakRepository()
{
@ -22,4 +23,12 @@ class WinStreakRepository extends RepositoryBase
new ColumnInt("value", value)
);
}
void removeWinStreak(int accountId, int gameId)
{
executeUpdate(DELETE,
new ColumnInt("accountId", accountId),
new ColumnInt("gameId", gameId)
);
}
}