From b73b2050d345e0ee47fd38952047bdf9d36365d3 Mon Sep 17 00:00:00 2001 From: Timothée Floure Date: Wed, 9 Mar 2016 17:27:13 +0100 Subject: Structure of the fourth week assignment --- src/ch/epfl/xblast/Lists.java | 9 ++++++ src/ch/epfl/xblast/Time.java | 8 ++++++ src/ch/epfl/xblast/server/Block.java | 45 ++++++++++++++++++++++++++++- src/ch/epfl/xblast/server/Bonus.java | 18 ++++++++++++ src/ch/epfl/xblast/server/GameState.java | 49 ++++++++++++++++++++++++++++++++ src/ch/epfl/xblast/server/Ticks.java | 7 +++++ 6 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 src/ch/epfl/xblast/Time.java create mode 100644 src/ch/epfl/xblast/server/Bonus.java create mode 100644 src/ch/epfl/xblast/server/GameState.java diff --git a/src/ch/epfl/xblast/Lists.java b/src/ch/epfl/xblast/Lists.java index 51e76b0..f541b37 100644 --- a/src/ch/epfl/xblast/Lists.java +++ b/src/ch/epfl/xblast/Lists.java @@ -44,4 +44,13 @@ public final class Lists { .collect(Collectors.toList()); } + /** + * Returns all the permutations of the elements of the given list + * + * @param l given list + * @return a list of all the permutations of the list + */ + public static List> permutations(List l) { + return null; + } } diff --git a/src/ch/epfl/xblast/Time.java b/src/ch/epfl/xblast/Time.java new file mode 100644 index 0000000..fa18f86 --- /dev/null +++ b/src/ch/epfl/xblast/Time.java @@ -0,0 +1,8 @@ +package ch.epfl.xblast; + +public interface Time { + int S_PER_MIN = 60; + int MS_PER_S = 1000; + int US_PER_S = 1000*MS_PER_S; + int NS_PER_S = 1000*US_PER_S; +} diff --git a/src/ch/epfl/xblast/server/Block.java b/src/ch/epfl/xblast/server/Block.java index 409f68e..4903e2b 100644 --- a/src/ch/epfl/xblast/server/Block.java +++ b/src/ch/epfl/xblast/server/Block.java @@ -26,7 +26,36 @@ public enum Block { /** * Crumbling Wall. */ - CRUMBLING_WALL; + CRUMBLING_WALL, + + /** + * + */ + BONUS_BOMB(Bonus.INC_BOMB), + + /** + * + */ + BONUS_RANGE(Bonus.INC_RANGE); + + /** + * Corresponding bonus, or null + */ + private Bonus maybeAssociatedBonus; + + /** + * Main builder, used by the bonus blocks + */ + private Block(Bonus maybeAssociatedBonus) { + this.maybeAssociatedBonus = maybeAssociatedBonus; + } + + /** + * Default builder, used by the ither blocks + */ + private Block() { + this.maybeAssociatedBonus = null; + } /** * Returns T(this block is free). @@ -55,4 +84,18 @@ public enum Block { return this == INDESTRUCTIBLE_WALL || this == DESTRUCTIBLE_WALL || this == CRUMBLING_WALL; } + /** + * + */ + public boolean isBonus() { + return false; + } + + /** + * + */ + public Bonus associatedBonus() { + return null; + } + } diff --git a/src/ch/epfl/xblast/server/Bonus.java b/src/ch/epfl/xblast/server/Bonus.java new file mode 100644 index 0000000..43be24f --- /dev/null +++ b/src/ch/epfl/xblast/server/Bonus.java @@ -0,0 +1,18 @@ +package ch.epfl.xblast.server; + +/** + * @author TimothéE FLOURE (257420) + */ +public enum Bonus { + INC_BOMB { + @Override + public Player applyTo(Player player) { return null; } + }, + + INC_RANGE { + @Override + public Player applyTo(Player player) { return null; } + }; + + abstract public Player applyTo(Player player); +} diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java new file mode 100644 index 0000000..625767a --- /dev/null +++ b/src/ch/epfl/xblast/server/GameState.java @@ -0,0 +1,49 @@ +package ch.epfl.xblast.server; + +import java.util.List; +import java.util.Optional; +import ch.epfl.xblast.*; +import ch.epfl.cs108.Sq; + +public final class GameState { + private final int ticks; + private final Board board; + private final List players; + private final List bombs; + private final List>> explosions; + private final List> blasts; + + public GameState(int ticks, Board board, List players, List bombs, List>> explosions, List> blasts) { + } + + public GameState(Board board, List players) { + } + + public int ticks() { + return 0; + } + + public boolean isGameOver() { + return false; + } + + public double remainingTime() { + return 0; + } + + public Optional winner() { + return null; + } + + public Board board() { + return null; + } + + public List players() { + return null; + } + + public List alivePlayers() { + return null; + } +} diff --git a/src/ch/epfl/xblast/server/Ticks.java b/src/ch/epfl/xblast/server/Ticks.java index aa08a23..fe3f40c 100644 --- a/src/ch/epfl/xblast/server/Ticks.java +++ b/src/ch/epfl/xblast/server/Ticks.java @@ -1,5 +1,7 @@ package ch.epfl.xblast.server; +import ch.epfl.xblast.Time; + /** * The Ticks interface defines durations in ticks of time-sensitive aspects of the game. * @@ -38,4 +40,9 @@ public interface Ticks { */ int BONUS_DISAPPEARING_TICKS = EXPLOSION_TICKS; + int TICKS_PER_SECOND = 20; + + int TICK_NANOSECOND_DURATION = TICKS_PER_SECOND / Time.NS_PER_S; + + int TOTAL_TICKS = 2 * Time.S_PER_MIN * TICKS_PER_SECOND; } -- cgit v1.2.3