From df3d031933572738ee341e69ecf5e5e5506a5a98 Mon Sep 17 00:00:00 2001 From: jslightham <31053827+jslightham@users.noreply.github.com> Date: Thu, 30 May 2019 23:44:30 -0400 Subject: [PATCH] shavingcream blindness --- data/enemies.dat | 2 +- data/rooms.dat | 2 +- data/synonyms.dat | 5 +++- data/words.dat | 2 +- src/com/bayviewglen/zork/Combat.java | 23 +++++++++++++++---- .../zork/Entities/Enemies/Enemy.java | 9 ++++++++ src/com/bayviewglen/zork/Game.java | 4 ++-- .../{ShavingCream.java => Shavingcream.java} | 16 ++++++------- 8 files changed, 45 insertions(+), 18 deletions(-) rename src/com/bayviewglen/zork/Items/{ShavingCream.java => Shavingcream.java} (68%) diff --git a/data/enemies.dat b/data/enemies.dat index 96bd145..20db5aa 100644 --- a/data/enemies.dat +++ b/data/enemies.dat @@ -1,4 +1,4 @@ -Enemy Name: Henry_Pellatt +Enemy Name: Henry Pellatt Description: The owner of the Castle Starting Room: Circle Room Damage Given: 25 \ No newline at end of file diff --git a/data/rooms.dat b/data/rooms.dat index c087a81..f284140 100644 --- a/data/rooms.dat +++ b/data/rooms.dat @@ -3,7 +3,7 @@ Room Description: You are in a circular room. The windows to the east are covere Locked: false Boarded: false Items:Lockpick,Milk -Riddler: "Hello there. My name is Kevin and I am Sir Pellatt's butler. I understand that my master
Sir Pellatt has wrongfully imprisoned you. If you answer my riddle I can give you something to
help you with your escape - nothing comes for free you know!", "What goes moo?", "Cows", ShavingCream +Riddler: "Hello there. My name is Kevin and I am Sir Pellatt's butler. I understand that my master
Sir Pellatt has wrongfully imprisoned you. If you answer my riddle I can give you something to
help you with your escape - nothing comes for free you know!", "What goes moo?", "Cows", Shavingcream Exit Rooms: W-Apple Hallway Room name: Apple Hallway diff --git a/data/synonyms.dat b/data/synonyms.dat index 6ee72c1..8dc57c9 100644 --- a/data/synonyms.dat +++ b/data/synonyms.dat @@ -44,4 +44,7 @@ swallow, eat absorb, eat drink, eat i, inventory - +henry, henrypellatt +pellatt, henrypellatt +shaving, shavingcream +cream, shavingcream \ No newline at end of file diff --git a/data/words.dat b/data/words.dat index 06b83bf..1e3f7d6 100644 --- a/data/words.dat +++ b/data/words.dat @@ -40,7 +40,7 @@ book, item socks, item painting, item notebook, item -shaving cream, item +shavingcream, item toothbrush, item toothpaste, item milk, item diff --git a/src/com/bayviewglen/zork/Combat.java b/src/com/bayviewglen/zork/Combat.java index 2791445..fa38bc2 100644 --- a/src/com/bayviewglen/zork/Combat.java +++ b/src/com/bayviewglen/zork/Combat.java @@ -3,15 +3,17 @@ package com.bayviewglen.zork; import java.lang.reflect.Constructor; import com.bayviewglen.zork.Entities.Entity; +import com.bayviewglen.zork.Entities.Player; import com.bayviewglen.zork.Entities.Enemies.Enemy; import com.bayviewglen.zork.Items.Item; +import com.bayviewglen.zork.Items.Shavingcream; public class Combat { - private Entity player; + private Player player; private Enemy enemy; // if turn is 0 it is player's turn, if 1 it is enemy's turn private int turn; - public Combat(Entity player, Enemy enemy) { + public Combat(Player player, Enemy enemy) { this.player = player; this.enemy = enemy; } @@ -25,7 +27,12 @@ public class Combat { object = (Item) ctor.newInstance(); double rand = Math.random(); - if(rand<0.1) { + if(object.equals(new Shavingcream())) { + System.out.println("You blinded " + enemy.getName()); + player.removeFromInventory(new Shavingcream()); + enemy.setBlinded(true); + } + else if(rand<0.1) { System.out.println("You missed!"); @@ -51,7 +58,15 @@ public class Combat { public double enemyAttack() { double rand = Math.random(); - if(rand<0.1) { + if(enemy.getBlinded()) { + if(rand <0.4) { + System.out.println(enemy.getName() + " is no longer blinded!"); + enemy.setBlinded(false); + } + else + System.out.println(enemy.getName() + " is blinded!"); + } + else if(rand<0.1) { System.out.println(enemy.getName() + " missed!"); }else if(rand < 0.15) { player.setHealth(player.getHealth()-enemy.getDamage()*1.5); diff --git a/src/com/bayviewglen/zork/Entities/Enemies/Enemy.java b/src/com/bayviewglen/zork/Entities/Enemies/Enemy.java index 5c20bcc..1128342 100644 --- a/src/com/bayviewglen/zork/Entities/Enemies/Enemy.java +++ b/src/com/bayviewglen/zork/Entities/Enemies/Enemy.java @@ -7,15 +7,18 @@ public class Enemy extends Entity{ private String name; private String description; private String room; + private boolean blinded; public Enemy(){ super(100.0, 100.0); damageGiven = 10; + blinded = false; } public Enemy(int damageGiven){ super(100.0, 100.0); this.damageGiven = damageGiven; + blinded = false; } public void setName(String name) { @@ -45,4 +48,10 @@ public class Enemy extends Entity{ public int getDamage() { return this.damageGiven; } + public boolean getBlinded() { + return blinded; + } + public void setBlinded(boolean blinded) { + this.blinded = blinded; + } } diff --git a/src/com/bayviewglen/zork/Game.java b/src/com/bayviewglen/zork/Game.java index 7ac4744..1f24545 100644 --- a/src/com/bayviewglen/zork/Game.java +++ b/src/com/bayviewglen/zork/Game.java @@ -502,7 +502,7 @@ class Game { if(command.hasItem()) { boolean has = false; for(Item i : player.getInventory()) { - if(i.getName().toLowerCase().equals(command.getItem())) { + if(i.getName().toLowerCase().replaceAll("\\s+","").equals(command.getItem())) { has = true; } } @@ -525,7 +525,7 @@ class Game { if(command.hasItem()) { boolean has = false; for(Item i : player.getInventory()) { - if(i.getName().toLowerCase().equals(command.getItem())) { + if(i.getName().toLowerCase().replaceAll("\\s+","").equals(command.getItem())) { has = true; } } diff --git a/src/com/bayviewglen/zork/Items/ShavingCream.java b/src/com/bayviewglen/zork/Items/Shavingcream.java similarity index 68% rename from src/com/bayviewglen/zork/Items/ShavingCream.java rename to src/com/bayviewglen/zork/Items/Shavingcream.java index a234e0c..2ab3640 100644 --- a/src/com/bayviewglen/zork/Items/ShavingCream.java +++ b/src/com/bayviewglen/zork/Items/Shavingcream.java @@ -1,8 +1,8 @@ -package com.bayviewglen.zork.Items; -public class ShavingCream extends Item{ - - public ShavingCream(){ - super(16, "Shaving Cream", "A can of shaving cream with foam still around the edge of the nozzle", false, 10, 1); - } - -} +package com.bayviewglen.zork.Items; +public class Shavingcream extends Item{ + + public Shavingcream(){ + super(16, "Shaving Cream", "A can of shaving cream with foam still around the edge of the nozzle", false, 10, 1); + } + +}