diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-22 05:35:16 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-22 05:35:16 +0100 |
commit | 13553219be27a8c7e4db029fa7ac8a407758b24d (patch) | |
tree | 134af784ad9b168b8ac382d3ea7ce5cefcb9d561 /core/src/ch/asynk | |
parent | 81c12a6760699dd07612ab771d6e3698c447e9d5 (diff) | |
download | RustAndDust-13553219be27a8c7e4db029fa7ac8a407758b24d.zip RustAndDust-13553219be27a8c7e4db029fa7ac8a407758b24d.tar.gz |
DB: add deleteGame(GameRecord)
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r-- | core/src/ch/asynk/rustanddust/util/DB.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/core/src/ch/asynk/rustanddust/util/DB.java b/core/src/ch/asynk/rustanddust/util/DB.java index e1cf1a5..95ed675 100644 --- a/core/src/ch/asynk/rustanddust/util/DB.java +++ b/core/src/ch/asynk/rustanddust/util/DB.java @@ -74,6 +74,7 @@ public class DB private static final String UPDATE_GAME = "update games set _p1=%d, _p2=%d, ts=current_timestamp where _id=%d;"; private static final String GET_STATE = "select payload from states where _g=%d;"; private static final String GET_GAMES = "select g.*, p1.name, p2.name, b.name from games g inner join players p1 on (g._p1=p1._id) inner join players p2 on (g._p2=p2._id) inner join battles b on (g._b=b._id);"; + private static final String DELETE_GAME = "delete from turns where _g=%d; delete from states where _g=%d; delete from games where _id=%d;"; private static final String DB_CRT = TBL_CFG_CRT + TBL_PLAYERS_CRT + TBL_BATTLES_CRT + TBL_GAMES_CRT + TBL_TURNS_CRT + TBL_STATES_CRT; @@ -239,6 +240,19 @@ public class DB return ret; } + public boolean deleteGame(GameRecord game) + { + RustAndDust.debug("deleteGame"); + try { + exec(String.format(DELETE_GAME, game.g, game.g, game.g)); + } catch (SQLiteGdxException e) { + RustAndDust.error("deleteGame"); + return false; + } + return true; + + } + public void loadGames() { RustAndDust.debug("loadGames"); |