Add: les fichiers pour la persistance

temp
Thomas Chazot 2 years ago
parent d6afccb50d
commit 7ef13f97ec

@ -9,7 +9,8 @@
"web": "expo start --web"
},
"dependencies": {
"@react-native-picker/picker": "^2.4.8",
"@expo/webpack-config": "^0.17.0",
"@react-native-picker/picker": "2.4.2",
"@react-navigation/bottom-tabs": "^6.4.0",
"@react-navigation/native": "^6.0.13",
"@react-navigation/stack": "^6.3.2",

@ -0,0 +1,19 @@
import { Conversation } from "../../core/conversation";
import { User } from "../../core/User/user";
import IDataManagerConversation from "../IDataManagerConversation";
export default class DataManagerConversationDatabase implements IDataManagerConversation{
createConversation(c: Conversation): void {
throw new Error("Method not implemented.");
}
getConversationFromUser(u: User): Conversation[] {
throw new Error("Method not implemented.");
}
deleteConversation(c: Conversation): void {
throw new Error("Method not implemented.");
}
updateConversation(c: Conversation): void {
throw new Error("Method not implemented.");
}
}

@ -0,0 +1,20 @@
import { Match } from "../../core/match";
import IDataManagerMatch from "../IDataManagerMatch";
export default class DataManagerMatchDatabase implements IDataManagerMatch{
getMatchById(id: string): Match | null {
throw new Error("Method not implemented.");
}
createMatch(m: Match): void {
throw new Error("Method not implemented.");
}
updateMatch(m: Match): void {
throw new Error("Method not implemented.");
}
deleteMatch(m: Match): void {
throw new Error("Method not implemented.");
}
}

@ -0,0 +1,13 @@
import { Conversation } from "../../core/conversation";
import { Message } from "../../core/message";
import IDataManagerMessage from "../IDataManagerMessage";
export default class DataManagerMessageDatabase implements IDataManagerMessage{
createMessage(m: Message): void {
throw new Error("Method not implemented.");
}
getMessageFromConversation(c: Conversation): Message[] {
throw new Error("Method not implemented.");
}
}

@ -0,0 +1,25 @@
import { User } from "../../core/User/user";
import IDataManagerUser from "../IDataManagerUser";
export default class DataManagerUserDatabase implements IDataManagerUser{
createUser(u: User): void {
throw new Error("Method not implemented.");
}
getUserById(id: string): User | null {
throw new Error("Method not implemented.");
}
getUserByUsernamePassword(username: string, password: string): User | null {
throw new Error("Method not implemented.");
}
getUserByUsername(username: string): User | null {
throw new Error("Method not implemented.");
}
updateUser(u: User): void {
throw new Error("Method not implemented.");
}
deleteUser(u: User): void {
throw new Error("Method not implemented.");
}
}

@ -0,0 +1,15 @@
import { Conversation } from "../core/conversation";
import { User } from "../core/User/user";
export default interface IDataManagerConversation{
createConversation(c:Conversation): void;
getConversationFromUser(u:User): Conversation[];
deleteConversation(c:Conversation): void;
updateConversation(c:Conversation): void;
}

@ -0,0 +1,13 @@
import { Match } from "../core/match";
export default interface IDataManagerMatch{
getMatchById(id:string): Match | null;
createMatch(m:Match): void;
updateMatch(m:Match): void;
deleteMatch(m:Match): void;
}

@ -0,0 +1,11 @@
import { Conversation } from "../core/conversation";
import { Message } from "../core/message";
export default interface IDataManagerMessage{
createMessage(m: Message): void;
getMessageFromConversation(c:Conversation): Message[];
}

@ -0,0 +1,17 @@
import { User } from "../core/User/user";
export default interface IDataManagerUser{
createUser(u:User): void;
getUserById(id:string): User | null;
getUserByUsernamePassword(username:string, password:string): User | null;
getUserByUsername(username:string): User | null;
updateUser(u:User):void;
deleteUser(u:User): void;
}

@ -0,0 +1,18 @@
import IDataManagerConversation from "./IDataManagerConversation";
import IDataManagerMatch from "./IDataManagerMatch";
import IDataManagerMessage from "./IDataManagerMessage";
import IDataManagerUser from './IDataManagerUser';
export default abstract class Manager{
managerConversation: IDataManagerConversation;
managerMessage: IDataManagerMessage;
managerMatch: IDataManagerMatch;
managerUser: IDataManagerUser;
constructor(managerConversation: IDataManagerConversation, managerMessage: IDataManagerMessage, managerMatch: IDataManagerMatch, managerUser: IDataManagerUser){
this.managerConversation=managerConversation;
this.managerMessage=managerMessage;
this.managerMatch=managerMatch;
this.managerUser=managerUser;
}
}

@ -0,0 +1,19 @@
import { Conversation } from "../../core/conversation";
import { User } from "../../core/User/user";
import IDataManagerConversation from "../IDataManagerConversation";
export default class DataManagerConversationStub implements IDataManagerConversation{
createConversation(c: Conversation): void {
throw new Error("Method not implemented.");
}
getConversationFromUser(u: User): Conversation[] {
throw new Error("Method not implemented.");
}
deleteConversation(c: Conversation): void {
throw new Error("Method not implemented.");
}
updateConversation(c: Conversation): void {
throw new Error("Method not implemented.");
}
}

@ -0,0 +1,21 @@
import { Match } from "../../core/match";
import IDataManagerConversation from "../IDataManagerConversation";
import IDataManagerMatch from "../IDataManagerMatch";
export default class DataManagerMatchStub implements IDataManagerMatch{
getMatchById(id: string): Match | null {
throw new Error("Method not implemented.");
}
createMatch(m: Match): void {
throw new Error("Method not implemented.");
}
updateMatch(m: Match): void {
throw new Error("Method not implemented.");
}
deleteMatch(m: Match): void {
throw new Error("Method not implemented.");
}
}

@ -0,0 +1,13 @@
import { Conversation } from "../../core/conversation";
import { Message } from "../../core/message";
import IDataManagerMessage from "../IDataManagerMessage";
export default class DataManagerMessageStub implements IDataManagerMessage{
createMessage(m: Message): void {
throw new Error("Method not implemented.");
}
getMessageFromConversation(c: Conversation): Message[] {
throw new Error("Method not implemented.");
}
}

@ -0,0 +1,89 @@
import { Skin } from "../../core/skin"
import { User } from "../../core/User/user"
import IDataManagerUser from "../IDataManagerUser"
export default class DataManagerUserStub implements IDataManagerUser{
tabAllUser: 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("S0006", "Bob Red",require('bob_party/assets/BobsSkins/BobRed.png'), 100), [new Skin("S0006", "Bob Red",require('bob_party/assets/BobsSkins/BobRed.png'), 100),], []),
]
/**
* createUser methode that allow us to create a user in the stub
* u the user to add
*/
createUser(u: User): void {
this.tabAllUser.push(u);
}
/**
* getUserById methode that allow us to find a user with his id in the stub
* id the id we want to search
* return User if found, null if not
*/
getUserById(id: string): User | null {
this.tabAllUser.forEach(user => {
if (user.getId()==id) {
return user;
}
});
return null;
}
/**
* getUserByUsernamePassword methode that allow us to find a user with his username and password in the stub
* username the username of the presumed user
* password the password of the presumed user
* return User if found, null if not
*/
getUserByUsernamePassword(username: string, password: string): User | null {
this.tabAllUser.forEach(user => {
if (user.getId()==username && user.getPassword()==password) {
return user;
}
});
return null;
}
/**
* getUserByUsername methode that allow us to find a user with his username in the stub
* username the username of the presumed user
* return User if found, null if not
*/
getUserByUsername(username: string): User | null {
this.tabAllUser.forEach(user => {
if (user.getId()==username) {
return user;
}
});
return null;
}
/**
* updateUser methode that allow us to update a user in the stub
* u the user we want to update
*/
updateUser(u: User): void {
this.tabAllUser.forEach(user => {
if (user.isEqual(u)) {
user=u;
}
});
}
/**
* deleteUser methode that allow us to delete a user in the stub
* u the user we want to delete
*/
deleteUser(u: User): void {
this.tabAllUser.forEach(user => {
if (user.isEqual(u)) {
this.tabAllUser.splice(this.tabAllUser.indexOf(u), 1);
}
});
}
}

