feat: rework CatPreset for add more detail + add preset

This commit is contained in:
2026-01-21 22:05:58 +01:00
parent 78d22b466d
commit d2a7e6cbac
11 changed files with 440 additions and 158 deletions

View File

@@ -28,24 +28,30 @@ public class CatPresetModel {
String name = "";
List<Categorie> categories;
long roundDuration;
long pauseDuration;
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "category_preset_catconfig", joinColumns = @JoinColumn(name = "id_preset"))
List<CategorieEmbeddable> categories;
SwordType swordType = SwordType.NONE;
ShieldType shieldType = ShieldType.NONE;
/* Bitmask protections:
* 1 - 1 - Head
* 2 - 2 - Throat
* 3 - 4 - Torso
* 4 - 8 - Arms
* 5 - 16 - Hands
* 6 - 32 - Groin
* 7 - 64 - Legs
/*
* 1 - 1 - Casque
* 2 - 2 - Gorgerin
* 3 - 4 - Coquille et Protection pelvienne
* 4 - 8 - Gant main(s) armée(s)
* 5 - 16 - Gant main bouclier
* 6 - 32 - Plastron
* 7 - 64 - Protection de bras armé(s)
* 8 - 128 - Protection de bras de bouclier
* 9 - 256 - Protection de jambes
* 10 - 512 - Protection de genoux
* 11 - 1024 - Protection de coudes
* 12 - 2048 - Protection dorsale
* 13 - 4096 - Protection de pieds
*/
int mandatoryProtection = 0;
int mandatoryProtection1 = 0;
int mandatoryProtection2 = 0;
@ManyToMany(mappedBy = "categoriesInscrites", fetch = FetchType.LAZY)
private List<RegisterModel> registers = new ArrayList<>();
@@ -68,4 +74,16 @@ public class CatPresetModel {
BUCKLER
}
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@RegisterForReflection
@Embeddable
public static class CategorieEmbeddable {
Categorie categorie;
long roundDuration;
long pauseDuration;
}
}

View File

@@ -271,10 +271,9 @@ public class CompetitionService {
presetModel.setName(preset.getName());
presetModel.setSwordType(preset.getSword());
presetModel.setShieldType(preset.getShield());
presetModel.setRoundDuration(preset.getRoundDuration());
presetModel.setPauseDuration(preset.getPauseDuration());
presetModel.setCategories(preset.getCategories());
presetModel.setMandatoryProtection(preset.getMandatoryProtection());
presetModel.setMandatoryProtection1(preset.getMandatoryProtection1());
presetModel.setMandatoryProtection2(preset.getMandatoryProtection2());
}
// Remove deleted presets
@@ -399,7 +398,8 @@ public class CompetitionService {
g.getCategoriesInscrites().clear();
g.getCategoriesInscrites().addAll(cats);
g.getCategoriesInscrites()
.removeIf(cat -> !cat.getCategories().contains(g.getCategorie()));
.removeIf(cat -> cat.getCategories().stream()
.noneMatch(e -> e.getCategorie().equals(g.getCategorie())));
}))
.chain(model -> Panache.withTransaction(() -> competitionGuestRepository.persist(model))
.call(r -> model.getCompetition().getSystem() == CompetitionSystem.INTERNAL ?
@@ -495,7 +495,8 @@ public class CompetitionService {
}
r.getCategoriesInscrites().addAll(cats);
r.getCategoriesInscrites()
.removeIf(cat -> !cat.getCategories().contains(r.getCategorie2()));
.removeIf(cat -> cat.getCategories().stream()
.noneMatch(e -> e.getCategorie().equals(r.getCategorie2())));
})))
.chain(r -> Panache.withTransaction(() -> registerRepository.persist(r)))
.call(r -> c.getSystem() == CompetitionSystem.INTERNAL ?

View File

@@ -610,7 +610,7 @@ public class ResultService {
} else if ((matchModel.isC1(comb) && win > 0) || matchModel.isC2(comb) && win < 0) {
stat.w++;
stat.win_ids.add(matchModel.getId());
stat.score += 3;
stat.score += 2;
} else {
stat.l++;
}

View File

@@ -1,7 +1,6 @@
package fr.titionfire.ffsaf.rest.data;
import fr.titionfire.ffsaf.data.model.CatPresetModel;
import fr.titionfire.ffsaf.utils.Categorie;
import io.quarkus.runtime.annotations.RegisterForReflection;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -16,17 +15,15 @@ public class PresetData {
private String name;
private CatPresetModel.SwordType sword;
private CatPresetModel.ShieldType shield;
private List<Categorie> categories;
long roundDuration;
long pauseDuration;
int mandatoryProtection;
private List<CatPresetModel.CategorieEmbeddable> categories;
private int mandatoryProtection1;
private int mandatoryProtection2;
public static PresetData fromModel(CatPresetModel model) {
if (model == null)
return null;
return new PresetData(model.getId(), model.getName(), model.getSwordType(), model.getShieldType(),
model.getCategories(), model.getRoundDuration(), model.getPauseDuration(),
model.getMandatoryProtection());
model.getCategories(), model.getMandatoryProtection1(), model.getMandatoryProtection2());
}
}