1 /*
2 * Copyright (c) 2021 Kaiserpfalz EDV-Service, Roland T. Lichti.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18 package de.kaiserpfalzedv.rpg.torg;
19
20 import de.kaiserpfalzedv.rpg.core.dice.LookupTable;
21 import lombok.extern.slf4j.Slf4j;
22
23 import jakarta.enterprise.context.Dependent;
24
25 /**
26 * BonusChart -- the bonus chart of TORG:Eternity.
27 *
28 * The bonus chart translates an exploded roll into a bonus for a test.
29 *
30 * @author klenkes74 {@literal <rlichti@kaiserpfalz-edv.de>}
31 * @since 2020-01-03
32 */
33 @Dependent
34 @Slf4j
35 public class BonusChart implements LookupTable {
36 @Override
37 public int lookup(final int roll) {
38 int result = 0;
39
40 switch (roll) {
41 case 14:
42 case 13:
43 result = 1;
44 break;
45 case 12:
46 case 11:
47 result = 0;
48 break;
49 case 10:
50 case 9:
51 result = -1;
52 break;
53 case 8:
54 case 7:
55 result = -2;
56 break;
57 case 6:
58 case 5:
59 result = -4;
60 break;
61 case 4:
62 case 3:
63 result = -6;
64 break;
65 case 2:
66 result = -8;
67 break;
68 case 1:
69 result = -10;
70 break;
71 default:
72 if (roll >= 20) {
73 result = 7 + (roll-20) / 5;
74 } else if (roll >= 15) {
75 result = 2 + (roll-15) % 5;
76 }
77 break;
78 }
79
80 log.debug("Bonus chart lookup: roll={}, result={}", roll, result);
81 return result;
82 }
83 }