-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tester.java
executable file
·135 lines (113 loc) · 3.94 KB
/
Tester.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* @author John Wuller
* @version 2.0
*
* This is a class which is being tested in order to make the battle
* appear nicer. It is still a work in progress.
*
* TODO:
* add "View stats" option
* get it to work and incorporate it
*
*/
public class Tester extends JFrame implements ActionListener{
public static String AtkNumber;
JButton atck1button;
JButton atck2button;
JButton atck3button;
JButton atck4button;
JButton viewStatsButton;
JButton switchOutButton;
Battle game;
Generic g = game.g;
boolean gottenResult;
public attack theAttack;
/**
* @author John Wuller
* @version 1.0
*
* The function to make the popup box
*/
public Tester (Pokemon pokemon){
super("What will "+pokemon.Name+" do?");
gottenResult = false;
String[] names = new String[5];
for (int i = 0; i < 4; i++) {
attack tAtk = pokemon.AttackList[i];
names[i] = tAtk.name + " (" + pokemon.pp[i] + "pp)";
}
names[4] = "View stats";
atck1button = new JButton(names[0]);
atck1button.setActionCommand("1");
atck1button.addActionListener(this);
atck2button = new JButton(names[1]);
atck2button.setActionCommand("2");
atck2button.addActionListener(this);
atck3button = new JButton(names[2]);
atck3button.setActionCommand("3");
atck3button.addActionListener(this);
atck4button = new JButton(names[3]);
atck4button.setActionCommand("4");
atck4button.addActionListener(this);
viewStatsButton = new JButton("View stats");
viewStatsButton.setActionCommand("vs");
viewStatsButton.addActionListener(this);
switchOutButton = new JButton("Switch out");
switchOutButton.setActionCommand("so");
switchOutButton.addActionListener(this);
//setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
setLayout(new FlowLayout());
add(atck1button);
add(atck2button);
add(atck3button);
add(atck4button);
add(viewStatsButton);
add(switchOutButton);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(400,150);
this.setVisible(true);
while(!gottenResult){
//wait for result
}
if(AtkNumber.equals("1"))
theAttack = pokemon.AttackList[0];
else if(AtkNumber.equals("2"))
theAttack = pokemon.AttackList[1];
else if(AtkNumber.equals("3"))
theAttack = pokemon.AttackList[2];
else if(AtkNumber.equals("4"))
theAttack = pokemon.AttackList[3];
else if(AtkNumber.equals("View stats"))
theAttack = Battle.viewStats;
/*else if(AtkNumber.equals("Switch out"))
theAttack = Battle.switchOut;*/
else
theAttack = Battle.Struggle;
}
/**
* @author John Wuller
* @version 1.1
*
* @param evt the choice
*
* This prints out the attack chosen
*/
public void actionPerformed(ActionEvent evt){
this.AtkNumber = evt.getActionCommand();
this.gottenResult = true;
//System.exit(0);
}
}
// _____________ ___________ _ _ __ _
// |_____ _____| / _________ \ | | | | | \ | |
// | | / / \ \ | | | | | |\ \ | |
// | | | | | | | | | | | | \ \ | |
// | | | | | | | |______| | | | \ \ | |
// | | | | | | | ______ | | | \ \ | |
// _ | | | | | | | | | | | | \ \ | |
// \\ / / | | | | | | | | | | \ \| |
// \\______/ / \ \_________/ / | | | | | | \ |
// \_______/ \___________/ |_| |_| |_| \__|