Example #1
0
File: being.go Project: beoran/woe
// Save a being to a sitef record.
func (me *Being) SaveSitef(rec *sitef.Record) (err error) {
	me.Entity.SaveSitef(rec)
	rec.PutInt("level", me.Level)

	if me.Gender != nil {
		rec.Put("gender", me.Gender.ID)
	}

	if me.Job != nil {
		rec.Put("job", me.Job.ID)
	}

	if me.Kin != nil {
		rec.Put("kin", me.Kin.ID)
	}

	me.Talents.SaveSitef(rec)
	me.Vitals.SaveSitef(rec)
	me.EquipmentValues.SaveSitef(rec)
	me.Aptitudes.SaveSitef(rec)
	me.Inventory.SaveSitef(rec)

	if me.Room != nil {
		rec.Put("room", me.Room.ID)
	}

	return nil
}
Example #2
0
File: being.go Project: beoran/woe
// Load a being from a sitef record.
func (me *Being) LoadSitef(rec sitef.Record) (err error) {
	me.Entity.LoadSitef(rec)

	me.Level = rec.GetIntDefault("level", 1)

	me.Gender = EntitylikeToGender(GenderEntityList.FindID(rec.Get("gender")))
	me.Job = EntitylikeToJob(JobEntityList.FindID(rec.Get("job")))
	me.Kin = EntitylikeToKin(KinEntityList.FindID(rec.Get("kin")))

	me.Talents.LoadSitef(rec)
	me.Vitals.LoadSitef(rec)
	me.EquipmentValues.LoadSitef(rec)
	me.Aptitudes.LoadSitef(rec)
	me.Inventory.LoadSitef(rec)

	if rec.Get("room") != "" {
		var err error
		me.Room, err = DefaultWorld.LoadRoom(rec.Get("room"))
		if err != nil {
			monolog.WriteError(err)
			return err
		}
	}
	return nil
}
Example #3
0
File: item.go Project: beoran/woe
func (me *Equipment) SaveSitef(rec sitef.Record) (err error) {
	for k, v := range me.Equipped {
		if v != nil {
			key := fmt.Sprintf("equipment[%s]", k)
			rec.Put(key, v.ID)
		}
	}
	return nil
}
Example #4
0
File: being.go Project: beoran/woe
func (me *Aptitudes) SaveSitef(rec *sitef.Record) (err error) {
	nskills := len(me.Skills)
	rec.PutInt("skills", nskills)
	for i := 0; i < nskills; i++ {
		rec.PutArrayIndex("skills", i, me.Skills[i].skill.ID)
	}

	return nil
}
Example #5
0
// Load a character from a sitef record.
func (me *Character) LoadSirec(rec sitef.Record) (err error) {
	aname := rec.Get("accountname")
	account, err := DefaultWorld.LoadAccount(aname)
	if err != nil {
		return err
	}
	me.Account = account
	me.Being.LoadSitef(rec)
	return nil
}
Example #6
0
File: item.go Project: beoran/woe
func (me *Equipment) LoadSitef(rec sitef.Record, world *World, dirname string) (err error) {
	for k := range EquipWhereList {
		key := fmt.Sprintf("equipment[%s]", k)
		val, ok := rec.MayGet(key)
		if ok {
			item, err := world.LoadItem(val)
			if item != nil && err == nil {
				me.Equipped[EquipWhere(k)] = item
			}
		}
	}
	return nil
}
Example #7
0
File: entity.go Project: beoran/woe
// Load an entity from a sitef record.
func (me *Entity) LoadSitef(rec sitef.Record) (err error) {
	me.ID = rec.Get("id")
	me.Name = rec.Get("name")
	me.Short = rec.Get("short")
	me.Long = rec.Get("long")
	return nil
}
Example #8
0
File: entity.go Project: beoran/woe
// Save an entity to a sitef record.
func (me *Entity) SaveSitef(rec *sitef.Record) (err error) {
	rec.Put("id", me.ID)
	rec.Put("name", me.Name)
	rec.Put("short", me.Short)
	rec.Put("long", me.Long)
	return nil
}
Example #9
0
// Save a character into a a sitef record.
func (me *Character) SaveSirec(rec *sitef.Record) (err error) {
	rec.Put("accountname", me.Account.Name)
	me.Being.SaveSitef(rec)
	return nil
}
Example #10
0
File: being.go Project: beoran/woe
func (me *EquipmentValues) LoadSitef(rec sitef.Record) (err error) {
	rec.GetStruct("", me)
	return nil
}
Example #11
0
File: being.go Project: beoran/woe
func (me *Vitals) LoadSitef(rec sitef.Record) (err error) {
	rec.GetStruct("", me)
	return nil
}
Example #12
0
File: being.go Project: beoran/woe
func (me *EquipmentValues) SaveSitef(rec *sitef.Record) (err error) {
	rec.PutStruct("", *me)
	return nil
}
Example #13
0
File: being.go Project: beoran/woe
func (me *Vitals) SaveSitef(rec *sitef.Record) (err error) {
	rec.PutStruct("", *me)
	return nil
}