Package model

Examples of model.PlantType


            connection = DAO.getDataSource().getConnection();
            pstmt = connection.prepareStatement(query);
            ResultSet rs = pstmt.executeQuery();

            while (rs.next()) {
                PlantType plant = new PlantType(rs.getInt("plant_type_id"));
                plant.setSpeciesName(rs.getString("species_name"));
                plant.setCost(rs.getInt("cost"));
                plant.setDescription(rs.getString("description"));
                plant.setCategory(rs.getString("category"));
                plant.setAvgBiomass(rs.getInt("max_biomass"));
                plant.setWaterNeedFrequency(rs.getInt("water_need_frequency"));
                plant.setLightNeedFrequency(rs.getInt("light_need_frequency"));
                plant.setGrowRadius(rs.getFloat("grow_radius"));
                plant.setCarryingCapacity(rs.getFloat("carrying_capacity"));

                String[] nodeList = rs.getString("node_list").split(",");

                int[] newNodeList = new int[nodeList.length];
                HashMap<Integer, Integer> nodeAmountList = new HashMap<Integer, Integer>();

                for (int i = 0; i < nodeList.length; i++) {
                    String[] nodePair = nodeList[i].split(":");

                    newNodeList[i] = Integer.parseInt(nodePair[0]);

                    if (nodePair.length == 1) {
                        nodeAmountList.put(newNodeList[i], 1);
                    } else {
                        nodeAmountList.put(newNodeList[i], Integer.parseInt(nodePair[1]));
                    }
                }

                plant.setNodeList(newNodeList);
                plant.setNodeAmountList(nodeAmountList);

                plant.setTrophicLevel(rs.getFloat("trophic_level"));
                plant.setGrowthRate(rs.getFloat("growth_rate"));
                plant.setModelID(rs.getInt("model_id"));
                plant.setHealChance(rs.getFloat("heal_chance"));
                plant.setGroupCapacity(rs.getInt("group_capacity"));
                plantList.add(plant);
            }

            rs.close();
            pstmt.close();

            HashMap<Integer, List<Integer>> hPredatorMap = HerbivoreDAO.getPreyToPredatorTable();

            for (PlantType plant : plantList) {
                int plant_id = plant.getID();

                if (hPredatorMap.containsKey(plant_id)) {
                    for (int predator_id : hPredatorMap.get(plant_id)) {
                        plant.addPredatorID(predator_id, Constants.ORGANISM_TYPE_ANIMAL);
                    }
                }
            }
        } finally {
            if (connection != null) {
View Full Code Here


            for (SpeciesType species : unlockList) {
                packet.addShort16((short) species.getGroupType());

                if (species.getGroupType() == Constants.ORGANISM_TYPE_PLANT) {
                    PlantType plant = (PlantType) species;

                    packet.addShort16((short) plant.getID());
                    packet.addString(plant.getSpeciesName());
                    packet.addString(plant.getDescription());
                    packet.addString(plant.getCategory());
                    packet.addShort16((short) plant.getCost());

                    String predatorList = "";
                    for (SpeciesType predator : plant.getPredatorList(Constants.ORGANISM_TYPE_ANIMAL)) {
                        predatorList += predator.getSpeciesName() + ", ";
                    }
                    if (predatorList.endsWith(", ")) {
                        predatorList = predatorList.substring(0, predatorList.lastIndexOf(","));
                    }

                    packet.addString(predatorList);
                    packet.addInt32(plant.getModelID());
                    packet.addInt32((int) plant.getAvgBiomass());
                } else if (species.getGroupType() == Constants.ORGANISM_TYPE_ANIMAL) {
                    AnimalType animal = (AnimalType) species;

                    packet.addShort16((short) animal.getID());
                    packet.addString(animal.getSpeciesName());
View Full Code Here

TOP

Related Classes of model.PlantType

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.