@ -0,0 +1,46 @@
import { Conversation } from "../../core/conversation";
import { Message } from "../../core/message";
import { Skin } from "../../core/Skin";
import { User } from "../../core/User/user";
import IManager from "../IManager";
import DataManagerConversationStub from "./DataManagerConversationStub";
import DataManagerMatchStub from "./DataManagerMatchStub";
import DataManagerMessageStub from "./DataManagerMessageStub";
import DataManagerUserStub from "./DataManagerUserStub";
export default class extends IManager{
currentUser: User|null=null;
/*
tabAllSkin: Skin[]=[
new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0),
new Skin("S0002", "Bob Blue",require('bob_party/assets/BobsSkins/BobBlue.png'), 100),
new Skin("S0003", "Bob BW",require('bob_party/assets/BobsSkins/BobBW.png'), 100),
new Skin("S0004", "Bob Green",require('bob_party/assets/BobsSkins/BobGreen.png'), 100),
new Skin("S0005", "Bob P&T",require('bob_party/assets/BobsSkins/BobPinkTurquoise.png'), 100),
new Skin("S0006", "Bob Red",require('bob_party/assets/BobsSkins/BobRed.png'), 100),
new Skin("S0007", "Bob Cute",require('bob_party/assets/BobsSkins/BobYellowGreenBlueHeart.png'), 100),
]
tabAllMessage: Message[]= [
new Message("Salut", this.tabAllUser[1], new Date(2022,12,12,11,30,40)),
new Message("Wesh", this.tabAllUser[0], new Date(2022,12,13,12,20,40)),
new Message("Ca va", this.tabAllUser[1], new Date(2022,12,14, 12, 30, 35)),
new Message("Ouais et toi?", this.tabAllUser[0], new Date(2022,12,14,12,35,0)),
new Message("Coucou", this.tabAllUser[3], new Date(2022,12,14,12,35,0)),
]
tablAllConersation: Conversation[]=[
new Conversation([this.tabAllUser[1],this.tabAllUser[0] ], [this.tabAllMessage[0], this.tabAllMessage[1], this.tabAllMessage[2], this.tabAllMessage[3]], "le super nom")
]
*/
constructor(){
super(new DataManagerConversationStub, new DataManagerMessageStub, new DataManagerMatchStub, new DataManagerUserStub);
}
}

