Merge remote-tracking branch 'origin/Persistance' into typescript création des interfaces ayant besion des classes
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
commit
7f0cf7c140
@ -1,6 +1,20 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import { GameMulti } from './src/core/gameMulti'
|
||||||
|
import { GameSolo } from './src/core/gameSolo'
|
||||||
|
import { Match } from './src/core/match'
|
||||||
|
import { MatchMulti } from './src/core/matchMulti'
|
||||||
import MainTabNavigator from './src/navigation/AppNavigator'
|
import MainTabNavigator from './src/navigation/AppNavigator'
|
||||||
|
import FakeSaverUser from './src/screens/services/userServices/fakeSaverUser'
|
||||||
|
import ManagerUser from './src/screens/services/userServices/ManagerUser'
|
||||||
|
import StubUser from './src/screens/services/userServices/stub'
|
||||||
|
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
return <MainTabNavigator/>
|
let m=new ManagerUser(new StubUser, new FakeSaverUser);
|
||||||
|
let tabU=m.getLoaderUser().loadAllUser();
|
||||||
|
m.setCurrentUser(tabU[0]);
|
||||||
|
|
||||||
|
let match= new MatchMulti("00001", [...tabU], new GameMulti("1", "SNAKE", require('./assets/Icons/UnSelected/Gamepad.png'),"ouin", 1, 1, new Map<number,number>));
|
||||||
|
console.log(m.getLoaderUser().loadUserByMatch(match));
|
||||||
|
//return <MainTabNavigator/>
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
import { Conversation } from "../../../core/conversation";
|
||||||
|
import { User } from "../../../core/User/user";
|
||||||
|
|
||||||
|
export default interface ILoaderConversation{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loadAllConversation methode that load every Conversation in the data management system
|
||||||
|
* return an array of Conversation
|
||||||
|
*/
|
||||||
|
loadAllConversation(): Conversation[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loadByID methode that load an array of Conversation from the data management system by its id
|
||||||
|
* id the id we want to search
|
||||||
|
* return a Conversation if found, if not null
|
||||||
|
*/
|
||||||
|
loadByID(id:string): Conversation | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loadByUser methode that load an array of Conversation from the data management system using a user
|
||||||
|
* u the user we want the conversations of
|
||||||
|
* return an array of Conversation
|
||||||
|
*/
|
||||||
|
loadByUser(u:User): Conversation[];
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
import { Conversation } from "../../../core/conversation";
|
||||||
|
|
||||||
|
export default interface ISaverConversation{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* saveConversation methode that save a Conversation in the data management system
|
||||||
|
* c the Conversation we want to save
|
||||||
|
*/
|
||||||
|
|
||||||
|
saveConversation(c:Conversation): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* deleteConversation methode that delete a Conversation in the data management system
|
||||||
|
* c the Conversation we want to delete
|
||||||
|
*/
|
||||||
|
deleteConversation(c:Conversation):void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updateConversation methode that update a Conversation in the data management system
|
||||||
|
* c the Conversation we want to update
|
||||||
|
*/
|
||||||
|
updateConversation(c:Conversation): void;
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
import { Match } from "../../../core/match";
|
||||||
|
|
||||||
|
export default interface ILoaderMatch{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loadAllMatch methode that load every Match from the data management system
|
||||||
|
* return an array of Match
|
||||||
|
*/
|
||||||
|
loadAllMatch(): Match[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loadByID methode that load a match from the data management system by its id
|
||||||
|
* id the id we want to search
|
||||||
|
* return a Match if found, if not null
|
||||||
|
*/
|
||||||
|
loadByID(id:string): Match | null;
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
import { Match } from "../../../core/match";
|
||||||
|
|
||||||
|
export default interface ISaverMatch{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* saveMatch methode that save a Match in the data management system
|
||||||
|
* m the Match we want to save
|
||||||
|
*/
|
||||||
|
|
||||||
|
saveMatch(m:Match): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* deleteMatch methode that delete a Match in the data management system
|
||||||
|
* m the Match we want to delete
|
||||||
|
*/
|
||||||
|
deleteMatch(m:Match):void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updateMatch methode that update a Match in the data management system
|
||||||
|
* m the Match we want to update
|
||||||
|
*/
|
||||||
|
updateMatch(m:Match): void;
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
import { Conversation } from "../../../core/conversation";
|
||||||
|
import { Message } from "../../../core/message";
|
||||||
|
|
||||||
|
export default interface ILoaderMessage{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loadAllMessage methode that load every Message from the data management system
|
||||||
|
* return an array of Message
|
||||||
|
*/
|
||||||
|
loadAllMessage(): Message[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loadByID methode that load a Message from the data management system by its id
|
||||||
|
* id the id we want to search
|
||||||
|
* return a Message if found, if not null
|
||||||
|
*/
|
||||||
|
loadByID(id:string): Message | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loadByUser methode that load an array of Message from the data management system using a Conversation
|
||||||
|
* c the Conversation we want the Messages of
|
||||||
|
* return an array of Message
|
||||||
|
*/
|
||||||
|
loadByConversation(c:Conversation): Message[];
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
import { Message } from "../../../core/message";
|
||||||
|
|
||||||
|
export default interface ISaverMessage{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* saveMessage methode that save a Message in the data management system
|
||||||
|
* m the Message we want to save
|
||||||
|
*/
|
||||||
|
|
||||||
|
saveMessage(m:Message): void;
|
||||||
|
|
||||||
|
}
|
@ -1,8 +1,46 @@
|
|||||||
|
import { Conversation } from "../../../core/conversation";
|
||||||
|
import { Match } from "../../../core/match";
|
||||||
import { User } from "../../../core/User/user";
|
import { User } from "../../../core/User/user";
|
||||||
|
|
||||||
export default interface ILoaderUser{
|
export default interface ILoaderUser{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loadAllUser methode that load every user from the data management system
|
||||||
|
* return an array of User
|
||||||
|
*/
|
||||||
|
loadAllUser(): User[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loadByID methode that load a user from the data management system by his id
|
||||||
|
* id the id we want to search
|
||||||
|
* return a User if found, if not null
|
||||||
|
*/
|
||||||
loadByID(id:string): User | null;
|
loadByID(id:string): User | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loadByUsername methode that load a user from the data management system by his username
|
||||||
|
* username the username we want to search
|
||||||
|
* return a User if found, if not null
|
||||||
|
*/
|
||||||
loadByUsername(username:string): User | null;
|
loadByUsername(username:string): User | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loadByUsernamePassword methode that load a user from the data management system by his username and his password
|
||||||
|
* username the username we want to search
|
||||||
|
* password the password we want to search
|
||||||
|
* return a User if found, if not null
|
||||||
|
*/
|
||||||
loadByUsernamePassword(username:string, password:string): User | null;
|
loadByUsernamePassword(username:string, password:string): User | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loadUserByMatch methode that load every user in a game
|
||||||
|
* return an array of User
|
||||||
|
*/
|
||||||
|
loadUserByMatch(m:Match): User[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* laodUserByConversation methode that load every user in a Conversation
|
||||||
|
* return an array of User
|
||||||
|
*/
|
||||||
|
laodUserByConversation(c:Conversation): User[];
|
||||||
}
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
import { User } from "../../../core/User/user";
|
||||||
|
import ILoaderUser from "./ILoaderUser";
|
||||||
|
import ISaverUser from "./ISaverUser";
|
||||||
|
|
||||||
|
export default class ManagerUser{
|
||||||
|
|
||||||
|
private currentUser: User | null;
|
||||||
|
|
||||||
|
private loaderUser: ILoaderUser;
|
||||||
|
|
||||||
|
private saverUser: ISaverUser;
|
||||||
|
|
||||||
|
constructor(loader:ILoaderUser, saver:ISaverUser){
|
||||||
|
this.currentUser=null;
|
||||||
|
this.loaderUser=loader;
|
||||||
|
this.saverUser=saver;
|
||||||
|
}
|
||||||
|
|
||||||
|
getCurrentUser(){
|
||||||
|
return this.currentUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
setCurrentUser(u:User){
|
||||||
|
this.currentUser=u;
|
||||||
|
}
|
||||||
|
|
||||||
|
getLoaderUser(){
|
||||||
|
return this.loaderUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
setLoaderUser(l:ILoaderUser){
|
||||||
|
this.loaderUser=l;
|
||||||
|
}
|
||||||
|
|
||||||
|
getsaverUser(){
|
||||||
|
return this.saverUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
setsaverUser(s:ISaverUser){
|
||||||
|
this.saverUser=s;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
import { User } from "../../../core/User/user";
|
||||||
|
import ISaverUser from "./ISaverUser";
|
||||||
|
|
||||||
|
|
||||||
|
export default class FakeSaverUser implements ISaverUser{
|
||||||
|
|
||||||
|
saveUser(u: User): void {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
deleteUser(u: User): void {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
updateUser(u: User): void {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
import { Conversation } from "../../../core/conversation";
|
||||||
|
import { Match } from "../../../core/match";
|
||||||
|
import { User } from "../../../core/User/user";
|
||||||
|
import ILoaderUser from "./ILoaderUser";
|
||||||
|
|
||||||
|
export default class LoaderUserApi implements ILoaderUser{
|
||||||
|
|
||||||
|
loadAllUser(): User[] {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
loadByID(id: string): User | null {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
loadByUsername(username: string): User | null {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
loadByUsernamePassword(username: string, password: string): User | null {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
loadUserByMatch(m: Match): User[] {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
laodUserByConversation(c: Conversation): User[] {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
import { User } from "../../../core/User/user";
|
||||||
|
import ISaverUser from "./ISaverUser";
|
||||||
|
|
||||||
|
|
||||||
|
export default class SaverUserApi implements ISaverUser{
|
||||||
|
|
||||||
|
saveUser(u: User): void {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
deleteUser(u: User): void {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
updateUser(u: User): void {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
import { Conversation } from "../../../core/conversation";
|
||||||
|
import { Match } from "../../../core/match";
|
||||||
|
import { Skin } from "../../../core/skin";
|
||||||
|
import { User } from "../../../core/User/user";
|
||||||
|
import ILoaderUser from "./ILoaderUser";
|
||||||
|
|
||||||
|
export default class StubUser implements ILoaderUser{
|
||||||
|
|
||||||
|
tabUS:User[]=[
|
||||||
|
new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]),
|
||||||
|
new User("48", "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]),
|
||||||
|
new User("17", "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)],),
|
||||||
|
new User("17", "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]),
|
||||||
|
];
|
||||||
|
|
||||||
|
loadAllUser(): User[] {
|
||||||
|
return this.tabUS;
|
||||||
|
}
|
||||||
|
loadByID(id: string): User | null {
|
||||||
|
for(let u of this.tabUS){
|
||||||
|
if (u.getId()==id){
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
loadByUsername(username: string): User | null {
|
||||||
|
for(let u of this.tabUS){
|
||||||
|
if (u.getUsername()==username){
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
loadByUsernamePassword(username: string, password: string): User | null {
|
||||||
|
for(let u of this.tabUS){
|
||||||
|
if (u.getUsername()==username && u.getPassword()==password){
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadUserByMatch(m: Match): User[] {
|
||||||
|
let tabUser:User[]=[];
|
||||||
|
m.getTabUsers().forEach(u => {
|
||||||
|
tabUser.push(u);
|
||||||
|
});
|
||||||
|
return tabUser;
|
||||||
|
}
|
||||||
|
laodUserByConversation(c: Conversation): User[] {
|
||||||
|
let tabUser:User[]=[];
|
||||||
|
c.getTabUser().forEach(u => {
|
||||||
|
tabUser.push(u);
|
||||||
|
});
|
||||||
|
return tabUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue