Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "net/http"
- $host_ip = "255.255.255.0"
- $directory = "/h/f/p/g/"
- $extension = ".jpg"
- # サーバへの気持ち
- $wait_time = 0.5
- $type = (1..3).to_a
- $rank = (0..5).to_a
- $num = (1..100).to_a
- def is_rank_plus? rank
- return rank%2 == 1
- end
- # RETURN: File Exists?
- def save_file file
- data = Net::HTTP.get $host_ip, ( $directory + file )
- p "http request :#{file}"
- return false if data =~ /Not Found/
- f = open file, "w"
- f.write data
- f.close
- p "save :#{file}"
- return true
- end
- def get_character_cards type, rank, number, diffs
- diffs.each do |d|
- file = ( sprintf "%d%d%03d%02d%s", type, rank, number, d, $extension )
- next if FileTest.exists? file
- break unless save_file file
- end
- end
- # 欠番
- f = open "3302002.jpg", "w"
- f.close
- # main
- $type.each do |t|
- $rank.each do |r|
- $num.each do |n|
- next if Dir::glob( sprintf "%d%d%03d*%s", t, r, n, $extension ).any?
- sleep $wait_time
- if is_rank_plus? r
- get_character_cards t, r, n, [2]
- get_character_cards t, r, n, [5, 6, 7, 8, 9]
- get_character_cards t, r, n, [11]
- else
- get_character_cards t, r, n, [1, 2, 3, 4]
- get_character_cards t, r, n, [10]
- end
- break unless Dir::glob( sprintf "%d%d%03d*%s", t, r, n, $extension ).any?
- end
- end
- end
Add Comment
Please, Sign In to add comment