Skip to content

Commit

Permalink
Start doing flying extention #89
Browse files Browse the repository at this point in the history
  • Loading branch information
HydrolienF committed Nov 4, 2024
1 parent f47d594 commit a5ec2ce
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 23 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/fr/formiko/kokcinelo/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class App extends Game {
private static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); // HTML INCOMPATIBLE
private int logLevel = Application.LOG_INFO;
private static boolean launchFromLauncher;
public static final List<String> PLAYABLE_LEVELS = List.of("1K", "2K", "2F", "3K", "3F", "4K", "4F", "4A");
public static final List<String> PLAYABLE_LEVELS = List.of("1K", "2K", "2F", "3K", "3F", "4K", "4F", "4A", "5K", "5F", "5A");
public static List<String> SUPPORTED_LANGUAGES;
public static Map<String, String> LANGUAGES_NAMES;
public static Map<String, Integer> LANGUAGES_PERCENTAGES;
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/fr/formiko/kokcinelo/model/Ant.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Ant(Color thoraxColor) {
@Override
public Set<Class<? extends Creature>> getCreaturesFriendly() { return Set.of(Ant.class, Aphid.class); }
@Override
public Set<Class<? extends Creature>> getCreaturesFriendlyWithVisibility() { return Set.of(Ant.class, VisibilityAphid.class); }
public Set<Class<? extends Creature>> getCreaturesFriendlyWithVisibilityWhenFlying() { return Set.of(Aphid.class); }

// FUNCTIONS -----------------------------------------------------------------
}
8 changes: 4 additions & 4 deletions core/src/main/java/fr/formiko/kokcinelo/model/Aphid.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* @since 0.1
*/
public class Aphid extends Creature {
// private Color color;
private static final Color orrange = new Color(0.86f, 0.50f, 0.1f, 1f);
private static final Map<Class<? extends Aphid>, Color> typeColorMap = Map.of(Aphid.class, new Color(0.4f, 1f, 0f, 1f),
SpeedAphid.class, Color.CYAN, HealthAphid.class, Color.RED, ScoreAphid.class, new Color(0.86f, 0.50f, 0.1f, 1f),
BigScoreAphid.class, new Color(0.86f, 0.50f, 0.1f, 1f), VisibilityAphid.class, new Color(0.05f, 0.25f, 0f, 1f));
SpeedAphid.class, Color.CYAN, HealthAphid.class, Color.RED, ScoreAphid.class, orrange,
BigScoreAphid.class, orrange, FlyingAphid.class, orrange, FlyingBigScoreAphid.class, orrange);

// CONSTRUCTORS --------------------------------------------------------------
/**
Expand Down Expand Up @@ -69,7 +69,7 @@ public Aphid() {
@Override
public Set<Class<? extends Creature>> getCreaturesFriendly() { return Set.of(Ant.class, Aphid.class); }
@Override
public Set<Class<? extends Creature>> getCreaturesFriendlyWithVisibility() { return Set.of(Ant.class, Aphid.class); }
public Set<Class<? extends Creature>> getCreaturesFriendlyWithVisibilityWhenFlying() { return Set.of(Ant.class, Aphid.class); }
@Override
public String getSpaceActionName() {
if (canFly) {
Expand Down
12 changes: 8 additions & 4 deletions core/src/main/java/fr/formiko/kokcinelo/model/Creature.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*/
public abstract class Creature extends MapItem {
public static final List<Class<? extends Creature>> ORDER = List.of(Ladybug.class, Ant.class, RedAnt.class, GreenAnt.class, Aphid.class,
HealthAphid.class, SpeedAphid.class, ScoreAphid.class, BigScoreAphid.class, VisibilityAphid.class);
protected boolean fliing;
HealthAphid.class, SpeedAphid.class, ScoreAphid.class, BigScoreAphid.class, FlyingAphid.class, FlyingBigScoreAphid.class);
protected boolean flying;
protected float maxLifePoints;
protected float hitPoints;
protected float shootPoints;
Expand Down Expand Up @@ -62,6 +62,10 @@ protected Creature(String textureName) {
}

