Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update NPC.java #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 37 additions & 69 deletions NPC.java
Original file line number Diff line number Diff line change
@@ -1,62 +1,51 @@
import java.util.Random;
import java.util.Scanner;

public class NPC extends Player
public class NPC
{
private boolean npcAlignment;
private int npcStrength;

static Scanner kb = new Scanner(System.in);
public static void goodNPCInteraction(){
Scanner kb = new Scanner(System.in);
int input;
System.out.println("Villager approaches! Villager says: Hi, traveller.");
System.out.println("\n1. What can you tell me about this area?" +
//not this!!!
"\n2. Up for a trade?" +
"\n3. [Ignore]");
input = kb.nextInt();
if(input == 1){
System.out.println("");
}
if(input == 2){
Random rand = new Random();

System.out.println("");
}
if(input == 3){
System.out.println("Villager: All right, then. See you, I guess.");
}
int input;
System.out.println("Villager approaches! Villager says: Hi, traveller.");
System.out.println("\n1. What can you tell me about this area?" +
"\n2. Up for a trade?" +
"\n3. [Ignore]");
input = kb.nextInt();
if(input == 1){
System.out.println("");
}
if(input == 2){
System.out.println("");
}
if(input == 3){
System.out.println("Villager: All right, then. See you, I guess.");
}
}

public static void badNPCInteraction(){
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]""");
System.out.println("1. [Give 1 coin]");
System.out.println("2. No, sorry.");
System.out.println("3. [Ignore]");
input = kb.nextInt();
if(input == 1){
System.out.println("You lost 1 coin.)");
currentCurrency = currentCurrency -1;

currentCurrency = currentCurrency -1;
System.out.println("Villager: That's funny. Got any more?");
System.out.println("""

1. No.
2. [Give 1 coin]""");
System.out.println("1. No.");
System.out.println("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;

currentCurrency = currentCurrency - 50;
}
if(input == 2){
System.out.println("(You lost 1 coin.)");
currentCurrency = currentCurrency -1;
currentCurrency = currentCurrency -1;
System.out.println("Villager: Yeah, all right. Very, VERY funny.");
System.out.println("The villager left, grumbling.");
}
Expand Down Expand Up @@ -96,46 +85,25 @@ public static void badNPCInteraction(){

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.");
}
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.");
}
}
if(input == 2){
System.out.println("Villager: I'll get you one day. Just wait and see.");
System.out.println("Villager left, angry.");
}
}
return currentCurrency;
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();
}
else badNPCInteraction();
}

public void setNpcStrength(int npcStrength) {
this.npcStrength = npcStrength;
}
}