Class: TrialUpdater

Inherits:
Object
  • Object
show all
Defined in:
app/models/trial_updater.rb

Overview

This class is updater of Trial.

Constant Summary

NORMAL_END =
0
ABNORMAL_END =
-1
FLAG_CELL_OFFSET_SIZE_RATE =
0.2

Class Method Summary (collapse)

Class Method Details

+ (Object) execute

execute trial updating.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/trial_updater.rb', line 18

def self.execute
  Trial.find_all_by_occurred_at(nil).each do |trial|
    prepare(trial)
    turn_num = 1
    until (trial.guard_defeated? or trial.intruder_defeated?) and 2 < turn_num
    #5.times do |turn_num|
      squad_setup(trial)
      #break if trial.active_squads.blank?
      p "-- proceed_turn " + (turn_num).to_s + " --"
      proceed_turn(trial)
      turn_num += 1
      break if turn_num > 100
    end
  end
end

+ (Object) execute_debug

Note:

TrialDeleter is called before executing.

execute trial updating.



10
11
12
13
14
15
# File 'app/models/trial_updater.rb', line 10

def self.execute_debug
  Trial.all.each do |trial|
    TrialDeleter.execute(trial.id)
  end
  execute
end