Skip to content

Instantly share code, notes, and snippets.

@Echocage
Last active February 22, 2018 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Echocage/3bd0a474205ac9669930ac61a9c135e4 to your computer and use it in GitHub Desktop.
Save Echocage/3bd0a474205ac9669930ac61a9c135e4 to your computer and use it in GitHub Desktop.
package com.vencillio.rs2.content.dialogue.impl;
import com.vencillio.core.util.Utility;
import com.vencillio.rs2.content.dialogue.DialogueManager;
import com.vencillio.rs2.content.dialogue.Emotion;
import com.vencillio.rs2.entity.item.Item;
import com.vencillio.rs2.entity.player.Player;
import com.vencillio.rs2.entity.player.net.out.impl.SendMessage;
/**
* Created by Tanner on 2/21/2018.
*/
public class DoubleLottoGame {
private static final int CHANCE_OF_LOSING = 55;
public static void playGame(Player player, String input) {
boolean won = Utility.random(100) >= CHANCE_OF_LOSING;
if (player.isPouchPayment())
if (player.getMoneyPouch() < Integer.parseInt(input))
player.send(new SendMessage("You don't have enough money to bet that much"));
return;
else if(!player.getInventory().hasItemAmount(995, Integer.parseInt(input)))
player.send(new SendMessage("You don't have enough money to bet that much"));
return;
if (won) {
if (player.isPouchPayment())
player.setMoneyPouch(player.getMoneyPouch() + (Integer.parseInt(input)));
else
player.getInventory().add(995, Integer.parseInt(input) );
DialogueManager.sendNpcChat(player, 1011, Emotion.HAPPY, "Congratulations, you have won double your bet");
} else {
player.getInventory().remove(new Item(995, Integer.parseInt(input)));
DialogueManager.sendNpcChat(player, 1011, Emotion.SAD, "Sorry you have lost the money, better luck next time");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment