Crossfire JXClient, Trunk  R20561
NewCharInfoBuilder.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.server.crossfire;
23 
25 import java.util.ArrayList;
26 import java.util.Arrays;
27 import java.util.List;
28 import org.jetbrains.annotations.NotNull;
29 
35 public class NewCharInfoBuilder {
36 
40  private int points;
41 
45  private int minValue;
46 
50  private int maxValue;
51 
55  @NotNull
56  private final List<String> statNames = new ArrayList<>();
57 
61  private boolean raceChoice;
62 
66  private boolean classChoice;
67 
71  private boolean startingMapChoice;
72 
78  @NotNull
79  public NewCharInfo finish() {
80  return new NewCharInfo(points, minValue, maxValue, statNames, raceChoice, classChoice, startingMapChoice);
81  }
82 
87  public void setPoints(final int points) {
88  this.points = points;
89  }
90 
96  public void setStatRange(final int minValue, final int maxValue) {
97  this.minValue = minValue;
98  this.maxValue = maxValue;
99  }
100 
105  public void setStatNames(@NotNull final String[] statNames) {
106  this.statNames.clear();
107  this.statNames.addAll(Arrays.asList(statNames));
108  }
109 
113  public void setRaceChoice() {
114  raceChoice = true;
115  }
116 
120  public void setClassChoice() {
121  classChoice = true;
122  }
123 
127  public void setStartingMapChoice() {
128  startingMapChoice = true;
129  }
130 
134  @NotNull
135  @Override
136  public String toString() {
137  return "XXX";
138  }
139 
140 }
void setStatRange(final int minValue, final int maxValue)
Sets the allowed stat value range.
NewCharInfo finish()
Finished parsing and returns the NewCharInfo instance for the parsed entry.
General information for creating new characters.
int points
The total number of points the character has to spend.
void setStartingMapChoice()
Sets that a starting map should be selected.
Builder for NewCharInfo instances while parsing a "replyinfo newcharinfo" response packet...
boolean startingMapChoice
Whether a starting map should be selected.
void setStatNames(@NotNull final String[] statNames)
Sets the stat names to spend on.
void setPoints(final int points)
Sets the number of points the character has to spend.