赞 | 50 |
VIP | 429 |
好人卡 | 14 |
积分 | 8 |
经验 | 146370 |
最后登录 | 2022-6-27 |
在线时间 | 3431 小时 |
Lv2.观梦者 会吐槽的画师
- 梦石
- 0
- 星屑
- 782
- 在线时间
- 3431 小时
- 注册时间
- 2011-6-10
- 帖子
- 6535
|
铃仙·优昙华院·因幡 发表于 2013-5-28 13:54
其实随机就好的办法是这样的:这样就很好的可以复制重复选择, 还有胡乱选择了. ...
如果按这样运行的话原来的脚本应该修改哪些? 润的脚本转型能力太弱……- #==============================================================================
- # ■ Scene_Subject
- #------------------------------------------------------------------------------
- # 考试类。
- #==============================================================================
- class Scene_Subject < Scene_Base
-
- def initialize(subject_index)
- @subject = [];
- @index_subject = 0;
- File.open("Subject#{subject_index}.txt","r") do |fp|
- @subject = fp.readlines;
- end
- @subject.each_index do |index|
-
- @subject[index].chomp!
- @subject[index] = @subject[index].split("||");
- end
- @max_index = @subject.size; # 题目最大数量
- @type = 0; # 抽题类型
- @answer = []; # 答题卡
- @title_index = []; # 剩下的题目序号
- for i in 0..@max_index
- @title_index << i;
- end
- @subject_subindex = -1; # 题号
- end
- #--------------------------------------------------------------------------
- # ● 开始处理
- # Subject_index : 考题库
- # type : 抽题类型, 0 按顺序, 1 随机
- #--------------------------------------------------------------------------
- def start
- create_menu_background
- next_subject
- end
- #--------------------------------------------------------------------------
- # ● 更新
- #--------------------------------------------------------------------------
- def update
- super
- update_menu_background
- update_subject_window
- end
- #--------------------------------------------------------------------------
- # ● 更新考卷
- #--------------------------------------------------------------------------
- def update_subject_window
- @subject_window.update
- if Input.trigger?(Input::C)
- @answer.pushAnswer(@subject_subindex, @subject_window.index); # 填写答题卡, [题目序号, 答案]
- next_subject; # 下一题
- end
- end
- #--------------------------------------------------------------------------
- # ● 计算得分
- #--------------------------------------------------------------------------
- def hand_paper
- code = 0; # 分数
- @answer.each do |answers|
- right_answer = @subject[answers[0]][1];
- code += 1 if right_answer.to_i == answers[1] + 1;
- end
- $game_player.result = code == @answer.size ? 100.0 : code.to_f / @answer.size * 100
- $scene = Scene_Map.new
- end
- #--------------------------------------------------------------------------
- # ● 结束处理
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_menu_background
- @subject_window.dispose;
- end
- #--------------------------------------------------------------------------
- # ● 下一题
- #--------------------------------------------------------------------------
- def next_subject
- @index_subject += 1;
- if @index_subject < 2
- case @type
- when 0
- @subject_subindex += 1;
- end
- @subject_window.dispose if @subject_window;
- @subject_window = Window_Subject.new(@subject[@subject_subindex]);
- else
- hand_paper
- end
- end
- end
复制代码 |
|