Skip to content

Commit

Permalink
Merge pull request #1 from grecodavide/development
Browse files Browse the repository at this point in the history
Merge Development for lab #2
  • Loading branch information
FrancescoCaracciolo authored Mar 19, 2024
2 parents b005cd5 + 346b163 commit c62d779
Show file tree
Hide file tree
Showing 38 changed files with 1,145 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-16">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
Expand Down
135 changes: 95 additions & 40 deletions deliveries/UML/class_diagram.mmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Stati
title: Model diagram
---
classDiagram
Match --> GameDeck
Expand All @@ -8,11 +8,11 @@ classDiagram
Match -- Player
MatchState <|-- WaitState
MatchState <|-- SetupState
MatchState <|-- ChoosePlayerState
MatchState <|-- NextTurnState
MatchState <|-- ChooseSecretObjectiveState
MatchState <|-- UpdatePlayerStatusState
MatchState <|-- DrawPhaseState
MatchState <|-- RankingsState
MatchState <|-- AfterMoveState
MatchState <|-- AfterDrawState
MatchState <|-- FinalState

Card <|-- InitialCard
Card <|-- PlayableCard
Expand All @@ -35,6 +35,7 @@ classDiagram
%%Side <-- Player
%%Side <-- Match
Side <-- PlacedCard
Corner <-- CardFace
%%Symbol <-- GoldCard
%% DrawSource <-- Player

Expand All @@ -54,24 +55,35 @@ classDiagram
CORNER_OBJ
}

class Corner {
<<Enumeation>>
TOP_LEFT
TOP_RIGHT
BOTTOM_LEFT
BOTTOM_RIGHT
}

class CardFace {
<<Record>>
- topLeft: Symbol
- topRight: Symbol
- bottomLeft: Symbol
- bottomRight: Symbol
- center: Set~Symbol~
+ CardFace(Symbol topLeft, Symbol topRight, Symbol bottomLeft, Symbol bottomRight, Set~Symbol~ center)
+ getCorner(Corner corner) Symbol
+ getCenter() Set~Symbol~
}

class Card {
<<Abstract>>
- front: CardFace
- back: CardFace
# sides : Map~Side, CardFace~
+ getSide(Side side) CardFace
}

class PlayableCard {
<<Abstract>>
- points: int
# points: int
}

