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.core.dice;
19
20 import de.kaiserpfalzedv.rpg.core.dice.mat.DieResult;
21
22 import java.util.Optional;
23
24 /**
25 * @author rlichti {@literal <rlichti@kaiserpfalz-edv.de>}
26 * @since 2020-08-12
27 */
28 public interface Die {
29 /**
30 * a single die roll.
31 * @return result of the single die roll.
32 */
33 DieResult roll();
34
35 /**
36 * the result of multiple dice rolls.
37 * @param number the number of dice rolls.
38 * @return ann array of Integer containing the results. The first element contains the sum, starting with index 1
39 * the results of the single rolls are returned.
40 */
41 DieResult[] roll(final int number);
42
43 /**
44 * @return returns the lookup table to compare the total to and print as result.
45 */
46 default Optional<LookupTable> getLookupTable() {
47 return Optional.empty();
48 }
49
50 /**
51 * @return The name of the die.
52 */
53 default String getDieType() {
54 return getClass().getSimpleName();
55 }
56
57 /**
58 * @return TRUE, if the result can be parsed as integer (and therefore calculations can be done)
59 */
60 boolean isNumericDie();
61 }