-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPokemonGame.java
More file actions
129 lines (115 loc) · 4.09 KB
/
PokemonGame.java
File metadata and controls
129 lines (115 loc) · 4.09 KB
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
/*
* This is the Pokemon Game class, a variant of the regular monopoly game.
* This game runs more the higher level functions and
* initialization procedures. Players are instantiated here as well as determing
* the winner, the number of players, the max number of rounds, etc.
*/
package project_3;
import java.util.*;
import javax.swing.JOptionPane;
/**
*
* @author Rohan Khante, Matthew Wentz, Jonathan Sorem, Robert James Davis
*/
public class PokemonGame {
public int max_rounds;
public int current_round =0;
public int num_players;
public String[] turn_order;
public String[] available_tokens;
public int board_position;
public boolean game_over = false;
public List<Integer> playerOrder;
public List<Player> Players;
public void newGame() //don't change the name
{
Values.currentBoard = Values.pboard;
getNumPlayers();
chooseToken();
rollForFirst();
// //This while loop somehow breaks things
// while(game_over != true) //newGame somehow enters this loop before calling all functions above it
// {
// //take turns here
// }
while(this.current_round <=this.max_rounds) //need to set max rounds somewhere
{
performRound();
}
winner();
}
public void rollForFirst()
{
//System.out.println("Test");
this.playerOrder = new ArrayList<>();
for (int i=1; i<=this.num_players; i++)
{
this.playerOrder.add(i);
}
Collections.shuffle(this.playerOrder);
this.Players = new ArrayList<>();
for(int i=0; i<this.num_players; i++)
{
this.Players.add(i, (new Player((int)this.playerOrder.get(i)) ));
}
}
public void performRound()
{
//functions from the term class will go here
for (int i = 0; i < this.num_players; i++)
{
Turn currentTurn = new Turn();
currentTurn.doPlayerTurn(Players.get(i));
}
this.current_round++;
}
public void auction()
{
//this should either be in the turn class or the space class
}
public void winner()
{
int maxAmount=0;// can someone have negative amount?
int index=0;
for(int i=0; i< this.num_players; i++)
{
this.Players.get(i).totalValue();
if (this.Players.get(i).totalValue > maxAmount)
{
maxAmount = this.Players.get(i).totalValue;
index = this.Players.get(i).id;
}
}
JOptionPane.showMessageDialog(null, "Winner is this no lifer dude with index being "
+ index+ " and money being " + maxAmount);
}
public void getNumPlayers()
{
boolean isValid = false;
while(isValid == false)
{
//System.out.println("Number of players: ");
this.num_players = Integer.parseInt(JOptionPane.showInputDialog("Enter number of players: "));
if((this.num_players < 5) && (this.num_players > 1))
{
isValid = true;
}
else
{
JOptionPane.showMessageDialog(null, "You put in invalid number of players. please choose between 2 and 4 players.");
}
}
}
public void chooseToken()
{
//this is where the players would choose their token
for(int x = 0; x < this.num_players; x++)
{
Values.playerNames[x] = JOptionPane.showInputDialog("Enter player "+(x+1)+"'s name");
Values.playerTokens[x] = (Integer.parseInt(JOptionPane.showInputDialog("Player " + (x+1) + ", please choose your token.\n1. Pikachu\n2. Bulbasaur\n3. Charmander\n4. Squirtle")))-1;
GUI.jLabel1.add(Values.tokens[Values.playerTokens[x]]);
Values.tokens[Values.playerTokens[x]].setLocation(Values.tokenXValues[0], Values.tokenYValues[0]);
}
this.max_rounds = Integer.parseInt(JOptionPane.showInputDialog("Enter the number of rounds to be played"));
}
}