|
| 1 | +/* |
| 2 | + * The MIT License (MIT) |
| 3 | + * |
| 4 | + * Copyright (c) 2013 AlgorithmX2 |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy of |
| 7 | + * this software and associated documentation files (the "Software"), to deal in |
| 8 | + * the Software without restriction, including without limitation the rights to |
| 9 | + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
| 10 | + * the Software, and to permit persons to whom the Software is furnished to do so, |
| 11 | + * subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included in all |
| 14 | + * copies or substantial portions of the Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
| 18 | + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
| 19 | + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 20 | + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 21 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | + */ |
| 23 | + |
| 24 | +package aekeylegacy.api.config; |
| 25 | + |
| 26 | +public enum FuzzyMode { |
| 27 | + /** |
| 28 | + * Matches any item from undamaged to including 0% durability, but not negative durability (where item damage |
| 29 | + * exceeds maxdamage). |
| 30 | + */ |
| 31 | + IGNORE_ALL(-1), |
| 32 | + /** |
| 33 | + * Matches items that have less than 100% durability (that is, at least 1 damage point) if a damaged item is used as |
| 34 | + * the filter, or undamaged items otherwise. |
| 35 | + */ |
| 36 | + PERCENT_99(0), |
| 37 | + /** |
| 38 | + * If an item with less than 75% durability is used as the filter, items with less than 75% durability are matched. |
| 39 | + * Otherwise items with 75% durability or more are matched. |
| 40 | + */ |
| 41 | + PERCENT_75(25), |
| 42 | + /** |
| 43 | + * If an item with less than 50% durability is used as the filter, items with less than 50% durability are matched. |
| 44 | + * Otherwise items with 50% durability or more are matched. |
| 45 | + */ |
| 46 | + PERCENT_50(50), |
| 47 | + /** |
| 48 | + * If an item with less than 25% durability is used as the filter, items with less than 50% durability are matched. |
| 49 | + * Otherwise items with 25% durability or more are matched. |
| 50 | + */ |
| 51 | + PERCENT_25(75); |
| 52 | + |
| 53 | + public final float breakPoint; |
| 54 | + /** |
| 55 | + * Note this is percentage "damaged". It's the inverse of percentage durability. |
| 56 | + */ |
| 57 | + public final float percentage; |
| 58 | + |
| 59 | + FuzzyMode(float p) { |
| 60 | + this.percentage = p; |
| 61 | + this.breakPoint = p / 100.0f; |
| 62 | + } |
| 63 | + |
| 64 | + public int calculateBreakPoint(int maxDamage) { |
| 65 | + return (int) (this.percentage * maxDamage / 100.0f); |
| 66 | + } |
| 67 | + |
| 68 | +} |
0 commit comments