Add: Match Services
continuous-integration/drone/push Build is failing Details

Persistance
Thomas Chazot 2 years ago
parent 570ade854a
commit 8e1b296011

@ -9,10 +9,15 @@ import { useUserStore } from './src/context/userContext';
import ManagerConversation from './src/services/conversationService/managerConversation' import ManagerConversation from './src/services/conversationService/managerConversation'
import { LoaderConversationApi } from './src/services/conversationService/loaderConversationApi' import { LoaderConversationApi } from './src/services/conversationService/loaderConversationApi'
import { FakeSaverConversation } from './src/services/conversationService/fakeSaverConversation' 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_USER = new ManagerUser(new LoaderUserApi, new FakeSaverUser);
export const MANAGER_CONVERSATION = new ManagerConversation(new LoaderConversationApi, new FakeSaverConversation); export const MANAGER_CONVERSATION = new ManagerConversation(new LoaderConversationApi, new FakeSaverConversation);
export const MANAGER_MATCH = new ManagerMatch(new LoaderMatchApi, new SaverMatchApi);
export default function App() { export default function App() {

@ -11,18 +11,18 @@ import {
} from 'react-native' } from 'react-native'
import { MANAGER_USER } from '../../../App'; import { MANAGER_USER } from '../../../App';
import { useUserStore } from '../../context/userContext'; import { useUserStore } from '../../context/userContext';
import { Match } from '../../core/match'; import { Match } from '../../core/Match/match';
import { User } from '../../core/User/user'; 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 GAMING_TIME=15;
const setUser = useUserStore((state) => state.setUser); const setUser = useUserStore((state) => state.setUser);
const nav = props.navigation;
const match=props.match;
const [count, setCount] = useState(0); const [count, setCount] = useState(0);
const [money, setMoney] = useState(0); const [money, setMoney] = useState(0);
@ -85,11 +85,14 @@ function CookieClicker(props: { navigation: any, match:Match}){
let tmp: User | null; let tmp: User | null;
tmp=MANAGER_USER.getCurrentUser(); tmp=MANAGER_USER.getCurrentUser();
if (tmp!=null){ if (tmp!=null){
/*
if (match.getTabUsers().includes(tmp)){ if (match.getTabUsers().includes(tmp)){
match.updatePostMatch(tmp, count); match.updatePostMatch(tmp, count);
setUser(tmp); setUser(tmp);
nav.goBack();
} }
*/
navigation.goBack();
} }
} }

@ -19,10 +19,10 @@ FC<{game: Game, nav: any}> =
{ {
return ( return (
<View> <View>
<Pressable onPress={() => nav.navigate('')}> <Pressable onPress={() => nav.navigate("CookieClicker")}>
<Image <Image
style={styles.image} style={styles.image}
source={game.getImageSource()} source={{uri: game.getImageSource()}}
/> />
<Text style={styles.name}>{game.getName()}</Text> <Text style={styles.name}>{game.getName()}</Text>
</Pressable> </Pressable>

@ -103,7 +103,7 @@ FC<{nav : any, skin: Skin, state: String}> =
case 'icon': case 'icon':
return ( return (
<View> <View>
<Image source={skin.getSkinSource()} style={styles.icon}/> <Image source={{uri: skin.getSkinSource()}} style={styles.icon}/>
</View> </View>
) )
@ -113,7 +113,7 @@ FC<{nav : any, skin: Skin, state: String}> =
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text> <Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
<Image <Image
style={styles.imageSkin} style={styles.imageSkin}
source={skin.getSkinSource()} source={{uri: skin.getSkinSource()}}
/> />
<Text style={styles.nomSkin}>100</Text> <Text style={styles.nomSkin}>100</Text>
</Pressable> </Pressable>
@ -124,7 +124,7 @@ FC<{nav : any, skin: Skin, state: String}> =
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text> <Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
<Image <Image
style={styles.imageSkin} style={styles.imageSkin}
source={skin.getSkinSource()} source={{uri: skin.getSkinSource()}}
/> />
</Pressable> </Pressable>
) )
@ -134,7 +134,7 @@ FC<{nav : any, skin: Skin, state: String}> =
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text> <Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
<Image <Image
style={styles.imageSkin} style={styles.imageSkin}
source={skin.getSkinSource()} source={{uri: skin.getSkinSource()}}
/> />
</Pressable> </Pressable>
) )
@ -142,7 +142,7 @@ FC<{nav : any, skin: Skin, state: String}> =
return( return(
<Image <Image
style={styles.imageSkin} style={styles.imageSkin}
source={skin.getSkinSource()} source={{uri: skin.getSkinSource()}}
/> />
) )
} }

@ -1,13 +1,13 @@
import { Skin } from "./core/skin"; import { Skin } from "./core/skin";
let tabSkinApp:Skin[]=[ let tabSkinApp:Skin[]=[
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),
new Skin("S0002", "Bob Blue",require('bob_party/assets/BobsSkins/BobBlue.png'), 100), 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("S0003", "Bob BW",require('bob_party/assets/BobsSkins/BobBW.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("S0004", "Bob Green",require('bob_party/assets/BobsSkins/BobGreen.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("S0005", "Bob P&T",require('bob_party/assets/BobsSkins/BobPinkTurquoise.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("S0006", "Bob Red",require('bob_party/assets/BobsSkins/BobRed.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("S0007", "Bob Cute",require('bob_party/assets/BobsSkins/BobYellowGreenBlueHeart.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),
] ]

@ -3,15 +3,15 @@ import { ImageSourcePropType } from "react-native";
import internal from "stream"; import internal from "stream";
export abstract class Game{ export abstract class Game{
readonly id:string; readonly id:number;
private name:string; private name:string;
private imageSource:ImageSourcePropType; private imageSource:string;
private gameSource:string; private gameSource:string;
private nbPlayerMin: number; private nbPlayerMin: number;
private nbPlayerMax:number; private nbPlayerMax:number;
/* Constructor of the class */ /* 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.id=id;
this.name=name; this.name=name;
this.imageSource=imageSource; this.imageSource=imageSource;
@ -41,7 +41,7 @@ export abstract class Game{
} }
/* Brief : Function setting the image of a game */ /* Brief : Function setting the image of a game */
setImageSource(imageSource:ImageSourcePropType){ setImageSource(imageSource:string){
this.imageSource=imageSource; this.imageSource=imageSource;
} }

@ -1,17 +1,17 @@
import { ImageSourcePropType } from 'react-native'; import { ImageSourcePropType } from 'react-native';
import { Game } from './game'; import { Game } from '../game';
import { User } from "./User/user"; import { User } from "../User/user";
export abstract class Match{ export abstract class Match{
readonly code:string; readonly code:number;
private inGame:Boolean; private inGame:Boolean=false;
private tabUsers:User[]; private tabUsers:User[];
private theGame:Game; 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.code=code;
this.inGame=false; this.inGame=inGame;
this.tabUsers=[...tabUser]; this.tabUsers=[...tabUser];
this.theGame=game; this.theGame=game;
} }

@ -1,12 +1,12 @@
import { Match } from "./match"; import { Match } from "./match";
import { User } from "./User/user"; import { User } from "../User/user";
import { Game } from "./game"; import { Game } from "../game";
import { GameCasino } from "./gameCasino"; import { GameCasino } from "../gameCasino";
import { ManagerCoinsUser } from "./User/userCoinsModifier"; 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); super(code, inGame, tabUser, game);
} }

@ -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<Match>{
return await MANAGER_MATCH.getsaverMatch().saveMatch(u, g);
}
}

@ -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));
}
}

@ -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));
}
}

@ -5,7 +5,7 @@ import { TextBase } from 'react-native';
export class User{ export class User{
readonly id: string; readonly id: number;
private username: string; private username: string;
private password: string; private password: string;
private nationality: string; private nationality: string;
@ -18,7 +18,7 @@ export class User{
private tabSkin: Skin[]; private tabSkin: Skin[];
/* Consturctor of the class */ /* 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[]){ nbGamesPlayed:number, currentSkin: Skin, tabSkin: Skin[]){
this.id=id; this.id=id;
this.username=username; this.username=username;

@ -8,21 +8,7 @@ export class UserCreator{
async createUser(username:string, password:string, nationality:string, sexe:string, date:Date){ async createUser(username:string, password:string, nationality:string, sexe:string, date:Date){
//Récup l'ID d'après dans la bdd //Récup l'ID d'après dans la bdd
let u:User; let u:null|User = await MANAGER_USER.getsaverUser().saveUser(username, password, nationality, sexe, date);
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);
MANAGER_USER.setCurrentUser(u); MANAGER_USER.setCurrentUser(u);
return u; return u;
} }

@ -3,14 +3,14 @@ import { User } from "./User/user";
export class Conversation{ export class Conversation{
private Id: string; private id: number;
private tabUser: User[]; private tabUser: User[];
private tabMessage: Message[]; private tabMessage: Message[];
private name: string; private name: string;
/* Constructor of the class */ /* Constructor of the class */
constructor(id: string, tabUser: User[], tabMessage:Message[], name:string){ constructor(id: number, tabUser: User[], tabMessage:Message[], name:string){
this.Id=id; this.id=id;
this.tabUser=[...tabUser]; this.tabUser=[...tabUser];
this.tabMessage=[...tabMessage]; this.tabMessage=[...tabMessage];
this.name=name; this.name=name;
@ -40,7 +40,7 @@ export class Conversation{
/* Brief : function returning the id of a conversation */ /* Brief : function returning the id of a conversation */
getId(){ getId(){
return this.Id; return this.id;
} }
/* Brief : function returning the name to a conversation */ /* Brief : function returning the name to a conversation */

@ -3,7 +3,7 @@ import { Game } from './game'
export class GameCasino extends 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); super(id, name, imageSource, gameSource, nbPlayerMin, nbPlayerMax);
} }

@ -4,7 +4,7 @@ import { Game } from './game'
export class GameMulti extends Game{ export class GameMulti extends Game{
readonly rankToCoins:Map<number,number> readonly rankToCoins:Map<number,number>
constructor(id:string, name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, rankToCoins:Map<number,number>){ constructor(id:number, name:string, imageSource:string, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, rankToCoins:Map<number,number>){
super(id, name, imageSource, gameSource, nbPlayerMin, nbPlayerMax); super(id, name, imageSource, gameSource, nbPlayerMin, nbPlayerMax);
this.rankToCoins=rankToCoins; this.rankToCoins=rankToCoins;
} }

@ -4,7 +4,7 @@ import { Game } from './game'
export class GameSolo extends Game{ export class GameSolo extends Game{
readonly ptsToCoins:Map<number,number> readonly ptsToCoins:Map<number,number>
constructor(id:string, name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, ptsToCoins:Map<number,number>){ constructor(id:number, name:string, imageSource:string, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, ptsToCoins:Map<number,number>){
super(id, name, imageSource, gameSource, nbPlayerMin,nbPlayerMax); super(id, name, imageSource, gameSource, nbPlayerMin,nbPlayerMax);
this.ptsToCoins=ptsToCoins; this.ptsToCoins=ptsToCoins;
} }

@ -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));
}
}

@ -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));
}
}

