Skip to content
This repository
tree: 71fd6f40f1
Fetching contributors…

Cannot retrieve contributors at this time

file 63 lines (56 sloc) 2.027 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
require 'dm-migrations'
require 'dm-migrations/migration_runner'

class JunkGame
    include DataMapper::Resource
    belongs_to :server
    belongs_to :user, :required => false

    property :id, Serial
    property :name, String
    property :deaths, Integer
    property :deathlev, Integer
    property :realtime, Integer
    property :turns, Integer
    property :birthdate, String
    property :conduct, String
    property :nconducts, Integer,
     :default => lambda { |r, p| (Integer r.conduct).to_s(2).count("1") } # count the number of bits set in conduct
    property :role, String
    property :deathdnum, Integer
    property :gender, String
    property :gender0, String
    property :uid, Integer
    property :maxhp, Integer
    property :points, Integer
    property :deathdate, String
    property :version, String
    property :align, String
    property :align0, String
    property :starttime, Integer
    property :endtime, Integer
    property :achieve, String
    property :nachieves, Integer
    property :hp, Integer
    property :maxlvl, Integer
    property :death, String
    property :race, String
    property :flags, String
    property :ascended, Boolean,
     :default => lambda { |r, p| r.death.start_with? "ascended" or r.death == "escaped (with amulet)" or r.death.start_with? "defied" }

    before :valid?, :trim_death
    # we need to limit the size of deaths
    def trim_death(context = :default)
       self.death = death[0,255]
    end

    # acehack/unnethack-specific properties
    property :carried, String
    property :event, String

    # acehack/unnethack-specific properties
    property :deathdname, String
    property :dlev_name, String
    property :elbereths, Integer, :default => -1

    property :xplevel, Integer, :default => 0
    property :exp, Integer, :default => 0
    property :mode, String

    # nethack4-specific properties
    property :charname, String
end
Something went wrong with that request. Please try again.