Lock Set deck --> if(card.isLocked() == true)
This commit is contained in:
parent
8e44e37804
commit
2c9242e45c
@ -49,6 +49,29 @@ public class DBConnection {
|
||||
return PostgresHelper.executeUpdate("Update user_cards set gesperrt = " + lock + " where name = \'" + name + "\';");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prüft ob eine Card für das Deck gesperrt ist
|
||||
* @param name Name der Card die zu prüfen ist
|
||||
* @return True falls gesperrt, ansonst false
|
||||
* @throws SQLException Locked Cards konnten nicht aus der DB geholt werden
|
||||
*/
|
||||
public boolean getCardLock(String name) throws SQLException {
|
||||
this.c = PostgresHelper.con();
|
||||
ArrayList<TradingDeal> tradingDeals = new ArrayList<TradingDeal>();
|
||||
boolean locked = false;
|
||||
stmt = this.c.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("select gesperrt from user_cards where name = \'" + name + "\';");
|
||||
while (rs.next()) {
|
||||
locked = rs.getBoolean("gesperrt");
|
||||
}
|
||||
rs.close();
|
||||
stmt.close();
|
||||
this.c.close();
|
||||
System.out.println("Trading Deals pulled successfully");
|
||||
return locked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Löscht einen Trading Deal aus der Datenbank
|
||||
* @param id Id des deals der gelöscht werden soll
|
||||
@ -129,6 +152,16 @@ public class DBConnection {
|
||||
* @return True bei erfolg, sonst false
|
||||
*/
|
||||
public boolean setDeck(String username, List<String> deck){
|
||||
for (String st :deck) {
|
||||
try {
|
||||
if(getCardLock(st)){
|
||||
return false;
|
||||
}
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!delDeck(username)){
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user