-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRPS.html
More file actions
178 lines (156 loc) · 10.9 KB
/
RPS.html
File metadata and controls
178 lines (156 loc) · 10.9 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" />
<script src="https://cdn.tailwindcss.com"></script>
<title>RPS</title>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
<div id="app">
<div class="grid grid-cols-3 pt-20 mx-auto max-w-lg min-h-[22%]">
<div class="text-center">
<i class="fa-solid fa-user text-5xl text-transparent bg-clip-text bg-gradient-to-b from-lime-400 to-lime-600"></i><br>
<span class="text-4xl" v-html="result2"></span>
</div>
<div class="flex justify-center items-center">
<span class="text-4xl" v-html="rawHtml"></span>
</div>
<div class="text-center">
<i class="fa-solid fa-desktop text-5xl text-transparent bg-clip-text bg-gradient-to-b from-amber-400 to-amber-600"></i><br>
<span class="text-4xl" v-html="result1"></span>
</div>
</div>
<div class="grid grid-cols-3 p-10 text-4xl mx-auto max-w-lg">
<div class="text-center">
<label>{{ Player_score }}</label>
</div>
<div class="text-center ">
</div>
<div class="text-center">
<label class="items-center">{{ Comp_score }}</label>
</div>
</div>
<div class="grid grid-cols-3 px-10 py-10 mx-auto max-w-lg min-h-[15%]">
<div class="text-center">
<button v-if="showRock" class="bg-transparent" @click="rand_select(); sel_rock()">
<i id="rock" class="rounded fa-solid fa-hill-rockslide text-7xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600 hover:bg-gradient-to-t"></i>
</button>
</div>
<div class="text-center">
<button v-if="showPaper" @click="rand_select(); sel_paper()">
<i id="pap" class="rounded fa-solid fa-scroll text-7xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600 hover:bg-gradient-to-t"></i>
</button>
</div>
<div class="text-center">
<button v-if="showScissors" @click="rand_select(); sel_scissors()">
<i id="sci" class="bg-fuchsia-100 rounded fa-solid fa-scissors text-7xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600 hover:bg-gradient-to-t"></i>
</button>
</div>
</div>
<div class="flex justify-center mx-auto max-w-lg p-10">
<button class="w-12 h-12 bg-fuchsia-400 text-white font-bold shadow-2xl rounded-full" @click="reset_score()">
<i class="text-3xl text-fuchsia-800 justify-center fa-solid fa-power-off hover:text-fuchsia-200"></i>
</button>
</div>
</div>
</body>
<script type="module">
const app = Vue.createApp({
data() {
return {
result1: " ",
result2: ' ',
output: ' ',
Comp_score: 0,
Player_score: 0,
rawHtml: '',
showRock: true,
showPaper: true,
showScissors: true
}
},
methods: {
rand_select() {
var items = Array("Rock", "Paper", "Scissors")
var a = Math.floor(Math.random()*items.length)
var item = items[a];
this.result1 = item;
},
// console.log(this.result1, //this.result2,this.output);
sel_rock() {
this.showRock = false;
this.result2 = '<i id="rock" class="rounded fa-solid fa-hill-rockslide text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">';
if(this.result1=="Paper"){
this.output = "Computer Won";
this.Comp_score++;
this.rawHtml = '<i class="fa-solid fa-thumbs-down fa-bounce text-transparent bg-clip-text bg-gradient-to-b from-amber-400 to-amber-600" style="--fa-animation-duration: 2s;"></i>';
this.result1='<i id="pap" class="rounded fa-solid fa-scroll text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">';
} else if(this.result1=="Scissors"){
this.output = "You Won";
this.Player_score++;
this.rawHtml = '<i class="fa-solid fa-thumbs-up fa-bounce text-transparent bg-clip-text bg-gradient-to-b from-lime-400 to-lime-600"></i>';
this.result1 = '<i id="sci" class="rounded fa-solid fa-scissors text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">';
} else {
this.output = "It's a tie"
this.rawHtml = '<i class="fa-brands fa-black-tie fa-beat text-transparent bg-clip-text bg-gradient-to-r from-lime-400 to-amber-400" style="--fa-animation-duration: 2s;"></i>';
this.result1 = '<i id="sci" class="rounded fa-solid fa-hill-rockslide text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">';
}
setTimeout(() => this.showRock = true, 200);
},
sel_paper() {
this.showPaper = false;
this.result2 = '<i id="pap" class="rounded fa-solid fa-scroll text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">';
if(this.result1=="Rock"){
this.output = "You Won";
this.Player_score++;
this.rawHtml = '<i class="fa-solid fa-thumbs-up fa-bounce text-transparent bg-clip-text bg-gradient-to-b from-lime-400 to-lime-600"></i>';
this.result1 = '<i id="rock" class="rounded fa-solid fa-hill-rockslide text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">';
} else if(this.result1=="Scissors"){
this.output = "Computer Won";
this.Comp_score++;
this.rawHtml = '<i class="fa-solid fa-thumbs-down fa-bounce text-transparent bg-clip-text bg-gradient-to-b from-amber-400 to-amber-600" style="--fa-animation-duration: 2s;"></i>';
this.result1 = '<i id="sci" class="rounded fa-solid fa-scissors text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">';
} else {
this.output = "It's a tie"
this.rawHtml = '<i class="fa-brands fa-black-tie fa-beat text-transparent bg-clip-text bg-gradient-to-r from-lime-400 to-amber-400" style="--fa-animation-duration: 2s;"></i>';
this.result1='<i id="pap" class="rounded fa-solid fa-scroll text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">';
}
setTimeout(() => this.showPaper = true, 200);
},
sel_scissors() {
this.showScissors = false;
this.result2 = '<i id="pap" class="rounded fa-solid fa-scissors text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">';
if(this.result1=="Rock"){
this.output = "Computer Won";
this.Comp_score++;
this.rawHtml = '<i class="fa-solid fa-thumbs-down fa-bounce text-transparent bg-clip-text bg-gradient-to-b from-amber-400 to-amber-600" style="--fa-animation-duration: 2s;"></i>';
this.result1='<i id="rock" class="rounded fa-solid fa-hill-rockslide text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">'
} else if(this.result1=="Paper"){
this.output = "You Won";
this.Player_score++;
this.rawHtml = '<i class="fa-solid fa-thumbs-up fa-bounce text-transparent bg-clip-text bg-gradient-to-b from-lime-400 to-lime-600"></i>';
this.result1='<i id="pap" class="rounded fa-solid fa-scroll text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">'
} else {
this.output = "It's a tie";
this.rawHtml = '<i class="fa-brands fa-black-tie fa-beat text-transparent bg-clip-text bg-gradient-to-r from-lime-400 to-amber-400" style="--fa-animation-duration: 2s;"></i>';
this.result1 = '<i id="sci" class="rounded fa-solid fa-scissors text-2xl text-transparent bg-clip-text bg-gradient-to-b from-fuchsia-400 to-fuchsia-600">';
}
setTimeout(() => this.showScissors = true, 200);
},
reset_score(){
this.Comp_score = 0;
this.Player_score = 0;
this.result1 = '';
this.result2 = '';
this.output = '';
this.rawHtml = '';
},
},
})
app.mount('#app')
</script>
</html>