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() { export default function App() {
return ( return (
<Text>CC</Text>
/*
<Provider store={store}> <Provider store={store}>
<MainTabNavigator/> <MainTabNavigator/>
</Provider> </Provider>
*/
); );
} }

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

@ -45,7 +45,11 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.12.9", "@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", "@jest/globals": "^29.3.1",
"@types/jest": "^29.2.3", "@types/jest": "^29.2.3",
"@types/jquery": "^3.5.14", "@types/jquery": "^3.5.14",
@ -53,6 +57,7 @@
"@types/node": "^18.8.4", "@types/node": "^18.8.4",
"@types/react": "~18.0.14", "@types/react": "~18.0.14",
"@types/react-native": "~0.69.1", "@types/react-native": "~0.69.1",
"babel-preset-react-native": "^4.0.0",
"ts-jest": "^29.0.3", "ts-jest": "^29.0.3",
"typescript": "^4.9.3" "typescript": "^4.9.3"
}, },

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

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

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

@ -21,129 +21,128 @@ import tabSkinApp from "../constSkin"
export const SkinComponent : export const SkinComponent:
/* Parameters : /* Parameters :
* skin : Skin to be displayed * skin : Skin to be displayed
* state : Indicates from wich screen the component has been called * state : Indicates from wich screen the component has been called
*/ */
FC<{nav : any, skin: Skin, state: String}> = FC<{ nav: any, skin: Skin, state: String }> =
({nav, skin, state}) => ({ 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) { async function changerSkin(skin: Skin) {
const m=new UserSkinModifier(); const m = new UserSkinModifier();
const tmp = MANAGER_USER.getCurrentUser(); const tmp = MANAGER_USER.getCurrentUser();
if (tmp!=null){ if (tmp !== null) {
await m.changeCurrentSkin(tmp, skin); await m.changeCurrentSkin(tmp, skin);
setUser(tmp); setUser(tmp);
MANAGER_USER.setCurrentUser(tmp); MANAGER_USER.setCurrentUser(tmp);
}
} }
}
const handleStoreChange = useCallback(async () => { const handleStoreChange = useCallback(async () => {
let tabSkinStore=[...tabSkinApp]; let tabSkinStore = [...tabSkinApp];
let tmp=MANAGER_USER.getCurrentUser()?.getTabSkin(); // const tmp=MANAGER_USER.getCurrentUser()?.getTabSkin();
if (tmp!=undefined){ // if (tmp!=undefined){
tmp.forEach(skin => { MANAGER_USER.getCurrentUser()?.getTabSkin()?.forEach(skin => {
for (let i=0; i<tabSkinStore.length; i++){ for (let i = 0; i < tabSkinStore.length; i++) {
if(skin.isEqual(tabSkinStore[i])){ if (skin.isEqual(tabSkinStore[i])) {
tabSkinStore.splice(i,1); tabSkinStore.splice(i, 1);
} }
} }
}); });
setTabSkin(tabSkinStore); setTabSkin(tabSkinStore);
} //}
}, []); }, []);
async function buySkin(skin:Skin) { async function buySkin(skin: Skin) {
const mSkin=new UserSkinModifier(); const mSkin = new UserSkinModifier();
const mCoins= new ManagerCoinsUser(); const mCoins = new ManagerCoinsUser();
const tmp = MANAGER_USER.getCurrentUser(); const tmp = MANAGER_USER.getCurrentUser();
if (tmp!=null){ if (tmp !== null) {
await mCoins.removeCoins(tmp,skin.getSkinCost()).then(async (res) => { await mCoins.removeCoins(tmp, skin.getSkinCost()).then(async (res) => {
if(res==true){ if (res == true) {
await mSkin.addSkin(tmp, skin); await mSkin.addSkin(tmp, skin);
setUser(tmp); setUser(tmp);
MANAGER_USER.setCurrentUser(tmp); MANAGER_USER.setCurrentUser(tmp);
Alert.alert("Achat du skin"); Alert.alert("Achat du skin");
handleStoreChange(); handleStoreChange();
} }
else{ else {
Alert.alert("Pas assez d'argent pour acheter le skin"); 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: /* 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 TopBar (icon) : Small image in a circle
* From the shop (shop) : Image + Name + Price, Pressable => Buy the skin * From the shop (shop) : Image + Name + Price, Pressable => Buy the skin
* From the profile (profile) : Name + Image, Pressable => Change the skin * From the profile (profile) : Name + Image, Pressable => Change the skin
*/ */
switch (state) { switch (state) {
case 'icon': case 'icon':
return ( return (
<View> <View>
<Image source={{uri: skin.getSkinSource()}} style={styles.icon}/> <Image source={{ uri: skin.getSkinSource() }} style={styles.icon} />
</View> </View>
) )
case 'shop': case 'shop':
return( return (
<Pressable onPress={() => buySkin(skin)} style={styles.imageWrapper}> <Pressable onPress={() => buySkin(skin)} style={styles.imageWrapper}>
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text> <Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
<Image <Image
style={styles.imageSkin} style={styles.imageSkin}
source={{uri: skin.getSkinSource()}} source={{ uri: skin.getSkinSource() }}
/> />
<Text style={styles.nomSkin}>100</Text> <Text style={styles.nomSkin}>100</Text>
</Pressable> </Pressable>
) )
case 'liste': case 'liste':
return( return (
<Pressable onPress={() => {changerSkin(skin); navigation.goBack()}} style={styles.imageWrapper}> <Pressable onPress={() => { changerSkin(skin); navigation.goBack() }} style={styles.imageWrapper}>
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text> <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 <Image
style={styles.imageSkin} 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>) =>{ updatePseudo: (state, action: PayloadAction<string>) =>{
const newUser: User = new User(currentUser.getId(), currentUser.getUsername(), currentUser.getPassword(), currentUser.getNationality(), currentUser.getSexe(), currentUser.getDateOfBirth()); const newUser: User = new User(currentUser.getId(), currentUser.getUsername(), currentUser.getPassword(), currentUser.getNationality(), currentUser.getSexe(), currentUser.getDateOfBirth());
console.log(currentUser);
newUser.setUsername(action.payload); newUser.setUsername(action.payload);
return { return {
...state, ...state,

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

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

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

File diff suppressed because it is too large Load Diff

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