Commit b8ae4126 authored by Mamadou Diallo's avatar Mamadou Diallo
Browse files

Amélioration du modèle et ajout du diagramme de classes de celui-ci

parent b91bedb5
@startuml
interface Carte {
}
abstract class CartesCreature
abstract class CartesTraques{
nom : String
phase : int
pouvoir : boolean
}
class Lieu
class Manifestation
class Survie
class CarteTraque{
nom : String
phase : int
symbole : Object
abstract pouvoir() : void
}
abstract class Pion
class Assimilation
class Secours
class Volonte
class Balise
class Maitre{
placerPion(pion Pion): void
formerReserve(): void
placerCartes(liste Lis<Carte>): void
avancerPion(pion Pion): void
}
class Plateau{
cases : List<Case>
}
Plateau - Pion
Plateau - Jeton
abstract class Joueur{
main : List<Carte>
defausse : List<Carte>
cratesJouees : List<Carte>
jouer(carte Cartes): void
piocher(carte Cartes, int nb): void
defausserCarte(carte Carte): void
}
class Creature {
listeCartesCreat : List<CartesCreature>
listeJetons : List<Jeton>
traquer(jouer Traque): void
affectuerAssaut(): void
//(CartesTraques ou Manifestation)
placerPlater(): void
poserJeton(jeton Jeton, carte Carte): void
}
class Traque{
listeCartesTraq : List<CartesTraques>
pion : Volonte
explorer(carteLieu Carte): void
resister(carte Survie): void
activerPouvoirCarte(carte Carte): void
lacherPrise(): void
}
abstract Jeton
class Artemia
class Cible
class JetonCreature
class Case
Carte <|.. CartesCreature
Carte <|.. CartesTraques
CartesTraques <|-- Lieu
CartesTraques <|-- Survie
CartesCreature <|-- Manifestation
CartesCreature <|-- CarteTraque
Pion <|-- Assimilation
Pion <|-- Secours
Pion <|-- Volonte
Pion <|-- Balise
Jeton <|-- Artemia
Jeton <|-- Cible
Jeton <|-- JetonCreature
Joueur <|-- Creature
Joueur <|-- Traque
Creature - CartesCreature : possède >
Traque - CartesTraques : possède >
Creature - Jeton : utilise >
Traque - Pion : utilise >
class Antre
class Jungle
class Riviere
class Plage
class Rover
class Marais
class Abri
class Epave
class Source
class Artefa
Lieu <|-- Antre
Lieu <|-- Jungle
Lieu <|-- Riviere
Lieu <|-- Plage
Lieu <|-- Rover
Lieu <|-- Marais
Lieu <|-- Abri
Lieu <|-- Epave
Lieu <|-- Source
Lieu <|-- Artefa
@enduml
......@@ -44,7 +44,13 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
......
package fr.univnantes.alma;
import fr.univnantes.alma.thrift.GameServerService;
//import fr.univnantes.alma.thrift.GameServerService;
import fr.univnantes.alma.handler.GameServiceHandler;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocolFactory;
......@@ -34,4 +34,6 @@ public class NotAloneApplication {
return new ServletRegistrationBean(tServlet, "/api");
}
}
package fr.univnantes.alma.controller;
import fr.univnantes.alma.model.cards.Card;
import fr.univnantes.alma.repository.CardRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.UUID;
@RestController @CrossOrigin(origins = "http://localhost:4200")
@RequestMapping("/api/v1")
public class CardController {
@Autowired
private CardRepository cardRepository;
@GetMapping("/cards")
public List<Card> getAllCards(){
return cardRepository.findAll();
}
@GetMapping("/cards/{id}")
public ResponseEntity<Card> getCardById(@PathVariable(value = "id" ) UUID cardID) throws Exception{
Card card = this.cardRepository.findById(cardID).orElseThrow(()-> new Exception("Card not found"));
return ResponseEntity.ok().body(card);
}
@PostMapping("/cards")
public Card createCard(@RequestBody Card card){
return cardRepository.save(card);
}
}
......@@ -15,6 +15,8 @@ import java.util.List;
@Component
public class GameServiceHandler implements GameServerService.Iface {
@Autowired
GameService service;
......@@ -49,3 +51,4 @@ public class GameServiceHandler implements GameServerService.Iface {
}
}
package fr.univnantes.alma.model.cards;
public class Card {
import fr.univnantes.alma.model.inerfaces.CardInterface;
import fr.univnantes.alma.model.utlis.Phase;
import java.util.UUID;
public abstract class Card implements CardInterface {
private Object title;
private Phase phase;
private String description;
public enum Lieu {
ANTRE, JUNGLE, RIVIERE, PLAGE, ROVER, MARAIS, ABRI, EPAVE, SOURCE, ARTEFACT
}
public enum Traque{
ACHARNEMENT, CHAMPS_DE_FORCE, MUTATION, FLASHBACK
}
public enum Survie{
RIPOSTE, VORTEX, ESQUIVE, VOLTE_FACE
}
public enum Phase {
ONE, TWO, THREE, FOUR
}
private UUID id;
public Card(Object title, Phase phase) {
this.title = title;
this.phase = phase;
this.description = this.addDescription(title);
this.id = this.generateId();
}
public String addDescription(Object cardTitle){
if (Lieu.ABRI.equals(cardTitle)) {
return "Description de la carte ABRI";
} else if (Lieu.ANTRE.equals(cardTitle)) {
return "Description de la carte ANTRE";
} else if (Lieu.ARTEFACT.equals(cardTitle)) {
return "Description de la carte ARTEFACT";
} else if (Lieu.EPAVE.equals(cardTitle)) {
return "Description de la carte EPAVE";
} else if (Lieu.JUNGLE.equals(cardTitle)) {
return "Description de la carte JUNGLE";
} else if (Lieu.MARAIS.equals(cardTitle)) {
return "Description de la carte MARAIS";
} else if (Lieu.PLAGE.equals(cardTitle)) {
return "Description de la carte PLAGE";
} else if (Lieu.RIVIERE.equals(cardTitle)) {
return "Description de la carte RIVIERE";
} else if (Lieu.ROVER.equals(cardTitle)) {
return "Description de la carte ROVER";
} else if (Lieu.SOURCE.equals(cardTitle)) {
return "Description de la carte SOURCE";
}else if(Traque.ACHARNEMENT.equals(cardTitle)){
return "Description de la carte ACHARNEMENT";
}else if(Traque.CHAMPS_DE_FORCE.equals(cardTitle)){
return "Description de la carte CHAMPS_DE_FORCE";
}else if(Traque.FLASHBACK.equals(cardTitle)){
return "Description de la carte FLASHBACK";
}else if(Traque.MUTATION.equals(cardTitle)){
return "Description de la carte MUTATION";
}else if(Survie.ESQUIVE.equals(cardTitle)){
return "Description de la carte ESQUIVE";
}else if(Survie.RIPOSTE.equals(cardTitle)){
return "Description de la carte RIPOSTE";
}else if(Survie.VOLTE_FACE.equals(cardTitle)){
return "Description de la carte VOLTE_FACE";
}else if(Survie.VORTEX.equals(cardTitle)){
return "Description de la carte VORTEX";
}
return "UnKnown";
public UUID generateId(){
UUID uniqID = UUID.randomUUID();
return uniqID;
}
@Override
public UUID getId() {
return id;
}
@Override
public Object getTitle() {
return title;
}
@Override
public Phase getPhase() {
return phase;
}
@Override
public String getDescription() {
return description;
}
@Override
public String toString(){
return "["+this.title+"\n"+this.description+"\n"+this.phase+"]";
}
public abstract String addDescription(Object cardTitle);
public abstract void effect(Object cardTitle);
}
package fr.univnantes.alma.model.cards;
import fr.univnantes.alma.model.utlis.LieuTitle;
import fr.univnantes.alma.model.utlis.Phase;
public class Lieu extends Card{
public Lieu(LieuTitle title, Phase phase) {
super(title, phase);
}
@Override
public String addDescription(Object object){
LieuTitle value = (LieuTitle)object;
switch (value){
case ABRI:
return "descripiton ABRI";
case ANTRE:
return "descripiton ANTRE";
case EPAVE:
return "descripiton EPAVE";
case PLAGE:
return "descripiton PLAGE";
case ROVER:
return "descripiton ROVER";
case JUNGLE:
return "descripiton JUNGLE";
case MARAIS:
return "descripiton MARAIS";
case SOURCE:
return "descripiton SOURCE";
case RIVIERE:
return "descripiton RIVIERE";
case ARTEFACT:
return "descripiton ARTEFACT";
default:
return "unKonwn";
}
}
@Override
public void effect(Object cardTitle) {
LieuTitle value = (LieuTitle) cardTitle;
switch (value){
case ABRI:
this.abriEffect();
case ANTRE:
this.antreEffect();
case EPAVE:
this.epaveEffect();
case PLAGE:
this.plageEffect();
case ROVER:
this.roverEffect();
case JUNGLE:
this.jungleEffect();
case MARAIS:
this.maraisEffect();
case SOURCE:
this.sourceEffect();
case RIVIERE:
this.riviereEffect();
case ARTEFACT:
this.artifactEffect();
}
}
public void abriEffect(){
}
public void jungleEffect(){
}
public void riviereEffect(){
}
public void plageEffect(){
}
public void roverEffect(){
}
public void maraisEffect(){
}
public void antreEffect(){
}
public void epaveEffect(){
}
public void sourceEffect(){
}
public void artifactEffect(){
}
}
package fr.univnantes.alma.model.cards;
import fr.univnantes.alma.model.utlis.Phase;
import fr.univnantes.alma.model.utlis.SurvieTitle;
public class Survie extends Card {
public Survie(SurvieTitle title, Phase phase) {
super(title, phase);
}
@Override
public String addDescription(Object cardTitle) {
SurvieTitle value = (SurvieTitle)cardTitle;
switch (value){
case VORTEX:
return "Description";
case ESQUIVE:
return "Description";
case RIPOSTE:
return "Description";
case VOLTE_FACE:
return "Description";
default:
return "UnKnown";
}
}
@Override
public void effect(Object cardTitle) {
SurvieTitle value = (SurvieTitle)cardTitle;
switch (value){
case VORTEX:
this.vortexEffect();
case ESQUIVE:
this.esquiveEffect();
case RIPOSTE:
this.riposteEffect();
case VOLTE_FACE:
this.volteFaceEffect();
}
}
public void vortexEffect(){
}
public void esquiveEffect(){
}
public void riposteEffect(){
}
public void volteFaceEffect(){
}
}
package fr.univnantes.alma.model.cards;
import fr.univnantes.alma.model.utlis.Phase;
import fr.univnantes.alma.model.utlis.TraqueTitle;
public class Traque extends Card{
public Traque(TraqueTitle title, Phase phase) {
super(title, phase);
}
@Override
public String addDescription(Object cardTitle) {
TraqueTitle value = (TraqueTitle)cardTitle;
switch (value){
case MUTATION:
return "Description";
case FLASHBACK:
return "Description";
case ACHARNEMENT:
return "Description";
case CHAMPS_DE_FORCE:
return "Description";
default:
return "UnKnown";
}
}
@Override
public void effect(Object cardTitle) {
TraqueTitle value = (TraqueTitle)cardTitle;
switch (value){
case MUTATION:
this.mutationEffect();
case FLASHBACK:
this.flashBackEffect();
case ACHARNEMENT:
this.acharnementEffect();
case CHAMPS_DE_FORCE:
this.champsDeForceEffect();
}
}
public void mutationEffect(){
}
public void flashBackEffect(){
}
public void acharnementEffect(){
}
public void champsDeForceEffect(){
}
}
package fr.univnantes.alma.model.inerfaces;
import fr.univnantes.alma.model.utlis.Phase;
import java.util.UUID;
public interface CardInterface {
public UUID getId();
public Phase getPhase();
public String getDescription();
public Object getTitle();
}
package fr.univnantes.alma.model.inerfaces;
import fr.univnantes.alma.model.cards.Card;
import java.util.List;
import java.util.UUID;
public interface PlayerInterface {
public List<CardInterface> getHand();
public List<CardInterface> getDiscards();
public List<CardInterface> getPlayedCards();
public String getName();
public UUID getId();
}
......@@ -8,6 +8,11 @@ public class Creature extends Player{
super(name);
}
@Override