fixed tests

This commit is contained in:
musilto9 2020-06-07 21:47:46 +02:00
parent 33c5abe4dd
commit 06027ccc83
13 changed files with 136 additions and 32 deletions

View File

@ -107,17 +107,19 @@ public class Battle {
windowOfBattle.getMenuOfActions().getConsole().removeActionListener(windowOfBattle.getMenuOfActions().getConsole().getActionListeners()[0]);
windowOfBattle.getMenuOfActions().getEscape().removeActionListener(windowOfBattle.getMenuOfActions().getEscape().getActionListeners()[0]);
windowOfBattle.getMenuOfActions().getInventory().removeActionListener(windowOfBattle.getMenuOfActions().getInventory().getActionListeners()[0]);
InteractionCell ic;
if (b) ic = new InteractionCell(-1, -1, windowOfBattle.getWinCutscene(),
new Dialog(windowOfFreeMove.getDialogBar()), windowOfFreeMove.getMapManager().getActualMap(), windowOfFreeMove, true);
else ic = new InteractionCell(-1, -1, windowOfBattle.getLoseCutscene(),
new Dialog(windowOfFreeMove.getDialogBar()), windowOfFreeMove.getMapManager().getActualMap(), windowOfFreeMove, true);
ic.startEvent();
windowOfFreeMove.getForegroundPanel().setColorForeground(0, 0, 0, 255);
windowOfFreeMove.setVisible(true);
windowOfFreeMove.requestFocus();
windowOfBattle.getGame().remove(windowOfBattle);
windowOfBattle.getMusicManager().stopMusic();
if (windowOfFreeMove.getMapManager() != null) {
InteractionCell ic;
if (b) ic = new InteractionCell(-1, -1, windowOfBattle.getWinCutscene(),
new Dialog(windowOfFreeMove.getDialogBar()), windowOfFreeMove.getMapManager().getActualMap(), windowOfFreeMove, true);
else ic = new InteractionCell(-1, -1, windowOfBattle.getLoseCutscene(),
new Dialog(windowOfFreeMove.getDialogBar()), windowOfFreeMove.getMapManager().getActualMap(), windowOfFreeMove, true);
ic.startEvent();
windowOfFreeMove.getForegroundPanel().setColorForeground(0, 0, 0, 255);
windowOfFreeMove.setVisible(true);
windowOfFreeMove.requestFocus();
windowOfBattle.getGame().remove(windowOfBattle);
windowOfBattle.getMusicManager().stopMusic();
}
// SaveManager saveManager = game.getFreeMove().getMapManager().getSaveManager();
// saveManager.saveGame();
}

View File

