From 0dba5653994d79ddbe1f7c03f6363b7eee780313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 15 Mar 2016 13:43:33 +0100 Subject: DB: add storeTurn(int) that copies data from games table --- core/src/ch/asynk/rustanddust/util/DB.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/src/ch/asynk/rustanddust/util/DB.java b/core/src/ch/asynk/rustanddust/util/DB.java index 2e108ca..f143585 100644 --- a/core/src/ch/asynk/rustanddust/util/DB.java +++ b/core/src/ch/asynk/rustanddust/util/DB.java @@ -247,6 +247,19 @@ public class DB return getGameId(opponent, battle, mode); } + private static final String COPY_TURN = "insert into turns(game,turn,player,hash,payload) select _id, turn, player, hash, payload from games where _id=%d;"; + + public boolean storeTurn(int game) + { + try { + exec(String.format(COPY_TURN, game)); + } catch (SQLiteGdxException e) { + RustAndDust.error("storeTurn"); + return false; + } + return true; + } + private static final String INSERT_TURN = "insert into turns(game,turn,player,hash,payload) values (%d,%d,%d,'%s','%s');"; public boolean storeTurn(int game, int turn, int player, String payload) -- cgit v1.1-2-g2b99