Class: Osu::DB::Score

Inherits:
Object
  • Object
show all
Defined in:
lib/osu-db/score.rb

Overview

Structure of scores.db

  • str[rdoc-ref:StringIO#read_str] #beatmapcode: digest of Beatmap

  • str[rdoc-ref:StringIO#read_str] #user: username

  • str[rdoc-ref:StringIO#read_str] #scorecode: digest of Score

  • int[rdoc-ref:StringIO#read_int] #x300, #x100, #x50: the number of 300s, 100s and 50s

  • int[rdoc-ref:StringIO#read_int] #geki, #katsu, #miss: these attributes may have different meaning is special modes

  • int[rdoc-ref:StringIO#read_int] #score, #combo: score and max combo

  • bool[rdoc-ref:StringIO#read_bool] #perfect?: full combo or not

  • bitset[rdoc-ref:StringIO#read_int] #mods: mods or game modifiers, see Mod and Mods

  • time[rdoc-ref:StringIO#read_time] #datetime: played time

  • 0xFFFFFFFF

  • int[rdoc-ref:StringIO#read_int] #scoreid: score id

Direct Known Subclasses

CTBScore, ManiaScore, OsuScore, TaikoScore

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(game_mode, ios = nil) ⇒ Score

Returns a new instance of Score.



35
36
37
38
# File 'lib/osu-db/score.rb', line 35

def initialize(game_mode, ios = nil)
  @game_mode = game_mode
  load(ios) if ios
end

Instance Attribute Details

#beatmapcodeObject (readonly)

Returns the value of attribute beatmapcode.



27
28
29
# File 'lib/osu-db/score.rb', line 27

def beatmapcode
  @beatmapcode
end

#comboObject (readonly)

Returns the value of attribute combo.



27
28
29
# File 'lib/osu-db/score.rb', line 27

def combo
  @combo
end

#datetimeObject (readonly)

Returns the value of attribute datetime.



27
28
29
# File 'lib/osu-db/score.rb', line 27

def datetime
  @datetime
end

#dummyObject (readonly)

Returns the value of attribute dummy.



27
28
29
# File 'lib/osu-db/score.rb', line 27

def dummy
  @dummy
end

#game_modeObject (readonly)

Returns the value of attribute game_mode.



27
28
29
# File 'lib/osu-db/score.rb', line 27

def game_mode
  @game_mode
end

#gekiObject (readonly)

Returns the value of attribute geki.



27
28
29
# File 'lib/osu-db/score.rb', line 27

def geki
  @geki
end

#katsuObject (readonly)

Returns the value of attribute katsu.



27
28
29
# File 'lib/osu-db/score.rb', line 27

def katsu
  @katsu
end

#missObject (readonly)

Returns the value of attribute miss.



27
28
29
# File 'lib/osu-db/score.rb', line 27

def miss
  @miss
end

#modsObject (readonly)

Returns the value of attribute mods.



27
28
29
# File 'lib/osu-db/score.rb', line 27

def mods
  @mods
end

#perfectObject (readonly) Also known as: perfect?, full_combo

Returns the value of attribute perfect.



27
28
29
# File 'lib/osu-db/score.rb', line 27

def perfect
  @perfect
end

#scoreObject (readonly)

Returns the value of attribute score.



27
28
29
# File 'lib/osu-db/score.rb', line 27

def score
  @score
end

#scorecodeObject (readonly)

Returns the value of attribute scorecode.



27
28
29
# File 'lib/osu-db/score.rb', line 27

def scorecode
  @scorecode
end

#scoreidObject (readonly)

Returns the value of attribute scoreid.



27
28
29
# File 'lib/osu-db/score.rb', line 27

def scoreid
  @scoreid
end

#userObject (readonly)

Returns the value of attribute user.



27
28
29
# File 'lib/osu-db/score.rb', line 27

def user
  @user
end

#x100Object (readonly)

Returns the value of attribute x100.



27
28
29
# File 'lib/osu-db/score.rb', line 27

def x100
  @x100
end

#x300Object (readonly)

Returns the value of attribute x300.



27
28
29
# File 'lib/osu-db/score.rb', line 27

def x300
  @x300
end

#x50Object (readonly)

Returns the value of attribute x50.



27
28
29
# File 'lib/osu-db/score.rb', line 27

def x50
  @x50
end

Instance Method Details

#accuracyObject

Raises:

  • (NotImplementedError)


44
45
46
# File 'lib/osu-db/score.rb', line 44

def accuracy
  raise NotImplementedError
end

#gradeObject

Raises:

  • (NotImplementedError)


48
49
50
# File 'lib/osu-db/score.rb', line 48

def grade
  raise NotImplementedError
end

#hitsObject

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/osu-db/score.rb', line 40

def hits
  raise NotImplementedError
end

#load(ios) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/osu-db/score.rb', line 52

def load(ios)
  ios.read_version

  @beatmapcode = ios.read_str
  @user = ios.read_str

  @scorecode = ios.read_str
  @x300, @x100, @x50, @geki, @katsu, @miss = *ios.unpack(12, 'v6')
  @score = ios.read_int(4)
  @combo = ios.read_int(2)
  @perfect = ios.read_bool
  @mods = Mods.new(ios.read_int(5))
  @datetime = ios.read_time
  @dummy = ios.read_int(4)              # TODO: always = 0xFFFFFFFF
  @scoreid = ios.read_int(4)
end