summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/database/GameCharacters.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/fourisland/fourpuzzle/database/GameCharacters.java')
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/database/GameCharacters.java72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/com/fourisland/fourpuzzle/database/GameCharacters.java b/src/com/fourisland/fourpuzzle/database/GameCharacters.java new file mode 100755 index 0000000..bcd533a --- /dev/null +++ b/src/com/fourisland/fourpuzzle/database/GameCharacters.java
@@ -0,0 +1,72 @@
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5
6package com.fourisland.fourpuzzle.database;
7
8import com.fourisland.fourpuzzle.*;
9import com.fourisland.fourpuzzle.gamestate.GameOverGameState;
10import java.util.ArrayList;
11
12/**
13 *
14 * @author hatkirby
15 */
16public class GameCharacters extends ArrayList<GameCharacter>
17{
18 private GameCharacters() {}
19
20 private static GameCharacters INSTANCE = new GameCharacters();
21 static GameCharacters getDefaultParty()
22 {
23 return INSTANCE;
24 }
25
26 static GameCharacters createParty()
27 {
28 GameCharacters temp = new GameCharacters();
29 temp.addAll(INSTANCE);
30
31 return temp;
32 }
33
34 public GameCharacter getLeader()
35 {
36 for (GameCharacter chara : this)
37 {
38 if (chara.isInParty())
39 {
40 return chara;
41 }
42 }
43
44 Game.setGameState(new GameOverGameState());
45 return null;
46 }
47
48 public boolean exists(String heroName) {
49 for (GameCharacter chara : this)
50 {
51 if (chara.getName().equals(heroName))
52 {
53 return true;
54 }
55 }
56
57 return false;
58 }
59
60 public GameCharacter get(String heroName) throws NullPointerException {
61 for (GameCharacter chara : this)
62 {
63 if (chara.getName().equals(heroName))
64 {
65 return chara;
66 }
67 }
68
69 throw new NullPointerException("Could not find character \"" + heroName + "\"");
70 }
71
72}