class InitialCard {
Expand All @@ -80,40 +92,46 @@ classDiagram

class ResourceCard {
+ ResourceCard(CardFace front, CardFace back, int points)
+ getPoints() : int
}

class GoldCard {
- multiplier: Symbol
- req: QuantityRequirement
+ GoldCard(CardFace front, CardFace back, int points, Symbol multiplier, QuantityRequirement req)
+ totPoints(Board) int
+ getMultiplier() Symbol
+ getRequirement() QuantityRequirement
+ totPoints(Board board) int
}

class Requirement {
<<Abstract>>
+ isSatisfied(Board bord) bool
+ isSatisfied(Board board) bool
}

class QuantityRequirement {
- reqs : Map~Integer, Symbol~
+ QuantityRequirement(Symbol simbol, Integer quantity)
+ isSatisfied(Board board) bool
}

class PositionRequirement {
- reqs: Map&ltPair&ltInteger, Integer&gt, Color&gt
+ PositionRequirement(Map&ltPair&ltInteger, Integer&gt, Color&gt)
+ isSatisfied(Board board) bool
}
class Objective {
- points: int
- req: Requirement
+ Objective(int points, Requirement req)
+ getPoints() int
+ getRequirement() Requirement
}
class Player {
- nickname: String
- match: Match
- points: Int
- board: Board
- resources: Map<Symbol, Integer>
- color: Color
- objective: Objective

Expand All @@ -122,6 +140,11 @@ classDiagram
+ drawCard(DrawSource draw) void
+ chooseObjective(Objective objective) void
+ getBoard() Board
+ getPoints() int
+ getSecretObjective() Objective
+ getColor() Color
+ getNickname() String
# setColor() void
}
class Color{
<<Enumeration>>
Expand All @@ -138,44 +161,66 @@ classDiagram
class Board {
- currentHand: List~PlayableCard~
- placed: Map&ltPair&ltInteger,Integer&gt, PlacedCard&gt
- availableResources: Map~Symbol, Integer~

+ Board()
+ getCurrentHand() List~PlayableCard~
+ addCardHand(PlayableCard card) void
+ removeCardHand(PlayableCard card) void
+ checkRequirement(Requirement req) bool
+ placeCard(Pair<Integer, Integer>, Card card, Side side) Map~Symbols, Integer~
+ getAvailableResources() Map~Symbol, Integer~
# getPlacedMap() Map&ltPair&ltInteger,Integer&gt, PlacedCard&gt
# addHandCard(PlayableCard card) void
# removeHandCard(PlayableCard card) void
# setInitialSide(Side side) void
# placeCard(Pair~Integer, Integer~, PlayableCard card, Side side) int
# setInitialCard(InitialCard card) void
+ verifyCardPlacement(Pair~Integer, Integer~ coords, Card card, Side side) bool
}
class PlacedCard {
<<Record>>
- card: Card
- turn: int
+ PlacedCard(Card card, int turn)
+ getCard() Card
+ getTurn() int
}

class Match {
- players: list~Players~
- maxPlayers: int
- currState: MatchState
- currentPlayer: Player
- initialsDeck: GameDeck~InitialCard~
- resourcesDeck: GameDeck~ResourceCard~
- goldsDeck: GameDeck~GoldCard~
- objectivesDeck: GameDeck~Objective~
- visibleGolds: Pair<GoldCard, GoldCard>
- visibleResources: Pair<ResourceCard>
- visibleObjectives: Pair<Objective, Objective>
- visibleGolds: Pair~GoldCard, GoldCard~
- visibleResources: Pair~ResourceCard, ResourceCard~
- visibleObjectives: Pair~Objective, Objective~
- currentProposedObjectives: Pair~Objective, Objective~
- started: bool
- lastTurn: bool
- finished: bool

+ Match(int maxPlayers) void
+ setState() void
+ Match(int maxPlayers, resourceDeck ) void
+ isFull() bool
+ isStarted() bool
+ isFinished() bool
+ addPlayer(Player player) void
+ removePlayer(Player player) void
+ getCurrentPlayer() Player
+ chooseSecretObjective(Objective obj) void
+ getSecretObjectives() Pair~Objective, Objective~
+ makeMove(Player player, Pair~Integer, Integer~ coords, PlayableCard card, Side side) void
+ drawCard(Player player, DrawSource draw) PlayableCard
- setupMatch() void
+ getPlayers() List~Player~
# getPoints() int
# addPoints() void
# chooseSecretObjective(Objective obj) void
# proposeSecretObjectives() Pair~Objective, Objective~
# makeMove(Pair~Integer, Integer~ coords, PlayableCard card, Side side) void
# drawCard(DrawSource draw) PlayableCard
# doStart() void
# doFinish() void
# setState() void
# setupDecks() void
# setupPlayers() void
# setupBoards() void
# nextPlayer() void

}
class DrawSource {
Expand All @@ -191,52 +236,62 @@ classDiagram
class MatchState {
<<Abstract>>
+ match: Match
+ MatchState(Match match)
+ transition() void
+ join() void
+ quit() void
+ addPlayer() void
+ removePlayer() void
+ proposeSecretObjectives() void
+ chooseSecretObjective() void
+ makeMove() void
+ drawCard() void

}

class WaitState{
+ WaitState() void
+ WaitState(Match match) void
+ transition() void
+ join() void
+ quit() void
+ addPlayer() void
+ removePlayer() void
}
class SetupState{
+ SetupState() void
+ SetupState(Match match) void
+ transition() void

}
class ChoosePlayerState {
+ ChoosePlayerState() void
class NextTurnState {
+ NextTurnState(Match match) void
+ proposeSecretObjectives() void
+ makeMove() void
+ transition() void
}

class ChooseSecretObjectiveState {
+ ChooseSecretObjectiveState() void
+ chooseSecretObjective() void
+ transition() void
}

class UpdatePlayerStatusState {
+ UpdatePlayerStatusState() void
class AfterMoveState {
+ AfterMoveState() void
+ drawCard() void
+ transition() void
}

class DrawPhaseState {
+ DrawPhaseState() void
class AfterDrawState {
+ AfterDrawState() void
+ transition() void
}

class RankingsState{
+ RankingsState() void
class FinalState{
+ FinalState() void
+ transition() void
}


class GameDeck {
<<Generics>>
- int size
- cardList: List~U~
- cardsList: List~U~
+ GameDeck(int size)
+ add(U card) void
+ pop() U
Expand Down
Binary file modified deliveries/UML/model.pdf
Binary file not shown.
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<configuration>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
<!--> Plugin to execute project -->
Expand All @@ -87,5 +89,15 @@
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
14 changes: 0 additions & 14 deletions src/main/java/it/polimi/ingsw/App.java

This file was deleted.

20 changes: 20 additions & 0 deletions src/main/java/it/polimi/ingsw/gamemodel/AfterDrawState.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package it.polimi.ingsw.gamemodel;

public class AfterDrawState extends MatchState {

public AfterDrawState(Match match) {
super(match);
}

@Override
public void transition() {
MatchState nextState;

if(match.isFinished())
nextState = new FinalState(match);
else
nextState = new NextTurnState(match);

match.setState(nextState);
}
}
19 changes: 19 additions & 0 deletions src/main/java/it/polimi/ingsw/gamemodel/AfterMoveState.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package it.polimi.ingsw.gamemodel;

public class AfterMoveState extends MatchState {

public AfterMoveState(Match match) {
super(match);
}

@Override
public void drawCard() throws WrongStateException {
this.transition();
}

@Override
public void transition() {
MatchState nextState = new AfterDrawState(match);
match.setState(nextState);
}
}
Loading

0 comments on commit c62d779

Please sign in to comment.