Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. package com.vencillio.rs2.content.dialogue.impl;
  2.  
  3. import com.vencillio.core.util.Utility;
  4. import com.vencillio.rs2.content.dialogue.DialogueManager;
  5. import com.vencillio.rs2.content.dialogue.Emotion;
  6. import com.vencillio.rs2.entity.item.Item;
  7. import com.vencillio.rs2.entity.player.Player;
  8. import com.vencillio.rs2.entity.player.net.out.impl.SendMessage;
  9.  
  10. /**
  11. * Created by Tanner on 2/21/2018.
  12. */
  13. public class DoubleLottoGame {
  14.  
  15. private static final int CHANCE_OF_LOSING = 55;
  16.  
  17. public static void playGame(Player player, String input) {
  18. boolean won = Utility.random(100) >= CHANCE_OF_LOSING;
  19.  
  20. if (player.isPouchPayment())
  21. if (player.getMoneyPouch() > Integer.parseInt(input))
  22. player.setMoneyPouch(player.getMoneyPouch() - Integer.parseInt(input));
  23.  
  24. else if (player.getInventory().hasItemAmount(995, Integer.parseInt(input)))
  25. player.getInventory().remove(new Item(995, Integer.parseInt(input)));
  26.  
  27. else
  28. player.send(new SendMessage("You don't have enough money to bet that much"));
  29.  
  30. if (won) {
  31. if (player.isPouchPayment())
  32. player.setMoneyPouch(player.getMoneyPouch() + (Integer.parseInt(input) * 2));
  33. else
  34. player.getInventory().add(995, Integer.parseInt(input) * 2);
  35.  
  36. DialogueManager.sendNpcChat(player, 1011, Emotion.HAPPY, "Congratulations, you have won double your bet");
  37. } else {
  38.  
  39. DialogueManager.sendNpcChat(player, 1011, Emotion.SAD, "Sorry you have lost the money, better luck next time");
  40. }
  41.  
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement