score

package
v0.0.0-...-75e2e84 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2014 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

This package will keep the score of territories.

There are two parallel tables of scores, pointing to the same data. One map is used for efficiently mapping from uid to a pointer to the score data, and one linear table is used to traverse the complete list for updates and saves. The reason for this is that there will be a lot of updates of scores, which has to be very efficient. Every such access have to lock the map. Whenever the whole list is traversed periodically, the map must not be locked as it takes some time.

Note that the score entry itself is not locked. That means that there is a small chance that data can be corrupted. The worst case is a failed update, which is acceptable.

The "BalanceScore" is similar to the total score, but it will decay towards a value greater than 0.

Index

Constants

View Source
const (
	ConfigScoreUpdatePeriod = 1e11                // The perdiod between updates of the database
	ConfigScoreHalfLife     = time.Hour * 24 * 30 // The half life off the score decay
	ConfigScoreBalHalfLife  = time.Hour * 24 * 5  // The half life off the scoreBalance decay
	ConfigScoreBalanceZero  = 10                  // The value that ScoreBalance will decay to, which is not 0
	ConfigHandicapLimit     = 10                  // Any more chunks than this will impose a handicap on the score
)

Variables

This section is empty.

Functions

func Add

func Add(uid uint32, points float64)

Add points to the Score and BalanceScore.

func Close

func Close() (ret bool)

Close the update process, and return the status

func Initialize

func Initialize(uid uint32)

Trig loading of a player

func Pay

func Pay(uid uint32, cost float64) bool

Pay 'cost' for a reward, and return true if the ScoreBalance was enough.

func Report

func Report(wr io.Writer)

Debug function

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL