parent
e37f2a0335
commit
3f5ab45877
@ -0,0 +1,39 @@
|
|||||||
|
import { FC, ReactNode, useCallback } from "react"
|
||||||
|
import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native"
|
||||||
|
import React from "react"
|
||||||
|
import { trace } from "console"
|
||||||
|
import { Game } from "../core/game"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Importing the correct stylesheet
|
||||||
|
*/
|
||||||
|
import styles from './style/Game.style';
|
||||||
|
import LobbySolo from "../screens/LobbySolo"
|
||||||
|
import ManagerMatch from "../services/matchServices/managerMatch"
|
||||||
|
import MatchCreator from "../core/Match/matchCreator"
|
||||||
|
import { useMatchStore } from "../context/matchContext"
|
||||||
|
import { MANAGER_MATCH, MANAGER_USER } from "../../appManagers"
|
||||||
|
import { Match } from "../core/Match/match"
|
||||||
|
import { User } from "../core/User/user"
|
||||||
|
|
||||||
|
export const PlayerBox :
|
||||||
|
|
||||||
|
/*
|
||||||
|
* match : match that must be displayed
|
||||||
|
* nav : tool needed to allow the navigation between the screens
|
||||||
|
*/
|
||||||
|
FC<{user: User}> =
|
||||||
|
({user}) =>
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<Image
|
||||||
|
style={styles.image}
|
||||||
|
source={{uri: user.getCurrentSkin().getSkinSource()}}
|
||||||
|
/>
|
||||||
|
<Text style={styles.name}>{user.getUsername()}</Text>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
import { StatusBar } from 'expo-status-bar'
|
||||||
|
import { View, Image, Text, Button} from 'react-native'
|
||||||
|
import React from 'react';
|
||||||
|
import stylesScreen from './style/screens.style';
|
||||||
|
import styles from './style/Settings.style';
|
||||||
|
import { TopBar } from '../components/TopBar';
|
||||||
|
import { BotBar } from '../components/BotBar';
|
||||||
|
import { Conversation } from '../core/conversation';
|
||||||
|
import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice';
|
||||||
|
import { useMatchStore } from '../context/matchContext';
|
||||||
|
import { FlatList, TextInput } from 'react-native-gesture-handler';
|
||||||
|
import { PlayerBox } from '../components/PlayerBox';
|
||||||
|
|
||||||
|
|
||||||
|
function MatchMaking(props: { navigation: any; }) {
|
||||||
|
|
||||||
|
const { navigation } = props
|
||||||
|
|
||||||
|
const match = useMatchStore().match;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={stylesScreen.container}>
|
||||||
|
<TopBar
|
||||||
|
nav={navigation}
|
||||||
|
state='matchmacking'
|
||||||
|
/>
|
||||||
|
<FlatList
|
||||||
|
data={match?.getTabUsers()}
|
||||||
|
keyExtractor={usr =>usr.getUsername()}
|
||||||
|
renderItem={({item}) => <PlayerBox user={item}/>}
|
||||||
|
/>
|
||||||
|
<View style={stylesScreen.bodyCenter}>
|
||||||
|
<Button
|
||||||
|
title='Lancer la partie'
|
||||||
|
onPress={() => navigation.navigate(match?.getGame().getName().replace(/\s/g, ''))}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<Image
|
||||||
|
style={{width:100, height:100}}
|
||||||
|
source={{uri: match?.getGame().getImageSource()}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MatchMaking
|
@ -1,62 +0,0 @@
|
|||||||
import LoaderUserApi from '../userServices/loaderUserApi';
|
|
||||||
import ILoaderUser from '../userServices/ILoaderUser';
|
|
||||||
import { Match } from '../../core/Match/match';
|
|
||||||
import MatchSolo from '../../core/Match/matchSolo';
|
|
||||||
import { GameSolo } from '../../core/gameSolo';
|
|
||||||
import tabUS from '../../constUser';
|
|
||||||
import { Conversation } from '../../core/conversation';
|
|
||||||
|
|
||||||
// Instances
|
|
||||||
const img = "";
|
|
||||||
let loader:ILoaderUser = new LoaderUserApi();
|
|
||||||
let map = new Map<number, number>([
|
|
||||||
[50, 3],
|
|
||||||
[75, 4],
|
|
||||||
[100, 5],
|
|
||||||
[150, 6]
|
|
||||||
]);
|
|
||||||
let game:GameSolo = new GameSolo(1, 'SuperJeu', img, 'source', 1, 1, map);
|
|
||||||
let match:Match = new MatchSolo(1, false, tabUS, game);
|
|
||||||
let convo:Conversation = new Conversation(1, tabUS, [], 'superConvo');
|
|
||||||
|
|
||||||
|
|
||||||
// Tests
|
|
||||||
describe('LoaderUserApi tests', () => {
|
|
||||||
describe('loadById tests', () => {
|
|
||||||
it('should return UserTest (id: 48)', () => {
|
|
||||||
expect(loader.loadByID(48)).toEqual(tabUS[0]);
|
|
||||||
})
|
|
||||||
it('should return null', () => {
|
|
||||||
expect(loader.loadByID(99999999999)).toBe(null);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('loadByUserName tests', () => {
|
|
||||||
it('should return USerTest (name: WeshWesh)', () => {
|
|
||||||
expect(loader.loadByUsername('WeshWesh')).toEqual(tabUS[0]);
|
|
||||||
})
|
|
||||||
it('should return null', () => {
|
|
||||||
expect(loader.loadByUsername('jExistePas')).toBe(null);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('loadByUserNamePassword tests', () => {
|
|
||||||
it('should return UserTest (name: WeshWesh, password: MdpDeOuf)', () => {
|
|
||||||
expect(loader.loadByUsernamePassword('WeshWesh', 'MdpDeOuf')).toEqual(tabUS[0]);
|
|
||||||
})
|
|
||||||
it('should return null', () => {
|
|
||||||
expect(loader.loadByUsernamePassword('jExistePas', 'jExistePas')).toBe(null);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('loadUserByMatch tests', () => {
|
|
||||||
it('should return tabUS', () => {
|
|
||||||
expect(loader.loadUserByMatch(match)).toEqual(tabUS);
|
|
||||||
})
|
|
||||||
it('should return null', () => {
|
|
||||||
expect(loader.loadByUsernamePassword('jExistePas', 'jExistePas')).toEqual(null);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('loadUserByConversation tests', () => {
|
|
||||||
it('should return tabUS', () => {
|
|
||||||
expect(loader.loadUserByConversation(convo)).toEqual(tabUS);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
import LoaderUserApi from '../userServices/loaderUserApi';
|
|
||||||
import SaverUserApi from '../userServices/saverUserApi';
|
|
||||||
|
|
||||||
|
|
||||||
// Instances
|
|
||||||
let saver:SaverUserApi = new SaverUserApi();
|
|
||||||
let loader = new LoaderUserApi();
|
|
||||||
|
|
||||||
|
|
||||||
// Tests
|
|
||||||
|
|
||||||
describe('SaverUserApi tests', () => {
|
|
||||||
describe('saverUser tests', () => {
|
|
||||||
})
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
|
|
||||||
it('should return true', () => {
|
|
||||||
expect(1+1).toBe(2);
|
|
||||||
})
|
|
@ -1,78 +0,0 @@
|
|||||||
import StubUser from '../userServices/stub';
|
|
||||||
import { User } from '../../core/User/user';
|
|
||||||
import { Skin } from '../../core/skin';
|
|
||||||
import { GameSolo } from '../../core/gameSolo';
|
|
||||||
import MatchSolo from '../../core/Match/matchSolo';
|
|
||||||
import { Match } from '../../core/Match/match';
|
|
||||||
import { Conversation } from '../../core/conversation';
|
|
||||||
|
|
||||||
// Instances
|
|
||||||
const img = "";
|
|
||||||
let stub:StubUser = new StubUser();
|
|
||||||
let map = new Map<number, number>([
|
|
||||||
[50, 3],
|
|
||||||
[75, 4],
|
|
||||||
[100, 5],
|
|
||||||
[150, 6]
|
|
||||||
]);
|
|
||||||
let tabUS:User[] = [
|
|
||||||
new User(1, "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin(1, "Bob", img, 0), [new Skin(1, "Bob", img, 0)]),
|
|
||||||
new User(2, "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin(1, "Bob", img, 0), [new Skin(1, "Bob", img, 0)]),
|
|
||||||
new User(3, "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, new Skin(1, "Bob", img, 0), [new Skin(1, "Bob", img, 0)],),
|
|
||||||
new User(4, "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, new Skin(1, "Bob", img, 0), [new Skin(1, "Bob", img, 0)]),
|
|
||||||
];
|
|
||||||
let game:GameSolo = new GameSolo(1, 'SuperJeu', img, 'source', 1, 1, map);
|
|
||||||
let match:Match = new MatchSolo(1, false, tabUS, game);
|
|
||||||
let convo:Conversation = new Conversation(1, tabUS, [], 'superConvo');
|
|
||||||
|
|
||||||
|
|
||||||
// Tests
|
|
||||||
describe('StubUser tests', () => {
|
|
||||||
describe('loadAllUser tests', () => {
|
|
||||||
it('should return tabUS', () => {
|
|
||||||
expect(stub.loadAllUser()).toEqual(tabUS);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('loadById tests', () => {
|
|
||||||
it('should return UserTest (id: 48)', () => {
|
|
||||||
expect(stub.loadByID(48)).toEqual(tabUS[0]);
|
|
||||||
})
|
|
||||||
it('should return null', () => {
|
|
||||||
expect(stub.loadByID(999999999999)).toBe(null);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('loadByUserName tests', () => {
|
|
||||||
it('should return USerTest (name: WeshWesh)', () => {
|
|
||||||
expect(stub.loadByUsername('WeshWesh')).toEqual(tabUS[0]);
|
|
||||||
})
|
|
||||||
it('should return null', () => {
|
|
||||||
expect(stub.loadByUsername('jExistePas')).toBe(null);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('loadByUserNamePassword tests', () => {
|
|
||||||
it('should return UserTest (name: WeshWesh, password: MdpDeOuf)', () => {
|
|
||||||
expect(stub.loadByUsernamePassword('WeshWesh', 'MdpDeOuf')).toEqual(tabUS[0]);
|
|
||||||
})
|
|
||||||
it('should return null', () => {
|
|
||||||
expect(stub.loadByUsernamePassword('jExistePas', 'jExistePas')).toBe(null);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('loadUserByMatch tests', () => {
|
|
||||||
it('should return tabUS', () => {
|
|
||||||
expect(stub.loadUserByMatch(match)).toEqual(tabUS);
|
|
||||||
})
|
|
||||||
it('should return null', () => {
|
|
||||||
expect(stub.loadByUsernamePassword('jExistePas', 'jExistePas')).toEqual(null);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('loadUserByConversation tests', () => {
|
|
||||||
it('should return tabUS', () => {
|
|
||||||
expect(stub.loadUserByConversation(convo)).toEqual(tabUS);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('loadLastId', () => {
|
|
||||||
it('should return U0005', () => {
|
|
||||||
expect(stub.loadLastId()).toBe('U0005');
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
Loading…
Reference in new issue