pala M-faction-3b: elo PvP inter-factions + /f top

This commit is contained in:
Anaïs Saraiva
2026-10-19 05:19:15 +02:00
parent 9a5b5acb03
commit 101384e4bf
5 changed files with 54 additions and 3 deletions
+4
View File
@@ -634,6 +634,10 @@ avant M4 (TODO:crafts-machines).
ECART : pas de recette decompression (legacy n'en a pas), guardian stone + broken
spawner absents du legacy (textures a extraire, TODO:M-spawner). VERIFIE : build
SUCCESSFUL, boot Done, 0 erreur. UNVERIFIED en jeu.
- M-faction-3b LIVRE 2026-10-19 ~05:15 : elo PvP inter-factions (base 1000, +10/-10,
plancher 0, hook AFTER_DEATH existant) + /f top (tri elo) + elo dans /f info/help.
ECART : formule exacte Paladium non publiee (UNVERIFIED). VERIFIE : build SUCCESSFUL,
boot Done, 0 erreur. UNVERIFIED en jeu (2 joueurs).
- M-palaforge LIVRE 2026-10-19 ~03:55 : bloc + BE partagee (3e mode) + gate mineur 14 +
table fonte wiki §3.2 (31 items, ratio floor usure) + fuels bois (+buche/planches/baton,
lave exclue : seau non rendu) + craft (1 findium + 4 furnaces + 4 briques, positions
@@ -209,7 +209,9 @@ public final class PalaCommands {
.then(Commands.literal("sethome")
.executes(command -> fSetHome(command.getSource())))
.then(Commands.literal("home")
.executes(command -> fHome(command.getSource()))));
.executes(command -> fHome(command.getSource())))
.then(Commands.literal("top")
.executes(command -> fTop(command.getSource()))));
dispatcher.register(Commands.literal("fc")
.then(Commands.argument("texte",
com.mojang.brigadier.arguments.StringArgumentType.greedyString())
@@ -440,7 +442,7 @@ public final class PalaCommands {
return 0;
}
source.sendSuccess(() -> Component.literal("§6[Faction " + faction.name + "] §7"
+ faction.members.size() + " membres"
+ faction.members.size() + " membres, " + faction.elo + " elo"
+ (faction.viceLeaders == null || faction.viceLeaders.isEmpty() ? ""
: " (co-chefs : " + faction.viceLeaders.size() + ")")
+ (faction.description.isEmpty() ? "" : " : " + faction.description)), false);
@@ -621,7 +623,7 @@ public final class PalaCommands {
private static int fHelp(CommandSourceStack source) {
source.sendSuccess(() -> Component.literal("§6[Faction] §7/f create|info|invite|join|"
+ "leave|disband|kick|transfer|desc|help|claim|unclaim|list|sethome|home|"
+ "promote|demote"), false);
+ "promote|demote|top"), false);
return Command.SINGLE_SUCCESS;
}
@@ -867,6 +869,31 @@ public final class PalaCommands {
}
}
// M-faction-3b : classement elo (tri decroissant, top 10).
private static int fTop(CommandSourceStack source) {
java.util.List<fr.surviepote.pala.core.PalaFactions.Faction> all =
new java.util.ArrayList<>();
for (String name : fr.surviepote.pala.core.PalaFactions.get().names()) {
all.add(fr.surviepote.pala.core.PalaFactions.get().byName(name));
}
all.sort((a, b) -> Integer.compare(b.elo, a.elo));
StringBuilder out = new StringBuilder("§6[Top Factions]");
if (all.isEmpty()) {
out.append("\n§7aucune faction.");
}
int rank = 1;
for (fr.surviepote.pala.core.PalaFactions.Faction faction : all) {
if (rank > 10) {
break;
}
out.append("\n§e#").append(rank).append(" ").append(faction.name)
.append(" §7(").append(faction.elo).append(" elo)");
rank++;
}
source.sendSuccess(() -> Component.literal(out.toString()), false);
return Command.SINGLE_SUCCESS;
}
private static int fDisband(CommandSourceStack source) {
try {
ServerPlayer player = source.getPlayerOrException();
@@ -37,6 +37,9 @@ public final class PalaFactions {
// M-faction-3a : co-chefs (UUID). Peuvent inviter/kick/unclaim/sethome.
// ECART : permissions fines par grade (GUI) en M-faction-3b.
public List<String> viceLeaders = new ArrayList<>();
// M-faction-3b : score elo (base 1000, +/-10 par kill PvP, plancher 0).
// ECART : formule exacte Paladium non publiee (UNVERIFIED).
public int elo = 1000;
}
private final Map<String, Faction> factions = new HashMap<>();
@@ -73,6 +76,18 @@ public final class PalaFactions {
dirty = true;
}
// M-faction-3b : kill PvP inter-factions (gagnant +10, perdant -10, plancher 0).
public void onPvpKill(String winnerUuid, String loserUuid) {
Faction winner = byMember(winnerUuid);
Faction loser = byMember(loserUuid);
if (winner == null || loser == null || winner == loser) {
return;
}
winner.elo += 10;
loser.elo = Math.max(0, loser.elo - 10);
markDirty();
}
/** Chef ou co-chef : peut inviter/kick/unclaim/sethome (M-faction-3a). */
public static boolean isOfficer(Faction faction, String uuid) {
return faction.owner.equals(uuid)
@@ -41,6 +41,11 @@ public final class PalaJobEvents {
if (!(killer instanceof ServerPlayer player)) {
return;
}
// M-faction-3b : elo PvP inter-factions (avant le hook chasseur).
if (entity instanceof ServerPlayer victim) {
fr.surviepote.pala.core.PalaFactions.get().onPvpKill(
player.getUUID().toString(), victim.getUUID().toString());
}
String id = BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()).toString();
double[] row = PalaConfig.get().hunterKills.get(id);
if (row == null) {
Binary file not shown.