[人狼] 初版自動按開始遊戲及自動投票程式
※ [本文轉錄自 HOT_Game 看板]
作者: Schelfaniel (Schelfaniel) 看板: HOT_Game
標題: [人狼] 初版自動按開始遊戲及自動投票程式
時間: Wed Mar 4 20:45:02 2009
本程式由 Ruby 撰寫
需要安裝 Ruby 元件 Watir ( gem install watir )
請於 irb 下使用,欲中斷自動執行請使用 ctrl-c
( 等我有空再改寫成視窗版 )
程式提供:
1.30 秒自動按開始遊戲
auto_up_start
2.60 秒自動投選擇的對象 ( 如果對象已死亡則會亂數投票)
auto_up_vote 名稱
3.60 秒自動亂數投票
auto_up_vote_random
程式如下 :
require 'rubygems'
require 'watir'
def ngct_start
$browser = Watir::IE.find(:url, /test.ngct.net/)
unless $browser
$browser = Watir::IE.new
$browser.goto 'http://test.ngct.net'
end
end
def up_votelink
$browser_up = $browser.frame(:name, 'up')
$browser_up.link(:name, 'vote_link').click
end
def up_gamestart
$browser_up.button(:index, 2).click
end
def up_return
$browser_up.link(:index, 2).click
end
def up_say text
$browser_up = $browser.frame(:name, 'up')
$browser_up.text_field(:id, "say").set(text)
$browser_up.button(:index, 1).click
end
def up_vote_random
result = true
up_votelink
sleep(0.1)
begin
index = rand($browser_up.radios.length) + 1
$browser_up.radio(:index, index).set
$browser_up.button(:index, 1).click
rescue
end
sleep(0.1)
up_return
result
end
def up_vote name
result = true
up_votelink
sleep(0.1)
begin
$browser_up.radio(:value, name).set
$browser_up.button(:index, 1).click
rescue
begin
index = rand($browser_up.radios.length) + 1
$browser_up.radio(:index, index).set
$browser_up.button(:index, 1).click
rescue
end
end
sleep(0.1)
up_return
result
end
def up_start
result = true
up_votelink
sleep(0.1)
begin
up_gamestart
rescue
result = nil
end
sleep(0.1)
up_return
result
end
def auto_up_start
up_say '啟動:自動按開始遊戲(30秒)'
$thread_stop = false
while $thread_stop == false
break unless up_start
sleep(30)
end
end
def auto_up_vote_random
up_say '啟動:自動亂數投票(60秒)'
$thread_stop = false
while $thread_stop == false
break unless up_vote_random
sleep(60)
end
end
def auto_up_vote name
up_say '啟動:自動投票(60秒)'
$thread_stop = false
while $thread_stop == false
break unless up_vote name
sleep(60)
end
end
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.126.52.118
推
03/04 20:52,
03/04 20:52
推
03/04 20:56,
03/04 20:56
推
03/04 20:57,
03/04 20:57
推
03/04 21:16,
03/04 21:16
→
03/04 21:17,
03/04 21:17
推
03/04 21:17,
03/04 21:17
推
03/04 21:24,
03/04 21:24
→
03/04 21:24,
03/04 21:24
推
03/04 22:59,
03/04 22:59
推
03/04 23:01,
03/04 23:01
推
03/05 00:00,
03/05 00:00
推
03/05 00:11,
03/05 00:11
→
03/05 00:41,
03/05 00:41
推
03/05 01:59,
03/05 01:59
推
03/05 02:11,
03/05 02:11
→
03/05 02:12,
03/05 02:12
→
03/05 02:12,
03/05 02:12
→
03/05 03:58,
03/05 03:58
推
03/05 04:19,
03/05 04:19
推
03/05 07:10,
03/05 07:10
推
03/05 17:40,
03/05 17:40
噓
03/05 17:42,
03/05 17:42
推
03/05 17:50,
03/05 17:50
推
03/05 17:51,
03/05 17:51
推
03/05 17:52,
03/05 17:52
推
03/05 18:19,
03/05 18:19
推
03/05 18:32,
03/05 18:32
推
03/05 18:35,
03/05 18:35
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.126.50.38
→
03/05 20:19, , 1F
03/05 20:19, 1F