-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.java
131 lines (121 loc) · 2.71 KB
/
Player.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
/**
* @(#)Player.java
*
*
* @author
* @version 1.00 2018/5/4
*/
import java.awt.image.*;
import java.awt.image.*;
import java.awt.*;
import java.util.*;
public class Player {
public int money=1000;
Image[] walks;
int direct=3;
final int UP=1;
final int LEFT=2;
final int DOWN=3;
final int RIGHT=4;
String name="RED";
Pokemon[] poke=new Pokemon[6];
int[] backpack = {0,0,0,0};
Pokemon[][] pcpokes=new Pokemon[9][12];
public Player(Image[] sprites) {
walks=sprites;
}
public Image move(int frame,int dir){
if (dir==UP){
return walks[frame+7];
}
else if (dir==DOWN){
return walks[frame-1];
}
else if (dir==RIGHT){
return walks[frame+3];
}
else{
return walks[frame+11];
}
}
public void addPoke(Pokemon p){
for (int i=0;i<6;i++){
if (poke[i]==null){
poke[i]=p;
return;
}
}
for(int i=0;i<9;i++){
for (int j=0;j<12;j++){
if(pcpokes[i][j]==null){
pcpokes[i][j]=p;
return;
}
}
}
}
public boolean pokesAlive(){
for(Pokemon p:poke){
if(p!=null&&p.getHP()>0){
return true;
}
}
return false;
}
public Image stand(int dir){
if (dir==UP){
return walks[9];
}
else if (dir==DOWN){
return walks[1];
}
else if (dir==RIGHT){
return walks[7];
}
else{
return walks[15];
}
}
public Pokemon[] getPokes(){
return poke;
}
public int getMoney(){
return money;
}
public void setMoney(int mon){
money=mon;
}
public String getStringMoney(){
return Integer.toString(money);
}
public void addItem(Item thing,int amount){
if(thing.getName().equals("Potion")){
backpack[1]+=amount;
}
else if(thing.getName().equals("Super Potion")){
backpack[2]+=amount;
}
else if(thing.getName().equals("Max Potion")){
backpack[3]+=amount;
}
else if(thing.getName().equals("Pokeball")){
backpack[0]+=amount;
}
}
public int[] getBackpack(){
return backpack;
}
public Pokemon[][] getPcPokes(){
return pcpokes;
}
/*public void addItem(Item thing){
backpack.add(thing);
}
public void removeItem(Item thing){
for (int c=0;c<backpack.size();c++){
if (backpack.get(c).equals(thing)){
backpack.remove(c);
}
}
}*/
}