Application qui marche sur android et ios
continuous-integration/drone/push Build is failing Details

Persistance
Thomas Chazot 2 years ago
parent 821982fb99
commit 95de9e2f34

@ -26,14 +26,9 @@ export const MANAGER_GAME = new ManagerGame(new LoaderGameApi);
export default function App() {
return (
<Text>CC</Text>
/*
<Provider store={store}>
<MainTabNavigator/>
</Provider>
*/
);
}

@ -1,13 +1,9 @@
module.exports = function(api) {
module.exports = function (api) {
api.cache(true);
return {
presets: [
presets: [
['babel-preset-expo'],
'@babel/preset-typescript',
],
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript', '@babel/preset-react',
],
['@babel/preset-env', { targets: { node: 'current' } }]
],
};
};

@ -45,7 +45,11 @@
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/preset-typescript": "^7.18.6",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/register": "^7.0.0",
"@babel/runtime": "^7.5.5",
"@jest/globals": "^29.3.1",
"@types/jest": "^29.2.3",
"@types/jquery": "^3.5.14",
@ -53,6 +57,7 @@
"@types/node": "^18.8.4",
"@types/react": "~18.0.14",
"@types/react-native": "~0.69.1",
"babel-preset-react-native": "^4.0.0",
"ts-jest": "^29.0.3",
"typescript": "^4.9.3"
},

