Add even more Advancements

This commit is contained in:
2026-05-31 22:31:02 +02:00
parent 8fa9f7b0d3
commit 847eb3fe5d
2 changed files with 30 additions and 56 deletions
@@ -148,19 +148,19 @@ class EventFight(id: EntityID<Int>) : IntEntity(id), Comparable<EventFight> {
} }
@JvmStatic @JvmStatic
fun getHighestPlacement(fighter: SteamwarUser) = fun countPlacement(fighter: SteamwarUser, placement: Int) =
useDb { useDb {
exec( exec(
"SELECT MIN(TT.Placement) AS Placement FROM FightPlayer INNER JOIN Fight F on FightPlayer.FightID = F.FightID INNER JOIN EventFight EF on F.FightID = EF.Fight INNER JOIN TeamTeilnahme TT on TT.EventID = EF.EventID WHERE UserID = ?", "SELECT COUNT(*) AS PlacementCount FROM FightPlayer INNER JOIN Fight F on FightPlayer.FightID = F.FightID INNER JOIN EventFight EF on F.FightID = EF.Fight INNER JOIN TeamTeilnahme TT on TT.EventID = EF.EventID WHERE UserID = ? AND Placement = ?",
args = listOf(IntegerColumnType() to fighter.id.value) args = listOf(IntegerColumnType() to fighter.id.value, IntegerColumnType() to placement)
) { ) {
if (it.next()) { if (it.next()) {
it.getInt("Placement") it.getInt("PlacementCount")
} else { } else {
Int.MAX_VALUE 0
} }
} }
?: Int.MAX_VALUE ?: 0
} }
} }
@@ -173,59 +173,36 @@ public class Advancements {
return (int) (fights / Math.max(eventFightCount / 100.0, 1)); return (int) (fights / Math.max(eventFightCount / 100.0, 1));
} }
); );
// playtime.add(previous);
// TODO: Implement per Type counter!
if (i == 0) { if (i == 0) {
Advancement third = new Advancement( placementsCounts(previous, 9f, 1, "gold_block", Advancement.Display.FrameType.CHALLENGE);
"steamwar:advancements/event_placement_3", placementsCounts(previous, 10f, 2, "iron_block", Advancement.Display.FrameType.GOAL);
Optional.of(previous), placementsCounts(previous, 11f, 3, "copper_block", Advancement.Display.FrameType.TASK);
new Advancement.Display(
Component.text("3. Place in Event"),
Component.text(""),
"copper_block",
Advancement.Display.FrameType.TASK,
2f,
9.5f
),
Advancement.HidePolicy.PREVIOUS_UNFINISHED,
1,
user -> EventFight.getHighestPlacement(user) <= 3 ? 1 : 0
);
Advancement first = new Advancement(
"steamwar:advancements/event_placement_1",
Optional.of(third),
new Advancement.Display(
Component.text("1. Place in Event"),
Component.text(""),
"gold_block",
Advancement.Display.FrameType.CHALLENGE,
3f,
9f
),
Advancement.HidePolicy.WITH_PREVIOUS,
1,
user -> EventFight.getHighestPlacement(user) == 1 ? 1 : 0
);
new Advancement(
"steamwar:advancements/event_placement_2",
Optional.of(first),
new Advancement.Display(
Component.text("2. Place in Event"),
Component.text(""),
"iron_block",
Advancement.Display.FrameType.GOAL,
4f,
9.25f
),
Advancement.HidePolicy.WITH_PREVIOUS,
1,
user -> EventFight.getHighestPlacement(user) <= 2 ? 1 : 0
);
} }
} }
} }
private static void placementsCounts(Advancement previous, float yCoord, int placement, String item, Advancement.Display.FrameType frameType) {
for (int placementCount = 1; placementCount <= 10; placementCount++) {
int finalPlacementCount = placementCount;
previous = new Advancement(
"steamwar:advancements/event_placement_" + placement + "_" + placementCount,
Optional.of(previous),
new Advancement.Display(
Component.text(placementCount + "x " + placement + ". Place in Event"),
Component.text(""),
item,
frameType,
2f + (placementCount - 1f),
yCoord
),
Advancement.HidePolicy.WITH_PREVIOUS,
1,
user -> EventFight.countPlacement(user, placement) >= finalPlacementCount ? 1 : 0
);
}
}
static { static {
Advancement previous = ROOT; Advancement previous = ROOT;
int[] checkedCounts = new int[]{1, 10, 100, 250, 500, 750, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000}; int[] checkedCounts = new int[]{1, 10, 100, 250, 500, 750, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000};
@@ -254,9 +231,6 @@ public class Advancements {
} }
static { static {
// WarGear
// MiniWarGear
// WarShip
Advancement previous = ROOT; Advancement previous = ROOT;
int[] acceptedCounts = new int[]{1, 5, 10, 15, 25, 50, 100, 150, 200, 250, 500, 750, 1000}; int[] acceptedCounts = new int[]{1, 5, 10, 15, 25, 50, 100, 150, 200, 250, 500, 750, 1000};
for (int i = 0; i < acceptedCounts.length; i++) { for (int i = 0; i < acceptedCounts.length; i++) {