鸿 网 互 联 www.68idc.cn

当前位置 : 服务器租用 > 编程语言开发 > ruby > >

My Adventure 目前进度

来源:互联网 作者:佚名 时间:2013-02-21 10:39
Updated: 2013-2-19 希望这个纯文字游戏不要和遗忘天际那样坑上这么久。【虽说遗忘天际II得等到暑假再说了_】 如果有高手愿意指出错误或者提出意见什么的,我还是很乐意接受的~ 嗯,有什么新进度的话,有时间我会发的 My Adventure的灵感来源是Emacs里面那个

Updated: 2013-2-19

希望这个纯文字游戏不要和遗忘天际那样坑上这么久。【虽说遗忘天际II得等到暑假再说了>_<】 
如果有高手愿意指出错误或者提出意见什么的,我还是很乐意接受的~ 
嗯,有什么新进度的话,有时间我会发的…… 

My Adventure的灵感来源是Emacs里面那个Adventure吧,一个纯文字的冒险游戏。游戏的地图大概是一个8*8*4(快开学了才发现8单位的高度根本做不完……还有,这么多场景名字也够难想的……)的世界,有点类似“密室逃脱”,只是范围大了点而已。还有就是傻瓜式的tips,估计只要会敲键盘、读得懂英文,应该就能顺利地玩下来吧。 
大家就不要吐槽我的英文水平了…… 
某天晚上灵光一现就想出了这个游戏的思路,网站空间香港服务器,于是寒假的任务之一就是把它写完。这份代码可以直接运行,服务器空间,保证暂时没有错误——除了到达某些场景以外,因为那些场景还没有被定义呢! 
里面有一些小细节,算是体现了我的个人幽默吧。 