// GET SET -------------------------------------------------------------------
public boolean canFly() { return canFly; }
public boolean isFlying() { return flying; }
public boolean startFlying() { return flying = true; }
public boolean stopFlying() { return flying = false; }
public int getGivenPoints() { return 0; }
public float getVisionRadius() { return visionRadius; }
public void setVisionRadius(float visionRadius) { this.visionRadius = visionRadius; }
Expand Down Expand Up @@ -102,7 +106,7 @@ public void setLifePoints(float lifePoints) {
public Set<Class<? extends Creature>> getCreaturesToHunt() { return Set.of(); }
public Set<Class<? extends Creature>> getCreaturesHuntedBy() { return Set.of(); }
public Set<Class<? extends Creature>> getCreaturesFriendly() { return Set.of(getClass()); }
public Set<Class<? extends Creature>> getCreaturesFriendlyWithVisibility() { return Set.of(getClass()); }
public Set<Class<? extends Creature>> getCreaturesFriendlyWithVisibilityWhenFlying() { return Set.of(getClass()); }
public boolean haveCreatureToHunt() {
return Controller.getController().allCreatures().stream().anyMatch(c -> c.isInstanceOf(getCreaturesToHunt()));
}
Expand Down Expand Up @@ -170,7 +174,7 @@ public Set<Creature> getAllFriendlyWithVisibilityCreature() {
Set::addAll);
}
public boolean isFriendly(Creature c) { return c.isInstanceOf(getCreaturesFriendly()); }
public boolean isFriendlyWithVisibility(Creature c) { return c.isInstanceOf(getCreaturesFriendlyWithVisibility()); }
public boolean isFriendlyWithVisibility(Creature c) { return c.isInstanceOf(getCreaturesFriendlyWithVisibilityWhenFlying()); }

// FUNCTIONS -----------------------------------------------------------------
@Override
Expand Down
12 changes: 12 additions & 0 deletions core/src/main/java/fr/formiko/kokcinelo/model/FlyingAphid.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package fr.formiko.kokcinelo.model;

