forked from relaxingstew/GameCodeScaffolding
-
Notifications
You must be signed in to change notification settings - Fork 2
/
NPC.java
171 lines (152 loc) · 6.88 KB
/
NPC.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
public class NPC
{
private boolean npcAlignment;
private int npcStrength;
private Trinket trin;
private ArrayList<Trinket> trinkets = new ArrayList<Trinket>();
static Scanner kb = new Scanner(System.in);
public static Trinket goodNPCInteraction(ArrayList<Trinket> trinkets){
int input;
System.out.println("Child villager approaches! Villager says: Hi, traveller.");
System.out.println("\n1. What can you tell me about this area?" +
"\n2. Hello." +
"\n3. [Ignore]");
input = kb.nextInt();
if(input == 1){
System.out.println("Villager: We are a very poor town indeed. My mother had to get another job last week!");
System.out.println("\n1. I'm sorry to hear that." +
"\n2. I'm going to help you.");
input = kb.nextInt();
if(input == 1){
System.out.println("Villager: I wish someone would save us.");
System.out.println("(The villager left, downtrodden.)");
}
if(input == 2){
System.out.println("Villager: Really? Well, then you'll need my help, too!");
System.out.println("(The villager hands you something. You're not exactly sure what it's supposed to do.");
trinkets.add(trinkets.get(3));
System.out.println("(The villager leaves, skipping.)");
}
}
if(input == 2){
System.out.println("Villager: Are you the one the moon spoke of?");
System.out.println("\n1. Yes, of course." +
"\n2. I guess...");
input = kb.nextInt();
if(input == 1){
System.out.println("Villager: Good!");
System.out.println("(The villager left, excited.)");
}
if(input == 2){
System.out.println("You don't sound too confident. I wish they sent someone else.");
System.out.println("(The villager left, worried.)");
}
}
if(input == 3){
System.out.println("Villager: All right, then. See you, I guess.");
}
else System.out.println("You screamed some weird gibberish. Villager left, bewildered.");
return trinkets.get(3);
}
public static int badNPCInteraction(int currentCurrency){
Scanner kb = new Scanner(System.in);
int input;
System.out.println("Villager approaches! Villager says: Got any cash?");
System.out.println("""
1. [Give 1 coin]
2. No, sorry.
3. [Ignore]""");
input = kb.nextInt();
if(input == 1){
currentCurrency = currentCurrency -1;
System.out.println("(You lost 1 coin. Money: " + currentCurrency + ")");
System.out.println("Villager: That's funny. Got any more?");
System.out.println("""
1. No.
2. [Give 1 coin]""");
input = kb.nextInt();
if(input == 1){
System.out.println("Villager: Well, I got your wallet right here, and you got plenty.");
System.out.println("The villager robbed you! Money lost...");
currentCurrency = currentCurrency - 50;
}
if(input == 2){
currentCurrency = currentCurrency -1;
System.out.println("(You lost 1 coin. Money: " + currentCurrency + ")");
System.out.println("Villager: Yeah, all right. Very, VERY funny.");
System.out.println("The villager left, grumbling.");
}
else System.out.println("You screamed some weird gibberish. Villager left, bewildered.");
}
if(input == 2){
System.out.println("Villager: You sure?");
System.out.println("""
1. I'm on an important mission.
2. VERY sure.
3. [Ignore]""");
input = kb.nextInt();
if(input == 1){
System.out.println("Villager: Doesn't sound important. You're no fun.");
System.out.println("The villager left, bored.");
}
if(input == 2){
System.out.println("Villager: Well, I got your wallet right here, and you got plenty.");
System.out.println("The villager robbed you! Money lost...");
//add amount of money later
}
if(input == 3){
System.out.println("Fine. Be that way.");
System.out.println("The villager left, grumbling.");
}
else System.out.println("You screamed some weird gibberish. Villager left, bewildered.");
}
if(input == 3){
System.out.println("Villager: Hey! I was talking to you!");
System.out.println("""
1. No money. Sorry.
2. [Ignore]""");
input = kb.nextInt();
if(input == 1){
System.out.println("Villager: Are you that hero? That one supposed to save us all? You don't look like much.");
System.out.println("""
1. Yeah. Maybe.
2. [Ignore]""");
input = kb.nextInt();
if(input == 1){
System.out.println("Villager: Some hero you are.");
System.out.println("Villager left, disappointed.");
}
if(input == 2) {
System.out.println("Villager: Some hero you are.");
System.out.println("Villager left, disappointed.");
} else System.out.println("You screamed some weird gibberish. Villager left, bewildered.");
}
if(input == 2){
System.out.println("Villager: I'll get you one day. Just wait and see.");
System.out.println("Villager left, angry.");
} else System.out.println("You screamed some weird gibberish. Villager left, bewildered.");
}
return currentCurrency;
}
//Getters and setters
public boolean getNPCAlignment() {
return npcAlignment;
}
public int getNpcStrength() {
return npcStrength;
}
public void setNpcAlignment(boolean npcAlignment) {
Random align = new Random();
this.npcAlignment = align.nextBoolean();
getNPCAlignment();
if(npcAlignment == true){
goodNPCInteraction(trinkets);
}
}
public void setNpcStrength(int npcStrength) {
this.npcStrength = npcStrength;
}
}