Moved some common utils to gameserver.
This commit is contained in:
@@ -25,7 +25,6 @@ import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.util.MathUtil;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.DoorData;
|
||||
import com.l2jmobius.gameserver.geoengine.geodata.ABlock;
|
||||
import com.l2jmobius.gameserver.geoengine.geodata.BlockComplex;
|
||||
@@ -46,6 +45,7 @@ import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
|
||||
import com.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import com.l2jmobius.gameserver.util.MathUtil;
|
||||
|
||||
/**
|
||||
* @author Hasha
|
||||
|
@@ -34,7 +34,6 @@ import java.util.function.BiPredicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.util.MathUtil;
|
||||
import com.l2jmobius.gameserver.enums.AttributeType;
|
||||
import com.l2jmobius.gameserver.enums.Position;
|
||||
import com.l2jmobius.gameserver.model.CharEffectList;
|
||||
@@ -50,6 +49,7 @@ import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.StatsHolder;
|
||||
import com.l2jmobius.gameserver.model.stats.TraitType;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.util.MathUtil;
|
||||
|
||||
public class CharStat
|
||||
{
|
||||
|
@@ -21,7 +21,6 @@ import java.util.Optional;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.util.MathUtil;
|
||||
import com.l2jmobius.gameserver.enums.AttributeType;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.AttributeFinalizer;
|
||||
@@ -51,6 +50,7 @@ import com.l2jmobius.gameserver.model.stats.finalizers.ShieldDefenceRateFinalize
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.ShotsBonusFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.SpeedFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.VampiricChanceFinalizer;
|
||||
import com.l2jmobius.gameserver.util.MathUtil;
|
||||
|
||||
/**
|
||||
* Enum of basic stats.
|
||||
|
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.util;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class MathUtil
|
||||
{
|
||||
public static byte add(byte oldValue, byte value)
|
||||
{
|
||||
return (byte) (oldValue + value);
|
||||
}
|
||||
|
||||
public static short add(short oldValue, short value)
|
||||
{
|
||||
return (short) (oldValue + value);
|
||||
}
|
||||
|
||||
public static int add(int oldValue, int value)
|
||||
{
|
||||
return oldValue + value;
|
||||
}
|
||||
|
||||
public static double add(double oldValue, double value)
|
||||
{
|
||||
return oldValue + value;
|
||||
}
|
||||
|
||||
public static byte mul(byte oldValue, byte value)
|
||||
{
|
||||
return (byte) (oldValue * value);
|
||||
}
|
||||
|
||||
public static short mul(short oldValue, short value)
|
||||
{
|
||||
return (short) (oldValue * value);
|
||||
}
|
||||
|
||||
public static int mul(int oldValue, int value)
|
||||
{
|
||||
return oldValue * value;
|
||||
}
|
||||
|
||||
public static double mul(double oldValue, double value)
|
||||
{
|
||||
return oldValue * value;
|
||||
}
|
||||
|
||||
public static byte div(byte oldValue, byte value)
|
||||
{
|
||||
return (byte) (oldValue / value);
|
||||
}
|
||||
|
||||
public static short div(short oldValue, short value)
|
||||
{
|
||||
return (short) (oldValue / value);
|
||||
}
|
||||
|
||||
public static int div(int oldValue, int value)
|
||||
{
|
||||
return oldValue / value;
|
||||
}
|
||||
|
||||
public static double div(double oldValue, double value)
|
||||
{
|
||||
return oldValue / value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param numToTest : The number to test.
|
||||
* @param min : The minimum limit.
|
||||
* @param max : The maximum limit.
|
||||
* @return the number or one of the limit (mininum / maximum).
|
||||
*/
|
||||
public static int limit(int numToTest, int min, int max)
|
||||
{
|
||||
return (numToTest > max) ? max : ((numToTest < min) ? min : numToTest);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user