public class FlyingAphid extends Aphid {
public FlyingAphid(){
super();
canFly = true;
}
@Override
public int getGivenPoints() { return 10; }
@Override
public void bonusWhenCollectHoneydew(Creature collector) { collector.addScore(2); }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package fr.formiko.kokcinelo.model;

public class FlyingBigScoreAphid extends BigScoreAphid {
public FlyingBigScoreAphid() {
super();
canFly = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package fr.formiko.kokcinelo.model;

public class FlyingLadybug extends Ladybug {
public FlyingLadybug(String textureName) {
super(textureName);
canFly = true;
}
public FlyingLadybug() { this("ladybug"); }
}
2 changes: 1 addition & 1 deletion core/src/main/java/fr/formiko/kokcinelo/model/Ladybug.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public Ladybug(String textureName) {
@Override
public Set<Class<? extends Creature>> getCreaturesFriendly() { return Set.of(Ladybug.class); }
@Override
public Set<Class<? extends Creature>> getCreaturesFriendlyWithVisibility() { return Set.of(Ladybug.class); }
public Set<Class<? extends Creature>> getCreaturesFriendlyWithVisibilityWhenFlying() { return Set.of(Ladybug.class); }
@Override
public String getSpaceActionName() {
if (canFly) {
Expand Down
8 changes: 5 additions & 3 deletions core/src/main/java/fr/formiko/kokcinelo/model/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ public final class Level {
newLevel("3K", Map.of(Aphid.class, 100, Ladybug.class, 1, GreenAnt.class, 3)),
newLevel("4K", Map.of(Ladybug.class, 1, RedAnt.class, 2, GreenAnt.class, 2,
Aphid.class, 50, ScoreAphid.class, 3, SpeedAphid.class, 10, HealthAphid.class, 10)),
newLevel("5K"),
newLevel("5K", List.of(FlyingLadybug.class), Map.of(FlyingLadybug.class, 1, RedAnt.class, 2, GreenAnt.class, 2,
Aphid.class, 50, FlyingAphid.class, 3, SpeedAphid.class, 10, HealthAphid.class, 10)),
newLevel("2F", List.of(RedAnt.class), Map.of(Aphid.class, 100, Ladybug.class, 2, RedAnt.class, 1)),
newLevel("3F", List.of(GreenAnt.class), Map.of(Aphid.class, 100, Ladybug.class, 2, GreenAnt.class, 1)),
newLevel("4F", List.of(RedAnt.class, GreenAnt.class), Map.of(Ladybug.class, 3, RedAnt.class, 1, GreenAnt.class, 1,
Aphid.class, 50, ScoreAphid.class, 3, SpeedAphid.class, 10, HealthAphid.class, 10)),
newLevel("5F"),
newLevel("5F", List.of(RedAnt.class, GreenAnt.class), Map.of(FlyingLadybug.class, 3, RedAnt.class, 1, GreenAnt.class, 1,
Aphid.class, 50, FlyingAphid.class, 3, SpeedAphid.class, 10, HealthAphid.class, 10)),
newLevel("4A", List.of(BigScoreAphid.class), Map.of(Ladybug.class, 4, RedAnt.class, 2, Aphid.class, 50, BigScoreAphid.class, 1)),
newLevel("5A"));
newLevel("5A", List.of(FlyingBigScoreAphid.class), Map.of(FlyingLadybug.class, 4, RedAnt.class, 2, Aphid.class, 50, FlyingBigScoreAphid.class, 1)));
// @formatter:on
private static final Set<String> levelLetters = Set.of("K", "F", "A");
private @Null List<Level> nextLevels; // Use getter with lazy initialization.
Expand Down

This file was deleted.

21 changes: 17 additions & 4 deletions core/src/main/java/fr/formiko/kokcinelo/tools/Fonts.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import fr.formiko.kokcinelo.model.Aphid;
import fr.formiko.kokcinelo.model.BigScoreAphid;
import fr.formiko.kokcinelo.model.Creature;
import fr.formiko.kokcinelo.model.FlyingAphid;
import fr.formiko.kokcinelo.model.FlyingBigScoreAphid;
import fr.formiko.kokcinelo.model.GreenAnt;
import fr.formiko.kokcinelo.model.HealthAphid;
import fr.formiko.kokcinelo.model.Ladybug;
import fr.formiko.kokcinelo.model.RedAnt;
import fr.formiko.kokcinelo.model.ScoreAphid;
import fr.formiko.kokcinelo.model.SpeedAphid;
import fr.formiko.kokcinelo.model.VisibilityAphid;
import fr.formiko.usual.g;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
Expand All @@ -32,10 +33,22 @@ public class Fonts extends BitmapFont {
public static final String DEFAULT_COLOR = "[#000000]";
private static String DEFAULT_CHARS;
private static EmojiSupport emojiSupport;
private static final Map<Class<? extends Creature>, String> icons = Map.of(Ant.class, "🐜", Ladybug.class, "🐞", Aphid.class, "🦗",
RedAnt.class, "🕷", GreenAnt.class, "🦂", SpeedAphid.class, "🟦", HealthAphid.class, "🟥", ScoreAphid.class, "🟧",
BigScoreAphid.class, "🟧", VisibilityAphid.class, "🟩");
private static final Map<Class<? extends Creature>, String> icons;
private static Map<Class<? extends Creature>, String> iconsTransformed;
static {
icons = new java.util.HashMap<>();
icons.put(Ant.class, "🐜");
icons.put(Ladybug.class, "🐞");
icons.put(Aphid.class, "🦗");
icons.put(RedAnt.class, "🕷");
icons.put(GreenAnt.class, "🦂");
icons.put(SpeedAphid.class, "🟦");
icons.put(HealthAphid.class, "🟥");
icons.put(ScoreAphid.class, "🟧");
icons.put(BigScoreAphid.class, "🟧");
icons.put(FlyingBigScoreAphid.class, "🔶");
icons.put(FlyingAphid.class, "🟪");
}

/**
* {@summary Load the default font.}
Expand Down
5 changes: 4 additions & 1 deletion core/src/main/java/fr/formiko/kokcinelo/tools/Musics.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ public class Musics {
Map.entry("2K", List.of("Sailors Of The Dvipa", 0.5f)),
Map.entry("3K", List.of("Madness", 1f)),
Map.entry("4K", List.of("Chase 1", 1f)),
Map.entry("5K", List.of("Chase 1", 1f)), // TODO: Change this music
Map.entry("2F", List.of("Hako 1", 1f)),
Map.entry("3F", List.of("Hako 2", 0.8f)),
Map.entry("4F", List.of("Chase 2", 1f)),
Map.entry("4A", List.of("The great battle", 1f))
Map.entry("5F", List.of("Chase 2", 1f)), // TODO: Change this music
Map.entry("4A", List.of("The great battle", 1f)),
Map.entry("5A", List.of("The great battle", 1f)) // TODO: Change this music
);
// @formatter:on

Expand Down
34 changes: 34 additions & 0 deletions core/src/main/java/fr/formiko/kokcinelo/view/LevelButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import fr.formiko.kokcinelo.model.Aphid;
import fr.formiko.kokcinelo.model.BigScoreAphid;
import fr.formiko.kokcinelo.model.Creature;
import fr.formiko.kokcinelo.model.FlyingAphid;
import fr.formiko.kokcinelo.model.FlyingBigScoreAphid;
import fr.formiko.kokcinelo.model.GreenAnt;
import fr.formiko.kokcinelo.model.HealthAphid;
import fr.formiko.kokcinelo.model.Ladybug;
Expand Down Expand Up @@ -303,6 +305,18 @@ private Sprite getSprite() {
sprite = Shapes.getCircledSprite(radius, App.GREEN, c, c2, c3, c4);
break;
}
case "5K": {
c = new Ladybug();
c.setZoom(ladybugSize);
c2 = new SpeedAphid();
c2.setZoom(smallAphidSize);
c3 = new HealthAphid();
c3.setZoom(smallAphidSize);
c4 = new FlyingAphid();
c4.setZoom(smallAphidSize);
sprite = Shapes.getCircledSprite(radius, App.GREEN, c, c2, c3, c4);
break;
}
case "2F": {
c = new Ladybug();
c.setZoom(ladybugSize);
Expand Down Expand Up @@ -331,6 +345,18 @@ private Sprite getSprite() {
sprite = Shapes.getCircledSprite(radius, App.GREEN, c, c2, c3, c4);
break;
}
case "5F": {
c = new Ant();
c.setZoom(antSize);
c2 = new SpeedAphid();
c2.setZoom(smallAphidSize);
c3 = new HealthAphid();
c3.setZoom(smallAphidSize);
c4 = new FlyingAphid();
c4.setZoom(smallAphidSize);
sprite = Shapes.getCircledSprite(radius, App.GREEN, c, c2, c3, c4);
break;
}
case "4A": {
c = new BigScoreAphid();
c.setZoom(aphidSize);
Expand All @@ -339,6 +365,14 @@ private Sprite getSprite() {
sprite = Shapes.getCircledSprite(radius, App.GREEN, c, c2);
break;
}
case "5A": {
c = new FlyingBigScoreAphid();
c.setZoom(aphidSize);
c2 = new Ladybug();
c2.setZoom(ladybugSize);
sprite = Shapes.getCircledSprite(radius, App.GREEN, c, c2);
break;
}
default: {
sprite = new Sprite(Shapes.getCircle(radius, App.GREEN));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ void testConstructor() {
assertDoesNotThrow(() -> new Ladybug());
assertDoesNotThrow(() -> new LadybugSideView());
assertDoesNotThrow(() -> new Aphid());
assertDoesNotThrow(() -> new VisibilityAphid());
assertDoesNotThrow(() -> new HealthAphid());
assertDoesNotThrow(() -> new SpeedAphid());
assertDoesNotThrow(() -> new ScoreAphid());
assertDoesNotThrow(() -> new BigScoreAphid());
assertDoesNotThrow(() -> new FlyingAphid());

}

Expand Down

0 comments on commit a5ec2ce

Please sign in to comment.