1 | package de.aikiit.game.kaiser; | |
2 | ||
3 | import java.util.InputMismatchException; | |
4 | import java.util.Scanner; | |
5 | ||
6 | /** | |
7 | * This class contains all available actions that have to be taken by the player of the game. | |
8 | * At the moment this is done via the operating system's console. | |
9 | */ | |
10 | public class KaiserActions { | |
11 | ||
12 | /** | |
13 | * Try to buy land in the current game. | |
14 | * | |
15 | * @param engine the current game engine | |
16 | * @return {@code true} if the buy action succeeded, {@code false} otherwise. | |
17 | */ | |
18 | public static boolean buy(KaiserEngine engine) { | |
19 | while (true) { | |
20 | try { | |
21 |
1
1. buy : removed call to java/io/PrintStream::println → SURVIVED |
System.out.println(KaiserEnginePrinter.ANSI_PURPLE + "Wieviel Land wollen Sie kaufen? 0 = nichts" + KaiserEnginePrinter.ANSI_RESET); |
22 | Long buy = new Scanner(System.in).nextLong(); | |
23 |
3
1. buy : negated conditional → KILLED 2. buy : replaced boolean return with true for de/aikiit/game/kaiser/KaiserActions::buy → KILLED 3. buy : changed conditional boundary → KILLED |
return engine.buyLand(buy) > 0; |
24 | } catch (InputMismatchException e) { | |
25 |
1
1. buy : removed call to java/io/PrintStream::print → NO_COVERAGE |
System.out.print(KaiserEnginePrinter.ANSI_PURPLE); |
26 |
1
1. buy : removed call to java/io/PrintStream::println → NO_COVERAGE |
System.out.println("Gib einen richtigen Wert ein, Du Knalltüte!"); |
27 |
1
1. buy : removed call to java/io/PrintStream::print → NO_COVERAGE |
System.out.print(KaiserEnginePrinter.ANSI_RESET); |
28 | } catch (IllegalArgumentException e) { | |
29 |
1
1. buy : removed call to java/io/PrintStream::print → NO_COVERAGE |
System.out.print(KaiserEnginePrinter.ANSI_PURPLE); |
30 |
1
1. buy : removed call to java/io/PrintStream::println → NO_COVERAGE |
System.out.println("Überleg doch mal, Du hast nur " + engine.getSupplies() + " Korn zur Verfügung. Nun denn, versuch es nochmals."); |
31 |
1
1. buy : removed call to java/io/PrintStream::print → NO_COVERAGE |
System.out.print(KaiserEnginePrinter.ANSI_RESET); |
32 | } | |
33 | } | |
34 | } | |
35 | ||
36 | /** | |
37 | * Perform a sell operation in the current game. | |
38 | * | |
39 | * @param engine the current game engine | |
40 | */ | |
41 | public static void sell(KaiserEngine engine) { | |
42 | while (true) { | |
43 | try { | |
44 |
1
1. sell : removed call to java/io/PrintStream::println → SURVIVED |
System.out.println(KaiserEnginePrinter.ANSI_PURPLE + "Wieviel Land wollen Sie verkaufen?" + KaiserEnginePrinter.ANSI_RESET); |
45 | Long sell = new Scanner(System.in).nextLong(); | |
46 |
1
1. sell : removed call to de/aikiit/game/kaiser/KaiserEngine::sellLand → SURVIVED |
engine.sellLand(sell); |
47 | return; | |
48 | } catch (InputMismatchException e) { | |
49 |
1
1. sell : removed call to java/io/PrintStream::print → NO_COVERAGE |
System.out.print(KaiserEnginePrinter.ANSI_PURPLE); |
50 |
1
1. sell : removed call to java/io/PrintStream::println → NO_COVERAGE |
System.out.println("Gib einen richtigen Wert ein, Du Knalltüte!"); |
51 |
1
1. sell : removed call to java/io/PrintStream::print → NO_COVERAGE |
System.out.print(KaiserEnginePrinter.ANSI_RESET); |
52 | } catch (IllegalArgumentException e) { | |
53 |
1
1. sell : removed call to java/io/PrintStream::print → NO_COVERAGE |
System.out.print(KaiserEnginePrinter.ANSI_PURPLE); |
54 |
1
1. sell : removed call to java/io/PrintStream::println → NO_COVERAGE |
System.out.println("Überleg doch mal, Du hast nur " + engine.getArea() + " Hektar Land. Probier es erneut."); |
55 |
1
1. sell : removed call to java/io/PrintStream::print → NO_COVERAGE |
System.out.print(KaiserEnginePrinter.ANSI_RESET); |
56 | } | |
57 | } | |
58 | } | |
59 | ||
60 | /** | |
61 | * Perform a feeding operation in the current game, that means give food to the population. | |
62 | * | |
63 | * @param engine the current game engine | |
64 | */ | |
65 | public static void feed(KaiserEngine engine) { | |
66 | while (true) { | |
67 | try { | |
68 |
1
1. feed : removed call to java/io/PrintStream::println → SURVIVED |
System.out.println(KaiserEnginePrinter.ANSI_PURPLE + "Wieviel dzt wollen Sie an Ihr Volk verteilen?" + KaiserEnginePrinter.ANSI_RESET); |
69 | Long feed = new Scanner(System.in).nextLong(); | |
70 |
1
1. feed : removed call to de/aikiit/game/kaiser/KaiserEngine::feedToPopulation → SURVIVED |
engine.feedToPopulation(feed); |
71 | return; | |
72 | } catch (InputMismatchException e) { | |
73 |
1
1. feed : removed call to java/io/PrintStream::print → NO_COVERAGE |
System.out.print(KaiserEnginePrinter.ANSI_PURPLE); |
74 |
1
1. feed : removed call to java/io/PrintStream::println → NO_COVERAGE |
System.out.println("Gib einen richtigen Wert ein, Du Knalltüte!"); |
75 |
1
1. feed : removed call to java/io/PrintStream::print → NO_COVERAGE |
System.out.print(KaiserEnginePrinter.ANSI_RESET); |
76 | } catch (IllegalArgumentException e) { | |
77 |
1
1. feed : removed call to java/io/PrintStream::print → NO_COVERAGE |
System.out.print(KaiserEnginePrinter.ANSI_PURPLE); |
78 |
1
1. feed : removed call to java/io/PrintStream::println → NO_COVERAGE |
System.out.println("Überleg doch mal, Du hast nur " + engine.getSupplies() + " Korn zur Verfügung. Nun denn, probier es erneut."); |
79 |
1
1. feed : removed call to java/io/PrintStream::print → NO_COVERAGE |
System.out.print(KaiserEnginePrinter.ANSI_RESET); |
80 | } | |
81 | } | |
82 | } | |
83 | ||
84 | /** | |
85 | * In order to feed your population you need to plant crops and cultivate your available area/land. | |
86 | * | |
87 | * @param engine the current game engine | |
88 | */ | |
89 | public static void cultivate(KaiserEngine engine) { | |
90 | while (true) { | |
91 | try { | |
92 |
1
1. cultivate : removed call to java/io/PrintStream::println → SURVIVED |
System.out.println(KaiserEnginePrinter.ANSI_PURPLE + "Wieviel Land wollen Sie bebauen?" + KaiserEnginePrinter.ANSI_RESET); |
93 | Long cultivate = new Scanner(System.in).nextLong(); | |
94 |
1
1. cultivate : removed call to de/aikiit/game/kaiser/KaiserEngine::cultivate → SURVIVED |
engine.cultivate(cultivate); |
95 | return; | |
96 | } catch (InputMismatchException e) { | |
97 |
1
1. cultivate : removed call to java/io/PrintStream::print → NO_COVERAGE |
System.out.print(KaiserEnginePrinter.ANSI_PURPLE); |
98 |
1
1. cultivate : removed call to java/io/PrintStream::println → NO_COVERAGE |
System.out.println("Gib einen richtigen Wert ein, Du Knalltüte!"); |
99 |
1
1. cultivate : removed call to java/io/PrintStream::print → NO_COVERAGE |
System.out.print(KaiserEnginePrinter.ANSI_RESET); |
100 | } catch (IllegalArgumentException e) { | |
101 |
1
1. cultivate : removed call to java/io/PrintStream::print → NO_COVERAGE |
System.out.print(KaiserEnginePrinter.ANSI_PURPLE); |
102 | switch (e.getMessage()) { | |
103 | case "You cannot cultivate more area than you have." -> | |
104 |
1
1. cultivate : removed call to java/io/PrintStream::println → NO_COVERAGE |
System.out.println("Überleg doch mal, Du hast nur " + engine.getArea() + " Hektar Land. Probier es nochmals."); |
105 | case "You cannot cultivate more than you have." -> | |
106 |
1
1. cultivate : removed call to java/io/PrintStream::println → NO_COVERAGE |
System.out.println("Nun denk doch mal nach, Du hast nur " + engine.getSupplies() + " Korn zur Verfügung. Nun denn, versuche es erneut."); |
107 | case "Not enough workers available." -> | |
108 |
1
1. cultivate : removed call to java/io/PrintStream::println → NO_COVERAGE |
System.out.println("Sie haben aber nur " + engine.getPopulation() + " Arbeiter. Noch einmal."); |
109 | } | |
110 |
1
1. cultivate : removed call to java/io/PrintStream::print → NO_COVERAGE |
System.out.print(KaiserEnginePrinter.ANSI_RESET); |
111 | } | |
112 | } | |
113 | } | |
114 | } | |
Mutations | ||
21 |
1.1 |
|
23 |
1.1 2.2 3.3 |
|
25 |
1.1 |
|
26 |
1.1 |
|
27 |
1.1 |
|
29 |
1.1 |
|
30 |
1.1 |
|
31 |
1.1 |
|
44 |
1.1 |
|
46 |
1.1 |
|
49 |
1.1 |
|
50 |
1.1 |
|
51 |
1.1 |
|
53 |
1.1 |
|
54 |
1.1 |
|
55 |
1.1 |
|
68 |
1.1 |
|
70 |
1.1 |
|
73 |
1.1 |
|
74 |
1.1 |
|
75 |
1.1 |
|
77 |
1.1 |
|
78 |
1.1 |
|
79 |
1.1 |
|
92 |
1.1 |
|
94 |
1.1 |
|
97 |
1.1 |
|
98 |
1.1 |
|
99 |
1.1 |
|
101 |
1.1 |
|
104 |
1.1 |
|
106 |
1.1 |
|
108 |
1.1 |
|
110 |
1.1 |