@ -139,7 +139,7 @@ public abstract class BattlePerson {
}
public void setHealth(int health) {
if (this.health > health) {
if (this.health > health && image != null) {
getHurt();
setImageEffect("hurt");
}

View File

@ -65,7 +65,7 @@ public class Npc extends Person {
moveRight();
break;
}
if (name.equals("monster")) {
if (name != null && name.equals("monster")) {
getMap().getSoundManager().playSound("monstersound.wav", 0.0f);
}
}
@ -146,4 +146,8 @@ public class Npc extends Person {
}
public String getName() { return name; }
public Timer getTimer() {
return timer;
}
}

View File

@ -41,6 +41,7 @@ public class Game extends JFrame {
//tohle spustí na začátku menu
add(menu);
menu.start();
//tohle spustí na začátku hru
// add(freeMove);
@ -48,7 +49,7 @@ public class Game extends JFrame {
//tohle spustí na začátku bitvu
// add(battle);
// battle.startBattle("storageroombattle");
// battle.start("storageroombattle");
//Tohle spustí na začátku tileset overview
//new LevelEditor();

View File

@ -263,7 +263,7 @@ public class LevelEditor extends JFrame {
private void initializeCellMap() {
cellMap.put("BLOCK", 0);
cellMap.put("EVENT", 0);
cellMap.put("INTER", 0);
cellMap.put("TRIGGER", 0);
cellMap.put("MOVETO", 0);
cellMap.put("DOOR/DOORTO", 0);

View File

@ -116,7 +116,7 @@ public class WindowOfBattle extends JPanel {
setCursor(Cursor.getDefaultCursor());
}
public void startBattle(String name) {
public void start(String name) {
LinkedList<Hero> heroes = new LinkedList<>();
LinkedList<Enemy> enemies = new LinkedList<>();

View File

@ -224,7 +224,7 @@ public class WindowOfFreeMove extends JLayeredPane {
setVisible(false);
WindowOfBattle battle = game.getBattle();
mapManager.getWindow().getGame().add(battle);
battle.startBattle(name);
battle.start(name);
}
public class Canvas extends JPanel {

View File

@ -33,6 +33,7 @@ public class WindowOfMenu extends JPanel {
private MusicManager musicManager;
public WindowOfMenu(Game game) {
setIgnoreRepaint(true);
this.game = game;
this.freeMove = game.getFreeMove();
screenSize = Toolkit.getDefaultToolkit().getScreenSize();
@ -164,7 +165,9 @@ public class WindowOfMenu extends JPanel {
@Override
public void mouseExited(MouseEvent e) { exitGame.setLocation(exitGame.getX(), exitGame.getY() + 3); }
});
}
public void start() {
musicManager = new MusicManager("Town2.wav", -25.0f);
musicManager.playMusic();
musicManager.fadeIn(10);
@ -182,27 +185,32 @@ public class WindowOfMenu extends JPanel {
repaint();
}
};
Timer timer = new Timer("Timer");
java.util.Timer timer = new Timer("Timer");
long delay = 3000L;
timer.schedule(task, delay);
setIgnoreRepaint(false);
}
@Override
protected void paintComponent(Graphics g) {
Image powered = null;
Image menu = null;
try {
powered = ImageIO.read(new File("src/main/resources/foregrounds/poweredByCellEngine.png"));
menu = ImageIO.read(new File("src/main/resources/foregrounds/menu.png"));
} catch (IOException e) {
e.printStackTrace();
if (!getIgnoreRepaint()) {
Image powered = null;
Image menu = null;
try {
powered = ImageIO.read(new File("src/main/resources/foregrounds/poweredByCellEngine.png"));
menu = ImageIO.read(new File("src/main/resources/foregrounds/menu.png"));
} catch (IOException e) {
e.printStackTrace();
}
g.setColor(Color.BLACK);
g.fillRect(0, 0, screenSize.width, screenSize.height);
if (!showMenu)
g.drawImage(powered, (screenSize.width - (powered.getWidth(null) / 2)) / 2, (screenSize.height - (powered.getHeight(null) / 2)) / 2,
(powered.getWidth(null) / 2), (powered.getHeight(null) / 2), null);
else g.drawImage(menu, 0, 0, screenSize.width, screenSize.height, null);
}
g.setColor(Color.BLACK);
g.fillRect(0, 0, screenSize.width, screenSize.height);
if (!showMenu) g.drawImage(powered, (screenSize.width - (powered.getWidth(null)/2)) / 2, (screenSize.height - (powered.getHeight(null)/2)) / 2,
(powered.getWidth(null)/2), (powered.getHeight(null)/2), null);
else g.drawImage(menu,0, 0, screenSize.width, screenSize.height,null);
}
private void cleanUp() {

View File

@ -0,0 +1,80 @@
<map>
<mapName>tutorial</mapName>
<events>
<trigger>
<x>11</x>
<y>6</y>
<active>false</active>
</trigger>
</events>
</map>
<map>
<mapName>openspace</mapName>
<events>
<trigger>
<x>6</x>
<y>4</y>
<active>true</active>
</trigger>
<trigger>
<x>14</x>
<y>16</y>
<active>false</active>
</trigger>
<chest>
<x>1</x>
<y>2</y>
<active>true</active>
</chest>
<chest>
<x>15</x>
<y>7</y>
<active>true</active>
</chest>
</events>
</map>
<map>
<mapName>office</mapName>
<events>
<trigger>
<x>4</x>
<y>2</y>
<active>false</active>
</trigger>
<chest>
<x>1</x>
<y>9</y>
<active>true</active>
</chest>
</events>
</map>
<map>
<mapName>boss</mapName>
<events>
<trigger>
<x>4</x>
<y>18</y>
<active>true</active>
</trigger>
</events>
</map>
<map>
<mapName>treasure</mapName>
<events>
<trigger>
<x>6</x>
<y>1</y>
<active>true</active>
</trigger>
</events>
</map>
<map>
<mapName>storageroom</mapName>
<events>
<trigger>
<x>6</x>
<y>2</y>
<active>true</active>
</trigger>
</events>
</map>

View File

@ -0,0 +1,6 @@
<location>
<map>storageroom</map>
<x>6</x>
<y>2</y>
<direction>0</direction>
</location>

View File

@ -48,7 +48,7 @@ public class LevelEditorTest {
imageCell = new ImageCell();
for (String tileset : tilesets) {
activeTilesets.add(tileset);
imageCell.imageTileset(new String[]{tileset});
imageCell.imageTileset(new String[]{"",tileset});
}
tilesetOverview.setActiveTilesets(activeTilesets);
tilesetOverview.generateOverview();

View File

@ -68,6 +68,10 @@ public class PathFinderTest {
testNpc = new Npc(startX, startY, testMap, freeMove.getMapManager());
testNpc.move(endX, endY);
while (testNpc.getTimer().isRunning()) {
continue;
}
//Assert
if (isPossible) {
Assertions.assertEquals(endX, testNpc.getX());

View File

@ -41,7 +41,6 @@ public class WindowOfFreeMoveTest {
freeMove.start(true);
testMap = Map.findMapByName("m6",freeMove);
freeMove.setMapManager(testMap);
freeMove.getMapManager().setMap(testMap);
person = freeMove.getMapManager().getActualMap().getPerson();
}