RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.triviabot.TriviaBot Class Reference

Manages the trivia bot system. More...

Collaboration diagram for com.runehive.content.triviabot.TriviaBot:

Static Public Member Functions

static void answer (Player player, String answer)
 Handles player answering the question.
static void assign ()
 Assigns a new question.
static void declare ()
 Declares the TriviaBot data.

Static Public Attributes

static int answeredTotal = 0

Static Private Member Functions

static void answered (Player player, String answer)
 Handles player answering the question successfully.

Static Private Attributes

static final String COLOR = "<col=354CE6>"
 Color of the TriviaBot messages.
static TriviaBotData CURRENT = null
 The current question/answer set.
static final Set< TriviaBotDataDATA = new HashSet<>()
 Holds all the bot data.

Detailed Description

Manages the trivia bot system.

Author
Daniel

Definition at line 25 of file TriviaBot.java.

Member Function Documentation

◆ answer()

void com.runehive.content.triviabot.TriviaBot.answer ( Player player,
String answer )
static

Handles player answering the question.

Definition at line 62 of file TriviaBot.java.

62 {
63 if (!player.settings.triviaBot) {
64 return;
65 }
66 if (CURRENT == null) {
67 player.send(new SendMessage(COLOR + "<icon=21> TriviaBot: </col>There is no question currently assigned!"));
68 return;
69 }
70 if (Arrays.stream(Config.BAD_STRINGS).anyMatch(answer::contains)) {
71 player.send(new SendMessage(COLOR + "<icon=21> TriviaBot: </col>You think you're funny, don't you? Guess what? You ain't."));
72 return;
73 }
74 if (Arrays.stream(CURRENT.getAnswers()).anyMatch(a -> a.equalsIgnoreCase(answer))) {
75 answered(player, answer);
76 return;
77 }
78 if (Utility.random(3) == 0) {
79 player.speak("Golly gee! I just entered a wrong trivia answer!");
80 }
81 player.send(new SendMessage(COLOR + "<icon=21> TriviaBot: </col>Sorry, the answer you have entered is incorrect! Try again!"));
82 }

References answer(), answered(), com.runehive.Config.BAD_STRINGS, COLOR, CURRENT, com.runehive.util.Utility.random(), com.runehive.game.world.entity.mob.player.Player.send(), com.runehive.game.world.entity.mob.player.Player.settings, com.runehive.game.world.entity.mob.Mob.speak(), and com.runehive.game.world.entity.mob.player.Settings.triviaBot.

Referenced by answer(), and answered().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ answered()

void com.runehive.content.triviabot.TriviaBot.answered ( Player player,
String answer )
staticprivate

Handles player answering the question successfully.

Definition at line 87 of file TriviaBot.java.

87 {
88 String color = player.right.getColor();
89 int reward = Utility.random(50, 150);
90 if (PlayerRight.isIronman(player)) {
91 player.bankVault.add(COINS, reward);
92 AchievementHandler.activate(player, AchievementKey.TRIVIABOT, 1);
93 player.answeredTrivias += 1;
94 player.send(new SendMessage(Utility.formatDigits(reward) + " coins were added into your bank vault."));
95 } else {
96 player.bankVault.add(BLOOD_MONEY, reward);
97 player.answeredTrivias += 1;
98 AchievementHandler.activate(player, AchievementKey.TRIVIABOT, 1);
99 player.send(new SendMessage(Utility.formatDigits(reward) + " blood money were added into your bank vault."));
100 }
101 // DISABLED
102 // World.sendMessage(COLOR + "<icon=21> TriviaBot: <col=" + color + ">" + player.getName() + "</col> has answered the question correctly!");
103 CURRENT = null;
104 }

References com.runehive.content.achievement.AchievementHandler.activate(), com.runehive.game.world.items.containers.bank.BankVault.add(), answer(), com.runehive.game.world.entity.mob.player.Player.bankVault, CURRENT, com.runehive.util.Utility.formatDigits(), com.runehive.game.world.entity.mob.player.PlayerRight.getColor(), com.runehive.game.world.entity.mob.player.PlayerRight.isIronman(), com.runehive.util.Utility.random(), com.runehive.game.world.entity.mob.player.Player.right, com.runehive.game.world.entity.mob.player.Player.send(), and com.runehive.content.achievement.AchievementKey.TRIVIABOT.

Referenced by answer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ assign()

void com.runehive.content.triviabot.TriviaBot.assign ( )
static

Assigns a new question.

Definition at line 53 of file TriviaBot.java.

53 {
54 // DISABLED
55 // CURRENT = Utility.randomElement(DATA);
56 // World.sendMessage(COLOR + "<icon=21> TriviaBot: </col>" + CURRENT.getQuestion(), player -> player.settings.triviaBot);
57 }

Referenced by com.runehive.game.task.impl.MessageEvent.execute().

Here is the caller graph for this function:

◆ declare()

void com.runehive.content.triviabot.TriviaBot.declare ( )
static

Declares the TriviaBot data.

Definition at line 46 of file TriviaBot.java.

46 {
47 Collections.addAll(DATA, TriviaBotData.values());
48 }

References DATA.

Referenced by com.runehive.RuneHive.processParallelStartupTasks().

Here is the caller graph for this function:

Member Data Documentation

◆ answeredTotal

int com.runehive.content.triviabot.TriviaBot.answeredTotal = 0
static

Definition at line 42 of file TriviaBot.java.

◆ COLOR

final String com.runehive.content.triviabot.TriviaBot.COLOR = "<col=354CE6>"
staticprivate

Color of the TriviaBot messages.

Definition at line 40 of file TriviaBot.java.

Referenced by answer().

◆ CURRENT

TriviaBotData com.runehive.content.triviabot.TriviaBot.CURRENT = null
staticprivate

The current question/answer set.

Definition at line 35 of file TriviaBot.java.

Referenced by answer(), and answered().

◆ DATA

final Set<TriviaBotData> com.runehive.content.triviabot.TriviaBot.DATA = new HashSet<>()
staticprivate

Holds all the bot data.

Definition at line 30 of file TriviaBot.java.

Referenced by declare().


The documentation for this class was generated from the following file: