Class: RubyGS::SaveFile

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_gs/save_file_reader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(save, filename, gs) ⇒ SaveFile

Returns a new instance of SaveFile.



43
44
45
# File 'lib/ruby_gs/save_file_reader.rb', line 43

def initialize save, filename, gs
  @save, @gs, @filename = save, gs, filename
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



79
80
81
# File 'lib/ruby_gs/save_file_reader.rb', line 79

def method_missing(sym, *args, &block)
  @save.send(sym, *args, &block)
end

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



41
42
43
# File 'lib/ruby_gs/save_file_reader.rb', line 41

def filename
  @filename
end

#gsObject

Returns the value of attribute gs.



41
42
43
# File 'lib/ruby_gs/save_file_reader.rb', line 41

def gs
  @gs
end

#saveObject

Returns the value of attribute save.



41
42
43
# File 'lib/ruby_gs/save_file_reader.rb', line 41

def save
  @save
end

Instance Method Details

#hatch_team_egg(slot) ⇒ Object



73
74
75
76
77
# File 'lib/ruby_gs/save_file_reader.rb', line 73

def hatch_team_egg slot
  raise "slot index must be between 0 and 5, inclusive" if !(0..5).include? slot
  @save.team.species_list[slot].assign  @save.team.pokemon[slot].species
    @save.team.pokemon[slot].happiness = 20
end

#set_team_egg(slot, egg_cycles) ⇒ Object



67
68
69
70
71
# File 'lib/ruby_gs/save_file_reader.rb', line 67

def set_team_egg slot, egg_cycles
  raise "slot index must be between 0 and 5, inclusive" if !(0..5).include? slot
  @save.team.species_list[slot] = 0xFD
    @save.team.pokemon[slot].happiness = egg_cycles
end

#set_team_species(slot, species) ⇒ Object



61
62
63
64
65
# File 'lib/ruby_gs/save_file_reader.rb', line 61

def set_team_species slot, species
  return if !(0..5).include? slot
  @save.team.pokemon[slot].species.assign species
  @save.team.species_list[slot].assign species
end

#verify_checksumsObject



47
48
49
50
51
52
53
54
# File 'lib/ruby_gs/save_file_reader.rb', line 47

def verify_checksums
  case gs
  when true
    return verify_gs_checksums
  when false
    return verify_c_checksums
  end 
end

#write(loc = @filename) ⇒ Object



56
57
58
59
# File 'lib/ruby_gs/save_file_reader.rb', line 56

def write(loc = @filename)
  @save.write(File.open(loc, "wb"))
  verify_checksums
end