@ -2,52 +2,52 @@ import { User } from './User/user'
export class Message{ export class Message{
private Id: string; private id: number;
private Content: string; private content: string;
private Sender: User; private sender: User;
private DateEnvoie: Date; private dateEnvoie: Date;
/* Constructor of the class */ /* Constructor of the class */
constructor(id: string, content: string, sender:User, dateEnvoie:Date){ constructor(id: number, content: string, sender:User, dateEnvoie:Date){
this.Id=id; this.id=id;
this.Content=content; this.content=content;
this.Sender=sender; this.sender=sender;
this.DateEnvoie=dateEnvoie; this.dateEnvoie=dateEnvoie;
} }
/* Brief : Function setting the content of a message */ /* Brief : Function setting the content of a message */
setMessageContent(content: string){ setMessageContent(content: string){
this.Content=content; this.content=content;
} }
/* Brief : Function setting the sender of a message */ /* Brief : Function setting the sender of a message */
setMessageSender(sender: User){ setMessageSender(sender: User){
this.Sender=sender; this.sender=sender;
} }
/* Brief : Function setting the date of a message */ /* Brief : Function setting the date of a message */
setMessageDate(dateEnvoie: Date){ setMessageDate(dateEnvoie: Date){
this.DateEnvoie=dateEnvoie; this.dateEnvoie=dateEnvoie;
} }
/* Brief : Function getting the id of a message */ /* Brief : Function getting the id of a message */
getMessageId(){ getMessageId(){
return this.Id; return this.id;
} }
/* Brief : Function getting the content of a message */ /* Brief : Function getting the content of a message */
getMessageContent(){ getMessageContent(){
return this.Content; return this.content;
} }
/* Brief : Function getting the sender of a message */ /* Brief : Function getting the sender of a message */
getMessageSender(){ getMessageSender(){
return this.Sender; return this.sender;
} }
/* Brief : Function getting the date of a message */ /* Brief : Function getting the date of a message */
getMessageDate(){ getMessageDate(){
return this.DateEnvoie; return this.dateEnvoie;
} }

@ -1,13 +1,13 @@
import { ImageSourcePropType } from "react-native"; import { ImageSourcePropType } from "react-native";
export class Skin{ export class Skin{
readonly id: string; readonly id: number;
private name: string; private name: string;
private source: ImageSourcePropType; private source: string;
private cost:number; private cost:number;
/* Constructor of the class */ /* 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.id=id;
this.name=name; this.name=name;
this.source=source; this.source=source;
@ -20,7 +20,7 @@ export class Skin{
} }
/* Brief : Fuction setting the source of the image of a skin */ /* Brief : Fuction setting the source of the image of a skin */
setSkinSource(source: ImageSourcePropType){ setSkinSource(source: string){
this.source=source; this.source=source;
} }

@ -8,20 +8,20 @@ import { User } from '../User/user';
// Instances // Instances
let conv:Conversation[] = []; let conv:Conversation[] = [];
let tab:Skin[] = []; 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 dateBirth = new Date(2010,0o3,0o7);
let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab); let usr = new User(1, '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 usr2 = new User(2, 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, tab);
let theDate = new Date(2022,10,14); let theDate = new Date(2022,10,14);
let theDate2 = new Date(2022,10,13); let theDate2 = new Date(2022,10,13);
let theDate3 = new Date(2022,10,15); 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 tabU:User[] = [usr, usr2];
let mess2 = new Message('M0002', 'Oui tout à fait', usr2, theDate); let mess2 = new Message(2, 'Oui tout à fait', usr2, theDate);
let mess3 = new Message('M0003', 'Mais oui trop de ouf', usr, theDate3); let mess3 = new Message(3, 'Mais oui trop de ouf', usr, theDate3);
let tabM:Message[] = [mess, mess2]; let tabM:Message[] = [mess, mess2];
let convo = new Conversation('C0001', tabU, tabM, 'the conv'); let convo = new Conversation(1, tabU, tabM, 'the conv');
let usr3 = new User('00003', 'wow', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab); let usr3 = new User(4, 'wow', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab);
// Get tests // Get tests

@ -1,4 +1,4 @@
import { MatchSolo } from '../MatchSolo'; import { MatchSolo } from '../Match/matchSolo';
import { Conversation } from '../Conversation'; import { Conversation } from '../Conversation';
import { Skin } from '../Skin'; import { Skin } from '../Skin';
import { User } from '../User/user'; import { User } from '../User/user';

@ -12,7 +12,7 @@ import SkinList from '../screens/SkinList'
import GameChoice from '../screens/GameChoice' import GameChoice from '../screens/GameChoice'
import SignIn from '../screens/SignIn' import SignIn from '../screens/SignIn'
import SignUp from '../screens/SignUp' import SignUp from '../screens/SignUp'
import CookieClicker from '../Games/CookieClicker/CookieClicker'
const HomeStack = createStackNavigator(); const HomeStack = createStackNavigator();
@ -25,7 +25,7 @@ function HomeStackScreen() {
<HomeStack.Navigator screenOptions={{ headerShown: false}}> <HomeStack.Navigator screenOptions={{ headerShown: false}}>
<HomeStack.Screen name="Home" component={Home} options={{animationEnabled: false,}}/> <HomeStack.Screen name="Home" component={Home} options={{animationEnabled: false,}}/>
<HomeStack.Screen name="Settings" component={Settings} /> <HomeStack.Screen name="Settings" component={Settings} />
<HomeStack.Screen name='GameChoice' component={GameChoice} options={{animationEnabled: false,}}/> <HomeStack.Screen name="GameChoice" component={GameChoice} options={{animationEnabled: false,}}/>
</HomeStack.Navigator> </HomeStack.Navigator>
); );
} }

@ -16,7 +16,7 @@ let tabConv:Conversation[]=[];
const msc = require('../../assets/Icons/FondGris.png'); 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 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<number,number>); 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<number,number>);
function GameChoice(props: { navigation: any; }) { function GameChoice(props: { navigation: any; }) {
const { navigation } = props const { navigation } = props
return ( return (

@ -26,11 +26,12 @@ export class LoaderConversationApi implements ILoaderConversation{
} }
}) })
.then(function (response: any) { .then(function (response: any) {
tabConv=[new Conversation("C0001", 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);
[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)]), tabConv=[new Conversation(1,
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 User(1, "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, skin, [skin]),
[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 User(3, "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, skin, [skin])],
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")]; [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; return tabConv;
} }

@ -1,4 +1,4 @@
import { Match } from "../../core/match"; import { Match } from "../../core/Match/match";
export default interface ILoaderMatch{ export default interface ILoaderMatch{

@ -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{ export default interface ISaverMatch{
@ -7,7 +9,7 @@ export default interface ISaverMatch{
* m the Match we want to save * m the Match we want to save
*/ */
saveMatch(m:Match): Promise<void>; saveMatch(u:User, g:Game): Promise<Match>;
/** /**
* deleteMatch methode that delete a Match in the data management system * deleteMatch methode that delete a Match in the data management system

@ -0,0 +1,13 @@
import { Match } from "../../core/Match/match";
import ILoaderMatch from "./ILoaderMatch";
export default class LoaderMatchApi implements ILoaderMatch{
async loadAllMatch(): Promise<Match[]> {
throw new Error("Method not implemented.");
}
async loadByID(id: string): Promise<Match | null> {
throw new Error("Method not implemented.");
}
}

@ -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;
}
}

@ -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> {
//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<void> {
throw new Error("Method not implemented.");
}
async updateMatch(m: Match): Promise<void> {
throw new Error("Method not implemented.");
}
}

@ -1,5 +1,5 @@
import { Conversation } from "../../core/conversation"; import { Conversation } from "../../core/conversation";
import { Match } from "../../core/match"; import { Match } from "../../core/Match/match";
import { User } from "../../core/User/user"; import { User } from "../../core/User/user";
export default interface ILoaderUser{ export default interface ILoaderUser{
@ -15,7 +15,7 @@ export default interface ILoaderUser{
* id the id we want to search * id the id we want to search
* return a User if found, if not null * return a User if found, if not null
*/ */
loadByID(id:string): Promise<User | null>; loadByID(id:number): Promise<User | null>;
/** /**
* loadByUsername methode that load a user from the data management system by his username * 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 * loadLastId methode that load the last id used to create a user
* return a String * return a String
*/ */
loadLastId(): Promise<string>; loadLastId(): Promise<number>;
} }

@ -7,7 +7,7 @@ export default interface ISaverUser{
* u the user we want to save * u the user we want to save
*/ */
saveUser(u:User | null): Promise<void>; saveUser(username:string, password:string, nationality:string, sexe:string, date:Date): Promise<User | null>;
/** /**
* deleteUser methode that delete a User in the data management system * deleteUser methode that delete a User in the data management system

@ -4,8 +4,8 @@ import ISaverUser from "./ISaverUser";
export default class FakeSaverUser implements ISaverUser{ export default class FakeSaverUser implements ISaverUser{
async saveUser(u: User): Promise<void> { async saveUser(username:string, password:string, nationality:string, sexe:string, date:Date): Promise<User | null> {
return; return null;
} }
async deleteUser(u: User): Promise<void> { async deleteUser(u: User): Promise<void> {
return; return;

@ -1,6 +1,6 @@
import tabSkinApp from "../../constSkin"; import tabSkinApp from "../../constSkin";
import { Conversation } from "../../core/conversation"; import { Conversation } from "../../core/conversation";
import { Match } from "../../core/match"; import { Match } from "../../core/Match/match";
import { Skin } from "../../core/skin"; import { Skin } from "../../core/skin";
import { User } from "../../core/User/user"; import { User } from "../../core/User/user";
import ILoaderUser from "./ILoaderUser"; import ILoaderUser from "./ILoaderUser";
@ -37,14 +37,14 @@ export default class LoaderUserApi implements ILoaderUser{
.then(function (response: any) { .then(function (response: any) {
if (response.data != null && response.data != undefined){ if (response.data != null && response.data != undefined){
Object.assign(test, response.data); 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; return us;
} }
async loadByID(id: string): Promise<User | null> { async loadByID(id: number): Promise<User | null> {
let test = new Test(true, 0, "wesh", 0); let test = new Test(true, 0, "wesh", 0);
try{ try{
await this.axios({ await this.axios({
@ -64,7 +64,7 @@ export default class LoaderUserApi implements ILoaderUser{
}catch (error) { }catch (error) {
console.error(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) { .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)]; 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),
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); 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; return user;
} }
@ -118,7 +119,7 @@ export default class LoaderUserApi implements ILoaderUser{
} }
async loadLastId(): Promise<string> { async loadLastId(): Promise<number> {
let test = new Test(true, 0, "wesh", 0); let test = new Test(true, 0, "wesh", 0);
try { try {
const response = await this.axios.get('https://jsonplaceholder.typicode.com/todos/1'); const response = await this.axios.get('https://jsonplaceholder.typicode.com/todos/1');
@ -126,7 +127,7 @@ export default class LoaderUserApi implements ILoaderUser{
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
return "U0001"; return 1;
} }

@ -6,7 +6,8 @@ export default class SaverUserApi implements ISaverUser{
private axios = require('axios').default; private axios = require('axios').default;
async saveUser(u: User): Promise<void> { async saveUser(username:string, password:string, nationality:string, sexe:string, date:Date): Promise<User | null> {
let us:User|null=null;
this.axios({ this.axios({
method: 'post', method: 'post',
url: '/user/12345', url: '/user/12345',
@ -14,8 +15,14 @@ export default class SaverUserApi implements ISaverUser{
firstName: 'Fred', firstName: 'Fred',
lastName: 'Flintstone' 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<void> { async deleteUser(u: User): Promise<void> {
throw new Error("Method not implemented."); throw new Error("Method not implemented.");

@ -1,22 +1,23 @@
import { Conversation } from "../../core/conversation"; import { Conversation } from "../../core/conversation";
import { Match } from "../../core/match"; import { Match } from "../../core/Match/match";
import { Skin } from "../../core/skin"; import { Skin } from "../../core/skin";
import { User } from "../../core/User/user"; import { User } from "../../core/User/user";
import ILoaderUser from "./ILoaderUser"; import ILoaderUser from "./ILoaderUser";
export default class StubUser implements 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[]=[ 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(1, "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, this.skin, [this.skin]),
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(2, "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, this.skin, [this.skin]),
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)]),
]; ];
async loadAllUser(): Promise<User[]> { async loadAllUser(): Promise<User[]> {
return this.tabUS; return this.tabUS;
} }
async loadByID(id: string): Promise<User | null> { async loadByID(id: number): Promise<User | null> {
for(let u of this.tabUS){ for(let u of this.tabUS){
if (u.getId()==id){ if (u.getId()==id){
return u; return u;
@ -57,7 +58,7 @@ export default class StubUser implements ILoaderUser{
return tabUser; return tabUser;
} }
async loadLastId(): Promise<string> { async loadLastId(): Promise<number> {
throw new Error("Method not implemented."); throw new Error("Method not implemented.");
} }

Loading…
Cancel
Save