|
|
|
@ -8,6 +8,7 @@ import {
|
|
|
|
|
Image,
|
|
|
|
|
TouchableHighlight,
|
|
|
|
|
Alert,
|
|
|
|
|
ImageBackground,
|
|
|
|
|
} from 'react-native'
|
|
|
|
|
import { MANAGER_MATCH, MANAGER_USER } from '../../../appManagers';
|
|
|
|
|
import { useMatchStore } from '../../context/matchContext';
|
|
|
|
@ -16,12 +17,12 @@ import { Match } from '../../core/Match/match';
|
|
|
|
|
import { User } from '../../core/User/user';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let points=0;
|
|
|
|
|
let points = 0;
|
|
|
|
|
|
|
|
|
|
function CookieClicker(props: { navigation: any}){
|
|
|
|
|
function CookieClicker(props: { navigation: any }) {
|
|
|
|
|
const { navigation } = props
|
|
|
|
|
|
|
|
|
|
const GAMING_TIME=120;
|
|
|
|
|
const GAMING_TIME = 120;
|
|
|
|
|
|
|
|
|
|
const setUser = useUserStore((state) => state.setUser);
|
|
|
|
|
|
|
|
|
@ -39,56 +40,56 @@ function CookieClicker(props: { navigation: any}){
|
|
|
|
|
const [timer, setTimer] = useState(GAMING_TIME);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onPressCookie(){
|
|
|
|
|
setMoney(money+clickSpeed);
|
|
|
|
|
setCount(count+clickSpeed);
|
|
|
|
|
points=count+clickSpeed;
|
|
|
|
|
function onPressCookie() {
|
|
|
|
|
setMoney(money + clickSpeed);
|
|
|
|
|
setCount(count + clickSpeed);
|
|
|
|
|
points = count + clickSpeed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onPressGrandma(){
|
|
|
|
|
if (money>=grandmaCost){
|
|
|
|
|
setMoney(money-grandmaCost);
|
|
|
|
|
setClickSpeed(clickSpeed+1);
|
|
|
|
|
setGrandmaCost(grandmaCost+10);
|
|
|
|
|
function onPressGrandma() {
|
|
|
|
|
if (money >= grandmaCost) {
|
|
|
|
|
setMoney(money - grandmaCost);
|
|
|
|
|
setClickSpeed(clickSpeed + 1);
|
|
|
|
|
setGrandmaCost(grandmaCost + 10);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onPressFarm(){
|
|
|
|
|
if (money>=farmCost){
|
|
|
|
|
setMoney(money-farmCost);
|
|
|
|
|
setClickSpeed(clickSpeed+25);
|
|
|
|
|
setFarmCost(farmCost+250);
|
|
|
|
|
function onPressFarm() {
|
|
|
|
|
if (money >= farmCost) {
|
|
|
|
|
setMoney(money - farmCost);
|
|
|
|
|
setClickSpeed(clickSpeed + 25);
|
|
|
|
|
setFarmCost(farmCost + 250);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onPressFactory(){
|
|
|
|
|
if (money>=factoryCost){
|
|
|
|
|
setMoney(money-factoryCost);
|
|
|
|
|
setClickSpeed(clickSpeed+200);
|
|
|
|
|
setFactoryCost(factoryCost+2000);
|
|
|
|
|
function onPressFactory() {
|
|
|
|
|
if (money >= factoryCost) {
|
|
|
|
|
setMoney(money - factoryCost);
|
|
|
|
|
setClickSpeed(clickSpeed + 200);
|
|
|
|
|
setFactoryCost(factoryCost + 2000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onPressWizard(){
|
|
|
|
|
if (money>=wizardCost){
|
|
|
|
|
setMoney(money-wizardCost);
|
|
|
|
|
setClickSpeed(clickSpeed+2500);
|
|
|
|
|
setWizardCost(wizardCost+25000);
|
|
|
|
|
function onPressWizard() {
|
|
|
|
|
if (money >= wizardCost) {
|
|
|
|
|
setMoney(money - wizardCost);
|
|
|
|
|
setClickSpeed(clickSpeed + 2500);
|
|
|
|
|
setWizardCost(wizardCost + 25000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onPressPortal(){
|
|
|
|
|
if (money>=portalCost){
|
|
|
|
|
setMoney(money-portalCost);
|
|
|
|
|
setClickSpeed(clickSpeed+20000);
|
|
|
|
|
setPortalCost(portalCost+200000);
|
|
|
|
|
function onPressPortal() {
|
|
|
|
|
if (money >= portalCost) {
|
|
|
|
|
setMoney(money - portalCost);
|
|
|
|
|
setClickSpeed(clickSpeed + 20000);
|
|
|
|
|
setPortalCost(portalCost + 200000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function endGame(){
|
|
|
|
|
const tmp=MANAGER_USER.getCurrentUser();
|
|
|
|
|
if (tmp!==null){
|
|
|
|
|
if (MANAGER_MATCH.getCurrentMatch()?.getTabUsers().includes(tmp)){
|
|
|
|
|
function endGame() {
|
|
|
|
|
const tmp = MANAGER_USER.getCurrentUser();
|
|
|
|
|
if (tmp !== null) {
|
|
|
|
|
if (MANAGER_MATCH.getCurrentMatch()?.getTabUsers().includes(tmp)) {
|
|
|
|
|
MANAGER_MATCH.getCurrentMatch()?.updatePostMatch(tmp, points);
|
|
|
|
|
setUser(tmp);
|
|
|
|
|
}
|
|
|
|
@ -97,10 +98,10 @@ function CookieClicker(props: { navigation: any}){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
let counter=GAMING_TIME;
|
|
|
|
|
let counter = GAMING_TIME;
|
|
|
|
|
var oneSecInterval = setInterval(() => {
|
|
|
|
|
setTimer(timer => timer - 1);
|
|
|
|
|
counter --;
|
|
|
|
|
counter--;
|
|
|
|
|
|
|
|
|
|
if (counter == 0) {
|
|
|
|
|
clearInterval(oneSecInterval);
|
|
|
|
@ -109,28 +110,29 @@ function CookieClicker(props: { navigation: any}){
|
|
|
|
|
navigation.navigate('Home');
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|
|
|
|
|
},[]);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<View style={styles.container}>
|
|
|
|
|
<View >
|
|
|
|
|
<Text>
|
|
|
|
|
<ImageBackground source={{ uri: "https://i0.wp.com/lesfoliesdejenny.fr/wp-content/uploads/2021/12/5.png?w=1080&ssl=1" }} resizeMode="cover" style={styles.image}>
|
|
|
|
|
<View style={styles.containerTop}>
|
|
|
|
|
<Text style={styles.cout}>
|
|
|
|
|
Timer: {timer}
|
|
|
|
|
</Text>
|
|
|
|
|
<TouchableHighlight onPress={onPressCookie} >
|
|
|
|
|
<Image style={styles.photo} source={{uri: 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/Persistance/bob_party/assets/ImagesJeux/CookieClicker/ChristmasCookie.png'}}/>
|
|
|
|
|
<Image style={styles.photo} source={{ uri: 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/Persistance/bob_party/assets/ImagesJeux/CookieClicker/ChristmasCookie.png' }} />
|
|
|
|
|
</TouchableHighlight>
|
|
|
|
|
<Text>
|
|
|
|
|
<Text style={styles.cout}>
|
|
|
|
|
Argent {money}
|
|
|
|
|
</Text>
|
|
|
|
|
<Text>
|
|
|
|
|
<Text style={styles.cout}>
|
|
|
|
|
Points {count}
|
|
|
|
|
</Text>
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
<View style={styles.containerRight}>
|
|
|
|
|
<TouchableHighlight onPress={onPressGrandma}>
|
|
|
|
|
<Image style={styles.photo} source={{uri: 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/Persistance/bob_party/assets/ImagesJeux/CookieClicker/ChristmasGrandma.png'}}/>
|
|
|
|
|
<Image style={styles.photo} source={{ uri: 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/Persistance/bob_party/assets/ImagesJeux/CookieClicker/ChristmasGrandma.png' }} />
|
|
|
|
|
</TouchableHighlight>
|
|
|
|
|
<View>
|
|
|
|
|
<Text style={styles.cout}>
|
|
|
|
@ -139,7 +141,7 @@ function CookieClicker(props: { navigation: any}){
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
<TouchableHighlight onPress={onPressFarm} style={styles.photo}>
|
|
|
|
|
<Image style={styles.photo} source={{uri: 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/Persistance/bob_party/assets/ImagesJeux/CookieClicker/ChristmasFarm.png'}}/>
|
|
|
|
|
<Image style={styles.photo} source={{ uri: 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/Persistance/bob_party/assets/ImagesJeux/CookieClicker/ChristmasFarm.png' }} />
|
|
|
|
|
</TouchableHighlight>
|
|
|
|
|
<View>
|
|
|
|
|
<Text style={styles.cout}>
|
|
|
|
@ -148,7 +150,7 @@ function CookieClicker(props: { navigation: any}){
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
<TouchableHighlight onPress={onPressFactory}>
|
|
|
|
|
<Image style={styles.photo} source={{uri: 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/Persistance/bob_party/assets/ImagesJeux/CookieClicker/ChristmasFactory.png'}}/>
|
|
|
|
|
<Image style={styles.photo} source={{ uri: 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/Persistance/bob_party/assets/ImagesJeux/CookieClicker/ChristmasFactory.png' }} />
|
|
|
|
|
</TouchableHighlight>
|
|
|
|
|
<View>
|
|
|
|
|
<Text style={styles.cout}>
|
|
|
|
@ -157,7 +159,7 @@ function CookieClicker(props: { navigation: any}){
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
<TouchableHighlight onPress={onPressWizard}>
|
|
|
|
|
<Image style={styles.photo} source={{uri: 'https://www.clasher.us/images/coc/units/Wizard_Tower7.png'}}/>
|
|
|
|
|
<Image style={styles.photo} source={{ uri: 'https://www.clasher.us/images/coc/units/Wizard_Tower7.png' }} />
|
|
|
|
|
</TouchableHighlight>
|
|
|
|
|
<View>
|
|
|
|
|
<Text style={styles.cout}>
|
|
|
|
@ -166,21 +168,26 @@ function CookieClicker(props: { navigation: any}){
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
<TouchableHighlight onPress={onPressPortal}>
|
|
|
|
|
<Image style={styles.photo} source={{uri: 'https://i.pinimg.com/originals/98/29/21/9829215db6f9210c0ae4e318e854cb1f.png'}}/>
|
|
|
|
|
<Image style={styles.photo} source={{ uri: 'https://i.pinimg.com/originals/98/29/21/9829215db6f9210c0ae4e318e854cb1f.png' }} />
|
|
|
|
|
</TouchableHighlight>
|
|
|
|
|
<View>
|
|
|
|
|
<Text style={styles.cout}>
|
|
|
|
|
Cost {portalCost}
|
|
|
|
|
</Text>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
</View>
|
|
|
|
|
</ImageBackground>
|
|
|
|
|
</View>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
|
container: {
|
|
|
|
|
flex: 1,
|
|
|
|
|
},
|
|
|
|
|
containerTop:{
|
|
|
|
|
top: 75,
|
|
|
|
|
margin: 10,
|
|
|
|
|
flex: 1,
|
|
|
|
@ -190,7 +197,6 @@ const styles = StyleSheet.create({
|
|
|
|
|
containerRight: {
|
|
|
|
|
flex: 1,
|
|
|
|
|
flexWrap: "wrap",
|
|
|
|
|
top: 100,
|
|
|
|
|
marginBottom: 20,
|
|
|
|
|
left: 100,
|
|
|
|
|
},
|
|
|
|
@ -208,12 +214,18 @@ const styles = StyleSheet.create({
|
|
|
|
|
marginBottom: 10
|
|
|
|
|
},
|
|
|
|
|
photo: {
|
|
|
|
|
width: 50,
|
|
|
|
|
height: 100
|
|
|
|
|
width: 75,
|
|
|
|
|
height: 75
|
|
|
|
|
},
|
|
|
|
|
cout: {
|
|
|
|
|
marginBottom: 20
|
|
|
|
|
}
|
|
|
|
|
marginBottom: 20,
|
|
|
|
|
color: "white",
|
|
|
|
|
fontSize: 15
|
|
|
|
|
},
|
|
|
|
|
image: {
|
|
|
|
|
flex: 1,
|
|
|
|
|
justifyContent: "center"
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|