Class: CARPS::SessionConfig

Inherits:
UserConfig show all
Defined in:
lib/carps/service/start/config.rb

Overview

A configuration file for games which keeps track of sessions, and the mod’s saved state

Direct Known Subclasses

DM::GameConfig, Player::GameConfig

Instance Method Summary collapse

Methods inherited from UserConfig

load

Methods inherited from YamlConfig

#fail_hard, #read

Constructor Details

#initialize(session, filename) ⇒ SessionConfig

Create from session ID and filename



27
28
29
30
# File 'lib/carps/service/start/config.rb', line 27

def initialize session, filename
   @session = session
   @filename = filename
end

Instance Method Details

#load_modObject

Load the mod



52
53
54
# File 'lib/carps/service/start/config.rb', line 52

def load_mod
   @save
end

#parse_yaml(conf) ⇒ Object



37
38
39
40
41
# File 'lib/carps/service/start/config.rb', line 37

def parse_yaml conf
   @filename = read_conf conf, "filename"
   @session = read_conf conf, "session"
   @save = conf["save"]
end

#register_session(manager) ⇒ Object

Set the session used by a session manager



33
34
35
# File 'lib/carps/service/start/config.rb', line 33

def register_session manager
   manager.session = @session
end

#saveObject

Save this game



57
58
59
# File 'lib/carps/service/start/config.rb', line 57

def save
   save_file "games/" + @filename + ".yaml"
end

#save_mod(mod) ⇒ Object

Save the mod

Also saves the file



46
47
48
49
# File 'lib/carps/service/start/config.rb', line 46

def save_mod mod 
   @save = mod
   save 
end