Crossfire JXClient, Trunk  R20561
ClassRaceInfo.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient 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 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient 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 JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff.
19  * Copyright (C) 2006-2011 Andreas Kirschbaum.
20  */
21 
22 package com.realtime.crossfire.jxclient.character;
23 
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.Collections;
27 import java.util.HashMap;
28 import java.util.List;
29 import java.util.Map;
30 import org.jetbrains.annotations.NotNull;
31 
36 public class ClassRaceInfo {
37 
41  @NotNull
42  private final String archName;
43 
47  @NotNull
48  private final String name;
49 
53  @NotNull
54  private final String msg;
55 
59  @NotNull
60  private final List<Choice> choices = new ArrayList<>();
61 
65  @NotNull
66  private final Map<Integer, Long> stats = new HashMap<>();
67 
76  public ClassRaceInfo(@NotNull final String archName, @NotNull final String name, @NotNull final String msg, @NotNull final Map<Integer, Long> stats, @NotNull final Collection<Choice> choices) {
77  this.archName = archName;
78  this.name = name;
79  this.msg = msg;
80  this.stats.putAll(stats);
81  this.choices.addAll(choices);
82  }
83 
88  @NotNull
89  public String getArchName() {
90  return archName;
91  }
92 
97  @NotNull
98  public String getName() {
99  return name;
100  }
101 
106  @NotNull
107  public String getMsg() {
108  return msg;
109  }
110 
116  public long getStatAdjustment(final int statNo) {
117  try {
118  return stats.get(statNo);
119  } catch (final NullPointerException ignored) {
120  return 0;
121  }
122  }
123 
128  @NotNull
129  public List<Choice> getChoices() {
130  return Collections.unmodifiableList(choices);
131  }
132 
136  @NotNull
137  @Override
138  public String toString() {
139  return "arch="+archName+", name="+name+", stats="+stats+", choices="+choices;
140  }
141 
142 }
final String name
The human readable race name.
String getName()
Returns the human readable race name.
String getMsg()
Returns the long description.
final Map< Integer, Long > stats
The stat adjustments.
final List< Choice > choices
The available choices.
List< Choice > getChoices()
Returns the available choices.
long getStatAdjustment(final int statNo)
Returns a stat adjustment.
ClassRaceInfo(@NotNull final String archName, @NotNull final String name, @NotNull final String msg, @NotNull final Map< Integer, Long > stats, @NotNull final Collection< Choice > choices)
Creates a new instance.
One possible class or race for character creation.
String getArchName()
Returns the archetype name.