Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft : Capture the flag #44

Open
wants to merge 25 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d1d3c67
Début du jeu CTF
orwenn22 Sep 12, 2023
d55bc11
CTF : amélioration code
orwenn22 Sep 13, 2023
847be56
CTF : ramener drapeau adverse à sa base
orwenn22 Sep 13, 2023
d778031
CTF : scoreboard avec les scores
orwenn22 Sep 13, 2023
dfaae9a
CTF : retirer commentaire TODO
orwenn22 Sep 13, 2023
b42becd
CTF : rendre le jeu gagnable
orwenn22 Sep 14, 2023
0b642b7
CTF : effet de glow
orwenn22 Sep 14, 2023
2aeb53d
CTF : drop le drapeau au sol
orwenn22 Sep 14, 2023
1338ead
CTF : cercles autour des spawns de drapeaux
orwenn22 Sep 15, 2023
9d16ab1
CTF : renommer teams en français
orwenn22 Sep 15, 2023
a60fda6
CTF:Ne pas drop le drapeau si joueur meurt dans le vide
orwenn22 Sep 16, 2023
ab41249
CTF : 8 joueurs max dans la game
orwenn22 Sep 17, 2023
5905c6e
CTF : amélioration check si le joueur casse son propre drapeau
orwenn22 Sep 17, 2023
a6a7ab4
CTF : ajouter killzone
orwenn22 Oct 1, 2023
a3f9f41
CTF : suivre la position des drapeaux
orwenn22 Oct 1, 2023
f1d5223
CTF: toujours drop le drapeau sur un block solide
orwenn22 Nov 9, 2023
ac3a4cf
CTF: amélioration drop drapeau
orwenn22 Nov 9, 2023
0c50291
CTF : utiliser TeamWin pour définir les vainqueurs
orwenn22 Dec 14, 2023
2401c97
Merge remote-tracking branch 'origin/dev' into CTF
orwenn22 Dec 14, 2023
39bde86
CTF : typo belowBock -> belowBlock
orwenn22 Dec 15, 2023
8183c2c
CTF : game_points -> gamePoint
orwenn22 Dec 15, 2023
211a8ef
CTF : belowBlock
orwenn22 Dec 15, 2023
4459613
CTF : ne pas utiliser le snake case dans initFlags
orwenn22 Dec 15, 2023
585eb48
CTF : Ne pas hardcoder les positions dans l'inventaire
orwenn22 Jan 5, 2024
e550b48
CTF : Gérer les particules dans une classe séparé
orwenn22 Jan 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions games/ctf/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription

plugins {
`java-library`
id("net.minecrell.plugin-yml.bukkit") version "0.5.2" // Generates plugin.yml
}

dependencies {
implementation(project(":core"))

compileOnly("io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT")

compileOnly("fr.efreicraft:ECATUP:latest.integration")
}

bukkit {
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD
name = "LudosCTF"
main = "fr.efreicraft.ludos.games.ctf.Main"
apiVersion = "1.19"
authors = listOf("Ewenn BAUDET")
prefix = "CTF"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package fr.efreicraft.ludos.games.ctf;

import fr.efreicraft.ludos.core.Core;
import fr.efreicraft.ludos.core.players.LudosPlayer;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerMoveEvent;

/**
* @author Ewenn BAUDET
* @param ctfLogic logique du jeu CTF
*/
public record EventListener(GameLogic ctfLogic) implements Listener {
JiveOff marked this conversation as resolved.
Show resolved Hide resolved
@EventHandler
public void onPlayerDrop(PlayerDropItemEvent event) {
event.setCancelled(true);
}

@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
event.setCancelled(true);
}

@EventHandler
public void onPlayerBreakBlock(BlockBreakEvent event) {
LudosPlayer ludosPlayer = Core.get().getPlayerManager().getPlayer(event.getPlayer());

String teamOfFlag; //on doit vérifier si le joueur n'appartient pas à cette team avant de casser le drapeau

//Obtenir la team du drapeau (déplacer ça autre part dans le future ?)
switch (event.getBlock().getBlockData().getMaterial()) {
case RED_BANNER -> teamOfFlag = "Rouge";
case BLUE_BANNER -> teamOfFlag = "Bleu";
default -> {
event.setCancelled(true);
return;
}
}

//gérer le cassage du drapeau
Location flagLocation = event.getBlock().getLocation();
event.setCancelled(ctfLogic.handleBreakFlag(ludosPlayer, teamOfFlag, flagLocation));
}

@EventHandler
public void onDeath(PlayerDeathEvent event) {
LudosPlayer ludosPlayer = Core.get().getPlayerManager().getPlayer(event.getPlayer());
ctfLogic.dropFlagIfCarried(ludosPlayer, ludosPlayer.entity().getLocation().getY() > -64);
}


@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
/*
LudosPlayer ludosPlayer = Core.get().getPlayerManager().getPlayer(event.getPlayer());
Location blockLocation = event.getBlock().getLocation();
ctfLogic.tryToScore(ludosPlayer, blockLocation);
*/
event.setCancelled(true);
}


@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
if(!event.hasChangedBlock()) return;

LudosPlayer ludosPlayer = Core.get().getPlayerManager().getPlayer(event.getPlayer());

ctfLogic.checkKillZone(ludosPlayer);

Location playerLocation = ludosPlayer.entity().getLocation();
ctfLogic.tryToScore(ludosPlayer, playerLocation);
}
}
Loading