📄 l1taxcalculator.java
字号:
/*
* 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 2, 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/
package l1j.server.server.model;
public class L1TaxCalculator {
/**
* 戦争税は15%固定
*/
private static final int WAR_TAX_RATES = 15;
/**
* 国税は10%固定(地域税に対する割合)
*/
private static final int NATIONAL_TAX_RATES = 10;
/**
* ディアド税は10%固定(戦争税に対する割合)
*/
private static final int DIAD_TAX_RATES = 10;
private final int _taxRatesCastle;
private final int _taxRatesTown;
private final int _taxRatesWar = WAR_TAX_RATES;
/**
* @param merchantNpcId
* 計算対象商店のNPCID
*/
public L1TaxCalculator(int merchantNpcId) {
_taxRatesCastle = L1CastleLocation.getCastleTaxRateByNpcId(merchantNpcId);
_taxRatesTown = L1TownLocation.getTownTaxRateByNpcid(merchantNpcId);
}
public int calcTotalTaxPrice(int price) {
int taxCastle = price * _taxRatesCastle;
int taxTown = price * _taxRatesTown;
int taxWar = price * WAR_TAX_RATES;
return (taxCastle + taxTown + taxWar) / 100;
}
// XXX 個別に計算する為、丸め誤差が出る。
public int calcCastleTaxPrice(int price) {
return (price * _taxRatesCastle) / 100 - calcNationalTaxPrice(price);
}
public int calcNationalTaxPrice(int price) {
return (price * _taxRatesCastle) / 100 / (100 / NATIONAL_TAX_RATES);
}
public int calcTownTaxPrice(int price) {
return (price * _taxRatesTown) / 100;
}
public int calcWarTaxPrice(int price) {
return (price * _taxRatesWar) / 100;
}
public int calcDiadTaxPrice(int price) {
return (price * _taxRatesWar) / 100 / (100 / DIAD_TAX_RATES);
}
/**
* 課税後の価格を求める。
*
* @param price
* 課税前の価格
* @return 課税後の価格
*/
public int layTax(int price) {
return price + calcTotalTaxPrice(price);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -