-
Notifications
You must be signed in to change notification settings - Fork 0
/
WordMasterJS.js
155 lines (123 loc) · 4.08 KB
/
WordMasterJS.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
154
155
var _pj;
var Consonants, FinalScore, HowManyConsonants, HowManyVowels, LCRoundLetters, LetterString, LettersToTest, PlayerName, PlayerWord, RoundConsonants, RoundLetters, RoundVowels, Score, WhereWeGoing, WordCount, WordsGuessed, WordsToScore, check, test, timeout, vowels;
function _pj_snippets(container) {
function in_es6(left, right) {
if (right instanceof Array || typeof right === "string") {
return right.indexOf(left) > -1;
} else {
if (right instanceof Map || right instanceof Set || right instanceof WeakMap || right instanceof WeakSet) {
return right.has(left);
} else {
return left in right;
}
}
}
container["in_es6"] = in_es6;
return container;
}
_pj = {};
_pj_snippets(_pj);
while (true) {
WhereWeGoing = input("Type P to play a round, S to see the scores, or Q to exit.");
if (WhereWeGoing === "P") {
PlayerName = input("What is your name?");
HowManyVowels = random.randint(1, 5);
vowels = ["A", "E", "I", "O", "U"];
RoundVowels = random.sample(vowels, HowManyVowels);
HowManyConsonants = 7 - HowManyVowels;
Consonants = ["B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "X", "Y", "Z"];
RoundConsonants = random.sample(Consonants, HowManyConsonants);
RoundLetters = RoundVowels + RoundConsonants;
LCRoundLetters = function () {
var _pj_a = [],
_pj_b = RoundLetters;
for (var _pj_c = 0, _pj_d = _pj_b.length; _pj_c < _pj_d; _pj_c += 1) {
var letters = _pj_b[_pj_c];
_pj_a.push(letters.lower());
}
return _pj_a;
}.call(this);
LettersToTest = RoundLetters + LCRoundLetters;
console.log(RoundLetters);
WordsGuessed = [];
check = false;
timeout = time.time() + 60 * 1;
while (true) {
test = 0;
if (test === 1 || time.time() > timeout) {
break;
}
test = test - 1;
PlayerWord = input("What words can you make from these letters?");
for (var letter, _pj_c = 0, _pj_a = PlayerWord, _pj_b = _pj_a.length; _pj_c < _pj_b; _pj_c += 1) {
letter = _pj_a[_pj_c];
if (!_pj.in_es6(letter, LettersToTest)) {
console.log("Letter not in allowed list");
check = true;
break;
}
}
if (check) {
check = false;
continue;
} else {
WordsGuessed.append(PlayerWord);
}
}
WordsGuessed = list(dict.fromkeys(WordsGuessed));
console.log("You found");
console.log(WordsGuessed);
WordsToScore = [];
for (var Word, _pj_c = 0, _pj_a = WordsGuessed, _pj_b = _pj_a.length; _pj_c < _pj_b; _pj_c += 1) {
Word = _pj_a[_pj_c];
if (Word.length < 3) {
console.log("uh oh, this word is too short");
console.log(Word);
} else {
if (my_dict.check(Word) === false) {
console.log("uh oh, this word wasn't found");
console.log(Word);
} else {
WordsToScore.append(Word);
}
}
}
console.log("These words will be scored");
console.log(WordsToScore);
Score = [0];
Score.append(WordsToScore.length);
for (var SWords, _pj_c = 0, _pj_a = WordsToScore, _pj_b = _pj_a.length; _pj_c < _pj_b; _pj_c += 1) {
SWords = _pj_a[_pj_c];
if (SWords.length === 3) {
Score.append(Number.parseInt(5));
}
if (SWords.length === 4) {
Score.append(Number.parseInt(10));
}
if (SWords.length === 5) {
Score.append(Number.parseInt(25));
}
if (SWords.length === 6) {
Score.append(Number.parseInt(50));
}
if (SWords.length === 7) {
Score.append(Number.parseInt(100));
}
if (SWords.length === 8) {
Score.append(Number.parseInt(250));
}
if (SWords.length > 9) {
Score.append(Number.parseInt(500));
}
}
console.log("Your final score is");
console.log(sum(Score));
RoundLetters.sort();
LetterString = "".join(RoundLetters);
FinalScore = sum(Score);
WordCount = WordsToScore.length;
}
if (WhereWeGoing === "Q") {
break;
}
}