ACCOUNTS = [[, ], [, ]] , , , , , , , ] 6 COMMANDS = [ , , , , , , , , , , , , , , , , ] 10 DELTA_POS = { => [1, 0, 0], => [-1, 0, 0], => [0, 1, 0], => [0, -1, 0], => [0, 1, 0], => [0, -1, 0], => [0, 0, 1], => [0, 0, -1] 13 } 14 FULL_NAME = { => , => , => , => , => , => , => , => } 18 HELP_ON_UNIX = [ , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 51 ] 52 HELP_OF_THE_GAME = [ , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 126 ] 127 PLACES = { => [ , , ], nil, [] 132 ], => [ , , ], 136 ], => [ , , ], 140 ], => [ , ], 144 ], => [ , ], 148 ], => [ , ], 152 ], => [ , ], 156 ], => [ , , , , ], 160 ], => [ , , , ], 164 ], => [ , , , ], 168 ], => [ , , , ], 172 ], => [ , , , ], 176 ], => [ , , , , ], nil, [] 181 ], => [ , , , ], [], [, , ] 185 ], => [ , , ], [], [, ] 189 ], => [ , , , , ], [], [, ] 193 ], => [ , , , ], [, ], [, ] 197 ], => [ , , ], [, ], [, ] 201 ], => [ , , , , ], nil, [] 205 ], => [ , , , ], nil, [] 209 ], => [ , , ], [, ], [] 213 ], => [ , , , ], nil, [] 217 ], => [ , , ], 221 ], => [ , ], 225 ], => [ , , , ], 229 ], => [ , , ], 233 ], => [ , , , ], 237 ], => [ , , , , , ], nil, [] 241 ], => [ , , , ], 245 ], => [ , , ], 249 ], => [ , , , , ], nil, [] 253 ], => [ , , ], 257 ], => [ , , ], 261 ], => [ , ], 265 ], => [ , , ], 269 ], => [ , , , ], 273 ], => [ , , , ], nil, [] 277 ], => [ , , ], 281 ], => [ , , ], 285 ], => [ , ], [], [] 290 ], => [ , , ], 294 ], => [ , , , ], [], nil 298 ], => [ , , ], 302 ], => [ , , , ], 306 ], => [ , , , , ], 310 ], => [ , , , , ], nil, [] 314 ], => [ , , , , ], nil, [] 318 ], => [ , , ], nil, [] 322 ], => [ , , ], nil, [] 326 ], => [ , , ], nil, [] 330 ], => [ , , ], nil, [] 334 ], => [ , , , ], nil, [] 338 ], => [ , , , ], nil, [] 342 ], => [ , , , ], nil, [] 346 ], => [ , , , ], nil, [] 350 ], => [ , , , , ], [], nil 354 ], => [ , , ], 358 ], => [ , ], 362 ], => [ , , , , ], nil, [] 366 ], => [ , ], 370 ], => [ , ], [], [] 374 ], => [ , ], nil, [] 378 ], => [ , , , ], [], nil 382 ], => [ , , , ], nil, [, ] 386 ], => [ , , ], nil, [] 390 ], => [ , , ], nil, [] 394 ], => [ , ], nil, [] 398 ], => [ , , , ], 403 ], => [ , , , ], 407 ], => [ , , , ], 411 ], => [ , , , ], 415 ], => [ , , , ], 419 ], => [ , , , , ], 423 ], => [ , , ], 427 ], => [ , , ], 431 ], => [ , , ], 435 ], => [ , , ], 439 ], => [ , , ], 443 ], => [ , , ], 447 ], => [ , ], 451 ], => [ , ], 455 ], => [ , ], 459 ], => [ , ], 463 ], => [ , , , , ], nil, [] 467 ], => [ , , ], nil, [] 472 ], => [ , , , , ], 476 ], => [ , , , ], 480 ], => [ , , , ], 484 ], => [ , , , ], 488 ], => [ , , , ], 492 ], => [ , , ], 496 ], => [ , , ], 500 ], => [ , , ], 504 ], => [ , , ], 508 ], => [ , , ], nil, [] 512 ], 513 } 514 TXT_PLACES = [ , , , , , , , , , , , , , , , , , , 533 "", "", "", "", "", "", "", , , , , , , , , , , , , , , , , , 551 "", "", "", "", "", "", "", , , , , , , , , , , , , , , , , , 569 "", "", "", "", "", "", "", , , , , , , , , , , , , , , , , , ] 589 START = [ , , , 593 ] 594 MESSAGE_ON_UNIX = [ , , , , 599 ] 600 NEW_MESSAGE_ON_UNIX = [ , , , , , , , 608 ] 609 RUBY_SAYS = [ , , , , , 615 ] 616 ITEMS = { => , => , => , => , => , => , => , => , => , => , => , => , => , => , => , => , => , 634 } 635 EXTRAS = { => , => , => , => , => , => , => , => , => , => , => , 647 } Place 653 attr_accessor :name 654 attr_accessor :note 655 attr_accessor :passable 656 attr_accessor :item 657 attr_accessor :extra 658 def initialize(name) 659 @name = name 660 @note, @passable, @item, @extra = PLACES[name] 661 @item = [] if @item.nil? 662 @extra = [] if @extra.nil? 663 end 664 def display(is_where = false) ) ? : $foot_print.include?(@name) $foot_print.push(@name) !is_where @passable.each{ |p| } @item.empty?; print_item(@item + @extra) 678 end 679 end 680 end 681 def try_go(place) 682 place.downcase! 683 1.times do place.length > 1 and !ALL_DIRECTIONS.include?(place) 685 place = place[0] DELTA_POS[place].nil? or !@passable.include?(place) 687 $posx += DELTA_POS[place][0] 688 $posy += DELTA_POS[place][1] 689 $posz += DELTA_POS[place][2] end end 695 def print_possible_direction @passable.each{ |s| } end 700 def try_put(item, target) target == $item.delete() ) increase_process end 709 end 710 end Computer 716 attr_accessor :user_name 717 attr_accessor :password 718 def enter login_name = gets.chomp! password = gets.chomp! 726 if ACCOUNTS.include?([login_name, password]) ) end %Y-%m-%d %H:%M:%S@user_name = login_name 733 @password = password ) end 739 end 740 def display_path(content) 741 width = 20 742 content.each{ |i| width = 40 if i.length > 20 } 743 for i in 0..content.length - 1 * (width - content[i].length) (i - 1) * width == 80 and i < content.length - 1 746 end content.length % (80 / width) != 0 748 end 749 def explore(cur_path) 750 loop do * (77 - cur_path.length), , command, target = gets.chomp.split(' ') 754 case command 755 when "", nil ; system when ; when target = target.nil? ).first ; display_path($file_list[cur_path]) ); display_path($file_list[target]) end target = target.nil? ).first elsif target == ; (cur_path == ) ? () : (return) temp = explore(target) ; end ; show_text(HELP_ON_UNIX) target.nil?; elsif $file_list[cur_path].include?(target) announce_death end $file_list[cur_path].include?(target) 786 case target when ; when ; when ; $np.display ; show_text(HELP_OF_THE_GAME) ; show_text(HELP_ON_UNIX) ; show_text(MESSAGE_ON_UNIX) ; show_text(NEW_MESSAGE_ON_UNIX) @user_name == ; ; show_text(TXT_PLACES) 798 end 799 end end target.nil?; elsif [cur_path, target] == [, ] ) ].delete(target) ].push() $file_list[].push() ].sort!{ |a, b| a.downcase <=> b.downcase } 813 increase_process , ] ; elsif !$place[0][1][0].passable.include?() , , ] ) ; end ; end end 828 end 829 end 830 end show_text(text) 836 count = 0 837 for i in text 838 count += 1 839 if count % 24 == 0 840 cmd = gets.chomp! cmd == end (count + 1) % 24 > 0 845 end 846 end 847 def print_item(list) , item } end 851 def increase_process 852 $process += 1 end 855 def announce_death gets; exit 859 end 860 def do_save , path = gets.downcase.chomp! path == begin ) 866 Marshal.dump($item, file) 867 Marshal.dump($posx, file) 868 Marshal.dump($posy, file) 869 Marshal.dump($posz, file) 870 Marshal.dump($place, file) 871 Marshal.dump($process, file) 872 Marshal.dump($np, file) 873 Marshal.dump($file_list, file) 874 Marshal.dump($foot_print, file) 875 file.close rescue; end 879 end 880 def do_load , path = gets.downcase.chomp! path == begin ) 886 $item = Marshal.load(file) 887 $posx = Marshal.load(file) 888 $posy = Marshal.load(file) 889 $posz = Marshal.load(file) 890 $place = Marshal.load(file) 891 $process = Marshal.load(file) 892 $np = Marshal.load(file) 893 $file_list = Marshal.load(file) 894 $foot_print = Marshal.load(file) 895 file.close rescue; end 899 end 900 def do_exit temp = gets.downcase.chomp! temp.nil? gets; exit 906 end 907 end 908 def match(b) 909 m = b.length 910 b = ' ' + b 911 max, str = 0, "" 912 COMMANDS.each do |a| 913 n = a.length 914 a = ' ' + a 915 f = [0] * (m * n + m) 916 for i in 1..n 917 for j in 1..m 918 f[m * i + j] = (a[i] == b[j]) ? (f[m * (i - 1) + j - 1] + 1) : ([f[m * (i - 1) + j], f[m * i + j - 1]].max) 919 end 920 end 921 max, str = f[m * n + m], a if (f[m * n + m] > max) or (f[m * n + m] == max and a[1] == b[1]) 922 end max < m / 2 end r(place); $place = [ 932 [ ), nil, r(), r(), r(), r(), r(), r()], ), r(), r(), r(), r(), r(), r(), r()], ), r(), r(), r(), r(), r(), r(), r()], ), r(), r(), r(), r(), r(), r(), r()], ), r(), r(), r(), r(), nil, nil, r()], ), r(), r(), r(), r(), nil, nil, r()], ), r(), r(), r(), r()], ), r()] 941 ], [ ), r(), r(), nil, r()], ), r(), r(), r(), r(), r(), r(), r()], ), r(), r(), nil, r(), nil, nil, r()], ), r(), r(), nil, r(), nil, r(), r()], ), r(), r(), r(), r(), nil, r(), r()], ), r(), r(), r(), r(), nil, r(), r()], ), r(), r(), r(), r(), r()], ), r()] 950 ], [ ), r(), r(), r(), r(), r(), r()], ), r(), r(), r(), r(), r(), r(), r()], ), r(), r(), r(), r(), r(), r(), r()], ), r(), r(), r(), r(), r(), r(), r()], ), r(), r(), r(), r(), r(), r(), r()], ), r(), r(), r(), r(), r(), r()], ), r(), r(), r()], ), r(), r(), r(), r()], 959 ], [ ), nil, r(), r(), r(), r()], ), r(), r(), r(), r()], ), r(), r(), r(), r()], ), r(), nil, r(), r(), r(), r()], ), r(), r(), r(), nil, nil, r(), r()], ), r(), r(), r(), r(), r()], ), r(), r(), r(), r(), r()], ), nil, nil, r()], 968 ], 969 ] 970 $item = [] 971 $process = 0 972 $foot_print = [] 973 $posx = $posy = $posz = 0 974 $unix = Computer.new 975 $file_list = { => [, , , , ], => [, , , , ], => [, , ], => [, , ], => [], => [], 982 } show_text(START) 988 loop do $np = $place[$posz][$posx][$posy] 991 $np.display command, target, a3, a4 = gets.downcase.split(' ') 994 case command when ; $np.display(true) ; show_text(HELP_OF_THE_GAME) , target.nil? print_item($item + $np.item + $np.extra) 1004 end , ITEMS[target], elsif $np.extra.include?(target); , EXTRAS[target], ; end , , target.nil? print_item($np.item) 1015 end 1016 elsif $np.item.include?(target) 1017 $np.item.delete(target) 1018 $item.push(target) elsif $np.extra.include?(target); ; end , target.nil? print_item($item) 1029 end 1030 elsif $item.include?(target) 1031 $item.delete(target) 1032 $np.item.push(target) ; end ; target.nil? ? $np.print_possible_direction : $np.try_go(target) target.nil? print_item($item) 1043 end 1044 elsif $item.include?(target) 1045 if !a4.nil? 1046 if $np.extra.include?(a4); $np.try_put(target, a4) end $np.extra.empty?; print_item($np.extra) 1054 end 1055 end end $np.name.include?(); $unix.enter ); $unix.enter end ; do_save ; do_load , , ; do_exit end 1068 end

网友评论
<