Package worldManager.gameEngine.species

Examples of worldManager.gameEngine.species.Organism


    private Organism createOrganism(int species_id, int group_size) {
        return createOrganism(getUniqueID(), species_id, group_size);
    }

    private Organism createOrganism(int organism_id, int species_id, int group_size) {
        Organism organism = null;

        if (species_id / 1000 == 1) {
            organism = new Plant(organism_id);
        } else {
            organism = new Animal(organism_id);
        }

        organism.setSpeciesTypeID(species_id);
        organism.setBiomass(organism.getSpeciesType().getAvgBiomass());
        organism.setGroupSize(group_size);

        return organism;
    }
View Full Code Here


            int size = organismList.size();
           
            for (int i = 0; i < Math.max(Constants.MAX_SPECIES_SIZE, size) && amount > 0; i++) {
                SpeciesType species = GameServer.getInstance().getSpecies(species_id);

                Organism organism = null;
                int numBirths = 0;

                if (i < size) {
                    organism = organismList.get(i);
                    int numSpace = species.getGroupCapacity() - organism.getGroupSize();

                    if (numSpace > 0) {
                        numBirths = Math.min(numSpace, amount);
                        amount -= numBirths;

                        organism.setGroupSize(organism.getGroupSize() + numBirths);
                    }
                } else {
                    numBirths = Math.min(amount, species.getGroupCapacity());
                    amount -= numBirths;

                    organism = createOrganism(species_id, numBirths);
                    organismList.add(organism);
                }

                if (numBirths > 0) {
                    if (numBirthList.containsKey(organism)) {
                        numBirthList.put(organism, numBirthList.get(organism) + numBirths);
                    } else {
                        numBirthList.put(organism, numBirths);
                    }
                }
            }

            if (amount > 0) {
                int numOrganisms = organismList.size();
                int newBirths = amount / numOrganisms, remainder = amount % numOrganisms;

                for (int i = 0; i < numOrganisms && amount > 0; i++) {
                    int numBirths = i < remainder ? newBirths + 1 : newBirths;
                    amount -= numBirths;

                    Organism organism = organismList.get(i);
                    organism.setGroupSize(organism.getGroupSize() + numBirths);

                    if (numBirths > 0) {
                        if (numBirthList.containsKey(organism)) {
                            numBirthList.put(organism, numBirthList.get(organism) + numBirths);
                        } else {
View Full Code Here

            if (groups != null && i < groups.size()) {
                Object[] group = groups.get(i);
                int group_id = (Integer) group[0];
                float[] position = (float[]) group[1];

                Organism organism = createOrganism(group_id, species_id, numBirths);

                if (organism.getOrganismType() == Constants.ORGANISM_TYPE_PLANT) {
                    createOrganismByResponse(organism, numBirths, zone_id, status, position[0], position[1], Constants.CREATE_LOAD);
                } else if (organism.getOrganismType() == Constants.ORGANISM_TYPE_ANIMAL) {
                    createOrganismByResponse(organism, numBirths, zone_id, status, Constants.CREATE_LOAD);
                }
            } else {
                Organism organism = createOrganism(species_id, numBirths);
                createOrganismByResponse(organism, numBirths, zone_id, status, Constants.CREATE_LOAD);
            }
        }
    }
View Full Code Here

                Collections.sort(organismList, OrganismComparator.GroupSizeComparatorASC);

                int numOrganisms = organismList.size();

                for (int i = 0; i < numOrganisms && amount > 0; i++) {
                    Organism organism = organismList.get(numOrganisms - 1 - i);

                    int numDeaths = Math.min(organism.getGroupSize(), amount);
                    amount -= numDeaths;

                    Animal predator = zone.findPredator(organism);

                    if (predator != null) {
View Full Code Here

                GameServer.getInstance().updateCash(player, 0);

                Zone zone = zones.get(zone_id);

                if (zone != null) {
                    Organism organism = createOrganism(species_id, amount);

                    for (int node_id : organism.getSpeciesType().getNodeList()) {
                        zone.addNewNode(node_id, amount * organism.getSpeciesType().getNodeAmount(node_id));
                    }

                    createOrganismByResponse(organism, organism.getGroupSize(), zone_id, Constants.CREATE_STATUS_PURCHASE, xCoor, yCoor, Constants.CREATE_USER);

                    try {
                        if (organism_type == Constants.ORGANISM_TYPE_PLANT) {
                            PlantStatDAO.insertPlantStat(organism.getID(), species_id, currentMonth, "Purchase", world.getEnvByUserID(player_id).getEnvironmentScore(), null, player_id, zone_id);
                        } else if (organism_type == Constants.ORGANISM_TYPE_ANIMAL) {
                            AnimalStatDAO.insertAnimalStat(organism.getID(), species_id, currentMonth, "Purchase", world.getEnvByUserID(player_id).getEnvironmentScore(), null, player_id, zone_id);
                        }

                        for (int node_id : species.getNodeList()) {
                            UserActionsDAO.createAction(zone.getManipulationID(), zone.getCurrentTimeStep(), 0, node_id, GameServer.getInstance().getSpeciesTypeByNodeID(node_id).getAvgBiomass() * organism.getGroupSize());
                        }
                    } catch (SQLException ex) {
                        System.err.println(ex.getMessage());
                    }

View Full Code Here

TOP

Related Classes of worldManager.gameEngine.species.Organism

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.