@ -86,9 +86,8 @@ function CookieClicker(props: { navigation: any}){
}
function endGame(){
let tmp: User | null;
tmp=MANAGER_USER.getCurrentUser();
if (tmp!=null){
const tmp=MANAGER_USER.getCurrentUser();
if (tmp!==null){
if (MANAGER_MATCH.getCurrentMatch()?.getTabUsers().includes(tmp)){
MANAGER_MATCH.getCurrentMatch()?.updatePostMatch(tmp, points);
setUser(tmp);

@ -1,5 +1,5 @@
import { FC, ReactNode, useCallback } from "react"
import { Pressable, Image, View} from "react-native"
import { Pressable, Image, View } from "react-native"
import React from "react"
/*
@ -30,95 +30,94 @@ const smessage = require('../../assets/Icons/Selected/SChat.png');
const sstore = require('../../assets/Icons/Selected/SStore.png');
export const BotBar :
/* Parameters :
* nav : tool needed to allow the navigation between the screens
* state : optional parameter that indicates from which screen the component has been called
(the string must be the name of the screen)
*/
FC<{nav: any, state?: String}> =
({nav, state}) =>
{
export const BotBar:
/* Parameters :
* nav : tool needed to allow the navigation between the screens
* state : optional parameter that indicates from which screen the component has been called
(the string must be the name of the screen)
*/
FC<{ nav: any, state?: String }> =
({ nav, state }) => {
const setTabSkin = useStoreStore((state) => state.setTabSkin);
const setTabConv = useConversationStore((state) => state.setTabConv);
const setTabSkin = useStoreStore((state) => state.setTabSkin);
const setTabConv = useConversationStore((state) => state.setTabConv);
const handleStoreChange = useCallback(async () => {
let tabSkinStore=[...tabSkinApp];
let tmp=MANAGER_USER.getCurrentUser()?.getTabSkin();
if (tmp!=undefined){
tmp.forEach(skin => {
for (let i=0; i<tabSkinStore.length; i++){
if(skin.isEqual(tabSkinStore[i])){
tabSkinStore.splice(i,1);
}
}
});
setTabSkin(tabSkinStore);
}
}, []);
const handleStoreChange = useCallback(async () => {
const handleConversationChange = useCallback(async () => {
let tmp=MANAGER_USER.getCurrentUser();
if (tmp!=undefined){
await MANAGER_CONVERSATION.getLoaderConversation().loadByUser(tmp).then((res) => {
MANAGER_CONVERSATION.setCurrentTabConv(res);
setTabConv(res);
});
}
}, []);
/*
By default, all the images are the white ones
*/
var imgLeft=message, imgMid=gamepad, imgRight=store
/*
For each screen corresponding to a screen of the bottom bar,
we need to change one of the icons to the corresponding blue one
(for example, when the chat screen is displayed,
the icon of the messages must switch to the blue one)
*/
switch (state) {
case 'Home':
imgMid = sgamepad
break;
case 'Chat':
imgLeft = smessage
break;
case 'Store':
imgRight = sstore
break;
default:
break;
}
let tabSkinStore = [...tabSkinApp];
// const tmp=MANAGER_USER.getCurrentUser()?.getTabSkin();
// if (tmp!==undefined){
MANAGER_USER.getCurrentUser()?.getTabSkin()?.forEach(skin => {
for (let i = 0; i < tabSkinStore.length; i++) {
if (skin.isEqual(tabSkinStore[i])) {
tabSkinStore.splice(i, 1);
}
}
});
setTabSkin(tabSkinStore);
// }
}, []);
const handleConversationChange = useCallback(async () => {
const tmp = MANAGER_USER.getCurrentUser();
if (tmp !== null) {
await MANAGER_CONVERSATION.getLoaderConversation().loadByUser(tmp).then((res) => {
MANAGER_CONVERSATION.setCurrentTabConv(res);
setTabConv(res);
});
}
}, []);
/*
By default, all the images are the white ones
*/
var imgLeft = message, imgMid = gamepad, imgRight = store
/*
For each screen corresponding to a screen of the bottom bar,
we need to change one of the icons to the corresponding blue one
(for example, when the chat screen is displayed,
the icon of the messages must switch to the blue one)
*/
switch (state) {
case 'Home':
imgMid = sgamepad
break;
case 'Chat':
imgLeft = smessage
break;
case 'Store':
imgRight = sstore
break;
default:
break;
}
/*
Once the icons are correctly attributed,
the function can display the component
*/
return (
<View style={styles.footer}>
<Pressable onPress={() => {handleConversationChange() ;nav.navigate('ChatTab')}}>
<Image
style={styles.icon}
source={imgLeft}
/>
</Pressable>
<Pressable onPress={()=> {nav.navigate('HomeTab', {screen: 'Home'})}}>
<Image
style={styles.icon}
source={imgMid}
/>
</Pressable>
<Pressable onPress={() => {handleStoreChange(); nav.navigate('StoreTab')}}>
<Image
style={styles.icon}
source={imgRight}
/>
</Pressable>
</View>
)
}
return (
<View style={styles.footer}>
<Pressable onPress={() => { handleConversationChange(); nav.navigate('ChatTab') }}>
<Image
style={styles.icon}
source={imgLeft}
/>
</Pressable>
<Pressable onPress={() => { nav.navigate('HomeTab', { screen: 'Home' }) }}>
<Image
style={styles.icon}
source={imgMid}
/>
</Pressable>
<Pressable onPress={() => { handleStoreChange(); nav.navigate('StoreTab') }}>
<Image
style={styles.icon}
source={imgRight}
/>
</Pressable>
</View>
)
}

@ -30,8 +30,8 @@ FC<{game: Game, nav: any}> =
const createNewMatchSolo = useCallback(async (game : Game, nav: any) => {
const m=new MatchCreator();
let tmp=MANAGER_USER.getCurrentUser();
if (tmp!=null){
const tmp=MANAGER_USER.getCurrentUser();
if (tmp!==null){
let match=await m.createMatch(tmp, game);
MANAGER_MATCH.setCurrentMatch(match);
setMatch(match);

@ -21,129 +21,128 @@ import tabSkinApp from "../constSkin"
export const SkinComponent :
export const SkinComponent:
/* Parameters :
* skin : Skin to be displayed
* state : Indicates from wich screen the component has been called
*/
FC<{nav : any, skin: Skin, state: String}> =
({nav, skin, state}) =>
{
/* Parameters :
* skin : Skin to be displayed
* state : Indicates from wich screen the component has been called
*/
FC<{ nav: any, skin: Skin, state: String }> =
({ nav, skin, state }) => {
const navigation = nav;
const navigation = nav;
const dispatch=useDispatch();
const dispatch = useDispatch();
const setUser = useUserStore((state) => state.setUser);
const setUser = useUserStore((state) => state.setUser);
const setTabSkin = useStoreStore((state) => state.setTabSkin);
const setTabSkin = useStoreStore((state) => state.setTabSkin);
async function changerSkin(skin:Skin) {
const m=new UserSkinModifier();
const tmp = MANAGER_USER.getCurrentUser();
if (tmp!=null){
await m.changeCurrentSkin(tmp, skin);
setUser(tmp);
MANAGER_USER.setCurrentUser(tmp);
async function changerSkin(skin: Skin) {
const m = new UserSkinModifier();
const tmp = MANAGER_USER.getCurrentUser();
if (tmp !== null) {
await m.changeCurrentSkin(tmp, skin);
setUser(tmp);
MANAGER_USER.setCurrentUser(tmp);
}
}
}
const handleStoreChange = useCallback(async () => {
const handleStoreChange = useCallback(async () => {
let tabSkinStore=[...tabSkinApp];
let tmp=MANAGER_USER.getCurrentUser()?.getTabSkin();
if (tmp!=undefined){
tmp.forEach(skin => {
for (let i=0; i<tabSkinStore.length; i++){
if(skin.isEqual(tabSkinStore[i])){
tabSkinStore.splice(i,1);
let tabSkinStore = [...tabSkinApp];
// const tmp=MANAGER_USER.getCurrentUser()?.getTabSkin();
// if (tmp!=undefined){
MANAGER_USER.getCurrentUser()?.getTabSkin()?.forEach(skin => {
for (let i = 0; i < tabSkinStore.length; i++) {
if (skin.isEqual(tabSkinStore[i])) {
tabSkinStore.splice(i, 1);
}
}
});
setTabSkin(tabSkinStore);
}
}, []);
async function buySkin(skin:Skin) {
const mSkin=new UserSkinModifier();
const mCoins= new ManagerCoinsUser();
const tmp = MANAGER_USER.getCurrentUser();
if (tmp!=null){
await mCoins.removeCoins(tmp,skin.getSkinCost()).then(async (res) => {
if(res==true){
await mSkin.addSkin(tmp, skin);
setUser(tmp);
MANAGER_USER.setCurrentUser(tmp);
Alert.alert("Achat du skin");
handleStoreChange();
}
else{
Alert.alert("Pas assez d'argent pour acheter le skin");
}
});
//}
}, []);
async function buySkin(skin: Skin) {
const mSkin = new UserSkinModifier();
const mCoins = new ManagerCoinsUser();
const tmp = MANAGER_USER.getCurrentUser();
if (tmp !== null) {
await mCoins.removeCoins(tmp, skin.getSkinCost()).then(async (res) => {
if (res == true) {
await mSkin.addSkin(tmp, skin);
setUser(tmp);
MANAGER_USER.setCurrentUser(tmp);
Alert.alert("Achat du skin");
handleStoreChange();
}
else {
Alert.alert("Pas assez d'argent pour acheter le skin");
}
});
}
}
}
/* The display of this component depends of the screen from where it has been called:
* From the TopBar (icon) : Small image in a circle
* From the shop (shop) : Image + Name + Price, Pressable => Buy the skin
* From the profile (profile) : Name + Image, Pressable => Change the skin
*/
switch (state) {
case 'icon':
return (
<View>
<Image source={{uri: skin.getSkinSource()}} style={styles.icon}/>
</View>
)
case 'shop':
return(
<Pressable onPress={() => buySkin(skin)} style={styles.imageWrapper}>
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
<Image
style={styles.imageSkin}
source={{uri: skin.getSkinSource()}}
/>
<Text style={styles.nomSkin}>100</Text>
</Pressable>
)
case 'liste':
return(
<Pressable onPress={() => {changerSkin(skin); navigation.goBack()}} style={styles.imageWrapper}>
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
/* The display of this component depends of the screen from where it has been called:
* From the TopBar (icon) : Small image in a circle
* From the shop (shop) : Image + Name + Price, Pressable => Buy the skin
* From the profile (profile) : Name + Image, Pressable => Change the skin
*/
switch (state) {
case 'icon':
return (
<View>
<Image source={{ uri: skin.getSkinSource() }} style={styles.icon} />
</View>
)
case 'shop':
return (
<Pressable onPress={() => buySkin(skin)} style={styles.imageWrapper}>
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
<Image
style={styles.imageSkin}
source={{ uri: skin.getSkinSource() }}
/>
<Text style={styles.nomSkin}>100</Text>
</Pressable>
)
case 'liste':
return (
<Pressable onPress={() => { changerSkin(skin); navigation.goBack() }} style={styles.imageWrapper}>
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
<Image
style={styles.imageSkin}
source={{ uri: skin.getSkinSource() }}
/>
</Pressable>
)
case 'profile':
return (
<Pressable onPress={() => Alert.alert("cool")} style={styles.imageWrapperProfil}>
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
<Image
style={styles.imageSkin}
source={{ uri: skin.getSkinSource() }}
/>
</Pressable>
)
default:
return (
<Image
style={styles.imageSkin}
source={{uri: skin.getSkinSource()}}
source={{ uri: skin.getSkinSource() }}
/>
</Pressable>
)
case 'profile':
return(
<Pressable onPress={() => Alert.alert("cool")} style={styles.imageWrapperProfil}>
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
<Image
style={styles.imageSkin}
source={{uri: skin.getSkinSource()}}
/>
</Pressable>
)
default:
return(
<Image
style={styles.imageSkin}
source={{uri: skin.getSkinSource()}}
/>
)
}
}
)
}
}

@ -31,7 +31,6 @@ export const currentUserSlice = createSlice({
updatePseudo: (state, action: PayloadAction<string>) =>{
const newUser: User = new User(currentUser.getId(), currentUser.getUsername(), currentUser.getPassword(), currentUser.getNationality(), currentUser.getSexe(), currentUser.getDateOfBirth());
console.log(currentUser);
newUser.setUsername(action.payload);
return {
...state,

@ -1,5 +1,5 @@
import { StatusBar } from 'expo-status-bar'
import { View} from 'react-native'
import { View } from 'react-native'
import React, { useCallback } from 'react';
import stylesScreen from './style/screens.style'
import { TopBar } from '../components/TopBar';
@ -14,108 +14,108 @@ import game from '../testGameSolo';
let tabConv:Conversation[]=[];
let tabConv: Conversation[] = [];
function Home(props: { navigation: any; }) {
const { navigation } = props
const { navigation } = props
const setTabGame = useGameStore((state) => state.setTabGame);
const setTabGameSolo = useGameStore((state) => state.setTabGameSolo);
const setTabGameMulti = useGameStore((state) => state.setTabGameMulti);
const setTabGame = useGameStore((state) => state.setTabGame);
const setTabGameSolo = useGameStore((state) => state.setTabGameSolo);
const setTabGameMulti = useGameStore((state) => state.setTabGameMulti);
/*
const handleGame = useCallback(async (typeJeu: string) => {
switch(typeJeu){
case 'solo':
let tabSolo:Game[]=[]
let tmp=MANAGER_GAME.getTabGameSolo();
if (tmp==null){
let tabAll=MANAGER_GAME.getTabGame();
if (tabAll==null){
await MANAGER_GAME.getLoaderGame().loadAllGame().then((res) => {
MANAGER_GAME.setTabGame(res);
setTabGame(res);
});
}
tabAll?.forEach(game =>{
if (game.getNbPlayerMax()==1){
tabSolo.push(game);
/*
const handleGame = useCallback(async (typeJeu: string) => {
switch(typeJeu){
case 'solo':
let tabSolo:Game[]=[]
let tmp=MANAGER_GAME.getTabGameSolo();
if (tmp==null){
let tabAll=MANAGER_GAME.getTabGame();
if (tabAll==null){
await MANAGER_GAME.getLoaderGame().loadAllGame().then((res) => {
MANAGER_GAME.setTabGame(res);
setTabGame(res);
});
}
})
MANAGER_GAME.setTabGameSolo(tabSolo);
setTabGameSolo(tabSolo);
tabAll?.forEach(game =>{
if (game.getNbPlayerMax()==1){
tabSolo.push(game);
}
})
MANAGER_GAME.setTabGameSolo(tabSolo);
setTabGameSolo(tabSolo);
navigation.navigate('GameChoiceTab')
}
else{
navigation.navigate('GameChoiceTab')
}
else{
navigation.navigate('GameChoiceTab')
}
case 'multi':
let tabMulti:Game[]=[]
let tkt=MANAGER_GAME.getTabGameSolo();
if (tkt==null){
let tabAll=MANAGER_GAME.getTabGame();
if (tabAll==null){
await MANAGER_GAME.getLoaderGame().loadAllGame().then((res) => {
MANAGER_GAME.setTabGame(res);
setTabGame(res);
});
}
tabAll?.forEach(game =>{
if (game.getNbPlayerMax()==1){
tabSolo.push(game);
}
case 'multi':
let tabMulti:Game[]=[]
let tkt=MANAGER_GAME.getTabGameSolo();
if (tkt==null){
let tabAll=MANAGER_GAME.getTabGame();
if (tabAll==null){
await MANAGER_GAME.getLoaderGame().loadAllGame().then((res) => {
MANAGER_GAME.setTabGame(res);
setTabGame(res);
});
}
})
MANAGER_GAME.setTabGameMulti(tabMulti);
setTabGameMulti(tabMulti);
tabAll?.forEach(game =>{
if (game.getNbPlayerMax()==1){
tabSolo.push(game);
}
})
MANAGER_GAME.setTabGameMulti(tabMulti);
setTabGameMulti(tabMulti);
navigation.navigate('GameChoiceTab')
}
else{
navigation.navigate('GameChoiceTab')
}
else{
navigation.navigate('GameChoiceTab')
}
}
}, []);
*/
}
}
}, []);
*/
const handleGame = useCallback(async (typeJeu: string) => {
let tmp=MANAGER_GAME.getTabGame();
if (tmp==null){
await MANAGER_GAME.getLoaderGame().loadAllGame().then((res) => {
const tmp = MANAGER_GAME.getTabGame();
if (tmp === null) {
await MANAGER_GAME.getLoaderGame().loadAllGame().then((res) => {
MANAGER_GAME.setTabGame(res);
setTabGame(res);
navigation.navigate('GameChoiceTab')
});
}
else{
else {
navigation.navigate('GameChoiceTab')
}
}, []);
}, []);
return (
<View style={stylesScreen.container}>
<TopBar
nav={navigation}
state= 'Home'
/>
<View style={stylesScreen.bodyCenter}>
<ButtonGameTypeChoice
title='Jouer Seul'
onPress={() => {handleGame("solo")}}
/>
<ButtonGameTypeChoice
title='Défier mes amis'
onPress={() => handleGame("multi")}
/>
</View>
<BotBar
nav={navigation}
state='Home'
/>
</View>
);
return (
<View style={stylesScreen.container}>
<TopBar
nav={navigation}
state='Home'
/>
<View style={stylesScreen.bodyCenter}>
<ButtonGameTypeChoice
title='Jouer Seul'
onPress={() => { handleGame("solo") }}
/>
<ButtonGameTypeChoice
title='Défier mes amis'
onPress={() => handleGame("multi")}
/>
</View>
<BotBar
nav={navigation}
state='Home'
/>
</View>
);
}
export default Home

@ -30,8 +30,8 @@ function Settings(props: { navigation: any; }) {
async function changeUsername(username:string){
const m = new UserModificationManager();
let tmp=MANAGER_USER.getCurrentUser();
if (tmp!=null){
const tmp=MANAGER_USER.getCurrentUser();
if (tmp!==null){
await m.changeUsername(tmp, username);
setUser(tmp);
MANAGER_USER.setCurrentUser(tmp);
@ -40,8 +40,8 @@ function Settings(props: { navigation: any; }) {
async function changePassword(password:string){
const m = new UserModificationManager();
let tmp=MANAGER_USER.getCurrentUser();
if (tmp!=null){
const tmp=MANAGER_USER.getCurrentUser();
if (tmp!==null){
await m.changePassword(tmp, password);
setUser(tmp);
MANAGER_USER.setCurrentUser(tmp);

@ -26,7 +26,6 @@ function SignUp(props: { navigation: any; }) {
function onDateSelected(event : DateTimePickerEvent, value : Date | undefined) {
console.log(value);
if (value != undefined) {
setDate(value);
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1 @@
Subproject commit b2c910a85ed84cb7e5108e7cb3406a2e825a858f
Loading…
Cancel
Save