Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 191 additions & 19 deletions backend/src/main/java/com/softdesign/plagueinc/util/EventReference.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;
import java.util.concurrent.CompletableFuture;

import com.softdesign.plagueinc.models.events.EventCard;
import com.softdesign.plagueinc.models.events.EventCard.GameStateAction;
Expand Down Expand Up @@ -38,7 +39,14 @@ public static EventCard birdMigration(){

public static EventCard bombedInfectedCities(){
//TODO: Implement condition & event
GameStateAction condition = (plague, gameState) -> {};
GameStateAction condition = (plague, gameState) -> {
if(gameState.getPlayState()!= PlayState.END_OF_TURN){
throw new IllegalStateException("PlayState is not END_OF_TERM");
}
if(!gameState.getCurrTurn().equals(plague)){
throw new IllegalStateException("It is not this players turn");
}
};
GameStateAction event = (plague, gameState) -> {};
return new EventCard("bombed_infected_cities", condition, event);
}//end of bombedInfectedCities
Expand Down Expand Up @@ -89,7 +97,16 @@ public static EventCard emergencyCare(){

public static EventCard executeInfected(){
//TODO: Implement condition & event
GameStateAction condition = (plague, gameState) -> {};
GameStateAction condition = (plague, gameState) -> {
if(gameState.getPlayState() != PlayState.END_OF_TURN){
throw new IllegalStateException("PlayState is not END_OF_TURN");
}
if(!gameState.getCurrTurn().equals(plague)){
throw new IllegalStateException("It is not this players turn");
}

//TODO: Add logic for other conditions on card (if killed a country)
};
GameStateAction event = (plague, gameState) -> {};
return new EventCard("execute_infected", condition, event);
}//end of executeInfected
Expand All @@ -113,28 +130,64 @@ public static EventCard geneticSurge(){

public static EventCard governmentCollapse(){
//TODO: Implement condition & event
GameStateAction condition = (plague, gameState) -> {};
GameStateAction condition = (plague, gameState) -> {
if(gameState.getPlayState() != PlayState.END_OF_TURN){
throw new IllegalStateException("PlayState is not END_OF_TURN");
}
if(!gameState.getCurrTurn().equals(plague)){
throw new IllegalStateException("It is not this players turn");
}

//TODO: add additional conditions for card
};
GameStateAction event = (plague, gameState) -> {};
return new EventCard("government_collapse", condition, event);
}//end of governmentCollapse

public static EventCard hereOnBusiness(){
//TODO: Implement condition & event
GameStateAction condition = (plague, gameState) -> {};
GameStateAction condition = (plague, gameState) -> {
if(gameState.getPlayState() != PlayState.START_OF_TURN){
throw new IllegalStateException("PlayState is not START_OF_TURN");
}
if(!gameState.getCurrTurn().equals(plague)){
throw new IllegalStateException("It is not this players turn");
}

//TODO: add aditional conditions
};
GameStateAction event = (plague, gameState) -> {};
return new EventCard("here_on_business", condition, event);
}//end of hereOnBusiness

public static EventCard immuneReaction(){
//TODO: Implement condition & event
GameStateAction condition = (plague, gameState) -> {};
GameStateAction condition = (plague, gameState) -> {
if(gameState.getPlayState() != PlayState.START_OF_TURN){
throw new IllegalStateException("PlayState is not START_OF_TURN");
}
if(!gameState.getCurrTurn().equals(plague)){
throw new IllegalStateException("It is not this players turn");
}

//TODO: add aditional conditions
};
GameStateAction event = (plague, gameState) -> {};
return new EventCard("immune_reaction", condition, event);
}//end of immuneReaction

public static EventCard infectedRefugees(){
//TODO: Implement condition & event
GameStateAction condition = (plague, gameState) -> {};
GameStateAction condition = (plague, gameState) -> {
if(gameState.getPlayState() != PlayState.END_OF_TURN){
throw new IllegalStateException("PlayState is not END_OF_TURN");
}
if(!gameState.getCurrTurn().equals(plague)){
throw new IllegalStateException("It is not this players turn");
}

//TODO: add aditional conditions
};
GameStateAction event = (plague, gameState) -> {};
return new EventCard("infected_refugees", condition, event);
}//end of infectedRefugees
Expand Down Expand Up @@ -162,84 +215,203 @@ public static EventCard neutralise(){

public static EventCard newTradeRoute(){
//TODO: Implement condition & event
GameStateAction condition = (plague, gameState) -> {};
GameStateAction condition = (plague, gameState) -> {
if(gameState.getPlayState() != PlayState.START_OF_TURN){
throw new IllegalStateException("PlayState is not START_OF_TURN");
}
if(!gameState.getCurrTurn().equals(plague)){
throw new IllegalStateException("It is not this players turn");
}

//TODO: add aditional conditions
};
GameStateAction event = (plague, gameState) -> {};
return new EventCard("new_trade_route", condition, event);
}//end of newTradeRoute

public static EventCard nuclearStrike(){
//TODO: Implement condition & event
GameStateAction condition = (plague, gameState) -> {};
GameStateAction condition = (plague, gameState) -> {
if(gameState.getPlayState() != PlayState.END_OF_TURN){
throw new IllegalStateException("PlayState is not END_OF_TURN");
}
if(!gameState.getCurrTurn().equals(plague)){
throw new IllegalStateException("It is not this players turn");
}

//TODO: add aditional conditions
};
GameStateAction event = (plague, gameState) -> {};
return new EventCard("nuclear_strike", condition, event);
}//end of nuclearStrike

public static EventCard olympics(){
//TODO: Implement condition & event
GameStateAction condition = (plague, gameState) -> {};
GameStateAction condition = (plague, gameState) -> {
if(gameState.getPlayState() != PlayState.START_OF_TURN){
throw new IllegalStateException("PlayState is not START_OF_TURN");
}
if(!gameState.getCurrTurn().equals(plague)){
throw new IllegalStateException("It is not this players turn");
}

//TODO: add aditional conditions
};
GameStateAction event = (plague, gameState) -> {};
return new EventCard("olympics", condition, event);
}//end of olympics

public static EventCard opportunisticBreakdown(){
//TODO: Implement condition & event
GameStateAction condition = (plague, gameState) -> {};
GameStateAction condition = (plague, gameState) -> {
if(gameState.getPlayState() != PlayState.END_OF_TURN){
throw new IllegalStateException("PlayState is not END_OF_TURN");
}
if(!gameState.getCurrTurn().equals(plague)){
throw new IllegalStateException("It is not this players turn");
}

//TODO: add aditional conditions
};
GameStateAction event = (plague, gameState) -> {};
return new EventCard("opportunitstic_breakdown", condition, event);
}//end of opportunisticBreakDown

public static EventCard pandemicAlert(){
//TODO: Implement condition & event
GameStateAction condition = (plague, gameState) -> {};
GameStateAction condition = (plague, gameState) -> {
if(gameState.getPlayState() != PlayState.END_OF_TURN){
throw new IllegalStateException("PlayState is not END_OF_TURN");
}
if(!gameState.getCurrTurn().equals(plague)){
throw new IllegalStateException("It is not this players turn");
}

//TODO: add aditional conditions
};
GameStateAction event = (plague, gameState) -> {};
return new EventCard("pandemic_alert", condition, event);
}//end of pandemicAlert

public static EventCard pilgrimage(){
//TODO: Implement condition & event
GameStateAction condition = (plague, gameState) -> {};
GameStateAction condition = (plague, gameState) -> {
if(gameState.getPlayState() != PlayState.START_OF_TURN){
throw new IllegalStateException("PlayState is not START_OF_TURN");
}
if(!gameState.getCurrTurn().equals(plague)){
throw new IllegalStateException("It is not this players turn");
}

//TODO: add aditional conditions
};
GameStateAction event = (plague, gameState) -> {};
return new EventCard("pilgrimage", condition, event);
}//end of pilgrimage

public static EventCard rioting(){
//TODO: Implement condition & event
GameStateAction condition = (plague, gameState) -> {};
GameStateAction event = (plague, gameState) -> {};
GameStateAction condition = (plague, gameState) -> {
if(!gameState.getPlayState.equals(PlayState.END_OF_TURN)){
throw new IllegalStateException("Game is not at end of turn");
}
if(!gameState.getCurrTurn().equals(plague)){
throw new IllegalStateException("It is not this players turn");
}
};
FutureInterface<CompletableFuture<Country>> createFuture = (plague) -> {
return new CompletableFuture<>().whenComplete((country, ex) -> {
if(ex != null){
//TODO implement error checking
}
else{
if(country.getInfectionByPlayer().keySet().contains(plague)){
country.infectCountry(plague);
country.infectCountry(plague);
}
else{
//TODO implement error checking
}
}
})
};
GameStateAction event = (plague, gameState) -> {
gameState.setCountrySelectionFuture(createFuture.op(plague));
};


return new EventCard("rioting", condition, event);
}//end of rioting

public static EventCard soapShortage(){
//TODO: Implement condition & event
GameStateAction condition = (plague, gameState) -> {};
GameStateAction condition = (plague, gameState) -> {
if(gameState.getPlayState() != PlayState.START_OF_TURN){
throw new IllegalStateException("PlayState is not START_OF_TURN");
}
if(!gameState.getCurrTurn().equals(plague)){
throw new IllegalStateException("It is not this players turn");
}

//TODO: add aditional conditions
};
GameStateAction event = (plague, gameState) -> {};
return new EventCard("soap_shortage", condition, event);
}//end of soap_shortage

public static EventCard summerVacation(){
//TODO: Implement condition & event
GameStateAction condition = (plague, gameState) -> {};
GameStateAction condition = (plague, gameState) -> {
if(gameState.getPlayState() != PlayState.START_OF_TURN){
throw new IllegalStateException("PlayState is not START_OF_TURN");
}
if(!gameState.getCurrTurn().equals(plague)){
throw new IllegalStateException("It is not this players turn");
}

//TODO: add aditional conditions
};
GameStateAction event = (plague, gameState) -> {};
return new EventCard("summerVacation", condition, event);
}//end of summerVacation

public static EventCard temporaryMutation(){
//TODO: Implement condition & event
GameStateAction condition = (plague, gameState) -> {};
GameStateAction condition = (plague, gameState) -> {
if(gameState.getPlayState() != PlayState.START_OF_TURN){
throw new IllegalStateException("PlayState is not START_OF_TURN");
}
if(!gameState.getCurrTurn().equals(plague)){
throw new IllegalStateException("It is not this players turn");
}

//TODO: add aditional conditions
};
GameStateAction event = (plague, gameState) -> {};
return new EventCard("temporary_mutation", condition, event);
}//end of temporaryMutation

public static EventCard winterVacation(){
//TODO: Implement condition & event
GameStateAction condition = (plague, gameState) -> {};
GameStateAction condition = (plague, gameState) -> {
if(gameState.getPlayState() != PlayState.START_OF_TURN){
throw new IllegalStateException("PlayState is not START_OF_TURN");
}
if(!gameState.getCurrTurn().equals(plague)){
throw new IllegalStateException("It is not this players turn");
}

//TODO: add aditional conditions
};
GameStateAction event = (plague, gameState) -> {};
return new EventCard("winter_vacation", condition, event);
}//end of winterVacation




private static interface FutureInterface<T>{
public CompletableFuture<T> op();
}



Expand Down