Removes dev door

This commit is contained in:
Kristian Knarvik 2018-03-21 10:20:43 +01:00
parent a869cb1049
commit ab31b9b4e0
4 changed files with 28 additions and 47 deletions

View File

@ -1,6 +1,5 @@
package inf101.v18.rogue101.enemies;
import inf101.v18.gfx.textmode.BlocksAndBoxes;
import inf101.v18.grid.ILocation;
import inf101.v18.rogue101.Main;
import inf101.v18.rogue101.game.Game;
@ -87,27 +86,6 @@ public class Boss implements INonPlayer {
return 3;
}
/**
* Generates a hp bar based on the boss' current hp
*
* @return HP bar as string
*/
private String hpBar() {
StringBuilder str = new StringBuilder(BlocksAndBoxes.BLOCK_HALF);
int hpLen = (int)((float)hp/getMaxHealth() * 10.0);
if (hp > 0 && hp < 100) {
hpLen++;
}
for (int i = 0; i < hpLen; i++) {
str.append("\u001b[91m" + BlocksAndBoxes.BLOCK_HALF + "\u001b[0m");
}
for (int i = 0; i < 10 - hpLen; i++) {
str.append(" ");
}
str.append(BlocksAndBoxes.BLOCK_HALF);
return str.toString();
}
@Override
public int handleDamage(IGame game, IItem source, int amount) {
hp -= amount;
@ -123,7 +101,7 @@ public class Boss implements INonPlayer {
}
((Game)game).win();
}
game.getPrinter().printAt(Main.COLUMN_RIGHTSIDE_START, 19, "Boss HP: " + hpBar());
game.getPrinter().printAt(Main.COLUMN_RIGHTSIDE_START, 19, "Boss HP: " + NPC.hpBar(this));
return amount;
}
}

View File

@ -5,7 +5,7 @@
# ###### # #
# # # G #
# # #
###=########################### #
############################### #
# # #
# < # G #
############## # G #

View File

@ -1,6 +1,5 @@
package inf101.v18.rogue101.objects;
import inf101.v18.gfx.textmode.BlocksAndBoxes;
import inf101.v18.gfx.textmode.Printer;
import inf101.v18.grid.GridDirection;
import inf101.v18.grid.ILocation;
@ -337,7 +336,7 @@ public class Player implements IPlayer {
*/
private void showStatus(IGame game) {
//TODO: Add item bonuses to visible stats.
game.formatStatus("HP: %s %d/%d ATK: %d DEF: %s DMG: %s", hpBar(), hp, getMaxHealth(), getAttack(), getDefence(), getDamage());
game.formatStatus("HP: %s %d/%d ATK: %d DEF: %s DMG: %s", NPC.hpBar(this), hp, getMaxHealth(), getAttack(), getDefence(), getDamage());
printInventory(game);
}
@ -356,27 +355,6 @@ public class Player implements IPlayer {
}
}
/**
* Generates a hp bar based on player's current hp
*
* @return HP bar as string
*/
private String hpBar() {
StringBuilder str = new StringBuilder(BlocksAndBoxes.BLOCK_HALF);
int hpLen = (int)((float)hp/getMaxHealth() * 10.0);
if (hp > 0 && hp < 100) {
hpLen++;
}
for (int i = 0; i < hpLen; i++) {
str.append("\u001b[91m" + BlocksAndBoxes.BLOCK_HALF + "\u001b[0m");
}
for (int i = 0; i < 10 - hpLen; i++) {
str.append(" ");
}
str.append(BlocksAndBoxes.BLOCK_HALF);
return str.toString();
}
/**
* Changes the first character in a string to uppercase.
*

View File

@ -1,5 +1,6 @@
package inf101.v18.rogue101.shared;
import inf101.v18.gfx.textmode.BlocksAndBoxes;
import inf101.v18.grid.GridDirection;
import inf101.v18.grid.ILocation;
import inf101.v18.rogue101.game.IGame;
@ -169,4 +170,28 @@ public class NPC {
MediaPlayer mediaPlayer = new MediaPlayer(sound);
mediaPlayer.play();
}
/**
* Generates a hp bar based on item's current hp
*
* @return HP bar as string
*/
public static String hpBar(IItem item) {
StringBuilder str = new StringBuilder(BlocksAndBoxes.BLOCK_HALF);
int hp = item.getCurrentHealth();
int hpLen = (int)((float)hp/item.getMaxHealth() * 10.0);
if (hp > 0 && hp < 100) {
str.append("\u001b[91m" + BlocksAndBoxes.BLOCK_BOTTOM + "\u001b[0m");
hpLen++;
} else {
for (int i = 0; i < hpLen; i++) {
str.append("\u001b[91m" + BlocksAndBoxes.BLOCK_HALF + "\u001b[0m");
}
}
for (int i = 0; i < 10 - hpLen; i++) {
str.append(" ");
}
str.append(BlocksAndBoxes.BLOCK_HALF);
return str.toString();
}
}