Tests out some new things

This commit is contained in:
Kristian Knarvik 2018-03-14 00:00:52 +01:00
parent b88f3c0ef4
commit 6a21332877
14 changed files with 131 additions and 45 deletions

View File

@ -25,7 +25,7 @@ Dette prosjektet inneholder [Semesteroppgave 1](SEM-1.md). Du kan også [lese op
* Levert av: *Kristian Knarvik* (*kkn015*)
* Del A: [x] helt ferdig, [ ] delvis ferdig
* Del B: [ ] helt ferdig, [x] delvis ferdig
* Del C: [ ] helt ferdig, [ ] delvis ferdig
* Del C: [ ] helt ferdig, [X] delvis ferdig
* [ ] hele semesteroppgaven er ferdig og klar til retting!
# Del A
@ -79,7 +79,7 @@ d)
* Main og Game har blitt endret til å tillate spilleren å selv velge når den har utført en tur. Dette har blitt gjort for å kunne ignorere uønskede tastetrykk, og for å tilby spilleren valg.
### Tredjepartsfiler
* Bow Fire Arrow Sound fra http://soundbible.com av Stephan Schutze
* Sword Swing Sound fra http://soundbible.com av Mike Koenig
* Large Fireball Sound fra http://soundbible.com av Mike Koenig
* Bow Fire Arrow Sound (http://soundbible.com, Stephan Schutze, Noncommercial 3.0)
* Sword Swing Sound (http://soundbible.com, Mike Koenig, Attribution 3.0)
* Large Fireball Sound (http://soundbible.com av Mike Koenig, Attribution 3.0)

View File

@ -333,7 +333,7 @@ public class Screen {
private final Canvas background;
private final Group root;
//private Paint bgColor = Color.CORNFLOWERBLUE;
private Paint bgColor = Color.BROWN;
private Paint bgColor = Color.BLACK;
private int aspect = 0;
private double scaling = 0;
private double currentScale = 1.0;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -75,7 +75,7 @@ public class Printer implements IPaintLayer {
return r;
}
Color DEFAULT_FILL = Color.BLACK;
Color DEFAULT_FILL = Color.WHITE;
Color DEFAULT_STROKE = Color.TRANSPARENT;
@ -91,7 +91,7 @@ public class Printer implements IPaintLayer {
// private int pageWidth = LINE_WIDTHS[resMode], pageHeight =
// PAGE_HEIGHTS[resMode];
private int leftMargin = 1, topMargin = 1;
private TextFont font = FONT_LMMONO;
private TextFont font = FONT_SYMBOLA;
private int videoAttrs = 0;
private String csiSeq = null;

View File

@ -229,7 +229,7 @@ public class Girl implements INonPlayer {
@Override
public String getPrintSymbol() {
return "𓀠";
return "\u001b[95m" + "\uD83D\uDEB6" + "\u001b[0m";
}
@Override

View File

@ -19,11 +19,8 @@ import inf101.v18.grid.ILocation;
import inf101.v18.rogue101.Main;
import inf101.v18.rogue101.enemies.Girl;
import inf101.v18.rogue101.examples.Carrot;
import inf101.v18.rogue101.items.IBuffItem;
import inf101.v18.rogue101.items.IWeapon;
import inf101.v18.rogue101.items.Manga;
import inf101.v18.rogue101.items.*;
import inf101.v18.rogue101.examples.Rabbit;
import inf101.v18.rogue101.items.Sword;
import inf101.v18.rogue101.map.GameMap;
import inf101.v18.rogue101.map.IGameMap;
import inf101.v18.rogue101.map.IMapView;
@ -91,6 +88,11 @@ public class Game implements IGame {
}
}
// Prints some helpful information.
String[] info = {"Controls:", "WASD or arrow keys for movement", "E to pick up an item", "Q to drop an item", "1-5 to choose an item", "N to change name", "ENTER to confirm", "R to use a ranged attack", "F to use a magic attack"};
for (int i = 0; i < info.length; i++) {
this.printer.printAt(map.getWidth() + 2, 1 + i, info[i]);
}
}
public Game(String mapString) {
@ -339,6 +341,7 @@ public class Game implements IGame {
itemFactories.put("G", Girl::new);
itemFactories.put(".", Dust::new);
itemFactories.put("S", Sword::new);
itemFactories.put("c", Chest::new);
}
@Override

View File

@ -0,0 +1,62 @@
package inf101.v18.rogue101.items;
import inf101.v18.rogue101.game.IGame;
import inf101.v18.rogue101.objects.IItem;
import java.util.List;
public class Chest implements IContainer {
@Override
public IItem get(int i) {
return null;
}
@Override
public List getContent() {
return null;
}
@Override
public boolean isFull() {
return false;
}
@Override
public int getCurrentHealth() {
return 0;
}
@Override
public int getDefence() {
return 0;
}
@Override
public int getMaxHealth() {
return 0;
}
@Override
public String getName() {
return null;
}
@Override
public int getSize() {
return 100;
}
public String getPrintSymbol() {
return "\uD83D\uDDC3";
}
@Override
public String getSymbol() {
return "C";
}
@Override
public int handleDamage(IGame game, IItem source, int amount) {
return 0;
}
}

View File

@ -1,7 +1,6 @@
package inf101.v18.rogue101.items;
import inf101.v18.rogue101.objects.IItem;
import java.util.List;
/**
@ -32,7 +31,4 @@ public interface IContainer<T extends IItem> extends IItem {
* @return True if it has no space left
*/
boolean isFull();
}

View File

@ -47,9 +47,13 @@ public class Manga implements IItem {
return 5;
}
@Override
public String getPrintSymbol() {
return "🕮";
}
@Override
public String getSymbol() {
//return "🕮";
return "M";
}

View File

@ -1,21 +1,21 @@
50 20
##################################################
# #
# #
# #
# G G #
# #
############### # #
# # #
# S # #
# @ ####################### #
# # #
# # #
# # #
# G #
# G #
# #
# #
# #
# G #
##################################################
40 20
########################################
# #
# #
# #
# G G #
# #
############### # #
# # #
# S # #
# @ ######## #########
# # #
# # #
# # #
# G #
# G #
# #
# #
# #
# G #
########################################

View File

@ -81,12 +81,21 @@ public class Player implements IPlayer {
return turnConsumed;
}
/**
* Lets the user write his/her name.
*
* @param game An IGame object
* @param key The key pressed
*/
private void write(IGame game, KeyCode key) {
if (key != KeyCode.ENTER) {
text += key.getName();
if (key == KeyCode.BACK_SPACE) {
text = text.substring(0, text.length() - 1);
game.displayMessage("Please enter your name: " + text);
} else if (key != KeyCode.ENTER) {
text += key.toString();
game.displayMessage("Please enter your name: " + text);
} else {
name = text;
name = text.toLowerCase();
text = "";
game.displayMessage("Name set.");
writing = false;
@ -102,7 +111,7 @@ public class Player implements IPlayer {
private boolean pickUpInit(IGame game) {
List<IItem> items = game.getLocalItems();
if (items.size() < 1) {
game.displayMessage("There is nothing to pick up.");
game.displayMessage("There is nothing to pick up");
} else {
if (items.size() == 1) {
pickUp(game, 0);
@ -129,6 +138,8 @@ public class Player implements IPlayer {
if (equipped.size() == 1) {
drop(game, 0);
return true;
} else if (equipped.size() < 1) {
game.displayMessage("You have nothing to drop");
} else {
StringBuilder msg = new StringBuilder("Items to drop:");
for (int i = 0; i < equipped.size(); i++) {
@ -195,7 +206,8 @@ public class Player implements IPlayer {
String name = item.getName();
items.add(firstCharToUpper(name));
}
game.formatStatus("HP: %d/%d ATK: %d DEF: %s INV: %s", hp, getMaxHealth(), getAttack(), getDefence(), String.join(",", items));
//TODO: Add item bonuses to visible stats.
game.formatStatus("HP: %d/%d ATK: %d DEF: %s DMG: %s INV: %s", hp, getMaxHealth(), getAttack(), getDefence(), getDamage(), String.join(",", items));
}
/**
@ -205,7 +217,11 @@ public class Player implements IPlayer {
* @return The input string with the first character uppercased
*/
private String firstCharToUpper(String input) {
return Character.toUpperCase(input.charAt(0)) + input.substring(1);
if (input.length() < 1) {
return input;
} else {
return Character.toUpperCase(input.charAt(0)) + input.substring(1);
}
}
private void tryToMove(IGame game, GridDirection dir) {
@ -257,7 +273,7 @@ public class Player implements IPlayer {
@Override
public String getName() {
return name;
return firstCharToUpper(name);
}
@Override
@ -265,6 +281,11 @@ public class Player implements IPlayer {
return 10;
}
@Override
public String getPrintSymbol() {
return "\u001b[96m" + "@" + "\u001b[0m";
}
@Override
public String getSymbol() {
return "@";