Package model

Examples of model.PvEWorldMap


                WorldMapDAO.savePvPWorldMap(pvpMap);
            } else if (world.getGameMode() == Constants.GAME_TYPE_PVE) {
                client.getServer().addToActivePvEWorld(world);

                //Create a pve map for this world
                PvEWorldMap pveMap = new PvEWorldMap(world.getID());
                client.getServer().addPvEWorldMap(pveMap);

                WorldMapDAO.savePvEWorldMap(pveMap);
            }
View Full Code Here


     * @return Returns a PvEWorldMapType from database by matching worldIDFk
     * If none found returns null.
     * @throws SQLException
     */
    public static PvEWorldMap getPvEWorldMapByWorldID(int worldId) throws SQLException {
        PvEWorldMap returnPvEWorldMap = null;

        if (worldId <= 0) {
            System.out.println("In WorldMapDAO.java -- worldId, passed argument, value is: " + worldId);
            System.out.println("Expected value > 0\nReturning null.");
        } else {
            String query = "SELECT * FROM world_map WHERE world_id = ?";

            Connection connection = null;
            PreparedStatement pstmt = null;

            try {
                connection = DAO.getDataSource().getConnection();
                pstmt = connection.prepareStatement(query);
                pstmt.setInt(1, worldId);
                ResultSet rs = pstmt.executeQuery();

                if (rs.next()) {
                    returnPvEWorldMap = new PvEWorldMap(rs.getInt("world_id"));
                    returnPvEWorldMap.setTableId(rs.getInt("table_id"));
                    returnPvEWorldMap.setTeam0Map(rs.getString("team0_map"));
                    returnPvEWorldMap.setSquareSize(rs.getInt("square_size"));
                }

                rs.close();
                pstmt.close();
            } catch (SQLException ex) {
View Full Code Here

     * @return Returns a PvEWorldMapType from database by matching worldIDFk,
     * which is extracted from passed map. If none found returns null.
     * @throws SQLException
     */
    public static PvEWorldMap getPvEWorldMapByWorldID(PvEWorldMap map) throws SQLException {
        PvEWorldMap returnPvEWorldMap = null;

        if (map == null || map.getWorldID() <= 0) {
            System.out.println("In WorldMapDAO.java -- map is null or worldIDFk <= 0");
            System.out.println("Expected value > 0\nReturning null");
        } else {
            String query = "SELECT * FROM world_map WHERE world_id = ?";

            Connection connection = null;
            PreparedStatement pstmt = null;

            try {
                connection = DAO.getDataSource().getConnection();
                pstmt = connection.prepareStatement(query);
                pstmt.setInt(1, map.getWorldID());
                ResultSet rs = pstmt.executeQuery();

                if (rs.next()) {
                    returnPvEWorldMap = new PvEWorldMap(rs.getInt("world_id"));
                    returnPvEWorldMap.setTableId(rs.getInt("table_id"));
                    returnPvEWorldMap.setTeam0Map(rs.getString("team0_map"));
                    returnPvEWorldMap.setSquareSize(rs.getInt("square_size"));
                }

                rs.close();
                pstmt.close();
            } catch (SQLException ex) {
View Full Code Here

     * @return Returns a PvEWorldMapType from database by matching worldIdPk,
     * which is extracted from passed world. If none found returns null.
     * @throws SQLException
     */
    public static PvEWorldMap getPvEWorldMapByWorldID(World world) throws SQLException {
        PvEWorldMap returnPvEWorldMap = null;

        if (world == null || world.getID() <= 0) {
            System.out.println("In WorldMapDAO.java -- world is null or worldIdPk <= 0");
            System.out.println("Expected value > 0\nReturning null");
        } else {
            String query = "SELECT * FROM world_map WHERE world_id = ?";

            Connection connection = null;
            PreparedStatement pstmt = null;

            try {
                connection = DAO.getDataSource().getConnection();
                pstmt = connection.prepareStatement(query);
                pstmt.setInt(1, world.getID());
                ResultSet rs = pstmt.executeQuery();

                if (rs.next()) {
                    returnPvEWorldMap = new PvEWorldMap(rs.getInt("world_id"));
                    returnPvEWorldMap.setTableId(rs.getInt("table_id"));
                    returnPvEWorldMap.setTeam0Map(rs.getString("team0_map"));
                    returnPvEWorldMap.setSquareSize(rs.getInt("square_size"));
                }

                rs.close();
                pstmt.close();
            } catch (SQLException ex) {
View Full Code Here

    public static void updatePvEWorldMap(PvEWorldMap map) throws SQLException {
        if (map == null || map.getWorldID() <= 0) {
            System.out.println("In WorldMapDAO.java -- map is null or worldIDFk <= 0");
            System.out.println("Expected value > 0");
        } else {
            PvEWorldMap checkPvEWorldMap = getPvEWorldMapByWorldID(map.getWorldID());
            if (checkPvEWorldMap == null || checkPvEWorldMap.getTableId() == 0) {
                System.out.println("PvEWorldMap does not exist in the database.");
            } else {
                String query = "UPDATE world_map SET world_id = ?, team0_map = ?, team1_map = ?, square_size = ? WHERE table_id = ?";

                Connection connection = null;
                PreparedStatement pstmt = null;

                try {
                    connection = DAO.getDataSource().getConnection();
                    pstmt = connection.prepareStatement(query);
                    pstmt.setInt(1, map.getWorldID());
                    pstmt.setString(2, map.getTeam0Map());
                    pstmt.setString(3, "N/A");
                    pstmt.setInt(4, map.getSquareSize());
                    pstmt.setInt(5, checkPvEWorldMap.getTableId());
                    pstmt.execute();
                    pstmt.close();
                } finally {
                    if (connection != null) {
                        connection.close();
View Full Code Here

            pvpMap.printObject();
        }

        System.out.println("All PvE maps====================");
        for (Integer key : pveWorldMaps.keySet()) {
            PvEWorldMap pveMap = pveWorldMaps.get(key);
            pveMap.toString();
        }
        System.out.println("********All maps end**********");
    }
View Full Code Here

                            pvpMap.quitOldTeamAndPosition(env.getRow(), env.getColumn());
                            pvpMap.printObject();

                            WorldMapDAO.updatePvPWorldMap(pvpMap);
                        } else if (world.getGameMode() == Constants.GAME_TYPE_PVE) {
                            PvEWorldMap pveMap = client.getServer().getPvEWorldMap(world.getID());
                            int position = pveMap.getPositionBasingOnRowAndCol(env.getRow(), env.getColumn());
                            pveMap.quitPosition(position);
                            pveMap.toString();

                            WorldMapDAO.updatePvEWorldMap(pveMap);
                        }

                        //Delete the environment from database.
View Full Code Here

                int world_id = WorldDAO.createWorld(world);
                world.setID(world_id);

                client.getServer().addToActivePvEWorld(world);

                PvEWorldMap pveMap = new PvEWorldMap(world.getID());
                client.getServer().addPvEWorldMap(pveMap);

                WorldMapDAO.savePvEWorldMap(pveMap);

                world.setGameEngine(client.getServer().createGameEngine(world));
            }
        }

        if (world == null) {
            world = WorldDAO.getWorldByName(worldName);

            if (world != null) {
                world.setGameEngine(client.getServer().createGameEngine(world));
                world.setEnvironments(EnvironmentDAO.getEnvironmentByWorldID(world.getID()));

                client.getServer().addToActivePvEWorld(world);
                client.getServer().addPvEWorldMap(WorldMapDAO.getPvEWorldMapByWorldID(world.getID()));
            }
        }

        if (world != null && !world.hasPlayer(client.getPlayer().getID())) {//If the pve world is active
            //Try to see if the environment of the current player is in the world buffer.
            if (world.hasEnvironmentOfPlayer(client.getPlayer().getID())) {
                responseJoinPvEWorld.setStatus((short) 0);
                responseJoinPvEWorld.setWorld(world);

                world.setPlayer(client.getPlayer());
                responseGetEnv.setWorld(world);
                client.setWorld(world);

                WorldDAO.updateLastPlayed(world.getID());

                for (Environment env : world.getEnvironments()) {
                    for (Zone zone : env.getZones()) {
                        if (zone.isEnable()) {
                            zone.setScoreCSV(ScoreCSVDAO.getCSV(zone.getID()));

                            zone.setParameters(ParamTableDAO.getByZoneID(zone.getID()));
                            PreyPredatorRatioDAO.createParameters(world.getCreatorID(),zone.getID());
                            HashMap<Integer, Integer[]> speciesList = ZoneSpeciesDAO.getSpecies(zone.getID());
                            HashMap<Integer, List<Object[]>> groupList = ZoneGroupsDAO.getGroups(zone.getID());

                            for (int species_id : speciesList.keySet()) {
                                Integer[] value = speciesList.get(species_id);
                                int num_groups = value[0], amount = value[1];

                                if (amount != 0 && num_groups != 0) {
                                    List<Object[]> groups = groupList.get(species_id);
                                    world.getGameEngine().createExistingOrganisms(species_id, zone.getID(), num_groups, amount, groups, Constants.CREATE_STATUS_DEFAULT);
                                }
                            }

                            zone.setBirthList(BirthListDAO.getList(zone.getID()));
                            zone.setDeathList(DeathListDAO.getList(zone.getID()));

                            zone.setAddNodeList(ZoneNodeAddDAO.getList(zone.getID()));
                        }
                    }
                }
            } else {
                if (world.getEnvironments().size() < world.getMaxPlayers()) {
                    responseJoinPvEWorld.setStatus((short) 0);
                    responseJoinPvEWorld.setWorld(world);

                    //Create an environment for this player
                    PvEWorldMap map = client.getServer().getPvEWorldMap(world.getID());

                    if (map != null) {
                        int position = map.assignEnvironmentPosition();
                        int row = map.getRow(position);
                        int col = map.getCol(position);

                        WorldMapDAO.updatePvEWorldMap(map);

                        //Create a new environment for this user.
                        Environment env = new Environment(-1);
View Full Code Here

TOP

Related Classes of model.PvEWorldMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.