예제 #1
0
        public static bool regrowWeeds(Patch patch)
        {
            bool shouldRemoveFromList = false;

            if (!patch.patchOccupied())
            {
                if (misc.random(4) != 0 || patch.isWeeding())
                {
                    return(false);
                }
                Player owner = Server.getPlayerForName(patch.getOwnerName());
                patch.setHasWeeds(true);
                patch.setStatus(patch.getStatus() - 1);
                if (patch.getStatus() <= -1)
                {
                    patch.setStatus(0);
                    shouldRemoveFromList = true;
                }
                if (owner != null)
                {
                    setConfig(owner, patch);
                }
            }
            return(shouldRemoveFromList);
        }
예제 #2
0
        public static bool growSapling(Patch patch)
        {
            Player owner = Server.getPlayerForName(patch.getOwnerName());

            if (owner != null)
            {
                if (owner.getInventory().replaceSingleItem((int)SAPLING_DATA[patch.getPatchIndex()][1], (int)SAPLING_DATA[patch.getPatchIndex()][2]))
                {
                    return(true);
                }
                else if (owner.getBank().findItem((int)SAPLING_DATA[patch.getPatchIndex()][1]) != -1)
                {
                    Item item = owner.getBank().getSlot(owner.getBank().findItem((int)SAPLING_DATA[patch.getPatchIndex()][1]));
                    if (item.getItemId() == (int)SAPLING_DATA[patch.getPatchIndex()][1])
                    {
                        item.setItemId((int)SAPLING_DATA[patch.getPatchIndex()][2]);
                        owner.getBank().refreshBank();
                        return(true);
                    }
                }
            }
            return(true);
        }
예제 #3
0
 public static void growPatch(Patch patch)
 {
     if (patch.isTree()) {
         if (patch.getStatus() == patch.checkHealthStatus()) {
             if (!patch.isHealthChecked()) {
                 return;
             }
         } else if  (patch.getStatus() == patch.chopStatus()) {
             return;
         } else if (patch.getStatus() == patch.stumpStatus()) {
             patch.setStatus(patch.chopStatus());
         } else {
             patch.setStatus(patch.getStatus() + 1);
         }
     } else if (patch.isFruitTree()) {
         if (patch.isWeeding()) {
             return;
         }
         if (patch.getStatus() == patch.checkHealthStatus()) {
             if (!patch.isHealthChecked()) {
                 return;
             }
         }
         if (patch.isHealthChecked()) {
             if (patch.getStatus() == patch.checkHealthStatus() - 1) { // all fruit
                 return;
             }
         }
         if (patch.getStatus() == patch.stumpStatus()) {
             patch.setStatus(patch.chopStatus());
         } else if (patch.getStatus() == patch.chopStatus()) {
             patch.setStatus(6);
         } else {
             patch.setStatus(patch.getStatus() + 1);
         }
     } else {
         patch.setStatus(patch.getStatus() + 1);
     }
     Player owner = Server.getPlayerForName(patch.getOwnerName());
     if (owner != null) {
         setConfig(owner, patch);
     }
     patch.setLastUpdate(Environment.TickCount);
 }
예제 #4
0
 public static bool regrowWeeds(Patch patch)
 {
     bool shouldRemoveFromList = false;
     if (!patch.patchOccupied()) {
         if (misc.random(4) != 0 || patch.isWeeding()) {
             return false;
         }
         Player owner = Server.getPlayerForName(patch.getOwnerName());
         patch.setHasWeeds(true);
         patch.setStatus(patch.getStatus() - 1);
         if (patch.getStatus() <= -1) {
             patch.setStatus(0);
             shouldRemoveFromList = true;
         }
         if (owner != null) {
             setConfig(owner, patch);
         }
     }
     return shouldRemoveFromList;
 }
예제 #5
0
        public static bool growSapling(Patch patch)
        {
            Player owner = Server.getPlayerForName(patch.getOwnerName());

            if (owner != null) {
                if (owner.getInventory().replaceSingleItem((int)SAPLING_DATA[patch.getPatchIndex()][1], (int)SAPLING_DATA[patch.getPatchIndex()][2]))
                {
                    return true;
                } else if (owner.getBank().findItem((int)SAPLING_DATA[patch.getPatchIndex()][1]) != -1) {
                    Item item = owner.getBank().getSlot(owner.getBank().findItem((int)SAPLING_DATA[patch.getPatchIndex()][1]));
                    if (item.getItemId() == (int)SAPLING_DATA[patch.getPatchIndex()][1]) {
                        item.setItemId((int)SAPLING_DATA[patch.getPatchIndex()][2]);
                        owner.getBank().refreshBank();
                        return true;
                    }
                }
            }
            return true;
        }
예제 #6
0
        public static void growPatch(Patch patch)
        {
            if (patch.isTree())
            {
                if (patch.getStatus() == patch.checkHealthStatus())
                {
                    if (!patch.isHealthChecked())
                    {
                        return;
                    }
                }
                else if (patch.getStatus() == patch.chopStatus())
                {
                    return;
                }
                else if (patch.getStatus() == patch.stumpStatus())
                {
                    patch.setStatus(patch.chopStatus());
                }
                else
                {
                    patch.setStatus(patch.getStatus() + 1);
                }
            }
            else if (patch.isFruitTree())
            {
                if (patch.isWeeding())
                {
                    return;
                }
                if (patch.getStatus() == patch.checkHealthStatus())
                {
                    if (!patch.isHealthChecked())
                    {
                        return;
                    }
                }
                if (patch.isHealthChecked())
                {
                    if (patch.getStatus() == patch.checkHealthStatus() - 1)                   // all fruit
                    {
                        return;
                    }
                }
                if (patch.getStatus() == patch.stumpStatus())
                {
                    patch.setStatus(patch.chopStatus());
                }
                else if (patch.getStatus() == patch.chopStatus())
                {
                    patch.setStatus(6);
                }
                else
                {
                    patch.setStatus(patch.getStatus() + 1);
                }
            }
            else
            {
                patch.setStatus(patch.getStatus() + 1);
            }
            Player owner = Server.getPlayerForName(patch.getOwnerName());

            if (owner != null)
            {
                setConfig(owner, patch);
            }
            patch.setLastUpdate(Environment.TickCount);
        }