@ -1,4 +1,4 @@
import { FC} from "react"
import { FC } from "react"
import { Pressable, Text} from "react-native"
import React from "react"
/*

@ -4,8 +4,8 @@ import tabSkinApp from './constSkin'
import { User } from "./core/User/user";
let UserActu:User=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, undefined);
let UserTest:User=new User("48", "Wesh Wesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[5], tabSkinApp, undefined);
let UserActu:User=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, []);
let UserTest:User=new User("48", "Wesh Wesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[5], tabSkinApp, []);
let tabMessageTest:Message[]=[
new Message("Salut", UserActu, new Date(2022,12,12,11,30,40)),

@ -5,10 +5,10 @@ import { User } from "./core/User/user";
import tabConv from "./constCov";
let UserActu:User=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, undefined);
let UserTest:User=new User("48", "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[2], tabSkinApp, undefined);
let UserActu:User=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, []);
let UserTest:User=new User("48", "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[2], tabSkinApp, []);
let Alban:User=new User("17", "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, tabSkinApp[1], tabSkinApp, tabConv);
let Fefe63:User=new User("17", "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[6], tabSkinApp, undefined);
let Fefe63:User=new User("17", "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[6], tabSkinApp, []);
let tabUS:User[]=[UserActu, UserTest, Alban, Fefe63];

@ -30,8 +30,8 @@ export class User{
this.currentCoins=currentCoins;
this.totalCoins=totalCoins;
this.currentSkin=currentSkin;
this.tabSkin=[...tabSkin];
this.tabConv=[...tabConv];
this.tabSkin=tabSkin.copyWithin(tabSkin.length, 0);
this.tabConv=tabConv.copyWithin(tabConv.length, 0);
}
@ -163,4 +163,11 @@ export class User{
this.tabConv.push(conv);
}
isEqual(u:User){
if (u.getId()==this.id){
return true;
}
return false;
}
}

@ -1,6 +1,6 @@
import { ImageSourcePropType } from 'react-native';
import { Game } from './game'
/*
export class GameSolo extends Game{
readonly ptsToCoins:Map<number,number>
@ -29,4 +29,4 @@ export class GameSolo extends Game{
}
return coins;
}
}*/
}

@ -1,8 +1,5 @@
import { ImageSourcePropType } from 'react-native';
import { Game } from './game';
import { GameCasino } from './gameCasino';
import { GameMulti } from './gameMulti';
import { GameSolo } from './gameSolo';
import { User } from "./User/user";

@ -1,4 +1,4 @@
import { Game } from '../Game';
import { Game } from '../game';
import { GameSolo } from '../GameSolo';

@ -15,8 +15,8 @@ let tabConv:Conversation[]=[];
const msc = require('../../assets/Icons/FondGris.png');
const UserActu=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, tabConv);
const jeuTest= new GameSolo("SNAKE", require('../../assets/Icons/UnSelected/Gamepad.png'),"ouin", 1, 1,new Map<number,number>);
//const UserActu=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, tabConv);
const jeuTest= new GameSolo("1", "SNAKE", require('../../assets/Icons/UnSelected/Gamepad.png'),"ouin", 1, 1, new Map<number,number>);
function GameChoice(props: { navigation: any; }) {
const { navigation } = props
return (

@ -8,13 +8,21 @@ import { Conversation } from '../core/conversation';
import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice';
import { useSelector } from 'react-redux';
import { RootState } from '../redux/store';
import Stub from '../Services/StubManager/Stub';
//const test= new GameSolo("test", require('bob_party/assets/ImagesJeux/BatailleNavale.jpeg'), "test", );
let tabConv:Conversation[]=[];
let manager=new Stub();
function Home(props: { navigation: any; }) {
console.log(manager.managerUser.getUserById("14"));
console.log(manager.managerUser.getUserById("0"));
const { navigation } = props
const currentUser = useSelector((state: RootState) => state.currentUser.value[0]);

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save