1 | package g0803.bindingofshiba; | |
2 | ||
3 | import g0803.bindingofshiba.bundles.Bundle; | |
4 | import g0803.bindingofshiba.bundles.DefaultBoundingBoxesProvider; | |
5 | import g0803.bindingofshiba.bundles.DefaultFontsProvider; | |
6 | import g0803.bindingofshiba.bundles.DefaultTexturesProvider; | |
7 | import g0803.bindingofshiba.gui.GUI; | |
8 | import g0803.bindingofshiba.gui.LanternaGUI; | |
9 | import g0803.bindingofshiba.gui.keyboard.Keyboard; | |
10 | import g0803.bindingofshiba.math.BoundingBox; | |
11 | import g0803.bindingofshiba.model.menu.MainMenu; | |
12 | import g0803.bindingofshiba.state.State; | |
13 | import g0803.bindingofshiba.state.menu.MenuState; | |
14 | import g0803.bindingofshiba.textures.ITexture; | |
15 | import java.awt.*; | |
16 | import java.io.IOException; | |
17 | import java.net.URISyntaxException; | |
18 | ||
19 | public class Main implements App { | |
20 | ||
21 | private State<?> state; | |
22 | private final GUI gui; | |
23 | ||
24 | private final Bundle<Font> fonts; | |
25 | private final Bundle<ITexture> textures; | |
26 | private final Bundle<BoundingBox> boundingBoxes; | |
27 | ||
28 | public Main() throws IOException, FontFormatException { | |
29 | this.fonts = new DefaultFontsProvider().getBundle(); | |
30 | this.textures = new DefaultTexturesProvider().getBundle(); | |
31 | this.boundingBoxes = new DefaultBoundingBoxesProvider().getBundle(); | |
32 | ||
33 | this.state = new MenuState(new MainMenu()); | |
34 | this.gui = new LanternaGUI(fonts, Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT); | |
35 | } | |
36 | ||
37 | public Main( | |
38 | State<?> initialState, | |
39 | GUI gui, | |
40 | Bundle<Font> fonts, | |
41 | Bundle<ITexture> textures, | |
42 | Bundle<BoundingBox> boundingBoxes) { | |
43 | this.fonts = fonts; | |
44 | this.textures = textures; | |
45 | this.boundingBoxes = boundingBoxes; | |
46 | ||
47 | this.state = initialState; | |
48 | this.gui = gui; | |
49 | } | |
50 | ||
51 | public static void main(String[] args) | |
52 | throws IOException, URISyntaxException, FontFormatException { | |
53 |
1
1. main : removed call to g0803/bindingofshiba/Main::start → NO_COVERAGE |
new Main().start(); |
54 | } | |
55 | ||
56 | @Override | |
57 | public void setState(State<?> state) { | |
58 | this.state = state; | |
59 | } | |
60 | ||
61 | @Override | |
62 | public Keyboard getKeyboard() { | |
63 |
1
1. getKeyboard : replaced return value with null for g0803/bindingofshiba/Main::getKeyboard → KILLED |
return this.gui.getKeyboard(); |
64 | } | |
65 | ||
66 | @Override | |
67 | public Bundle<Font> getFonts() { | |
68 |
1
1. getFonts : replaced return value with null for g0803/bindingofshiba/Main::getFonts → NO_COVERAGE |
return fonts; |
69 | } | |
70 | ||
71 | @Override | |
72 | public Bundle<ITexture> getTextures() { | |
73 |
1
1. getTextures : replaced return value with null for g0803/bindingofshiba/Main::getTextures → NO_COVERAGE |
return textures; |
74 | } | |
75 | ||
76 | @Override | |
77 | public Bundle<BoundingBox> getBoundingBoxes() { | |
78 |
1
1. getBoundingBoxes : replaced return value with null for g0803/bindingofshiba/Main::getBoundingBoxes → NO_COVERAGE |
return boundingBoxes; |
79 | } | |
80 | ||
81 | public void start() throws IOException { | |
82 | int frameTime = 1000 / Constants.FPS; | |
83 | ||
84 | Keyboard keyboard = this.gui.getKeyboard(); | |
85 | ||
86 |
1
1. start : negated conditional → NO_COVERAGE |
while (this.state != null) { |
87 | long startTime = System.currentTimeMillis(); | |
88 | ||
89 |
1
1. start : removed call to g0803/bindingofshiba/gui/keyboard/Keyboard::update → NO_COVERAGE |
keyboard.update(); |
90 |
1
1. start : negated conditional → NO_COVERAGE |
if (keyboard.isClosed()) break; |
91 | ||
92 |
1
1. start : removed call to g0803/bindingofshiba/state/State::step → NO_COVERAGE |
this.state.step(this, this.gui); |
93 | ||
94 |
1
1. start : Replaced long subtraction with addition → NO_COVERAGE |
long elapsedTime = System.currentTimeMillis() - startTime; |
95 |
1
1. start : Replaced long subtraction with addition → NO_COVERAGE |
long sleepTime = frameTime - elapsedTime; |
96 | ||
97 | try { | |
98 |
3
1. start : changed conditional boundary → NO_COVERAGE 2. start : negated conditional → NO_COVERAGE 3. start : removed call to java/lang/Thread::sleep → NO_COVERAGE |
if (sleepTime > 0) Thread.sleep(sleepTime); |
99 | } catch (InterruptedException ignored) { | |
100 | break; | |
101 | } | |
102 | } | |
103 | ||
104 |
1
1. start : removed call to g0803/bindingofshiba/gui/GUI::close → NO_COVERAGE |
this.gui.close(); |
105 | } | |
106 | } | |
Mutations | ||
53 |
1.1 |
|
63 |
1.1 |
|
68 |
1.1 |
|
73 |
1.1 |
|
78 |
1.1 |
|
86 |
1.1 |
|
89 |
1.1 |
|
90 |
1.1 |
|
92 |
1.1 |
|
94 |
1.1 |
|
95 |
1.1 |
|
98 |
1.1 2.2 3.3 |
|
104 |
1.1 |