Module: Battle::SceneMock

Defined in:
scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 BattleSceneMock.rb

Overview

Module responsive of mocking the battle scene so nothing happen on the reality

How to use:

scene = @scene.clone
scene.extend(SceneMock)

Note: super inside this script might call the original function

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#mock_actionsArray<Hash> (readonly)

Get the mock actions

Returns:

  • (Array<Hash>)


27
28
29
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 BattleSceneMock.rb', line 27

def mock_actions
  @mock_actions
end

Class Method Details

.extended(mod)

Method called when a scene gets mocked (through extend)

Parameters:



13
14
15
16
17
18
19
20
21
22
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 BattleSceneMock.rb', line 13

def extended(mod)
  mod.instance_variable_set(:@battle_info, Marshal.load(Marshal.dump(mod.battle_info)))
  mod.instance_variable_set(:@viewport, nil)
  mod.instance_variable_set(:@visual, mod.visual.clone)
  mod.visual.instance_variable_set(:@scene, mod)
  mod.visual.extend(VisualMock)
  mod.instance_variable_set(:@logic, mod.logic.clone)
  mod.logic.instance_variable_set(:@scene, mod)
  mod.logic.extend(LogicMock)
end

Instance Method Details

#display_message



50
51
52
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 BattleSceneMock.rb', line 50

def display_message(*)
  return 0
end

#display_message_and_wait



46
47
48
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 BattleSceneMock.rb', line 46

def display_message_and_wait(*)
  return 0
end

#message_window



41
42
43
44
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 BattleSceneMock.rb', line 41

def message_window
  log_error("message_window called by #{caller[0]}")
  return nil
end

#mock_clear_actions

Function that clears the mock actions



37
38
39
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 BattleSceneMock.rb', line 37

def mock_clear_actions
  @mock_actions = []
end

#mock_push_action(data)

Function that pushes an action to the action array (thing that happens during execution)

Parameters:

  • data (Hash)


31
32
33
34
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 BattleSceneMock.rb', line 31

def mock_push_action(data)
  @mock_actions ||= []
  @mock_actions << data
end

#update



54
55
56
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 BattleSceneMock.rb', line 54

def update
  return nil
end