package org.achacha.webcardgame.game.dbo;

import org.achacha.base.db.BaseIndexedDbo;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Player
 */
public class PlayerDbo extends BaseIndexedDbo {
    private static final Logger LOGGER = LogManager.getLogger(PlayerDbo.class);

    /** Player id */
    protected long id;

    /** Login that owns this player */
    protected long loginId;

    /** Energy stores in the inventory */
    protected long energy;

    /** Inventory */
    protected InventoryDbo inventory;

    @Override
    public long getId() {
        return this.id;
    }

    @Override
    public void fromResultSet(ResultSet rs) throws SQLException {
        this.id = rs.getLong("id");
        this.loginId = rs.getLong("login__id");
        this.energy = rs.getLong("energy");
        this.inventory = InventoryDboFactory.getByPlayerId(this.id);

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("fromResultSet: this="+this);
        }
    }

    public long getEnergy() {
        return energy;
    }
}

@@ -220,16 +220,45 @@
 ception;
+%0Aimport java.util.Collection;
 %0A%0A/**%0A *
@@ -637,24 +637,83 @@
 inventory;%0A%0A
+    /** Cards */%0A    protected Collection%3CCardDbo%3E cards;%0A%0A
     @Overrid
@@ -975,24 +975,25 @@
 (%22energy%22);%0A
+%0A
         this
@@ -1048,16 +1048,76 @@
 his.id);
+%0A        this.cards = CardDboFactory.getByPlayerId(this.id);
 %0A%0A      

Add cards loading to player