diff --git a/bob_party/App.tsx b/bob_party/App.tsx index 8442ede..87920dc 100644 --- a/bob_party/App.tsx +++ b/bob_party/App.tsx @@ -9,10 +9,15 @@ import { useUserStore } from './src/context/userContext'; import ManagerConversation from './src/services/conversationService/managerConversation' import { LoaderConversationApi } from './src/services/conversationService/loaderConversationApi' import { FakeSaverConversation } from './src/services/conversationService/fakeSaverConversation' +import ManagerMatch from './src/services/matchServices/managerMatch' +import LoaderMatchApi from './src/services/matchServices/loaderMatchApi' +import SaverMatchApi from './src/services/matchServices/saverMatchApi' export const MANAGER_USER = new ManagerUser(new LoaderUserApi, new FakeSaverUser); export const MANAGER_CONVERSATION = new ManagerConversation(new LoaderConversationApi, new FakeSaverConversation); +export const MANAGER_MATCH = new ManagerMatch(new LoaderMatchApi, new SaverMatchApi); + export default function App() { diff --git a/bob_party/src/Games/CookieClicker/cookieClicker.tsx b/bob_party/src/Games/CookieClicker/cookieClicker.tsx index 74b92a9..38c3c61 100644 --- a/bob_party/src/Games/CookieClicker/cookieClicker.tsx +++ b/bob_party/src/Games/CookieClicker/cookieClicker.tsx @@ -11,18 +11,18 @@ import { } from 'react-native' import { MANAGER_USER } from '../../../App'; import { useUserStore } from '../../context/userContext'; -import { Match } from '../../core/match'; +import { Match } from '../../core/Match/match'; import { User } from '../../core/User/user'; -function CookieClicker(props: { navigation: any, match:Match}){ +function CookieClicker(props: { navigation: any}){ + const { navigation } = props + const GAMING_TIME=15; const setUser = useUserStore((state) => state.setUser); - const nav = props.navigation; - const match=props.match; const [count, setCount] = useState(0); const [money, setMoney] = useState(0); @@ -85,11 +85,14 @@ function CookieClicker(props: { navigation: any, match:Match}){ let tmp: User | null; tmp=MANAGER_USER.getCurrentUser(); if (tmp!=null){ + /* if (match.getTabUsers().includes(tmp)){ match.updatePostMatch(tmp, count); setUser(tmp); - nav.goBack(); + } + */ + navigation.goBack(); } } diff --git a/bob_party/src/components/GameComponent.tsx b/bob_party/src/components/GameComponent.tsx index c778e09..7f74b07 100644 --- a/bob_party/src/components/GameComponent.tsx +++ b/bob_party/src/components/GameComponent.tsx @@ -19,10 +19,10 @@ FC<{game: Game, nav: any}> = { return ( - nav.navigate('')}> + nav.navigate("CookieClicker")}> {game.getName()} diff --git a/bob_party/src/components/Skin.tsx b/bob_party/src/components/Skin.tsx index b4120ea..a09101d 100644 --- a/bob_party/src/components/Skin.tsx +++ b/bob_party/src/components/Skin.tsx @@ -103,7 +103,7 @@ FC<{nav : any, skin: Skin, state: String}> = case 'icon': return ( - + ) @@ -113,7 +113,7 @@ FC<{nav : any, skin: Skin, state: String}> = {skin.getSkinName()} 100€ @@ -124,7 +124,7 @@ FC<{nav : any, skin: Skin, state: String}> = {skin.getSkinName()} ) @@ -134,7 +134,7 @@ FC<{nav : any, skin: Skin, state: String}> = {skin.getSkinName()} ) @@ -142,7 +142,7 @@ FC<{nav : any, skin: Skin, state: String}> = return( ) } diff --git a/bob_party/src/constSkin.ts b/bob_party/src/constSkin.ts index 473c83e..395c45e 100644 --- a/bob_party/src/constSkin.ts +++ b/bob_party/src/constSkin.ts @@ -1,13 +1,13 @@ import { Skin } from "./core/skin"; let tabSkinApp: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), + new Skin(1, "Bob","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobClassic.png", 0), + new Skin(2, "Bob Blue","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobBlue.png", 100), + new Skin(3, "Bob BW","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobBW.png", 100), + new Skin(4, "Bob Green","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobGreen.png", 100), + new Skin(5, "Bob P&T", "https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobPinkTurquoise.png", 100), + new Skin(6, "Bob Red", "https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobRed.png", 100), + new Skin(7, "Bob Cute", "https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobYellowGreenBlueHeart.png", 100), ] diff --git a/bob_party/src/core/Game.ts b/bob_party/src/core/Game.ts index 2274d6c..337c734 100644 --- a/bob_party/src/core/Game.ts +++ b/bob_party/src/core/Game.ts @@ -3,15 +3,15 @@ import { ImageSourcePropType } from "react-native"; import internal from "stream"; export abstract class Game{ - readonly id:string; + readonly id:number; private name:string; - private imageSource:ImageSourcePropType; + private imageSource:string; private gameSource:string; private nbPlayerMin: number; private nbPlayerMax:number; /* Constructor of the class */ - constructor (id:string, name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){ + constructor (id:number, name:string, imageSource:string, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){ this.id=id; this.name=name; this.imageSource=imageSource; @@ -41,7 +41,7 @@ export abstract class Game{ } /* Brief : Function setting the image of a game */ - setImageSource(imageSource:ImageSourcePropType){ + setImageSource(imageSource:string){ this.imageSource=imageSource; } diff --git a/bob_party/src/core/match.ts b/bob_party/src/core/Match/match.ts similarity index 83% rename from bob_party/src/core/match.ts rename to bob_party/src/core/Match/match.ts index 4ecfacc..3265e5c 100644 --- a/bob_party/src/core/match.ts +++ b/bob_party/src/core/Match/match.ts @@ -1,17 +1,17 @@ import { ImageSourcePropType } from 'react-native'; -import { Game } from './game'; -import { User } from "./User/user"; +import { Game } from '../game'; +import { User } from "../User/user"; export abstract class Match{ - readonly code:string; - private inGame:Boolean; + readonly code:number; + private inGame:Boolean=false; private tabUsers:User[]; private theGame:Game; - constructor(code:string, inGame:Boolean, tabUser:User[], game:Game){ + constructor(code:number, inGame:Boolean, tabUser:User[], game:Game){ this.code=code; - this.inGame=false; + this.inGame=inGame; this.tabUsers=[...tabUser]; this.theGame=game; } diff --git a/bob_party/src/core/matchCasino.ts b/bob_party/src/core/Match/matchCasino.ts similarity index 50% rename from bob_party/src/core/matchCasino.ts rename to bob_party/src/core/Match/matchCasino.ts index f758b48..6376812 100644 --- a/bob_party/src/core/matchCasino.ts +++ b/bob_party/src/core/Match/matchCasino.ts @@ -1,12 +1,12 @@ import { Match } from "./match"; -import { User } from "./User/user"; -import { Game } from "./game"; -import { GameCasino } from "./gameCasino"; -import { ManagerCoinsUser } from "./User/userCoinsModifier"; +import { User } from "../User/user"; +import { Game } from "../game"; +import { GameCasino } from "../gameCasino"; +import { ManagerCoinsUser } from "../User/userCoinsModifier"; -export class MatchMulti extends Match{ +export default class MatchCasino extends Match{ - constructor(code:string, inGame:Boolean, tabUser:User[], game:GameCasino){ + constructor(code:number, inGame:Boolean, tabUser:User[], game:GameCasino){ super(code, inGame, tabUser, game); } diff --git a/bob_party/src/core/Match/matchCreator.ts b/bob_party/src/core/Match/matchCreator.ts new file mode 100644 index 0000000..22f5eb4 --- /dev/null +++ b/bob_party/src/core/Match/matchCreator.ts @@ -0,0 +1,12 @@ +import { MANAGER_MATCH } from "../../../App"; +import ManagerMatch from "../../services/matchServices/managerMatch"; +import { Game } from "../game"; +import { User } from "../User/user"; +import { Match } from "./match"; + +export default class MatchCreator{ + + async createMatchSolo(u:User, g:Game): Promise{ + return await MANAGER_MATCH.getsaverMatch().saveMatch(u, g); + } +} \ No newline at end of file diff --git a/bob_party/src/core/Match/matchMulti.ts b/bob_party/src/core/Match/matchMulti.ts new file mode 100644 index 0000000..c72ba66 --- /dev/null +++ b/bob_party/src/core/Match/matchMulti.ts @@ -0,0 +1,17 @@ +import { Match } from "./match"; +import { User } from "../User/user"; +import { Game } from "../game"; +import { GameMulti } from "../gameMulti"; +import { ManagerCoinsUser } from "../User/userCoinsModifier"; + +export default class MatchMulti extends Match{ + + constructor(code:number, inGame:Boolean, tabUser:User[], game:GameMulti){ + super(code, inGame, tabUser, game); + } + + updatePostMatch(user:User, points: number): void { + const manage= new ManagerCoinsUser(); + manage.addCoins(user, this.getGame().coinsCalculator(points)); + } +} \ No newline at end of file diff --git a/bob_party/src/core/Match/matchSolo.ts b/bob_party/src/core/Match/matchSolo.ts new file mode 100644 index 0000000..fef2170 --- /dev/null +++ b/bob_party/src/core/Match/matchSolo.ts @@ -0,0 +1,17 @@ +import { Match } from "./match"; +import { GameSolo } from "../gameSolo"; +import { User } from "../User/user"; +import { Game } from "../game"; +import { ManagerCoinsUser } from "../User/userCoinsModifier"; + +export default class MatchSolo extends Match{ + + constructor(code:number, inGame:Boolean, tabUser:User[], game:GameSolo){ + super(code, inGame, tabUser, game); + } + + updatePostMatch(user:User, points: number): void { + const manage= new ManagerCoinsUser(); + manage.addCoins(user, this.getGame().coinsCalculator(points)); + } +} \ No newline at end of file diff --git a/bob_party/src/core/User/user.ts b/bob_party/src/core/User/user.ts index c337912..e49404f 100644 --- a/bob_party/src/core/User/user.ts +++ b/bob_party/src/core/User/user.ts @@ -5,7 +5,7 @@ import { TextBase } from 'react-native'; export class User{ - readonly id: string; + readonly id: number; private username: string; private password: string; private nationality: string; @@ -18,7 +18,7 @@ export class User{ private tabSkin: Skin[]; /* Consturctor of the class */ - constructor(id: string, username: string, password:string, nationality: string, sexe: string, dateOfBirth: Date, currentCoins: number, totalCoins: number, + constructor(id: number, username: string, password:string, nationality: string, sexe: string, dateOfBirth: Date, currentCoins: number, totalCoins: number, nbGamesPlayed:number, currentSkin: Skin, tabSkin: Skin[]){ this.id=id; this.username=username; diff --git a/bob_party/src/core/User/userCreator.ts b/bob_party/src/core/User/userCreator.ts index 18be053..4c5104d 100644 --- a/bob_party/src/core/User/userCreator.ts +++ b/bob_party/src/core/User/userCreator.ts @@ -8,21 +8,7 @@ export class UserCreator{ async createUser(username:string, password:string, nationality:string, sexe:string, date:Date){ //Récup l'ID d'après dans la bdd - let u:User; - let newId:string=""; - - let oldId = await MANAGER_USER.getLoaderUser().loadLastId(); - oldId=oldId.slice(1); - let leInt=parseInt(oldId); - newId+="U"; - for (let i = 0; i < 4-leInt.toString().length; i++) { - newId = newId + "0"; - } - leInt+=1; - newId=newId+leInt; - console.log(newId); - u = new User(newId, username, password, nationality, sexe, date, 0, 0, 0, tabSkinApp[0], [tabSkinApp[0]]); - await MANAGER_USER.getsaverUser().saveUser(u); + let u:null|User = await MANAGER_USER.getsaverUser().saveUser(username, password, nationality, sexe, date); MANAGER_USER.setCurrentUser(u); return u; } diff --git a/bob_party/src/core/conversation.ts b/bob_party/src/core/conversation.ts index ac94d9a..0ac989f 100644 --- a/bob_party/src/core/conversation.ts +++ b/bob_party/src/core/conversation.ts @@ -3,14 +3,14 @@ import { User } from "./User/user"; export class Conversation{ - private Id: string; + private id: number; private tabUser: User[]; private tabMessage: Message[]; private name: string; /* Constructor of the class */ - constructor(id: string, tabUser: User[], tabMessage:Message[], name:string){ - this.Id=id; + constructor(id: number, tabUser: User[], tabMessage:Message[], name:string){ + this.id=id; this.tabUser=[...tabUser]; this.tabMessage=[...tabMessage]; this.name=name; @@ -40,7 +40,7 @@ export class Conversation{ /* Brief : function returning the id of a conversation */ getId(){ - return this.Id; + return this.id; } /* Brief : function returning the name to a conversation */ diff --git a/bob_party/src/core/gameCasino.ts b/bob_party/src/core/gameCasino.ts index 6029a90..92d1ba8 100644 --- a/bob_party/src/core/gameCasino.ts +++ b/bob_party/src/core/gameCasino.ts @@ -3,7 +3,7 @@ import { Game } from './game' export class GameCasino extends Game{ - constructor(id:string, name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){ + constructor(id:number, name:string, imageSource:string, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){ super(id, name, imageSource, gameSource, nbPlayerMin, nbPlayerMax); } diff --git a/bob_party/src/core/gameMulti.ts b/bob_party/src/core/gameMulti.ts index e76862e..b897be5 100644 --- a/bob_party/src/core/gameMulti.ts +++ b/bob_party/src/core/gameMulti.ts @@ -4,7 +4,7 @@ import { Game } from './game' export class GameMulti extends Game{ readonly rankToCoins:Map - constructor(id:string, name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, rankToCoins:Map){ + constructor(id:number, name:string, imageSource:string, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, rankToCoins:Map){ super(id, name, imageSource, gameSource, nbPlayerMin, nbPlayerMax); this.rankToCoins=rankToCoins; } diff --git a/bob_party/src/core/gameSolo.ts b/bob_party/src/core/gameSolo.ts index e631b3b..5ebcf59 100644 --- a/bob_party/src/core/gameSolo.ts +++ b/bob_party/src/core/gameSolo.ts @@ -4,7 +4,7 @@ import { Game } from './game' export class GameSolo extends Game{ readonly ptsToCoins:Map - constructor(id:string, name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, ptsToCoins:Map){ + constructor(id:number, name:string, imageSource:string, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, ptsToCoins:Map){ super(id, name, imageSource, gameSource, nbPlayerMin,nbPlayerMax); this.ptsToCoins=ptsToCoins; } diff --git a/bob_party/src/core/matchMulti.ts b/bob_party/src/core/matchMulti.ts deleted file mode 100644 index 2003035..0000000 --- a/bob_party/src/core/matchMulti.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Match } from "./match"; -import { User } from "./User/user"; -import { Game } from "./game"; -import { GameMulti } from "./gameMulti"; -import { ManagerCoinsUser } from "./User/userCoinsModifier"; - -export class MatchMulti extends Match{ - - constructor(code:string, inGame:Boolean, tabUser:User[], game:GameMulti){ - super(code, inGame, tabUser, game); - } - - updatePostMatch(user:User, points: number): void { - const manage= new ManagerCoinsUser(); - manage.addCoins(user, this.getGame().coinsCalculator(points)); - } -} \ No newline at end of file diff --git a/bob_party/src/core/matchSolo.ts b/bob_party/src/core/matchSolo.ts deleted file mode 100644 index 1fd2287..0000000 --- a/bob_party/src/core/matchSolo.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Match } from "./match"; -import { GameSolo } from "./gameSolo"; -import { User } from "./User/user"; -import { Game } from "./game"; -import { ManagerCoinsUser } from "./User/userCoinsModifier"; - -export class MatchSolo extends Match{ - - constructor(code:string, inGame:Boolean, tabUser:User[], game:GameSolo){ - super(code, inGame, tabUser, game); - } - - updatePostMatch(user:User, points: number): void { - const manage= new ManagerCoinsUser(); - manage.addCoins(user, this.getGame().coinsCalculator(points)); - } -} \ No newline at end of file diff --git a/bob_party/src/core/message.ts b/bob_party/src/core/message.ts index 087833d..5f9aed5 100644 --- a/bob_party/src/core/message.ts +++ b/bob_party/src/core/message.ts @@ -2,52 +2,52 @@ import { User } from './User/user' export class Message{ - private Id: string; - private Content: string; - private Sender: User; - private DateEnvoie: Date; + private id: number; + private content: string; + private sender: User; + private dateEnvoie: Date; /* Constructor of the class */ - constructor(id: string, content: string, sender:User, dateEnvoie:Date){ - this.Id=id; - this.Content=content; - this.Sender=sender; - this.DateEnvoie=dateEnvoie; + constructor(id: number, content: string, sender:User, dateEnvoie:Date){ + this.id=id; + this.content=content; + this.sender=sender; + this.dateEnvoie=dateEnvoie; } /* Brief : Function setting the content of a message */ setMessageContent(content: string){ - this.Content=content; + this.content=content; } /* Brief : Function setting the sender of a message */ setMessageSender(sender: User){ - this.Sender=sender; + this.sender=sender; } /* Brief : Function setting the date of a message */ setMessageDate(dateEnvoie: Date){ - this.DateEnvoie=dateEnvoie; + this.dateEnvoie=dateEnvoie; } /* Brief : Function getting the id of a message */ getMessageId(){ - return this.Id; + return this.id; } /* Brief : Function getting the content of a message */ getMessageContent(){ - return this.Content; + return this.content; } /* Brief : Function getting the sender of a message */ getMessageSender(){ - return this.Sender; + return this.sender; } /* Brief : Function getting the date of a message */ getMessageDate(){ - return this.DateEnvoie; + return this.dateEnvoie; } diff --git a/bob_party/src/core/skin.ts b/bob_party/src/core/skin.ts index 5351764..fb8583c 100644 --- a/bob_party/src/core/skin.ts +++ b/bob_party/src/core/skin.ts @@ -1,13 +1,13 @@ import { ImageSourcePropType } from "react-native"; export class Skin{ - readonly id: string; + readonly id: number; private name: string; - private source: ImageSourcePropType; + private source: string; private cost:number; /* Constructor of the class */ - constructor(id:string, name: string, source:ImageSourcePropType, Cost:number){ + constructor(id:number, name: string, source:string, Cost:number){ this.id=id; this.name=name; this.source=source; @@ -20,7 +20,7 @@ export class Skin{ } /* Brief : Fuction setting the source of the image of a skin */ - setSkinSource(source: ImageSourcePropType){ + setSkinSource(source: string){ this.source=source; } diff --git a/bob_party/src/core/tests/conversation.test.ts b/bob_party/src/core/tests/conversation.test.ts index c7ea9be..d336118 100644 --- a/bob_party/src/core/tests/conversation.test.ts +++ b/bob_party/src/core/tests/conversation.test.ts @@ -8,20 +8,20 @@ import { User } from '../User/user'; // Instances let conv:Conversation[] = []; let tab:Skin[] = []; -let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0); +new Skin(1, "Bob","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobClassic.png", 0); let dateBirth = new Date(2010,0o3,0o7); -let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab); -let usr2 = new User('00002', 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, tab); +let usr = new User(1, 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab); +let usr2 = new User(2, 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, tab); let theDate = new Date(2022,10,14); let theDate2 = new Date(2022,10,13); let theDate3 = new Date(2022,10,15); -let mess = new Message('M0001', 'Bob Party est le meilleur projet', usr, theDate2); +let mess = new Message(1, 'Bob Party est le meilleur projet', usr, theDate2); let tabU:User[] = [usr, usr2]; -let mess2 = new Message('M0002', 'Oui tout à fait', usr2, theDate); -let mess3 = new Message('M0003', 'Mais oui trop de ouf', usr, theDate3); +let mess2 = new Message(2, 'Oui tout à fait', usr2, theDate); +let mess3 = new Message(3, 'Mais oui trop de ouf', usr, theDate3); let tabM:Message[] = [mess, mess2]; -let convo = new Conversation('C0001', tabU, tabM, 'the conv'); -let usr3 = new User('00003', 'wow', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab); +let convo = new Conversation(1, tabU, tabM, 'the conv'); +let usr3 = new User(4, 'wow', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab); // Get tests diff --git a/bob_party/src/core/tests/matchSolo.test.ts b/bob_party/src/core/tests/matchSolo.test.ts index 94f4d72..8ec9cb8 100644 --- a/bob_party/src/core/tests/matchSolo.test.ts +++ b/bob_party/src/core/tests/matchSolo.test.ts @@ -1,4 +1,4 @@ -import { MatchSolo } from '../MatchSolo'; +import { MatchSolo } from '../Match/matchSolo'; import { Conversation } from '../Conversation'; import { Skin } from '../Skin'; import { User } from '../User/user'; diff --git a/bob_party/src/navigation/AppNavigator.tsx b/bob_party/src/navigation/AppNavigator.tsx index 0a299bd..d58258a 100644 --- a/bob_party/src/navigation/AppNavigator.tsx +++ b/bob_party/src/navigation/AppNavigator.tsx @@ -12,7 +12,7 @@ import SkinList from '../screens/SkinList' import GameChoice from '../screens/GameChoice' import SignIn from '../screens/SignIn' import SignUp from '../screens/SignUp' - +import CookieClicker from '../Games/CookieClicker/CookieClicker' const HomeStack = createStackNavigator(); @@ -25,7 +25,7 @@ function HomeStackScreen() { - + ); } diff --git a/bob_party/src/screens/GameChoice.tsx b/bob_party/src/screens/GameChoice.tsx index 9fd8061..29f0c88 100644 --- a/bob_party/src/screens/GameChoice.tsx +++ b/bob_party/src/screens/GameChoice.tsx @@ -16,7 +16,7 @@ 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 cookieClicker= new GameSolo("1", "Cookie Clicker", require('../../assets/Icons/UnSelected/Gamepad.png'), "/Games/CookieClicker/cookieClicker.tsx", 1, 1, new Map); +const cookieClicker= new GameSolo(1, "Cookie Clicker", "https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobYellowGreenBlueHeart.png", "/Games/CookieClicker/cookieClicker.tsx", 1, 1, new Map); function GameChoice(props: { navigation: any; }) { const { navigation } = props return ( diff --git a/bob_party/src/services/conversationService/loaderConversationApi.ts b/bob_party/src/services/conversationService/loaderConversationApi.ts index ae78e87..8e0a5b8 100644 --- a/bob_party/src/services/conversationService/loaderConversationApi.ts +++ b/bob_party/src/services/conversationService/loaderConversationApi.ts @@ -26,11 +26,12 @@ export class LoaderConversationApi implements ILoaderConversation{ } }) .then(function (response: any) { - tabConv=[new Conversation("C0001", - [new User("U0001", "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("U0002", "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)]),], - [new Message("M0001", "bonjour", new User("U0001", "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 Date(2022,12,12)), - new Message("M0002", "test", new User("U0002", "Fefe63", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, new Skin("S0002", "Bob Blue",require('bob_party/assets/BobsSkins/BobBlue.png'), 100), [new Skin("S0002", "Bob Blue",require('bob_party/assets/BobsSkins/BobBlue.png'), 100)]), new Date(2022,12,13))], "leNom")]; + let skin= new Skin(1, "Bob","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobClassic.png", 0); + tabConv=[new Conversation(1, + [new User(1, "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, skin, [skin]), + new User(3, "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, skin, [skin])], + [new Message(1, "bonjour", new User(1, "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, skin, [skin]), new Date(2022,12,12)), + new Message(2, "test", new User(2, "Fefe63", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, skin, [skin]), new Date(2022,12,13))], "leNom")]; }); return tabConv; } diff --git a/bob_party/src/services/matchServices/ILoaderMatch.ts b/bob_party/src/services/matchServices/ILoaderMatch.ts index 231ae1b..dc7f950 100644 --- a/bob_party/src/services/matchServices/ILoaderMatch.ts +++ b/bob_party/src/services/matchServices/ILoaderMatch.ts @@ -1,4 +1,4 @@ -import { Match } from "../../core/match"; +import { Match } from "../../core/Match/match"; export default interface ILoaderMatch{ diff --git a/bob_party/src/services/matchServices/ISaverMatch.ts b/bob_party/src/services/matchServices/ISaverMatch.ts index 4f261cd..2786262 100644 --- a/bob_party/src/services/matchServices/ISaverMatch.ts +++ b/bob_party/src/services/matchServices/ISaverMatch.ts @@ -1,4 +1,6 @@ -import { Match } from "../../core/match"; +import { Game } from "../../core/game"; +import { Match } from "../../core/Match/match"; +import { User } from "../../core/User/user"; export default interface ISaverMatch{ @@ -7,7 +9,7 @@ export default interface ISaverMatch{ * m the Match we want to save */ - saveMatch(m:Match): Promise; + saveMatch(u:User, g:Game): Promise; /** * deleteMatch methode that delete a Match in the data management system diff --git a/bob_party/src/services/matchServices/loaderMatchApi.ts b/bob_party/src/services/matchServices/loaderMatchApi.ts new file mode 100644 index 0000000..8e7a461 --- /dev/null +++ b/bob_party/src/services/matchServices/loaderMatchApi.ts @@ -0,0 +1,13 @@ +import { Match } from "../../core/Match/match"; +import ILoaderMatch from "./ILoaderMatch"; + +export default class LoaderMatchApi implements ILoaderMatch{ + + async loadAllMatch(): Promise { + throw new Error("Method not implemented."); + } + async loadByID(id: string): Promise { + throw new Error("Method not implemented."); + } + +} \ No newline at end of file diff --git a/bob_party/src/services/matchServices/managerMatch.ts b/bob_party/src/services/matchServices/managerMatch.ts new file mode 100644 index 0000000..83383b1 --- /dev/null +++ b/bob_party/src/services/matchServices/managerMatch.ts @@ -0,0 +1,41 @@ +import { Match } from "../../core/Match/Match"; +import ILoaderMatch from "./ILoaderMatch"; +import ISaverMatch from "./ISaverMatch"; + +export default class ManagerMatch{ + + private currentMatch: Match | null=null; + + private loaderMatch: ILoaderMatch; + + private saverMatch: ISaverMatch; + + constructor(loader:ILoaderMatch, saver:ISaverMatch){ + this.loaderMatch=loader; + this.saverMatch=saver; + } + + getCurrentMatch(){ + return this.currentMatch; + } + + setCurrentMatch(u:Match | null){ + this.currentMatch=u; + } + + getLoaderMatch(){ + return this.loaderMatch; + } + + setLoaderMatch(l:ILoaderMatch){ + this.loaderMatch=l; + } + + getsaverMatch(){ + return this.saverMatch; + } + + setsaverMatch(s:ISaverMatch){ + this.saverMatch=s; + } +} \ No newline at end of file diff --git a/bob_party/src/services/matchServices/saverMatchApi.ts b/bob_party/src/services/matchServices/saverMatchApi.ts new file mode 100644 index 0000000..2b12e60 --- /dev/null +++ b/bob_party/src/services/matchServices/saverMatchApi.ts @@ -0,0 +1,32 @@ +import { Game } from "../../core/game"; +import { Match } from "../../core/Match/match"; + +import { User } from "../../core/User/user"; +import ISaverMatch from "./ISaverMatch"; +import { GameSolo } from "../../core/gameSolo"; +import { GameMulti } from "../../core/gameMulti"; +import MatchSolo from "../../core/Match/matchSolo"; +import MatchMulti from "../../core/Match/matchMulti"; +import MatchCasino from "../../core/Match/matchCasino"; + +export default class SaverMatchApi implements ISaverMatch{ + + async saveMatch(u:User, g:Game): Promise { + //match = mettre dans bdd + if (g instanceof GameSolo){ + return new MatchSolo(12, false, [u], g); + } + else if(g instanceof GameMulti){ + return new MatchMulti(12, false, [u], g); + } + return new MatchCasino(12, false, [u], g); + + } + async deleteMatch(m: Match): Promise { + throw new Error("Method not implemented."); + } + async updateMatch(m: Match): Promise { + throw new Error("Method not implemented."); + } + +} \ No newline at end of file diff --git a/bob_party/src/services/userServices/ILoaderUser.ts b/bob_party/src/services/userServices/ILoaderUser.ts index aa700a4..46eafbf 100644 --- a/bob_party/src/services/userServices/ILoaderUser.ts +++ b/bob_party/src/services/userServices/ILoaderUser.ts @@ -1,5 +1,5 @@ import { Conversation } from "../../core/conversation"; -import { Match } from "../../core/match"; +import { Match } from "../../core/Match/match"; import { User } from "../../core/User/user"; export default interface ILoaderUser{ @@ -15,7 +15,7 @@ export default interface ILoaderUser{ * id the id we want to search * return a User if found, if not null */ - loadByID(id:string): Promise; + loadByID(id:number): Promise; /** * loadByUsername methode that load a user from the data management system by his username @@ -48,5 +48,5 @@ export default interface ILoaderUser{ * loadLastId methode that load the last id used to create a user * return a String */ - loadLastId(): Promise; + loadLastId(): Promise; } \ No newline at end of file diff --git a/bob_party/src/services/userServices/ISaverUser.ts b/bob_party/src/services/userServices/ISaverUser.ts index 54e9a41..c8938da 100644 --- a/bob_party/src/services/userServices/ISaverUser.ts +++ b/bob_party/src/services/userServices/ISaverUser.ts @@ -7,7 +7,7 @@ export default interface ISaverUser{ * u the user we want to save */ - saveUser(u:User | null): Promise; + saveUser(username:string, password:string, nationality:string, sexe:string, date:Date): Promise; /** * deleteUser methode that delete a User in the data management system diff --git a/bob_party/src/services/userServices/fakeSaverUser.ts b/bob_party/src/services/userServices/fakeSaverUser.ts index f85d8c4..79d2105 100644 --- a/bob_party/src/services/userServices/fakeSaverUser.ts +++ b/bob_party/src/services/userServices/fakeSaverUser.ts @@ -4,8 +4,8 @@ import ISaverUser from "./ISaverUser"; export default class FakeSaverUser implements ISaverUser{ - async saveUser(u: User): Promise { - return; + async saveUser(username:string, password:string, nationality:string, sexe:string, date:Date): Promise { + return null; } async deleteUser(u: User): Promise { return; diff --git a/bob_party/src/services/userServices/loaderUserApi.ts b/bob_party/src/services/userServices/loaderUserApi.ts index ae9b4fe..70a102e 100644 --- a/bob_party/src/services/userServices/loaderUserApi.ts +++ b/bob_party/src/services/userServices/loaderUserApi.ts @@ -1,6 +1,6 @@ import tabSkinApp from "../../constSkin"; import { Conversation } from "../../core/conversation"; -import { Match } from "../../core/match"; +import { Match } from "../../core/Match/match"; import { Skin } from "../../core/skin"; import { User } from "../../core/User/user"; import ILoaderUser from "./ILoaderUser"; @@ -37,14 +37,14 @@ export default class LoaderUserApi implements ILoaderUser{ .then(function (response: any) { if (response.data != null && response.data != undefined){ Object.assign(test, response.data); - us.push(new User("17", "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[6], tabSkinApp)); + us.push(new User(1, "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[6], tabSkinApp)); } }); return us; } - async loadByID(id: string): Promise { + async loadByID(id: number): Promise { let test = new Test(true, 0, "wesh", 0); try{ await this.axios({ @@ -64,7 +64,7 @@ export default class LoaderUserApi implements ILoaderUser{ }catch (error) { console.error(error); } - return new User("17", "Bite", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 123, 123324, 12, tabSkinApp[6], tabSkinApp); + return new User(1, "Bite", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 123, 123324, 12, tabSkinApp[6], tabSkinApp); } @@ -102,8 +102,9 @@ export default class LoaderUserApi implements ILoaderUser{ } }) .then(function (response: any) { - const tabTest=[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)]; - user=new User("U0001", username, password, "ouioui", "homme", new Date(2022,12,12), 200, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), tabTest); + const tabTest=[new Skin(1, "Bob","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobClassic.png", 0), + new Skin(2, "Bob Blue","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobBlue.png", 100)]; + user=new User(1, username, password, "ouioui", "homme", new Date(2022,12,12), 200, 123324, 12, new Skin(1, "Bob","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobClassic.png", 0), tabTest); }); return user; } @@ -118,7 +119,7 @@ export default class LoaderUserApi implements ILoaderUser{ } - async loadLastId(): Promise { + async loadLastId(): Promise { let test = new Test(true, 0, "wesh", 0); try { const response = await this.axios.get('https://jsonplaceholder.typicode.com/todos/1'); @@ -126,7 +127,7 @@ export default class LoaderUserApi implements ILoaderUser{ } catch (error) { console.error(error); } - return "U0001"; + return 1; } diff --git a/bob_party/src/services/userServices/saverUserApi.ts b/bob_party/src/services/userServices/saverUserApi.ts index cff04b7..5a16365 100644 --- a/bob_party/src/services/userServices/saverUserApi.ts +++ b/bob_party/src/services/userServices/saverUserApi.ts @@ -6,7 +6,8 @@ export default class SaverUserApi implements ISaverUser{ private axios = require('axios').default; - async saveUser(u: User): Promise { + async saveUser(username:string, password:string, nationality:string, sexe:string, date:Date): Promise { + let us:User|null=null; this.axios({ method: 'post', url: '/user/12345', @@ -14,8 +15,14 @@ export default class SaverUserApi implements ISaverUser{ firstName: 'Fred', lastName: 'Flintstone' } - }); - + }).then(function (response: any) { + if (response.data != null && response.data != undefined){ + let test:any; + Object.assign(test, response.data); + us=test; + } + }); + return us; } async deleteUser(u: User): Promise { throw new Error("Method not implemented."); diff --git a/bob_party/src/services/userServices/stub.ts b/bob_party/src/services/userServices/stub.ts index b654e81..6843696 100644 --- a/bob_party/src/services/userServices/stub.ts +++ b/bob_party/src/services/userServices/stub.ts @@ -1,22 +1,23 @@ import { Conversation } from "../../core/conversation"; -import { Match } from "../../core/match"; +import { Match } from "../../core/Match/match"; import { Skin } from "../../core/skin"; import { User } from "../../core/User/user"; import ILoaderUser from "./ILoaderUser"; export default class StubUser implements ILoaderUser{ + skin:Skin=new Skin(1, "Bob","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobClassic.png", 0); + + 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)]), + new User(1, "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, this.skin, [this.skin]), + new User(2, "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, this.skin, [this.skin]), ]; async loadAllUser(): Promise { return this.tabUS; } - async loadByID(id: string): Promise { + async loadByID(id: number): Promise { for(let u of this.tabUS){ if (u.getId()==id){ return u; @@ -57,7 +58,7 @@ export default class StubUser implements ILoaderUser{ return tabUser; } - async loadLastId(): Promise { + async loadLastId(): Promise { throw new Error("Method not implemented."); }