(ruby)(DQ10)(ドラゴンクエスト10)(七不思議の出現時間までをカウントダウンするスクリプト)

 「夢幻郷」はすでに出現条件が解析されているのでそちらの情報を参照のこと
よって残り6つの出現されるとされる時間までを表示するスクリプトです

 「ast.rb」と「lib_ast.rb」を同じフォルダに置いて
「ast.rb」をrubyで実行してください



情報の内容としては
/場所と七不思議/ 出現開始時間JST(出現開始時間までの残り時間)/出現終了時間JST(終了時間までの残り時間)/
となっています
「出現開始時間までの残り時間」は、出現開始時間を過ぎたら「経過時間」を表示します

ファイル名:ast.rb

#!/usr/local/bin/ruby -Ku if system('clear') then clear_cmd = 'clear' else clear_cmd = 'cls' end require './lib_ast.rb' OneDay = '72:00'.to_sec() mystery_datas = [ ['夢幻の森(幽霊列車)', '00:06:00', '06:00'], ['アズラン(人形)' , '00:36:00', '15:00'], ['ダラズ(巨人)' , '01:00:00', '06:00'], ['リンクル(首長竜)' , '01:00:00', '30:00'], ['ザクバン(UFO)' , '01:06:00', '08:00'], ['ラギ(雪女)' , '01:06:00', '21:00'] ] mystery_datas.map!{|i| from_sec = i[1].to_sec [ i[0], from_sec, from_sec + i[2].to_sec, ] } schedule_table = [] 22.times{|c| base_time = OneDay * c mystery_datas.each{|md| schedule_table << [ md[0], md[1] + base_time, md[2] + base_time ] } } schedule_table.map!{|i| [ i[0], i[1], i[2], i[1].to_hhmmss(false, false), i[2].to_hhmmss(false, false) ] } over24hours = schedule_table[(117..119)] last_jst_sec = 0 loop{ sleep(0.1) jst_sec = 'jst'.to_sec if jst_sec == last_jst_sec then #print('.') next end system(clear_cmd) last_jst_sec = jst_sec puts() jst_sec_over24 = jst_sec + 86400 ast_sec = jst_sec.to_ast_sec puts('JST:' << jst_sec.to_hhmmss(false, false) << ' / ' << 'AST:' << ast_sec.to_hhmmss(false, false) << ((ast_sec.daytime?)?' (DayTime)':' (NightTime)') ) puts() founds = 0 futures = [] if (0..1080).include?(jst_sec) then over24hours.each{|i| if (i[1]..i[2]).include?(jst_sec_over24) then futures << i founds += 1 end } end schedule_table.each{|i| if i[2] >= jst_sec then futures << i founds += 1 if founds == 12 then break end end } futures.each{|i| if (0..1080).include?(jst_sec) and (i[2] >= 86400) then from_remain = (i[1] - jst_sec_over24).abs.to_hhmmss(false, false) to_remain = (i[2] - jst_sec_over24).abs.to_hhmmss(false, false) is_hottime = (jst_sec_over24 > i[1])?' hot!':'' else from_remain = (i[1] - jst_sec).abs.to_hhmmss(false, false) to_remain = (i[2] - jst_sec).abs.to_hhmmss(false, false) is_hottime = (jst_sec > i[1])?' hot!':'' end puts(''<< i[0].krjust(20) << ' ' << i[3] << '(' << from_remain << ') 〜 ' << i[4] << '(' << to_remain << ')' << is_hottime ) } }
ファイル名:lib_ast.rb

class String AST_DHMS = [86400, 3600, 60, 1] def to_sec() if self == 'jst' then now_jst = Time.now() return(now_jst.hour * 3600 + now_jst.min * 60 + now_jst.sec) end if self == 'ast' then now_jst = Time.now() return(((now_jst.hour * 3600 + now_jst.min * 60 + now_jst.sec) * 20) % 86400) end buf1 = self.split(':') buf2 = buf1.length buf3 = 0 buf2.times{|c| buf3 += buf1[c].to_i * AST_DHMS[4-buf2+c] } return(buf3) end def prune_days() return(self.to_sec().prune_days().to_hhmmss(false, false)) end def to_hhmmss() if (self == 'jst') or (self == 'ast') then return(self.to_sec().to_hhmmss(false, false)) end return(self.to_sec().to_hhmmss(false, false)) end def krjust(number_of_chars) c = 0 self.each_char{|char| if char.bytesize == 1 then c += 1 else c += 2 end } buf = number_of_chars - c if buf < 0 then buf = 0 end return((' ' * buf) << self) end end class Fixnum def to_hhmmss(show_dd = true, manage_days = true) ddhhmmss = [0,0,0,0] if manage_days then buf = self.divmod(86400) else buf = [0, self] end ddhhmmss[0] = buf[0] buf = buf[1].divmod(3600) ddhhmmss[1] = buf[0] buf = buf[1].divmod(60) ddhhmmss[2] = buf[0] ddhhmmss[3] = buf[1] if !show_dd then ddhhmmss.delete_at(0) end ddhhmmss.map!{|i| i.to_s.rjust(2,'0')} return ddhhmmss.join(':') end def prune_days() return(self % 86400) end def to_ast_sec(is_prune_days = true) if is_prune_days then return((self * 20) % 86400) else return(self * 20) end end def daytime?() return (21600..64799).include?(self % 86400) end end