-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDraw.js
153 lines (146 loc) · 3.67 KB
/
Draw.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import React, { useState } from 'react'
import { Button, Text } from 'react-native-paper'
import { View,StyleSheet, TouchableOpacity } from 'react-native'
import { useNavigation } from '@react-navigation/native';
import {Image} from 'expo-image';
export default function Draw ({route}) {
const navigation = useNavigation();
const[runs,Setruns] = useState(null);
const[balls,setballs] =useState(0);
const[Score,SetScore] = useState(null);
const[wicket,setWicket]=useState(0);
const perso = route.params.oppo;
const scoregen =(max,min)=>{
return Math.floor(min + Math.random() * (max - min));
}
const HitIt=()=>{
console.log(perso)
if(wicket<=3 && balls<6)
{
//runs gets incremented
Setruns(scoregen(0,6))
if(runs==0)
{
setballs(balls+1)
setWicket(wicket+1)
}else{
setballs(balls+1)
SetScore(Score+runs)
}
}else{
alert("GAME OVER");
navigation.navigate('Chase',{navigation,Score});
console.log("Total Score "+Score);
}
}
//check if the balls<=6 and the number of wickets are less than 3 if so then throw the ball and score run
//if the run is 0 then incrase the wicket or else add up to the score variable .
//
return (
<View style={styles.rect}>
<Image style={styles.image}source={require("./assets/VS.png")}/>
<View style={styles.texxtc}>
<Text style={styles.player2}>{perso[0]}</Text>
</View>
<Text style={{fontSize:15,textAlign:'center',top:'-13%',fontFamily:'IBM Plex Mono'}}>We have {perso[0]} on Strike</Text>
<View style={{width:'50%',height:'50%',alignSelf:'center',position:'absolute',top:'25%'}}>
<View style={{width:'100%',height:'28%'}}>
<Image style={styles.board} source={require('./assets/Scoreboard.png')}></Image>
</View>
</View>
<View style={styles.score}>
<Text style={styles.total}>{Score}</Text>
<Text style={styles.run}>{runs}</Text>
</View>
{/* <Text>Ball :{balls}</Text>
<Text>Wicket : {wicket}</Text>*/}
<Image style={styles.vector} source={require("./assets/Vector.png")} />
<Image style={styles.imagestd} source={require("./assets/cricket-stadium.png")}/>
<TouchableOpacity style={styles.strikebtn} onPress={HitIt}>
<Image style={{height:'40%',width:'25%'}}source={require("./assets/strikbtn.png")}/>
</TouchableOpacity>
</View>
);
}
const styles = StyleSheet.create({
texxtc:{
width:'60%',
height:'10%',
top:'-2%',
marginLeft:'70%'
},
run:{
fontSize:40,
top:'20%',
fontFamily:'IBM Plex Mono',
color:'#0B063A'
},
image:{
width:'19%',
height:'10%',
top:'6%',
alignSelf:'center'
},
total:{
fontSize:50,
fontFamily:'FlipClock'
},
strikebtn:{
top:'20%',
left:'40%'
},
imagestd:{
position:'absolute',
alignSelf:'center',
width: '100%',
height: '55%' ,
top:'47%'
},
score:{
alignSelf:'center',
top:'2%',
},
texxted:{
top:'-3%',
width:'30%',
height:'10%',
left:'10%'
},
board:{
alignSelf:'center',
height:'30%',
width:'120%'
},
player:
{
fontFamily: 'IBM Plex Mono',
top:'-80%',
color:'#0B063A',
fontSize:20,
},
player2:{
fontFamily: 'IBM Plex Mono',
fontSize:20,
color:'#0B063A',
},
rect:{
alignContent:'center',
marginTop:-70,
width: '95%',
height: '99%',
left: 9.99 ,
top: 96.23 ,
backgroundColor: "#DBDABD",
},
texxt:{
fontFamily: 'IBM Plex Mono',
textAlign:'center',
fontSize:15
},
vector:{
top:16,
right:50,
height:20,
width:20
}
});