赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 39450 |
最后登录 | 2007-7-17 |
在线时间 | 0 小时 |
Lv1.梦旅人 (禁止发言) 涅磐之男
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 0 小时
- 注册时间
- 2006-6-30
- 帖子
- 67
|
关于blackjack(21点纸牌游戏) 脚本翻译及完美化
更新结果:
1,修正字体问题
2,翻译游戏语句
3,新建立@help.window
4,修正0赌本也可开始赌博问题
5,中文RM可使用.
游戏中可通过$scene = Scene_Blackjack.new呼唤此游戏
感谢原作者,感谢frantice为我们提供如此多精美的脚本,谢谢!
如需此游戏介绍,请跟贴或短信告知.
贴出更新脚本:
- $fontface = Font.default_name
- $fontsize = 22
- #游戏中可通过$scene = Scene_Blackjack.new呼唤此游戏
- class Scene_Blackjack
- def main
- @help_window = Window_Help.new
- @table_window = Window_Table.new
- @bet_window = Window_Bet.new
- @bet_window.index = 0
- @money_window = Window_Money.new
- @hitstay_window = Window_HitStay.new
- @hitstay_window.active = false
- @cards = []
- @graphic = []
- @card_used = 0
- variable_init
- shuffle2
- val_graphic
- shuffle
- Graphics.transition
- loop do
- Graphics.update
- Input.update
- update
- if $scene != self
- break
- end
- end
- Graphics.freeze
- @help_window.dispose
- @table_window.dispose
- @bet_window.dispose
- @money_window.dispose
- @hitstay_window.dispose
- end
- def update
- @table_window.update
- @bet_window.update
- @help_window.update
- @money_window.update
- @hitstay_window.update
- if @bet_window.active
- update_bet
- return
- end
- if @hitstay_window.active
- update_hitstay
- return
- end
- end
- def update_bet
- @help_window.set_text("请选择你想投入的赌本。")
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @bet_window.index = 5
- return
- end
- if Input.trigger?(Input::C)
- case @bet_window.index
- when 0
- @bet = 25
- if ($game_party.gold >= @bet) and ((@currentbet+@bet) <= 500)
- $game_system.se_play($data_system.decision_se)
- bet
- else
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- when 1
- @bet = 50
- if ($game_party.gold >= @bet) and ((@currentbet+@bet) <= 500)
- $game_system.se_play($data_system.decision_se)
- bet
- else
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- when 2
- @bet = 100
- if ($game_party.gold >= @bet) and ((@currentbet+@bet) <= 500)
- $game_system.se_play($data_system.decision_se)
- bet
- else
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- when 3
- @bet = 500
- if ($game_party.gold >= @bet) and ((@currentbet+@bet) <= 500)
- $game_system.se_play($data_system.decision_se)
- bet
- else
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- when 4
- if @bet == 0
- $game_system.se_play($data_system.buzzer_se)
- else
- $game_system.se_play($data_system.decision_se)
- start_blackjack
- end
- when 5
- $game_system.se_play($data_system.cancel_se)
- $game_party.gain_gold(@currentbet)
- $scene = Scene_Map.new
- end
- end
- end
- def update_hitstay
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @hitstay_window.index = 1
- return
- end
- if Input.trigger?(Input::C)
- case @hitstay_window.index
- when 0
- hit
- when 1
- stay
- end
- end
- end
- def bet
- $game_party.lose_gold(@bet)
- @currentbet += @bet
- @money_window.refresh(@currentbet)
- end
- def start_blackjack
- @help_window.set_text("请选择摸牌或保留。")
- @bet_window.active = false
- @m_hand1 = @cards[@card_used]
- @graphic1 = @graphic[@card_used]
- check_cards
- @card_used +=1
- @m_hand2 = @cards[@card_used]
- @graphic2 = @graphic[@card_used]
- check_cards
- @card_used +=1
- @d_hand1 = @cards[@card_used]
- @d_graphic1 = @graphic[@card_used]
- check_cards
- @card_used +=1
- @d_hand2 = @cards[@card_used]
- @d_graphic2 = @graphic[@card_used]
- @m_total = @m_hand1+@m_hand2
- @d_total = @d_hand1+@d_hand2
- if @m_hand1 == 1
- @m_ace =1
- @m_hand1=@m_hand1+10
- @m_total=@m_hand1 + @m_hand2
- end
- if @m_hand2 == 1
- if @m_hand1 != 11
- @m_ace = 1
- @m_hand2 = @m_hand2+10
- @m_total = @m_hand1+@m_hand2
- else
- @m_hand2 = 1
- @m_total = @m_hand1+@m_hand2
- end
- end
- if @d_hand1 == 1
- @d_ace =1
- @d_hand1=@d_hand1+10
- @d_total=@d_hand1 + @d_hand2
- end
- if @d_hand2 == 1
- if @d_hand1 != 11
- @d_ace = 1
- @d_hand2 = @d_hand2+10
- @d_total = @d_hand1+@d_hand2
- else
- @d_card2 = 1
- @d_total = @d_hand1+@d_hand2
- end
- end
- draw_cards
- check_win
- end
- def shuffle
- j = 51
- k = 0
- temp = 0
- temp2 = 0
- while (j>=0)
- k = rand(j)
- temp = @cards[j]
- temp2 = @graphic[j]
- @cards[j] = @cards[k]
- @graphic[j] = @graphic[k]
- @cards[k] = temp
- @graphic[k] = temp2
- j-=1
- end
- end
- def shuffle2
- @cards = [1,2,3,4,5,6,7,8,9,10,10,10,10,
- 1,2,3,4,5,6,7,8,9,10,10,10,10,
- 1,2,3,4,5,6,7,8,9,10,10,10,10,
- 1,2,3,4,5,6,7,8,9,10,10,10,10,
- 0,0]
- end
- def val_graphic
- for i in 0...53
- @graphic[i] = i
- end
- end
- def check_cards
- if @card_used == 52
- shuffle
- @card_used = 0
- end
- end
- def draw_cards
- @table_window.refresh(@m_hand1,@graphic1,
- @m_hand2,@graphic2,
- @m_hand3,@graphic3,
- @m_hand4,@graphic4,
- @m_hand5,@graphic5,
- @d_hand1,52,
- @d_hand2,@d_graphic2,
- @d_hand3,@d_graphic3,
- @d_hand4,@d_graphic4,
- @d_hand5,@d_graphic5,
- @m_total)
- end
- def draw_real_cards
- @table_window.refresh(@m_hand1,@graphic1,
- @m_hand2,@graphic2,
- @m_hand3,@graphic3,
- @m_hand4,@graphic4,
- @m_hand5,@graphic5,
- @d_hand1,@d_graphic1,
- @d_hand2,@d_graphic2,
- @d_hand3,@d_graphic3,
- @d_hand4,@d_graphic4,
- @d_hand5,@d_graphic5,
- @m_total)
- end
- def variable_init
- @bet = 0
- @currentbet = 0
- @dummy_gold = 0
- @m_hand1 = 0
- @graphic1 = 53
- @m_hand2 = 0
- @graphic2 = 53
- @m_hand3 = 0
- @graphic3 = 53
- @m_hand4 = 0
- @graphic4 = 53
- @m_hand5 = 0
- @graphic5 = 53
- @d_hand1 = 0
- @d_graphic1 = 53
- @d_hand2 = 0
- @d_graphic2 = 53
- @d_hand3 = 0
- @d_graphic3 = 53
- @d_hand4 = 0
- @d_graphic4 = 53
- @d_hand5 = 0
- @d_graphic5 = 53
- @m_ace = 0
- @d_ace = 0
- @test = 0
- end
- def hit
- check_cards
- @card_used +=1
- if @m_hand3 == 0
- @m_hand3 = @cards[@card_used]
- @graphic3 = @graphic[@card_used]
- elsif @m_hand4 == 0 and @m_hand3 != 0
- @m_hand4 = @cards[@card_used]
- @graphic4 = @graphic[@card_used]
- elsif @m_hand5 == 0 and @m_hand4 != 0
- @m_hand5 = @cards[@card_used]
- @graphic5 = @graphic[@card_used]
- end
- if @cards[@card_used] == 1
- if @m_total <=10
- @m_ace = 1
- @m_total += 11
- else
- @m_total += 1
- end
- else
- @m_total += @cards[@card_used]
- end
- check_win2
- end
- def stay
- while (@d_total<=@m_total)
- check_cards
- @card_used +=1
- if @d_hand3 == 0
- @d_hand3 = @cards[@card_used]
- @d_graphic3 = @graphic[@card_used]
- elsif @d_hand4 == 0 and @m_hand3 != 0
- @d_hand4 = @cards[@card_used]
- @d_graphic4 = @graphic[@card_used]
- elsif @d_hand5 == 0 and @m_hand4 != 0
- @d_hand5 = @cards[@card_used]
- @d_graphic5 = @graphic[@card_used]
- end
- if @cards[@card_used] == 1
- if @d_total <=10
- @d_ace = 1
- @d_total += 11
- else
- @d_total += 1
- end
- else
- @d_total += @cards[@card_used]
- end
- end
- check_win3
- end
- def check_win
- if @test == 0
- if @m_total == 21 and @d_total != 21
- draw_real_cards
- win
- elsif @m_total != 21 and @d_total == 21
- draw_real_cards
- lose
- elsif @m_total == 21 and @d_total == 21
- draw_real_cards
- tie
- else
- @test = 1
- @hitstay_window.active = true
- end
- end
- end
- def check_win2
- if @m_total >= 22 and @m_ace == 1
- @m_total -= 10
- @m_ace = 0
- draw_cards
- elsif @m_total >= 22
- draw_real_cards
- lose
- elsif @m_total == 21
- draw_real_cards
- win
- elsif @m_total <=20
- draw_cards
- @hitstay_window.active = true
- end
- end
- def check_win3
- if @d_total >= 22 and @d_ace == 1
- @d_total -= 10
- @d_ace = 0
- draw_real_cards
- elsif @d_total >= 22
- draw_real_cards
- win
- elsif @d_total == 21
- draw_real_cards
- lose
- elsif @d_total > @m_total and @d_total <= 20
- draw_real_cards
- lose
- elsif @d_total == @m_total
- draw_real_cards
- tie
- elsif @d_total < @m_total
- draw_real_cards
- win
- end
- end
- def win
- $game_party.gain_gold(@currentbet*2)
- @help_window.set_text("你赢了!")
- delay(3)
- $scene = Scene_Map.new
- end
- def lose
- @help_window.set_text("你输了…")
- delay(3)
- $scene = Scene_Map.new
- end
- def tie
- $game_party.gain_gold(@currentbet)
- @help_window.set_text("Tie!")
- delay(3)
- $scene = Scene_Map.new
- end
- def delay(seconds)
- for i in 0...(seconds * 10)
- sleep 0.1
- Graphics.update
- end
- end
- end
- class Window_Table < Window_Base
- def initialize
- super(0, 64, 512, 416)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.font.name = $fontface
- self.contents.font.size = $fontsize
- refresh
- end
- #--------------------------------------------------------------------------
- def refresh(hand1 = 0, graphic1 = 53,
- hand2 = 0, graphic2 = 53,
- hand3 = 0, graphic3 = 53,
- hand4 = 0, graphic4 = 53,
- hand5 = 0, graphic5 = 53,
- d_hand1 = 0, d_graphic1 = 53,
- d_hand2 = 0, d_graphic2 = 53,
- d_hand3 = 0, d_graphic3 = 53,
- d_hand4 = 0, d_graphic4 = 53,
- d_hand5 = 0, d_graphic5 = 53,
- total = 0)
- @hand1 = hand1
- @hand2 = hand2
- @hand3 = hand3
- @hand4 = hand4
- @hand5 = hand5
- @d_hand1 = d_hand1
- @d_hand2 = d_hand2
- @d_hand3 = d_hand3
- @d_hand4 = d_hand4
- @d_hand5 = d_hand5
- @graphic1 = graphic1
- @graphic2 = graphic2
- @graphic3 = graphic3
- @graphic4 = graphic4
- @graphic5 = graphic5
- @d_graphic1 = d_graphic1
- @d_graphic2 = d_graphic2
- @d_graphic3 = d_graphic3
- @d_graphic4 = d_graphic4
- @d_graphic5 = d_graphic5
- @total = total
- self.contents.clear
- self.contents.draw_text(32, 320, 128, 32, "你现在的点数: " + @total.to_s)
- graphic
- end
- def graphic
- x = 0
- y = 0
- @frame_width = 71
- @frame_height = 96
- if @graphic1 !=nil
- @xpos1 = @graphic1*@frame_width
- else
- @xpos1 = 52
- end
- if @graphic2 !=nil
- @xpos2 = @graphic2*@frame_width
- else
- @xpos2 = 52
- end
- if @graphic3 !=nil
- @xpos3 = @graphic3*@frame_width
- else
- @xpos3 = 52
- end
- if @graphic4 !=nil
- @xpos4 = @graphic4*@frame_width
- else
- @xpos4 = 52
- end
- if @graphic5 !=nil
- @xpos5 = @graphic5*@frame_width
- else
- @xpos5 = 52
- end
- if @d_graphic1 !=nil
- @xposd1 = @d_graphic1*@frame_width
- else
- @xposd1 = 52
- end
- if @graphic2 !=nil
- @xposd2 = @d_graphic2*@frame_width
- else
- @xposd2 = 52
- end
- if @d_graphic3 !=nil
- @xposd3 = @d_graphic3*@frame_width
- else
- @xposd3 = 52
- end
- if @graphic4 !=nil
- @xposd4 = @d_graphic4*@frame_width
- else
- @xposd4 = 52
- end
- if @d_graphic5 !=nil
- @xposd5 = @d_graphic5*@frame_width
- else
- @xposd5 = 52
- end
- bitmap = RPG::Cache.picture("cards")
- src_rect_hand1 = Rect.new(@xpos1, 0, @frame_width, @frame_height)
- src_rect_hand2 = Rect.new(@xpos2, 0, @frame_width, @frame_height)
- src_rect_hand3 = Rect.new(@xpos3, 0, @frame_width, @frame_height)
- src_rect_hand4 = Rect.new(@xpos4, 0, @frame_width, @frame_height)
- src_rect_hand5 = Rect.new(@xpos5, 0, @frame_width, @frame_height)
- src_rect_d_hand1 = Rect.new(@xposd1, 0, @frame_width, @frame_height)
- src_rect_d_hand2 = Rect.new(@xposd2, 0, @frame_width, @frame_height)
- src_rect_d_hand3 = Rect.new(@xposd3, 0, @frame_width, @frame_height)
- src_rect_d_hand4 = Rect.new(@xposd4, 0, @frame_width, @frame_height)
- src_rect_d_hand5 = Rect.new(@xposd5, 0, @frame_width, @frame_height)
- self.contents.blt(0,192,bitmap,src_rect_hand1)
- self.contents.blt(96,192,bitmap,src_rect_hand2)
- self.contents.blt(96*2,192,bitmap,src_rect_hand3)
- self.contents.blt(96*3,192,bitmap,src_rect_hand4)
- self.contents.blt(96*4,192,bitmap,src_rect_hand5)
- self.contents.blt(0,0,bitmap,src_rect_d_hand1)
- self.contents.blt(96,0,bitmap,src_rect_d_hand2)
- self.contents.blt(96*2,0,bitmap,src_rect_d_hand3)
- self.contents.blt(96*3,0,bitmap,src_rect_d_hand4)
- self.contents.blt(96*4,0,bitmap,src_rect_d_hand5)
- end
- end
- class Window_Bet < Window_Selectable
- # ------------------------------------
- def initialize
- super(512, 64, 128, 224)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.font.name = $fontface
- self.contents.font.size = $fontsize
- @column_max = 1
- refresh
- self.index = 0
- end
- # ------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- @item_max = 6
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- # ------------------------------------
- def draw_item(index)
- x = 4
- y = index * 32
- rect = Rect.new(x, y, self.width / @column_max - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- case index
- when 0
- self.contents.draw_text(x , y, 128, 32, "25", 0)
- when 1
- self.contents.draw_text(x , y, 128, 32, "50", 0)
- when 2
- self.contents.draw_text(x , y, 128, 32, "100", 0)
- when 3
- self.contents.draw_text(x , y, 128, 32, "500", 0)
- when 4
- self.contents.draw_text(x , y, 128, 32, "完成", 0)
- when 5
- self.contents.draw_text(x , y, 128, 32, "退出", 0)
- end
- end
- # ------------------------------------
- def update_help
- @help_window.set_text("" )
- end
- end
- class Window_Money < Window_Base
- # ------------------------------------
- def initialize
- super(512, 288, 128, 96)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.font.name = $fontface
- self.contents.font.size = $fontsize
- @bet = 0
- refresh(@bet)
- end
- # ------------------------------------
- def refresh(bet)
- @bet = bet
- self.contents.clear
- self.contents.font.color = normal_color
- self.contents.draw_text(0, 0, 96, 32, $game_party.gold.to_s,2)
- self.contents.draw_text(0, 32, 96, 32, @bet.to_s, 2)
- end
- end
- class Window_HitStay < Window_Selectable
- # ------------------------------------
- def initialize
- super(512, 384, 128, 96)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.font.name =$fontface
- self.contents.font.size = $fontsize
- @column_max = 1
- refresh
- self.index = 0
- end
- # ------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- @item_max = 2
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- # ------------------------------------
- def draw_item(index)
- x = 4
- y = index * 32
- rect = Rect.new(x, y, self.width / @column_max - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- case index
- when 0
- self.contents.draw_text(x , y, 128, 32, "摸牌", 0)
- when 1
- self.contents.draw_text(x , y, 128, 32, "保留", 0)
- end
- end
- # ------------------------------------
- def update_help
- @help_window.set_text("" )
- end
- end
-
复制代码
工程下载:http://rpg.blue/upload_program/files/blackjack.exe
|
|