Advertisement
Guest User

[RUBY]Window BuyToken

a guest
Nov 29th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.39 KB | None | 0 0
  1. #==============================================================================#
  2. #========================== TOKEN SYSTEM ======================================#
  3. #==============================================================================#
  4. # CREATED BY ANDRIANFK AT 11/27/2014 (MY FAHKIN BEARD-DAY :DD )                #
  5. #==============================================================================#
  6. module AAA
  7.   module Token
  8.     BUY_SUCCESS = "Transaksi berhasil"
  9.     BUY_FAILURE = "Transaksi gagal"
  10.     NOT_ENOUGH_MONEY = "Uang anda tidak mencukupi"
  11.     TYPE = "Mohon ketik #{type} anda.."
  12.   end
  13.   module ExchangeToken
  14.     TokenExchange = 50
  15.     # Berapa gold setara dengan 1 token?
  16.     TokenFee = 1000
  17.     # Berapa harga 1 token?
  18.   end
  19. end
  20. #==============================================================================#
  21. class Win_TokenShop < Window_Base
  22.   def initialize
  23.     @win = super(1,1,120,80)
  24.     @token_win = super(130,1,120,80)
  25.     @exch_win = super(260,1,120,80)
  26.     @userdat_win = super(390,1,125,300)
  27.     @pulsa_win = super(1,130,100,70)
  28.     @payment_win = super(120,130,80,54)
  29.     @button1 = Button.new(@win,1,1,"Buy Token") { @token_win.active }
  30.     @button2 = Button.new(@win,1,12,"Exchange Token") { @exch_win.active }
  31.     @button3 = Button.new(@token_win,1,1,"PayPal"){ @userdat_win.active }
  32.     @button4 = Button.new(@token_win,1,12,"Pulsa"){ @pulsa_win.active }
  33.     @button5 = Button.new(@exch_win,1,(Font.default_size+42),"Exchange"){ exchanged(@textbox1.text.to_i*AAA::ExchangeToken,@textbox1.text.to_i) }
  34.     @button6 = Button.new(@userdat_win,10,80,"Accept") { userdata_paypal(@textbox2.text) }
  35.     @button7 = Button.new(@pulsa_win,48,50,"Accept") { userdata_pulsa(@textbox3.text) }
  36.     @textbox1 = Textbox.new(@exch_win,3,40,106){ exchanged(@textbox1.text.to_i*AAA::ExchangeToken,@textbox1.text.to_i) }
  37.     @textbox2 = Textbox.new(@userdat_win,5,50,280) { userdata_paypal(@textbox2.text) }
  38.     @textbox3 = Textbox.new(@pulsa_win,3,25,85) { userdata_pulsa(@textbox3.text) }
  39.     @check1 = CheckButton.new(@payment_win,5,5,"50 Token")
  40.     @check2 = CheckButton.new(@payment_win,5,30,"100 Token")
  41.     @exch_win.draw_text(20,1,contents.width,WLH,"Exchange Token")
  42.     @userdat_win.draw_text(20,1,contents.width,WLH,"Paypal Buy")
  43.     @userdat_win.draw_text(1,25,contents.width,WLH,"Paypal PIN/Token")
  44.     @pulsa_win.draw_text(20,1,contents.width,WLH,"Pulsa/Token")
  45.   end
  46.  
  47.   def update
  48.     if @payment_win.active
  49.       @check1.update
  50.       @check2.update
  51.       @payment_win.update
  52.     end
  53.     if @win.active
  54.       @win.update
  55.       @button1.update
  56.       @button2.update
  57.     end
  58.     super
  59.     if @token_win.active
  60.       @button3.update
  61.       @button4.update
  62.       @token_win.update
  63.     end
  64.     if @exch_win.active
  65.       @exch_win.update
  66.       @button5.update
  67.       @textbox1.update
  68.     end
  69.     if @userdat_win.active
  70.       @userdat_win.update
  71.       @button6.update
  72.       @textbox2.update
  73.     end
  74.     if @pulsa_win.active
  75.       @pulsa_win.update
  76.       @button7.update
  77.       @textbox3.update
  78.     end
  79.   end
  80.  
  81.   def userdata_pulsa(*args)
  82.     num = args
  83.     a = cektoken
  84.     harga = a*ExchangeToken::TokenFee
  85.     socket.send("<pulsa>#{num};#{harga}</pulsa>")
  86.     if @successfull
  87.       $window["alert"].open(AAA::Token::BUY_SUCCESS)
  88.       $token += a
  89.     elsif @failed
  90.       if @not_enough
  91.         $window["alert"].open(AAA::Token::NOT_ENOUGH_MONEY)
  92.       else
  93.         $window["alert"].open(AAA::Token::BUY_FAILURE)
  94.       end
  95.     end
  96.   end
  97.  
  98.   def userdata_paypal(*args)
  99.     $window["alert"].open("Fitur ini belum tersedia")
  100.   end
  101.  
  102.   def cektoken
  103.     hasil = 0
  104.     if @check1.checked?
  105.       hasil += 50
  106.     end
  107.     if @check2.checked?
  108.       hasil += 100
  109.     end
  110.     return hasil
  111.   end
  112.  
  113.   def exchanged(*args)
  114.     $token-=args[1]
  115.     $game_party.gain_gold(args[0])
  116.     Sound.play_shop
  117.   end
  118.  
  119. end
  120. class Game_Party
  121.   def token
  122.     return $token
  123.   end
  124.  
  125.   def add_token(add)
  126.     $token += add
  127.   end
  128. end
  129. class Scene_Servers < Scene_Base
  130.   alias tokinit initialize
  131.   def initialize
  132.     tokinit
  133.     @buttontobuy = Button.new(nil,1,43,"   Buy Token   "){ Win_TokenShop.new }
  134.   end
  135.   alias tokupd update
  136.   def update
  137.     tokupd
  138.     @buttontobuy.update
  139.   end
  140.   alias toktmnt terminate
  141.   def terminate
  142.     toktmnt
  143.     @buttontobuy.dispose
  144.   end
  145. end
  146. #==============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement