Model_implementation #15
Merged
emre.kartal
merged 7 commits from Model_implementation
into master
2 years ago
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/Sources/bowlin_project/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/Sources/bowlin_project/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/Sources/bowlin_project/.dart_tool" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/Bowl_in.iml" filepath="$PROJECT_DIR$/.idea/Bowl_in.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.0 MiB |
@ -0,0 +1,13 @@
|
||||
class Achievement {
|
||||
String _name;
|
||||
|
||||
// Constructor
|
||||
Achievement(this._name);
|
||||
|
||||
// Getters and setters
|
||||
String get name => _name;
|
||||
|
||||
set name(String value) {
|
||||
_name = value;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class Game {
|
||||
Uuid _id;
|
||||
DateTime _time;
|
||||
int _pointsCurrentUser;
|
||||
bool _isFinished;
|
||||
List<String> _playerImages = [];
|
||||
|
||||
// Constructor
|
||||
Game(this._id, this._time, this._pointsCurrentUser, this._isFinished, this._playerImages);
|
||||
|
||||
// Getters and setters
|
||||
Uuid get id => _id;
|
||||
|
||||
set id(Uuid value) {
|
||||
_id = value;
|
||||
}
|
||||
|
||||
DateTime get time => _time;
|
||||
|
||||
set time(DateTime value) {
|
||||
_time = value;
|
||||
}
|
||||
|
||||
int get pointsCurrentUser => _pointsCurrentUser;
|
||||
|
||||
set pointsCurrentUser(int value) {
|
||||
_pointsCurrentUser = value;
|
||||
}
|
||||
|
||||
bool get isFinished => _isFinished;
|
||||
|
||||
set isFinished(bool value) {
|
||||
_isFinished = value;
|
||||
}
|
||||
|
||||
List<String> get playerImages => _playerImages;
|
||||
|
||||
set playerImages(List<String> value) {
|
||||
_playerImages = value;
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'Player.dart';
|
||||
import 'Round.dart';
|
||||
|
||||
class GameDetail {
|
||||
Uuid _id;
|
||||
DateTime _time;
|
||||
Uuid _winner;
|
||||
int _nbPoints;
|
||||
bool _isFinished;
|
||||
Round _currentRound;
|
||||
Player _host;
|
||||
List<Round> _rounds = [];
|
||||
List<Player> _players = [];
|
||||
|
||||
// Constructor
|
||||
GameDetail(
|
||||
this._id,
|
||||
this._time,
|
||||
this._winner,
|
||||
this._nbPoints,
|
||||
this._isFinished,
|
||||
this._currentRound,
|
||||
this._host,
|
||||
this._rounds,
|
||||
this._players);
|
||||
|
||||
// Getters and setters
|
||||
Uuid get id => _id;
|
||||
|
||||
set id(Uuid value) {
|
||||
_id = value;
|
||||
}
|
||||
|
||||
DateTime get time => _time;
|
||||
|
||||
set time(DateTime value) {
|
||||
_time = value;
|
||||
}
|
||||
|
||||
Uuid get winner => _winner;
|
||||
|
||||
set winner(Uuid value) {
|
||||
_winner = value;
|
||||
}
|
||||
|
||||
int get nbPoints => _nbPoints;
|
||||
|
||||
set nbPoints(int value) {
|
||||
_nbPoints = value;
|
||||
}
|
||||
|
||||
bool get isFinished => _isFinished;
|
||||
|
||||
set isFinished(bool value) {
|
||||
_isFinished = value;
|
||||
}
|
||||
|
||||
Round get currentRound => _currentRound;
|
||||
|
||||
set currentRound(Round value) {
|
||||
_currentRound = value;
|
||||
}
|
||||
|
||||
Player get host => _host;
|
||||
|
||||
set host(Player value) {
|
||||
_host = value;
|
||||
}
|
||||
|
||||
List<Round> get rounds => _rounds;
|
||||
|
||||
set rounds(List<Round> value) {
|
||||
_rounds = value;
|
||||
}
|
||||
|
||||
List<Player> get players => _players;
|
||||
|
||||
set players(List<Player> value) {
|
||||
_players = value;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'package:uuid/uuid_util.dart';
|
||||
import 'Player.dart';
|
||||
|
||||
class Guest extends Player {
|
||||
// Constructor
|
||||
Guest(Uuid id, String image, String name) : super(id, image, name);
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
abstract class IAuthManager {
|
||||
|
||||
// Methods
|
||||
bool verifiedUser(String name, String password);
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'package:uuid/uuid_util.dart';
|
||||
import 'GameDetail.dart';
|
||||
import 'Player.dart';
|
||||
|
||||
abstract class IGameManager {
|
||||
// Methods
|
||||
GameDetail getGameById(Uuid id);
|
||||
List<GameDetail> getGamesByPlayerId(Uuid id);
|
||||
List<GameDetail> getGamesByPlayer(Player user);
|
||||
List<GameDetail> getGamesByPlayers(List<Player> users);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
import 'User.dart';
|
||||
import 'Game.dart';
|
||||
import 'IUserManager.dart';
|
||||
import 'IGameManager.dart';
|
||||
import 'Game.dart';
|
||||
|
||||
abstract class IManager {
|
||||
late User _userCurrent;
|
||||
late Game _gameCurrent;
|
||||
IUserManager _userMgr;
|
||||
IGameManager _gameMgr;
|
||||
|
||||
// Constructor
|
||||
IManager(this._userCurrent, this._gameCurrent);
|
||||
|
||||
// Getters and setters
|
||||
User get userCurrent => _userCurrent;
|
||||
Game get gameCurrent => _gameCurrent;
|
||||
IUserManager get userMgr => _userMgr;
|
||||
IGameManager get gameMgr => _gameMgr;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'User.dart';
|
||||
import 'IAuthManager.dart';
|
||||
|
||||
abstract class IUserManager {
|
||||
IAuthManager _authMgr;
|
||||
|
||||
// Methods
|
||||
IAuthManager get authMgr => _authMgr;
|
||||
List<User> getUsersByName(String name);
|
||||
User getUserById(Uuid id);
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class Player {
|
||||
final Uuid _id;
|
||||
String _name;
|
||||
String _image;
|
||||
|
||||
// Constructor
|
||||
Player(this._id, this._name, this._image);
|
||||
|
||||
// Getters and setters
|
||||
Uuid get id => _id;
|
||||
|
||||
String get name => _name;
|
||||
|
||||
set name(String value) {
|
||||
_name = value;
|
||||
}
|
||||
|
||||
String get image => _image;
|
||||
|
||||
set image(String value) {
|
||||
_image = value;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
import 'Player.dart';
|
||||
|
||||
class Round {
|
||||
int _firstThrow;
|
||||
int _secondThrow;
|
||||
int _points;
|
||||
Player _player;
|
||||
|
||||
// Constructor
|
||||
Round(this._firstThrow, this._secondThrow, this._points, this._player);
|
||||
|
||||
// Getters and setters
|
||||
int get firstThrow => _firstThrow;
|
||||
|
||||
set firstThrow(int value) {
|
||||
_firstThrow = value;
|
||||
}
|
||||
|
||||
int get secondThrow => _secondThrow;
|
||||
|
||||
set secondThrow(int value) {
|
||||
_secondThrow = value;
|
||||
}
|
||||
|
||||
int get points => _points;
|
||||
|
||||
set points(int value) {
|
||||
_points = value;
|
||||
}
|
||||
|
||||
Player get player => _player;
|
||||
|
||||
set player(Player value) {
|
||||
_player = value;
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
class Stat {
|
||||
int _nbVictory;
|
||||
int _nbDefeat;
|
||||
int _nbGames;
|
||||
int _highscore;
|
||||
int _nbStrikes;
|
||||
int _nbSpares;
|
||||
int _nbScore;
|
||||
int _avgScore;
|
||||
double _avgPinsPerRound;
|
||||
|
||||
// Constructor
|
||||
Stat(
|
||||
this._nbVictory,
|
||||
this._nbDefeat,
|
||||
this._nbGames,
|
||||
this._highscore,
|
||||
this._nbStrikes,
|
||||
this._nbSpares,
|
||||
this._nbScore,
|
||||
this._avgScore,
|
||||
this._avgPinsPerRound,
|
||||
);
|
||||
|
||||
// Getters and setters
|
||||
int get nbVictory => _nbVictory;
|
||||
|
||||
set nbVictory(int value) {
|
||||
_nbVictory = value;
|
||||
}
|
||||
|
||||
int get nbDefeat => _nbDefeat;
|
||||
|
||||
set nbDefeat(int value) {
|
||||
_nbDefeat = value;
|
||||
}
|
||||
|
||||
int get nbGames => _nbGames;
|
||||
|
||||
set nbGames(int value) {
|
||||
_nbGames = value;
|
||||
}
|
||||
|
||||
int get highscore => _highscore;
|
||||
|
||||
set highscore(int value) {
|
||||
_highscore = value;
|
||||
}
|
||||
|
||||
int get nbStrikes => _nbStrikes;
|
||||
|
||||
set nbStrikes(int value) {
|
||||
_nbStrikes = value;
|
||||
}
|
||||
|
||||
int get nbSpares => _nbSpares;
|
||||
|
||||
set nbSpares(int value) {
|
||||
_nbSpares = value;
|
||||
}
|
||||
|
||||
int get nbScore => _nbScore;
|
||||
|
||||
set nbScore(int value) {
|
||||
_nbScore = value;
|
||||
}
|
||||
|
||||
int get avgScore => _avgScore;
|
||||
|
||||
set avgScore(int value) {
|
||||
_avgScore = value;
|
||||
}
|
||||
|
||||
double get avgPinsPerRound => _avgPinsPerRound;
|
||||
|
||||
set avgPinsPerRound(double value) {
|
||||
_avgPinsPerRound = value;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'Achievement.dart';
|
||||
import 'Player.dart';
|
||||
import 'Stat.dart';
|
||||
|
||||
class User extends Player {
|
||||
String _mail;
|
||||
List<Achievement> _achievements = <Achievement>[];
|
||||
List<User> _friends = <User>[];
|
||||
List<Stat> _stats = <Stat>[];
|
||||
|
||||
// Constructor
|
||||
User(Uuid id, String name, String image, this._mail, this._achievements, this._friends, this._stats)
|
||||
: super(id, name, image);
|
||||
|
||||
// Getters and setters
|
||||
String get mail => _mail;
|
||||
|
||||
set mail(String value) {
|
||||
_mail = value;
|
||||
}
|
||||
|
||||
List<Achievement> get achievements => _achievements;
|
||||
|
||||
set achievements(List<Achievement> value) {
|
||||
_achievements = value;
|
||||
}
|
||||
|
||||
List<User> get friends => _friends;
|
||||
|
||||
set friends(List<User> value) {
|
||||
_friends = value;
|
||||
}
|
||||
|
||||
List<Stat> get stats => _stats;
|
||||
|
||||
set stats(List<Stat> value) {
|
||||
_stats = value;
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
import '../lib/model/Player.dart';
|
||||
import '../lib/model/Guest.dart';
|
||||
import '../lib/model/User.dart';
|
||||
import '../lib/model/Stat.dart';
|
||||
import 'dart:math';
|
||||
import '../lib/model/Achievement.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
void main() {
|
||||
List<Stat> stats = [];
|
||||
Random random = new Random();
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Stat stat = new Stat(
|
||||
random.nextInt(50) + 1, // valeur aléatoire entre 1 et 50
|
||||
random.nextInt(20) + 1, // valeur aléatoire entre 1 et 20
|
||||
random.nextInt(30) + 1, // valeur aléatoire entre 1 et 30
|
||||
random.nextInt(1000) + 1, // valeur aléatoire entre 1 et 1000
|
||||
random.nextInt(10) + 1, // valeur aléatoire entre 1 et 10
|
||||
random.nextInt(5) + 1, // valeur aléatoire entre 1 et 5
|
||||
random.nextInt(5000) + 1000, // valeur aléatoire entre 1000 et 6000
|
||||
random.nextInt(300) + 1, // valeur aléatoire entre 1 et 300
|
||||
random.nextDouble() * 10 // valeur aléatoire entre 0 et 10
|
||||
);
|
||||
stats.add(stat);
|
||||
}
|
||||
|
||||
User ami = new User(Uuid(), "Lucas","https://fastly.picsum.photos/id/288/2000/2000.jpg?hmac=AUboE-jzAzofYj_O3w_EqtZU3JHzcg7HR1IQd1Ce7lY","Lucas.delanier@etu.uca.fr",[],[],[]);
|
||||
|
||||
List<Player> players = [
|
||||
new Player(Uuid(), "Rami", "https://fastly.picsum.photos/id/1060/2000/2000.jpg?hmac=_RrU8GpkCDUlVKfgyWE-GcX-GS5TKNyUzdFbJAGXHV4"),
|
||||
new Player(Uuid(), "Emre", "https://fastly.picsum.photos/id/670/2000/2000.jpg?hmac=zWqTr_vDEab3dBtp7JZgJP8TRCPNanJ4tYwDDd-jGYA"),
|
||||
new Guest(Uuid(), "Bot1","https://fastly.picsum.photos/id/820/2000/2000.jpg?hmac=Ctxx2feJNZnG1S7UPx_YrWcEw89tKb7fR8i1W-VTOz4"),
|
||||
new Guest(Uuid(), "Bot2","https://fastly.picsum.photos/id/288/2000/2000.jpg?hmac=AUboE-jzAzofYj_O3w_EqtZU3JHzcg7HR1IQd1Ce7lY"),
|
||||
ami,
|
||||
new User(
|
||||
Uuid(),
|
||||
"Louison",
|
||||
"https://fastly.picsum.photos/id/1029/2000/2000.jpg?hmac=_K3pMobVk00dfNR7rsj1NLnEBB5Gf88SvGPbbjoH-Uc",
|
||||
"louison.parant@etu.uca.fr",
|
||||
[
|
||||
new Achievement("5 games"),
|
||||
new Achievement("2 strikes in a row"),
|
||||
new Achievement("Win a game")
|
||||
],
|
||||
[
|
||||
ami
|
||||
],
|
||||
stats
|
||||
)
|
||||
];
|
||||
|
||||
|
||||
print("Players :");
|
||||
// afficahge de toutes les informations de tous les joueurs
|
||||
for (var player in players) {
|
||||
if (player is Guest) {
|
||||
print("\tID: ${player.id}, Nom: ${player.name}, Image: ${player.image}, Type: Guest");
|
||||
} else if (player is User) {
|
||||
print("\tID: ${player.id}, Nom: ${player.name}, Image: ${player.image}, Type: User");
|
||||
print("\tAchievements:");
|
||||
for (var achievement in player.achievements) {
|
||||
print("\t\tNom: ${achievement.name}");
|
||||
}
|
||||
print("\tStats:");
|
||||
for (var stat in player.stats) {
|
||||
print("\t\tVictoires: ${stat.nbVictory}, Défaites: ${stat.nbDefeat}, Parties jouées: ${stat.nbGames}, Meilleur score: ${stat.highscore}, Nombre de strikes: ${stat.nbStrikes}, Nom de spares: ${stat.nbStrikes}, Moyenne score: ${stat.avgScore}, Moyenne score par round: ${stat.avgPinsPerRound}");
|
||||
}
|
||||
print("\tAmis:");
|
||||
for (var amis in player.friends) {
|
||||
print("\t\tNom: ${amis.name}, Mail: ${amis.mail}");
|
||||
}
|
||||
|
||||
} else {
|
||||
print("\tID: ${player.id}, Nom: ${player.name}, Image: ${player.image}, Type: Player");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print("GameDetail :");
|
||||
|
||||
|
||||
}
|
Loading…
Reference in new issue