Merge branch 'Persistance' of https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY into Persistance
continuous-integration/drone/push Build is failing Details

Persistance
Mathilde JEAN 2 years ago
commit 23811c669b

@ -1,4 +1,4 @@
import React, { Component, useEffect, useState } from 'react'
import React, { Component, useCallback, useEffect, useState } from 'react'
import {
StyleSheet,
TouchableOpacity,
@ -9,25 +9,24 @@ import {
TouchableHighlight,
Alert,
} from 'react-native'
import { MANAGER_USER } from '../../../App';
import { MANAGER_MATCH, MANAGER_USER } from '../../../App';
import { useMatchStore } from '../../context/matchContext';
import { useUserStore } from '../../context/userContext';
import { Match } from '../../core/Match/match';
import { User } from '../../core/User/user';
let points=0;
function CookieClicker(props: { navigation: any}){
const { navigation } = props
const GAMING_TIME=15;
const GAMING_TIME=30;
const setUser = useUserStore((state) => state.setUser);
const resetMatch = useMatchStore((state) => state.resetMatch);
const [count, setCount] = useState(0);
const [money, setMoney] = useState(0);
const [clickSpeed, setClickSpeed] = useState(1);
@ -43,6 +42,7 @@ function CookieClicker(props: { navigation: any}){
function onPressCookie(){
setMoney(money+clickSpeed);
setCount(count+clickSpeed);
points=count+clickSpeed;
}
function onPressGrandma(){
@ -89,13 +89,12 @@ function CookieClicker(props: { navigation: any}){
let tmp: User | null;
tmp=MANAGER_USER.getCurrentUser();
if (tmp!=null){
if (useMatchStore().match?.getTabUsers().includes(tmp)){
useMatchStore().match?.updatePostMatch(tmp, count);
if (MANAGER_MATCH.getCurrentMatch()?.getTabUsers().includes(tmp)){
MANAGER_MATCH.getCurrentMatch()?.updatePostMatch(tmp, points);
setUser(tmp);
}
resetMatch();
navigation.goBack();
}
resetMatch();
}
useEffect(() => {
@ -106,8 +105,9 @@ function CookieClicker(props: { navigation: any}){
if (counter == 0) {
clearInterval(oneSecInterval);
Alert.alert("fin du jeu");
endGame();
Alert.alert("fin du jeu");
navigation.navigate('Home');
}
}, 1000);
},[]);
@ -182,7 +182,7 @@ function CookieClicker(props: { navigation: any}){
const styles = StyleSheet.create({
container: {
top: 20,
top: 75,
margin: 10,
flex: 1,
justifyContent: 'center',

@ -1,4 +1,4 @@
import { FC, ReactNode } from "react"
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"
@ -26,7 +26,9 @@ FC<{game: Game, nav: any}> =
const setMatch = useMatchStore((state) => state.setMatch);
async function createNewMatchSolo(game : Game, nav: any) {
const createNewMatchSolo = useCallback(async (game : Game, nav: any) => {
const m=new MatchCreator();
let tmp=MANAGER_USER.getCurrentUser();
if (tmp!=null){
@ -35,7 +37,7 @@ FC<{game: Game, nav: any}> =
setMatch(match);
nav.navigate("GameSolo");
}
}
}, []);
return (

@ -19,10 +19,8 @@ export class GameSolo extends Game{
let test;
for (let key of this.ptsToCoins.keys()){
test = this.ptsToCoins.get(key);
if (test != undefined){
coins=test;
}
if (points<key ){
coins=key;
if (test != undefined && test>=points){
return coins;
}
}

@ -12,12 +12,11 @@ import { Conversation } from '../core/conversation';
import { GameSolo } from '../core/gameSolo';
let tabConv:Conversation[]=[];
const cookieClicker= new GameSolo(1, "Cookie Clicker", "https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/ImagesJeux/Pong.png", "/Games/CookieClicker/cookieClicker.tsx", 1, 1, new Map([
[100, 100],
[1000, 300],
[10000, 400]
]));
const map = new Map();
map.set(0,0);
map.set(15,10);
map.set(20,15);
const cookieClicker= new GameSolo(1, "Cookie Clicker", "https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/ImagesJeux/Pong.png", "/Games/CookieClicker/cookieClicker.tsx", 1, 1, map);
function GameChoice(props: { navigation: any; }) {

Loading…
Cancel
Save