-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
106 lines (106 loc) · 2.76 KB
/
main.ts
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
radio.onReceivedNumber(function (receivedNumber) {
mottaget = 1
Motståndarens_val = receivedNumber
})
input.onButtonPressed(Button.A, function () {
if (skickat == 0) {
Mitt_val = Mitt_val + 1
if (Mitt_val == 4) {
Mitt_val = 1
}
}
})
input.onButtonPressed(Button.B, function () {
soundExpression.hello.playUntilDone()
radio.sendNumber(Mitt_val)
skickat = 1
basic.clearScreen()
})
let mottaget = 0
let skickat = 0
let Motståndarens_val = 0
let Mitt_val = 0
radio.setGroup(1)
Mitt_val = 1
Motståndarens_val = 0
let sten = 1
let sax = 2
let påse = 3
skickat = 0
mottaget = 0
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. # # # .
. . # . .
`)
basic.forever(function () {
if (skickat == 0) {
if (Mitt_val == sten) {
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. # # # .
. . # . .
`)
}
if (Mitt_val == sax) {
basic.showLeds(`
# . . . .
. # # . .
. . . # #
. # # . .
# . . . .
`)
}
if (Mitt_val == påse) {
basic.showLeds(`
# . . . #
# . . . #
# . . . #
# . . . #
. # # # .
`)
}
}
basic.pause(1)
if (mottaget == 1) {
if (Motståndarens_val == Mitt_val) {
basic.showLeds(`
. . . . .
# # # # #
. . . . .
# # # # #
. . . . .
`)
} else if (Mitt_val == sten) {
if (Motståndarens_val == sax) {
basic.showIcon(IconNames.Happy)
soundExpression.giggle.playUntilDone()
} else if (Motståndarens_val == påse) {
basic.showIcon(IconNames.Sad)
soundExpression.sad.playUntilDone()
}
} else if (Mitt_val == sax) {
if (Motståndarens_val == 3) {
basic.showIcon(IconNames.Happy)
soundExpression.giggle.playUntilDone()
} else if (Motståndarens_val == 1) {
basic.showIcon(IconNames.Sad)
soundExpression.sad.playUntilDone()
}
} else if (Mitt_val == påse) {
if (Motståndarens_val == 3) {
basic.showIcon(IconNames.Happy)
soundExpression.giggle.playUntilDone()
} else if (Motståndarens_val == 1) {
basic.showIcon(IconNames.Sad)
soundExpression.sad.playUntilDone()
}
}
mottaget = 0
skickat = 0
}
})