*/
public void play(final String channel, final boolean hard) {
new Thread(new Runnable() {
public void run() {
try {
IndexWord word = getRandomWord(hard);
// System.out.println("Word is: " + word);
String scrambled = scramble(word.getLemma());
bot.wordGameRunning = true;
bot.sawGameDone = false;
bot.wordScore = 200;
if (hard)
bot.wordScore = bot.wordScore * 3;
bot.wordWord = word.getLemma();
String dots = "";
char[] toCharArray = word.getLemma().substring(2)
.toCharArray();
for (int i = 0; i < toCharArray.length; i++) {
dots = dots + ".";
}
int deduction = 10;
int thinkingTime = 15000;
// scrambled word
bot.send_privmsg(channel, "[w] [" + scrambled + "]");
if (isDone(thinkingTime, deduction))
return;
// part of speech
bot.send_privmsg(channel, "[w] Part of speech: "
+ word.getPOS().getLabel());
if (isDone(thinkingTime, deduction))
return;
// beginning
bot.send_privmsg(channel, "[w] ["
+ word.getLemma().charAt(0) + dots + ".]");
if (isDone(thinkingTime, deduction))
return;
// beginning and end
bot.send_privmsg(channel, "[w] ["
+ word.getLemma().charAt(0)
+ dots
+ word.getLemma().charAt(
word.getLemma().length() - 1) + "]");
if (isDone(thinkingTime, 60))
return;
// definition
String sendString = WNLookup.getStaticDefString(
word.getLemma()).split(";")[0].trim().replaceAll(
"#", "");
sendString = shortenIfRequired(sendString);
bot.send_privmsg(channel, "[w] Definition: " + sendString);
if (isDone(thinkingTime, deduction))
return;
// antonyms
String res = SemanticRelations.getAntoString(
word.getLemma()).replaceAll("\\[ none \\]", "")
.trim();
if (!res.equals("")) {
res = shortenIfRequired(res);
bot.send_privmsg(channel, "[w] Opposite: " + res);
if (isDone(thinkingTime, deduction))
return;
}
// synonymes
res = SemanticRelations.getSynoString(word.getLemma())
.replaceAll("\\[ none \\]", "").trim();
if (!res.equals("")) {
res = shortenIfRequired(res);
bot.send_privmsg(channel, "[w] Synonym: " + res);
if (isDone(thinkingTime, deduction))
return;
}
// hypernyms
if (word.getPOS().equals(POS.NOUN)
|| word.getPOS().equals(POS.VERB)) {
res = SemanticRelations.getHyperString(word.getLemma())
.replaceAll("\\[ none \\]", "").trim();
if (!res.equals("")) {
res = shortenIfRequired(res);
bot.send_privmsg(channel, "[w] Parents: " + res);
if (isDone(thinkingTime, deduction))
return;
}
}
// hyponyms
if (word.getPOS().equals(POS.NOUN)) {
String hypo = SemanticRelations.getHypoString(
word.getLemma()).replaceAll("\\[ none \\]", "")
.trim();
if (!hypo.equals("")) {
hypo = shortenIfRequired(hypo);
bot.send_privmsg(channel, "[w] Children: " + hypo);
if (isDone(thinkingTime, deduction))
return;
}
}
// siblings
if (word.getPOS().equals(POS.NOUN)
|| word.getPOS().equals(POS.VERB)) {
res = SemanticRelations.getSiblingsString(
word.getLemma()).replaceAll("\\[ none \\]", "")
.trim();
if (!res.equals("")) {
res = shortenIfRequired(res);
bot.send_privmsg(channel, "[w] Siblings: " + res);
if (isDone(thinkingTime, deduction))
return;
}
}
// holo- and meronyms
if (word.getPOS().equals(POS.NOUN)) {
String hypo = SemanticRelations.getMeroString(
word.getLemma()).replaceAll("\\[ none \\]", "")
.trim();
if (!hypo.equals("")) {
hypo = shortenIfRequired(hypo);
bot.send_privmsg(channel, "[w] Meronyms (parts): "
+ hypo);
if (isDone(thinkingTime, deduction))
return;
}
hypo = SemanticRelations.getHoloString(word.getLemma())
.replaceAll("\\[ none \\]", "").trim();
if (!hypo.equals("")) {
hypo = shortenIfRequired(hypo);
bot.send_privmsg(channel, "[w] Holonyms (whole): "
+ hypo);
if (isDone(thinkingTime, deduction))
return;
}
}
bot.send_privmsg(channel, "[w] Time over! The word was: "
+ word.getLemma());
bot.wordGameRunning = false;
bot.sawGameDone = true;
} catch (InterruptedException e) {
System.out.println("Threads caused trouble!");
bot.send_privmsg(channel, "Ooops! Something went wrong!");