Example #1
0
//玩家属性变化
func (ts *TaskSystem) OnPropertyChange(self datatype.Entityer, prop string, old interface{}) int {
	if !entity.IsPlayer(self) {
		return 1
	}
	player := self.(*entity.Player)

	switch prop {
	}

	val, _ := player.Get(prop)

	row := player.TaskPropRecord_r.FindProperty(prop)
	for row != -1 {
		taskid, _, needval, _ := player.TaskPropRecord_r.GetRow(row)
		res, err := datatype.CompareNumber(needval, val)
		if err != nil {
			log.LogError(err)
		}

		if res <= 0 { //已经满条件,删除这条记录
			player.TaskPropRecord_r.Del(row)
			task := ts.GetTask(taskid)
			if task != nil {
				ts.TestComplete(player, task)
			}
			row--
		}

		row = player.TaskPropRecord_r.FindNextProperty(prop, row)
	}
	return 1
}
Example #2
0
func (tb *TaskBase) AddPropRecord(player *entity.Player, taskid string, property string, needval string) bool {
	if property == "" {
		return true
	}

	val, err := player.Get(property) //没有这个属性
	if err != nil {
		log.LogError("task need property not found, ", property)
		return true
	}

	res, err := datatype.CompareNumber(needval, val)
	if err != nil {
		log.LogError(err)
		return true
	}

	row := player.TaskPropRecord_r.FindID(taskid) //表中是否已经有记录
	for row != -1 {
		_, prop, _, _ := player.TaskPropRecord_r.GetRow(row)
		if prop == property {
			if res <= 0 { //已经满条件,删除这条记录
				player.TaskPropRecord_r.Del(row)
				return true
			}
			return false
		}
		row = player.TaskRecord_r.FindNextID(taskid, row)
	}

	if res <= 0 {
		return true
	}

	player.TaskPropRecord_r.AddRowValue(-1, taskid, property, needval)
	return false
}