19 changed files with 1026 additions and 0 deletions
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
*.swp |
||||
*.swo |
||||
/tmp |
||||
!*/**/.gitkeep |
||||
tags |
||||
|
||||
target |
||||
logs |
||||
|
||||
.idea |
||||
*.iml |
||||
|
||||
gamedata.ser |
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<groupId>letz</groupId> |
||||
<artifactId>letzplay</artifactId> |
||||
<version>1.0</version> |
||||
<packaging>jar</packaging> |
||||
<properties> |
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||||
</properties> |
||||
|
||||
<build> |
||||
<finalName>letzplay</finalName> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-compiler-plugin</artifactId> |
||||
<version>3.8.0</version> |
||||
<configuration> |
||||
<source>11</source> |
||||
<target>11</target> |
||||
</configuration> |
||||
</plugin> |
||||
|
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-surefire-plugin</artifactId> |
||||
<version>2.21.0</version> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.junit.platform</groupId> |
||||
<artifactId>junit-platform-surefire-provider</artifactId> |
||||
<version>1.2.0-M1</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.junit.jupiter</groupId> |
||||
<artifactId>junit-jupiter-engine</artifactId> |
||||
<version>5.4.1</version> |
||||
</dependency> |
||||
</dependencies> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
<dependencies> |
||||
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api --> |
||||
<dependency> |
||||
<groupId>org.junit.jupiter</groupId> |
||||
<artifactId>junit-jupiter-api</artifactId> |
||||
<version>5.4.1</version> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
</project> |
@ -0,0 +1,89 @@
@@ -0,0 +1,89 @@
|
||||
package letzplay.core; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class GameEngine implements Trigger { |
||||
private LevelSystem lvlSys; |
||||
private List<Quest> quests; |
||||
private List<String> state; |
||||
|
||||
|
||||
private GameEngine() { |
||||
lvlSys = LevelSystem.getInstance(); |
||||
quests = new ArrayList<>(); |
||||
state = new ArrayList<>(); |
||||
} |
||||
|
||||
public static GameEngine getInstance() { |
||||
return new GameEngine(); |
||||
} |
||||
|
||||
public void initQuests(List<Quest> qs) { |
||||
this.quests = qs; |
||||
} |
||||
|
||||
private void finishQuest(Quest q) { |
||||
if (q.progression().done == q.progression().of && !q.finished()) { |
||||
q.setFinished(); |
||||
lvlSys.addExperience(q.getGainExp()); |
||||
} |
||||
} |
||||
|
||||
public List<Quest> availableQuests() { |
||||
List<Quest> result = new ArrayList<>(); |
||||
for (Quest q : quests |
||||
) { |
||||
if (q.getMinLvl() <= lvlSys.currentLvl() && !q.finished()) { |
||||
result.add(q); |
||||
} |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public List<Quest> doneQuests() { |
||||
List<Quest> result = new ArrayList<>(); |
||||
for (Quest q : quests |
||||
) { |
||||
if (q.finished()) { |
||||
result.add(q); |
||||
} |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public int currentLvl() { |
||||
return lvlSys.currentLvl(); |
||||
} |
||||
|
||||
public float currentExp() { |
||||
return lvlSys.currentExperience(); |
||||
} |
||||
|
||||
|
||||
public void update() { |
||||
for (Quest q : quests |
||||
) { |
||||
if (q.getMinLvl() <= lvlSys.currentLvl()) { |
||||
finishQuest(q); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return lvlSys.toString() + "\n " + quests.toString(); |
||||
} |
||||
|
||||
@Override |
||||
public void trigger(String msg) { |
||||
state.add(msg); |
||||
for (Quest q : quests) { |
||||
q.trigger(msg); |
||||
} |
||||
} |
||||
|
||||
public List<String> getState() { |
||||
return state; |
||||
} |
||||
} |
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
package letzplay.core; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
public interface GameLoop { |
||||
GameEngine game = GameEngine.getInstance(); |
||||
|
||||
void init(); |
||||
|
||||
void input(String trigger); |
||||
|
||||
void update(); |
||||
|
||||
Output output(); |
||||
|
||||
void save() throws IOException; |
||||
|
||||
void load() throws IOException, ClassNotFoundException; |
||||
} |
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
package letzplay.core; |
||||
|
||||
public class LevelSystem { |
||||
private int currentLvl; |
||||
private float experience; |
||||
|
||||
private LevelSystem(int currentLvl, float experience) { |
||||
this.currentLvl = currentLvl; |
||||
this.experience = experience; |
||||
} |
||||
|
||||
public static LevelSystem getInstance() { |
||||
return new LevelSystem(0, 0); |
||||
} |
||||
|
||||
private void lvlUp() { |
||||
currentLvl++; |
||||
} |
||||
|
||||
public void addExperience(float exp) { |
||||
experience += exp; |
||||
if (experience >= 100) { |
||||
lvlUp(); |
||||
experience = experience % 100; |
||||
} |
||||
} |
||||
|
||||
public int currentLvl() { |
||||
return currentLvl; |
||||
} |
||||
|
||||
public float currentExperience() { |
||||
return experience; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "Current Level: " + currentLvl + "\n" + "Experience to next " + |
||||
"Level: " + experience + "%"; |
||||
} |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
package letzplay.core; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class Output { |
||||
public List<Quest> quests = new ArrayList<>(); |
||||
public int lvl; |
||||
public float exp; |
||||
|
||||
public Output(List<Quest> quests, int lvl, float exp) { |
||||
this.quests.addAll(quests); |
||||
this.lvl = lvl; |
||||
this.exp = exp; |
||||
} |
||||
} |
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
package letzplay.core; |
||||
|
||||
public class Progression { |
||||
|
||||
int done; |
||||
int of; |
||||
|
||||
|
||||
public Progression(int done, int of) { |
||||
this.done = done; |
||||
this.of = of; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return done + " of " + of; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,94 @@
@@ -0,0 +1,94 @@
|
||||
package letzplay.core; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class Quest implements Trigger { |
||||
private String title; |
||||
private String description; |
||||
private List<Task> taskList; |
||||
private int minLvl; |
||||
private float gainExp; |
||||
private boolean finished; |
||||
private List<String> triggers; |
||||
|
||||
public Quest(String title, String description, int minLvl, float gainExp) { |
||||
this.title = title; |
||||
this.description = description; |
||||
this.minLvl = minLvl; |
||||
this.gainExp = gainExp; |
||||
taskList = new ArrayList<>(); |
||||
triggers = new ArrayList<>(); |
||||
finished = false; |
||||
} |
||||
|
||||
public void addTask(Task task) { |
||||
addTrigger(task.getTrigger()); |
||||
taskList.add(task); |
||||
} |
||||
|
||||
public void addTask(List<Task> tasks) { |
||||
for (Task t : tasks) { |
||||
addTask(t); |
||||
} |
||||
} |
||||
|
||||
public Progression progression() { |
||||
int done = 0; |
||||
for (Task task : taskList) { |
||||
if (task.isDone()) { |
||||
done++; |
||||
} |
||||
} |
||||
return new Progression(done, taskList.size()); |
||||
} |
||||
|
||||
|
||||
public String getTitle() { |
||||
return title; |
||||
} |
||||
|
||||
public String getDescription() { |
||||
return description; |
||||
} |
||||
|
||||
public List<Task> getTaskList() { |
||||
return taskList; |
||||
} |
||||
|
||||
public int getMinLvl() { |
||||
return minLvl; |
||||
} |
||||
|
||||
public float getGainExp() { |
||||
return gainExp; |
||||
} |
||||
|
||||
public void setFinished() { |
||||
finished = true; |
||||
} |
||||
|
||||
public boolean finished() { |
||||
return finished; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return title + ": " + progression().toString() + "\n" + description + |
||||
"\nTasks: " + taskList.toString() + "\n"; |
||||
} |
||||
|
||||
@Override |
||||
public void trigger(String msg) { |
||||
if (triggers.contains(msg)) { |
||||
for (Task t : taskList) { |
||||
t.trigger(msg); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
private void addTrigger(String trigger) { |
||||
triggers.add(trigger); |
||||
} |
||||
} |
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
package letzplay.core; |
||||
|
||||
public class Task implements Trigger { |
||||
private String title; |
||||
private String description; |
||||
private boolean done; |
||||
private String trigger; |
||||
|
||||
public Task(String title, String description, String trigger) { |
||||
this.title = title; |
||||
this.description = description; |
||||
this.trigger = trigger; |
||||
this.done = false; |
||||
} |
||||
|
||||
private void complete() { |
||||
done = true; |
||||
} |
||||
|
||||
public boolean isDone() { |
||||
return done; |
||||
} |
||||
|
||||
public String getTitle() { |
||||
return title; |
||||
} |
||||
|
||||
public String getDescription() { |
||||
return description; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object obj) { |
||||
if (this == obj) |
||||
return true; |
||||
if (obj == null) |
||||
return false; |
||||
if (!(obj instanceof Task)) |
||||
return false; |
||||
Task other = (Task) obj; |
||||
|
||||
return this.getTitle().equals(other.getTitle()) && |
||||
this.getDescription().equals(other.getDescription()); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return title + "\n" + description + "\nDone: " + done + "\n"; |
||||
} |
||||
|
||||
@Override |
||||
public void trigger(String msg) { |
||||
if (trigger.equals(msg)) { |
||||
complete(); |
||||
} |
||||
} |
||||
|
||||
public String getTrigger() { |
||||
return trigger; |
||||
} |
||||
} |
@ -0,0 +1,5 @@
@@ -0,0 +1,5 @@
|
||||
package letzplay.core; |
||||
|
||||
public interface Trigger { |
||||
void trigger(String msg); |
||||
} |
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
package letzplay.ganttproject; |
||||
|
||||
import letzplay.core.GameLoop; |
||||
import letzplay.core.Output; |
||||
|
||||
import java.io.*; |
||||
import java.util.ArrayList; |
||||
|
||||
public class GanttGameLoop implements GameLoop { |
||||
|
||||
private static GanttGameLoop instance = null; |
||||
|
||||
private GanttGameLoop() { |
||||
} |
||||
|
||||
public static GanttGameLoop getGameLoop() { |
||||
if (instance == null) { |
||||
instance = new GanttGameLoop(); |
||||
} |
||||
return instance; |
||||
} |
||||
|
||||
@Override |
||||
public void init() { |
||||
game.initQuests(GanttProject.init()); |
||||
} |
||||
|
||||
@Override |
||||
public void input(String trigger) { |
||||
System.out.println("Trigger: "+trigger); |
||||
game.trigger(trigger); |
||||
} |
||||
|
||||
@Override |
||||
public void update() { |
||||
game.update(); |
||||
} |
||||
|
||||
@Override |
||||
public Output output() { |
||||
//System.out.println(game.toString());
|
||||
return new Output(game.availableQuests(), game.currentLvl(), |
||||
game.currentExp()); |
||||
} |
||||
|
||||
@Override |
||||
public void save() throws IOException { |
||||
FileOutputStream writeData = new FileOutputStream("gamedata.ser"); |
||||
ObjectOutputStream writeStream = new ObjectOutputStream(writeData); |
||||
|
||||
writeStream.writeObject(game.getState()); |
||||
writeStream.flush(); |
||||
writeStream.close(); |
||||
} |
||||
|
||||
@Override |
||||
public void load() throws IOException, ClassNotFoundException { |
||||
FileInputStream readData = new FileInputStream("gamedata.ser"); |
||||
ObjectInputStream readStream = new ObjectInputStream(readData); |
||||
|
||||
ArrayList<String> data = (ArrayList<String >) readStream.readObject(); |
||||
readStream.close(); |
||||
|
||||
for (String s:data) { |
||||
input(s); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,227 @@
@@ -0,0 +1,227 @@
|
||||
package letzplay.ganttproject; |
||||
|
||||
import letzplay.core.Quest; |
||||
import letzplay.core.Task; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import static letzplay.ganttproject.GanttProjectTriggers.*; |
||||
|
||||
public class GanttProject { |
||||
|
||||
private static Quest q1() { |
||||
Quest q = new Quest("Willkommen bei Letzplay!", "Viel spaß beim " + |
||||
"spielen ;)", 0, 100); |
||||
List<Task> tasks = new ArrayList<>(); |
||||
tasks.add(new Task("Füge dich als Resource hinzu! ", |
||||
"Du bist der Projektplaner, also füge dich als erstes hinzu!", |
||||
res + add)); |
||||
|
||||
q.addTask(tasks); |
||||
|
||||
return q; |
||||
} |
||||
|
||||
private static Quest q2() { |
||||
Quest q = new Quest("Rollenerstellung", "Füge nun alle Rollen hinzu" |
||||
, 1, 50); |
||||
|
||||
List<Task> tasks = new ArrayList<>(); |
||||
tasks.add(new Task("Programmierung", "Füge Programmierung den Rollen " + |
||||
"hinzu", rol + add + programmierung)); |
||||
|
||||
tasks.add(new Task("Geschäftsführung", "Füge Geschäftsführung den Rollen " + |
||||
"hinzu", rol + add + geschäftsführung)); |
||||
|
||||
tasks.add(new Task("Marketing", "Füge Marketing den Rollen " + |
||||
"hinzu", rol + add + marketing)); |
||||
|
||||
tasks.add(new Task("Finanzen", "Füge Finanzen den Rollen " + |
||||
"hinzu", rol + add + finanzen)); |
||||
|
||||
q.addTask(tasks); |
||||
|
||||
return q; |
||||
} |
||||
|
||||
private static Quest q3() { |
||||
Quest q = new Quest("Erstelle geeignete Resourcen", |
||||
"Du hast 3 Personen zur verfügung: Chris ist der technisch " + |
||||
"affine, Franz ist geschickt mit dem Umgang von " + |
||||
"Menschen und Julia behält den Blick für das große " + |
||||
"ganze! Nun füge sie als Resourcen hinzu", 1, 50); |
||||
List<Task> tasks = new ArrayList<>(); |
||||
tasks.add(new Task("Füge Chris hinzu", "Füge Chris unter Resourcen als" + |
||||
" Full-Stack-Developer hinzu", res + add + chris)); |
||||
|
||||
tasks.add(new Task("Füge Franz hinzu", "Füge Franz unter Resourcen " + |
||||
"als Marketing hinzu", res + add + franz)); |
||||
|
||||
tasks.add(new Task("Füge Julia hinzu", "Füge Julia unter Resourcen " + |
||||
"als Geschäftsführung hinzu", res + add + julia)); |
||||
|
||||
q.addTask(tasks); |
||||
|
||||
return q; |
||||
} |
||||
|
||||
private static Quest q4() { |
||||
Quest q = new Quest("Milestones", "Füge sie als Task hinzu und setzte sie als Milestone", 2, |
||||
50); |
||||
|
||||
List<Task> tasks = new ArrayList<>(); |
||||
tasks.add(new Task("Appentwicklung", "Füge Appentwicklung als Task " + |
||||
"hinzu und makiere es als Milestone", tsk + mil + appentwicklung)); |
||||
|
||||
tasks.add(new Task("Marketingplanung", "Füge Marketingplanung als Task " + |
||||
"hinzu und makiere es als Milestone", tsk + mil + marketingplanung)); |
||||
|
||||
tasks.add(new Task("Businessplan", "Füge Businessplan als Task " + |
||||
"hinzu und makiere es als Milestone", tsk + mil + businessplan)); |
||||
|
||||
q.addTask(tasks); |
||||
|
||||
return q; |
||||
} |
||||
|
||||
private static Quest q5() { |
||||
Quest q = new Quest("Tasks", |
||||
"Füge nun die Aufgaben als Task hinzu", 2, 50); |
||||
List<Task> tasks = new ArrayList<>(); |
||||
tasks.add(new Task("Backend", "Füge die Aufgabe Backend hinzu", |
||||
tsk + add + backend)); |
||||
|
||||
tasks.add(new Task("Frontend", "Füge die Aufgabe Frontend hinzu", |
||||
tsk + add + frontend)); |
||||
|
||||
tasks.add(new Task("Infrastruktur", "Füge die Aufgabe Infrastruktur " + |
||||
"hinzu", tsk + add + infrastruktur)); |
||||
|
||||
tasks.add(new Task("Demo-Vorstellung", "Füge die Aufgabe " + |
||||
"Demo-Vorstellung hinzu", tsk + add + demovorstellung)); |
||||
|
||||
tasks.add(new Task("Werbekampagne", "Füge die Aufgabe Werbekampagne " + |
||||
"hinzu", tsk + add + werbekampagne)); |
||||
|
||||
tasks.add(new Task("Revenue-Model", "Füge die Aufgabe Revenue-Model " + |
||||
"hinzu", tsk + add + revenuemodel)); |
||||
|
||||
tasks.add(new Task("Umsatzplanung", "Füge die Aufgabe Umsatzplanung " + |
||||
"hinzu", tsk + add + umsatzplanung)); |
||||
|
||||
q.addTask(tasks); |
||||
|
||||
return q; |
||||
} |
||||
|
||||
private static Quest q6() { |
||||
Quest q = new Quest("Dependencies", "Füge nun alle Abhängigkeiten hinzu" |
||||
, 2, 70); |
||||
|
||||
List<Task> tasks = new ArrayList<>(); |
||||
tasks.add(new Task("Infrastruktur->Backend", "Backend ist von " + |
||||
"Infrastruktur abhängig", tsk + dep + infrastruktur + ":" + backend)); |
||||
tasks.add(new Task("Backend->Frontend", "Frontend ist von " + |
||||
"Backend abhängig", tsk + dep + backend + ":" + frontend)); |
||||
tasks.add(new Task("Frontend->Demo", "Demo-Vorstellung ist von " + |
||||
"Frontend abhängig", |
||||
tsk + dep + frontend + ":" + demovorstellung)); |
||||
tasks.add(new Task("Appentwicklung->Werbekampange", "Die " + |
||||
"Appentwicklung muss vollständig sein, bevor die " + |
||||
"Werbekampagne starten kann", |
||||
tsk + dep + appentwicklung + ":" + werbekampagne)); |
||||
tasks.add(new Task("Demo-Vorstellung->Werbekampange", "Das Produkt muss vorher Vorgestellt werden, bevor die " + |
||||
"Werbekampagne starten kann", |
||||
tsk + dep + demovorstellung + ":" + werbekampagne)); |
||||
tasks.add(new Task("Revenue-Model->Umsatzplan", "Es muss erst klar " + |
||||
"sein wie Geld eingenommen werden kann, bevor der " + |
||||
"Jahresumsatz geplant werden kann", |
||||
tsk + dep + revenuemodel + ":" + umsatzplanung)); |
||||
|
||||
q.addTask(tasks); |
||||
|
||||
return q; |
||||
} |
||||
|
||||
private static Quest q7() { |
||||
Quest q = new Quest("Resourcenzuteilung", |
||||
"Du hast Resourcen zur Verfügung und Aufgaben die erledigt " + |
||||
"werden müssen, teile nun die Resourcen ein", 3, 50); |
||||
List<Task> tasks = new ArrayList<>(); |
||||
tasks.add(new Task("Backend:Programmierung", "Teile die Aufgabe Backend" + |
||||
" der Programmierung zu", |
||||
tsk + res + backend + ":" + chris)); |
||||
|
||||
tasks.add(new Task("Frontend:Programmierung", "Teile die Aufgabe " + |
||||
"Frontend der Programmierung zu", |
||||
tsk + res + frontend + ":" + chris)); |
||||
|
||||
tasks.add(new Task("Infrastruktur:Programmierung", "Teile die Aufgabe Infrastruktur " + |
||||
"der Programmierung zu", |
||||
tsk + res + infrastruktur + ":" + chris)); |
||||
|
||||
tasks.add(new Task("Demo-Vorstellung:Marketing", "Teile die Aufgabe " + |
||||
"Demo-Vorstellung den Marketing zu", |
||||
tsk + res + demovorstellung + ":" + franz)); |
||||
|
||||
tasks.add(new Task("Werbekampagne:Marketing", "Teile die Aufgabe Werbekampagne " + |
||||
"den Marketing zu", tsk + res + werbekampagne + ":" + franz)); |
||||
|
||||
tasks.add(new Task("Revenue Model:Geschäftsführung", "Teile die " + |
||||
"Aufgabe Revenue Model den Geschäftsführer zu", |
||||
tsk + res + revenuemodel + ":" + julia)); |
||||
|
||||
tasks.add(new Task("Umsatzplanung:Finanzen", "Teile die Aufgabe " + |
||||
"Umsatzplanung " + |
||||
"den Finanzen zu", tsk + res + umsatzplanung + ":" + julia)); |
||||
|
||||
q.addTask(tasks); |
||||
|
||||
return q; |
||||
} |
||||
|
||||
private static Quest q8() { |
||||
Quest q = new Quest("Zeiteinteilung", "Teile nun allen Tasks die Zeit zu", 4, 80); |
||||
|
||||
List<Task> tasks = new ArrayList<>(); |
||||
tasks.add(new Task("Backend: 75 Tage", "Backend braucht 75 Tage", |
||||
tsk + dur + backend + ":75")); |
||||
|
||||
tasks.add(new Task("Frontend: 84 Tage", "Frontend braucht 84", |
||||
tsk + dur + frontend + ":84")); |
||||
|
||||
tasks.add(new Task("Infrastruktur: 60 Tage", "Infrastruktur braucht 60 Tage" + |
||||
"hinzu", tsk + dur + infrastruktur + ":60")); |
||||
|
||||
tasks.add(new Task("Demo-Vorstellung: 5 Tage", "Demo-Vorstellung braucht 5 Tage", |
||||
tsk + dur + demovorstellung + ":5")); |
||||
|
||||
tasks.add(new Task("Werbekampagne: 38", "Werbekampagne braucht 38 Tage", |
||||
tsk + dur + werbekampagne + ":38")); |
||||
|
||||
tasks.add(new Task("Revenue-Model: 131", "Revenue-Model braucht 131 Tage", |
||||
tsk + dur + revenuemodel + ":131")); |
||||
|
||||
tasks.add(new Task("Umsatzplanung: 131", "Umsatzplanung braucht 131 Tage", |
||||
tsk + dur + umsatzplanung + ":131")); |
||||
|
||||
q.addTask(tasks); |
||||
|
||||
return q; |
||||
} |
||||
|
||||
public static List<Quest> init() { |
||||
List<Quest> quests = new ArrayList<>(); |
||||
quests.add(q1()); |
||||
quests.add(q2()); |
||||
quests.add(q3()); |
||||
quests.add(q4()); |
||||
quests.add(q5()); |
||||
quests.add(q6()); |
||||
quests.add(q7()); |
||||
quests.add(q8()); |
||||
|
||||
return quests; |
||||
} |
||||
} |
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
package letzplay.ganttproject; |
||||
|
||||
public class GanttProjectTriggers { |
||||
//Type
|
||||
public static final String res = "res:"; |
||||
public static final String tsk = "tsk:"; |
||||
public static final String rol = "rol:"; |
||||
public static final String dep = "dep:"; |
||||
|
||||
//Operation
|
||||
public static final String add = "add:"; |
||||
public static final String mod = "mod:"; |
||||
public static final String mil = "mil:"; |
||||
public static final String dur = "dur:"; |
||||
|
||||
//resources
|
||||
public static final String julia = "julia"; |
||||
public static final String franz = "franz"; |
||||
public static final String chris = "chris"; |
||||
|
||||
//roles
|
||||
public static final String programmierung = "programmierung"; |
||||
public static final String geschäftsführung = "geschäftsführung"; |
||||
public static final String marketing = "marketing"; |
||||
public static final String finanzen = "finanzen"; |
||||
|
||||
//milestones
|
||||
public static final String appentwicklung = "appentwicklung"; |
||||
public static final String marketingplanung = "marketingplanung"; |
||||
public static final String businessplan = "businessplan"; |
||||
|
||||
//tasks
|
||||
public static final String backend = "backend"; |
||||
public static final String frontend = "frontend"; |
||||
public static final String infrastruktur = "infrastruktur"; |
||||
public static final String itadministration = "it-administration"; |
||||
public static final String demovorstellung = "demo-vorstellung"; |
||||
public static final String werbekampagne = "werbekampagne"; |
||||
public static final String revenuemodel = "revenue-model"; |
||||
public static final String umsatzplanung = "umsatzplanung"; |
||||
|
||||
} |
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
package letzplay.core; |
||||
|
||||
|
||||
import letzplay.core.GameEngine; |
||||
import letzplay.ganttproject.GanttProject; |
||||
import org.junit.jupiter.api.BeforeAll; |
||||
import org.junit.jupiter.api.Test; |
||||
import letzplay.core.Quest; |
||||
import letzplay.core.Task; |
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals; |
||||
|
||||
class GameEngineTest { |
||||
static GameEngine game; |
||||
|
||||
@BeforeAll |
||||
public static void beforeAll() { |
||||
game = GameEngine.getInstance(); |
||||
game.initQuests(GanttProject.init()); |
||||
} |
||||
|
||||
@Test |
||||
public void testInit() { |
||||
assertEquals(game.availableQuests().size(), 1); |
||||
assertEquals(game.currentLvl(), 0); |
||||
} |
||||
|
||||
@Test |
||||
public void testQuestComplete() { |
||||
Quest quest = game.availableQuests().get(0); |
||||
for (Task t : quest.getTaskList() |
||||
) { |
||||
t.trigger(t.getTrigger()); |
||||
} |
||||
|
||||
game.update(); |
||||
|
||||
assertEquals(game.currentLvl(), 1); |
||||
assertEquals(game.doneQuests().size(), 1); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
package letzplay.core; |
||||
|
||||
import letzplay.core.Progression; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals; |
||||
|
||||
class ProgressionTest { |
||||
|
||||
@Test |
||||
public void testProgression() { |
||||
Progression prog = new Progression(0, 5); |
||||
|
||||
assertEquals(prog.done, 0); |
||||
assertEquals(prog.of, 5); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
package letzplay.core; |
||||
|
||||
import letzplay.core.Quest; |
||||
import letzplay.core.Task; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals; |
||||
import static org.junit.jupiter.api.Assertions.assertTrue; |
||||
|
||||
class QuestTest { |
||||
private String title = "title"; |
||||
private String description = "description"; |
||||
private String trigger = "trg"; |
||||
|
||||
@Test |
||||
public void testQuestCreation() { |
||||
Quest q = new Quest(title, description, 0, 100); |
||||
|
||||
assertEquals(q.getDescription(), description); |
||||
assertEquals(q.getTitle(), title); |
||||
assertEquals(q.getTaskList().size(), 0); |
||||
assertEquals(q.progression().of, 0); |
||||
assertEquals(q.progression().done, 0); |
||||
assertEquals(q.getGainExp(), 100); |
||||
assertEquals(q.getMinLvl(), 0); |
||||
} |
||||
|
||||
@Test |
||||
public void testAddTask() { |
||||
Quest q = new Quest(title, description, 0, 100); |
||||
Task task = new Task(title, description, trigger); |
||||
|
||||
q.addTask(task); |
||||
|
||||
assertEquals(q.getTaskList().size(), 1); |
||||
assertEquals(q.progression().done, 0); |
||||
assertEquals(q.progression().of, 1); |
||||
assertEquals(q.getTaskList().get(0), task); |
||||
} |
||||
|
||||
@Test |
||||
public void testAddTaskList() { |
||||
Quest q = new Quest(title, description, 0, 100); |
||||
Task task1 = new Task(title + 1, description, trigger + 1); |
||||
Task task2 = new Task(title + 2, description, trigger + 2); |
||||
Task task3 = new Task(title + 3, description, trigger + 3); |
||||
|
||||
List<Task> list = new ArrayList<>(); |
||||
list.add(task1); |
||||
list.add(task2); |
||||
list.add(task3); |
||||
|
||||
q.addTask(list); |
||||
|
||||
assertEquals(q.getTaskList().size(), 3); |
||||
assertEquals(q.progression().done, 0); |
||||
assertEquals(q.progression().of, 3); |
||||
} |
||||
|
||||
@Test |
||||
public void testCompleteTask() { |
||||
Quest q = new Quest(title, description, 0, 100); |
||||
Task task = new Task(title, description, trigger); |
||||
|
||||
q.addTask(task); |
||||
|
||||
q.trigger("trg"); |
||||
|
||||
assertEquals(q.progression().done, 1); |
||||
assertEquals(q.progression().of, 1); |
||||
assertTrue(q.getTaskList().get(0).isDone()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
package letzplay.core; |
||||
|
||||
import letzplay.core.Quest; |
||||
import letzplay.core.Task; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import static org.junit.jupiter.api.Assertions.*; |
||||
|
||||
class TaskTest { |
||||
private String title = "title"; |
||||
private String description = "description"; |
||||
private String trigger = "trg"; |
||||
|
||||
@Test |
||||
void testTaskCreation() { |
||||
Task task = new Task(title, description, trigger); |
||||
|
||||
assertEquals(task.getDescription(), description); |
||||
assertEquals(task.getTitle(), title); |
||||
assertFalse(task.isDone()); |
||||
} |
||||
|
||||
@Test |
||||
void testTaskComplete() { |
||||
Task task = new Task(title, description, trigger); |
||||
|
||||
task.trigger("trg"); |
||||
|
||||
assertEquals(task.getDescription(), description); |
||||
assertEquals(task.getTitle(), title); |
||||
assertTrue(task.isDone()); |
||||
} |
||||
|
||||
@Test |
||||
void testTaskCanBeEqual() { |
||||
Task task1 = new Task(title, description, trigger); |
||||
Task task2 = new Task(title, description, trigger); |
||||
|
||||
assertEquals(task1, task2); |
||||
} |
||||
|
||||
@Test |
||||
void testTaskCanBeUnequal() { |
||||
Task task1 = new Task(title, description, trigger); |
||||
Task task2 = new Task(title + 1, description, trigger); |
||||
|
||||
assertNotEquals(task1, task2); |
||||
assertNotEquals(null, task1); |
||||
assertNotEquals(task1, new Quest(title, description, 0, 0)); |
||||
} |
||||
} |
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
package letzplay.ganttproject; |
||||
|
||||
import letzplay.core.Output; |
||||
import letzplay.ganttproject.GanttGameLoop; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.List; |
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals; |
||||
import static letzplay.ganttproject.GanttProjectTriggers.*; |
||||
|
||||
class GanttGameLoopTest { |
||||
|
||||
@Test |
||||
public void testLoop() { |
||||
GanttGameLoop loop = GanttGameLoop.getGameLoop(); |
||||
|
||||
loop.init(); |
||||
loop.update(); |
||||
loop.output(); |
||||
} |
||||
|
||||
@Test |
||||
public void testTrigger() { |
||||
GanttGameLoop loop = GanttGameLoop.getGameLoop(); |
||||
Output out; |
||||
|
||||
System.out.println("Iteration 0"); |
||||
loop.init(); |
||||
loop.update(); |
||||
loop.output(); |
||||
|
||||
System.out.println("Iteration 1"); |
||||
loop.input(res+add); |
||||
loop.update(); |
||||
loop.output(); |
||||
out = loop.output(); |
||||
|
||||
assertEquals(out.lvl, 1); |
||||
assertEquals(out.quests.size(), 2); |
||||
} |
||||
|
||||
@Test |
||||
public void testSaveAndLoad(){ |
||||
GanttGameLoop loop = GanttGameLoop.getGameLoop(); |
||||
|
||||
loop.init(); |
||||
loop.input("test1"); |
||||
loop.input("test2"); |
||||
loop.update(); |
||||
|
||||
List<String> before = loop.game.getState(); |
||||
|
||||
try { |
||||
loop.save(); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
loop.init(); |
||||
try { |
||||
loop.load(); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} catch (ClassNotFoundException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
List<String> after = loop.game.getState(); |
||||
|
||||
assertEquals(before,after); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue