RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
VoteDialogue.java
1package com.osroyale.content.dialogue.impl;
2
3import com.osroyale.content.dialogue.Dialogue;
4import com.osroyale.content.dialogue.DialogueFactory;
5import com.osroyale.content.dialogue.Expression;
6import com.osroyale.content.store.Store;
7import com.osroyale.game.world.World;
8import com.osroyale.game.world.entity.mob.player.Player;
9import com.osroyale.net.packet.out.SendInputAmount;
10import com.osroyale.net.packet.out.SendURL;
11import com.osroyale.util.Utility;
12
40
41public class VoteDialogue extends Dialogue {
42
43 @Override
44 public void sendDialogues(DialogueFactory factory) {
45 Player player = factory.getPlayer();
46 factory.sendNpcChat(7481, Expression.HAPPY, "Hello " + player.getName() + "!", "What can I do for you today?");
47
48 factory.sendOption("Would you want to know what are some of the benefits of voting are?", () -> {
49 factory.sendPlayerChat(Expression.HAPPY, "Yes I would!");
50 factory.sendNpcChat(7481, "Voting results in attracting new players!", "In return, you'll receive", "vote points that you can use to buy", "items from the vote store.");
51 }, "Exchange vote token", () -> {
52 World.schedule(1, () -> player.send(new SendInputAmount("How many vote tokens would you like to exchange?", 10, input -> exchange(factory, Integer.parseInt(input)))));
53 }, "Show me your voting store!", () -> {
54 Store.STORES.get("Tarnish Vote Store").open(player);
55 }, "I would like to vote to support this great server!", () -> {
56 player.send(new SendURL("https://tarnishps.everythingrs.com/services/vote"));
57 factory.sendNpcChat(7481, "Thank you for voting!");
58 }, "Nevermind, I don't want to do anything for this server.", () -> {
59 factory.clear();
60 });
61 factory.execute();
62 }
63
65 private void exchange(DialogueFactory factory, int amount) {
66 Player player = factory.getPlayer();
67 if (amount > 10000) {
68 factory.sendNpcChat(7481, Expression.SAD, "Sorry but you can only exchange", " 10,000 tokens at a time!").execute();
69 return;
70 }
71
72 int tokenAmount = player.inventory.computeAmountForId(7478);
73
74 if (amount > tokenAmount)
75 amount = tokenAmount;
76
77 if (amount == 0) {
78 factory.sendNpcChat(7481, Expression.SAD, "Sorry but you do not have enough", "vote tokens to do this!").execute();
79 return;
80 }
81
82 player.votePoints += amount;
83 player.inventory.remove(7478, amount);
84 factory.sendNpcChat(7481, Expression.SAD, "I've exchanged " + amount + " vote tokens for you!", "You now have " + Utility.formatDigits(player.votePoints) + " vote points!").execute();
85 }
86}
final DialogueFactory sendOption(String option1, Runnable action1, String option2, Runnable action2)
final DialogueFactory sendPlayerChat(String... lines)
final DialogueFactory sendNpcChat(int id, String... lines)
void sendDialogues(DialogueFactory factory)
static void schedule(Task task)
Definition World.java:284
static String formatDigits(final int amount)
Definition Utility.java:78