Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
Not Alone
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mamadou Saliou DIALLO
Not Alone
Commits
8263b7ca
Commit
8263b7ca
authored
Dec 06, 2020
by
Mamadou Saliou DIALLO
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: create pawn class and handle his associations.
Handled associations: Pawn-Square and Pawn-Tracked.
parent
2c12a00c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
0 deletions
+80
-0
not-alone-server/src/main/java/fr/univnantes/alma/model/Pawn.java
...e-server/src/main/java/fr/univnantes/alma/model/Pawn.java
+47
-0
not-alone-server/src/main/java/fr/univnantes/alma/model/player/Tracked.java
...rc/main/java/fr/univnantes/alma/model/player/Tracked.java
+15
-0
not-alone-server/src/main/java/fr/univnantes/alma/model/square/Square.java
...src/main/java/fr/univnantes/alma/model/square/Square.java
+18
-0
No files found.
not-alone-server/src/main/java/fr/univnantes/alma/model/Pawn.java
0 → 100644
View file @
8263b7ca
package
fr.univnantes.alma.model
;
import
fr.univnantes.alma.model.player.Creature
;
import
fr.univnantes.alma.model.player.Tracked
;
import
fr.univnantes.alma.model.square.Square
;
import
fr.univnantes.alma.references.associations.BidirectionalManyToOne
;
import
fr.univnantes.alma.references.associations.BidirectionalOneToOne
;
import
fr.univnantes.alma.references.interfaces.ManyToOneAssociation
;
import
fr.univnantes.alma.references.interfaces.OneToOneAssociation
;
/**
* Pawn used by the tracked.
*/
public
class
Pawn
{
/**
* Associated square.
*/
private
OneToOneAssociation
<
Pawn
,
Square
>
square
;
/**
* Owner of the card (Creature hand).
*/
private
ManyToOneAssociation
<
Pawn
,
Tracked
>
owner
;
/**
* Create new Pawn.
*/
public
Pawn
()
{
square
=
new
BidirectionalOneToOne
<>(
this
,
Square:
:
getPawn
);
owner
=
new
BidirectionalManyToOne
<>(
this
,
Tracked:
:
getPawns
);
}
/**
* Return the associated square to the pawn.
* @return Square.
*/
public
OneToOneAssociation
<
Pawn
,
Square
>
getSquare
()
{
return
square
;
}
/**
* Return pawn owner.
* @return Tracked
*/
public
ManyToOneAssociation
<
Pawn
,
Tracked
>
getOwner
()
{
return
owner
;
}
}
not-alone-server/src/main/java/fr/univnantes/alma/model/player/Tracked.java
View file @
8263b7ca
package
fr.univnantes.alma.model.player
;
import
fr.univnantes.alma.model.Pawn
;
import
fr.univnantes.alma.model.card.place.PlaceCard
;
import
fr.univnantes.alma.references.associations.BidirectionalOneToMany
;
import
fr.univnantes.alma.references.interfaces.OneToManyAssociation
;
...
...
@@ -18,6 +19,12 @@ public class Tracked extends Player {
* Tracked player discard.
*/
private
OneToManyAssociation
<
Tracked
,
PlaceCard
>
discard
;
/**
* Tracked player discard.
*/
private
OneToManyAssociation
<
Tracked
,
Pawn
>
pawns
;
/**
* Create new Tracked Player.
* By default, player is UNBLOCKED.
...
...
@@ -30,6 +37,7 @@ public class Tracked extends Player {
hand
=
new
BidirectionalOneToMany
<>(
this
,
PlaceCard:
:
getHandOwner
);
discard
=
new
BidirectionalOneToMany
<>(
this
,
PlaceCard:
:
getDiscardOwner
);
pawns
=
new
BidirectionalOneToMany
<>(
this
,
Pawn:
:
getOwner
);
}
/**
...
...
@@ -48,4 +56,11 @@ public class Tracked extends Player {
return
discard
;
}
/**
* Return pawns.
* @return Pawns
*/
public
OneToManyAssociation
<
Tracked
,
Pawn
>
getPawns
()
{
return
pawns
;
}
}
not-alone-server/src/main/java/fr/univnantes/alma/model/square/Square.java
View file @
8263b7ca
package
fr.univnantes.alma.model.square
;
import
fr.univnantes.alma.model.Pawn
;
import
fr.univnantes.alma.references.associations.BidirectionalOneToOne
;
import
fr.univnantes.alma.references.interfaces.OneToOneAssociation
;
/***
* Game board square.
*/
...
...
@@ -10,12 +14,18 @@ public abstract class Square {
*/
private
int
position
;
/**
* Associated square.
*/
private
OneToOneAssociation
<
Square
,
Pawn
>
pawn
;
/**
* Create new instance of Square.
* @param squarePosition square position
*/
public
Square
(
final
int
squarePosition
)
{
this
.
position
=
squarePosition
;
pawn
=
new
BidirectionalOneToOne
<>(
this
,
Pawn:
:
getSquare
);
}
/**
...
...
@@ -25,4 +35,12 @@ public abstract class Square {
public
int
getPosition
()
{
return
position
;
}
/**
* Return associated pawn to the square.
* @return Pawn
*/
public
OneToOneAssociation
<
Square
,
Pawn
>
getPawn
()
{
return
pawn
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment