Add global score coefficient

This commit is contained in:
nemunaire 2021-09-06 11:58:03 +02:00
parent cd73622cae
commit 105034ec8c
7 changed files with 20 additions and 9 deletions

View file

@ -37,7 +37,7 @@ func ExportTeams(includeMembers bool) (ret map[string]ExportedTeam, err error) {
team.Name,
fmt.Sprintf("#%06x", team.Color),
rank[team.Id],
points,
points * GlobalScoreCoefficient,
members,
team.ExternalId,
}

View file

@ -95,7 +95,7 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
ret.Name = t.Name
ret.Id = t.Id
points, _ := t.GetPoints()
ret.Points = int64(points)
ret.Points = int64(float64(points) * GlobalScoreCoefficient)
if members, err := t.GetMembers(); err == nil {
ret.Members = members
}
@ -124,7 +124,7 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
exercice.Finished = strings.Replace(e.Finished, "$FILES$", FilesDir, -1)
exercice.VideoURI = e.VideoURI
exercice.TotalTries = e.TriedCount()
exercice.Gain = int(float64(e.Gain) * e.Coefficient)
exercice.Gain = int(float64(e.Gain) * e.Coefficient * GlobalScoreCoefficient)
} else {
solved, stime := t.HasSolved(e)
exercice.SolvedTime = &stime
@ -146,7 +146,7 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
}
if gain, err := e.EstimateGain(*t, solved); err == nil {
exercice.Gain = int(gain)
exercice.Gain = int(gain * GlobalScoreCoefficient)
} else {
log.Println("ERROR during gain estimation:", err)
}
@ -175,9 +175,9 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
} else {
for _, h := range hints {
if t == nil || HintCoefficient < 0 || t.HasHint(h) {
exercice.Hints = append(exercice.Hints, myTeamHint{h.Id, h.Title, h.Content, h.File, h.Cost})
exercice.Hints = append(exercice.Hints, myTeamHint{h.Id, h.Title, h.Content, h.File, int64(float64(h.Cost) * GlobalScoreCoefficient)})
} else if t.CanSeeHint(h) {
exercice.Hints = append(exercice.Hints, myTeamHint{h.Id, h.Title, "", "", h.Cost})
exercice.Hints = append(exercice.Hints, myTeamHint{h.Id, h.Title, "", "", int64(float64(h.Cost) * GlobalScoreCoefficient)})
}
}
}
@ -241,7 +241,7 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
flag.Choices[c.Value] = c.Label
}
} else {
flag.ChoicesCost = k.ChoicesCost
flag.ChoicesCost = int64(float64(k.ChoicesCost) * GlobalScoreCoefficient)
}
}

View file

@ -6,6 +6,8 @@ import (
"strings"
)
var GlobalScoreCoefficient float64 = 1
// exportedExercice is a structure representing a challenge, as exposed to players.
type exportedExercice struct {
Title string `json:"title"`
@ -50,7 +52,7 @@ func ExportThemes() (interface{}, error) {
exercice.Headline,
exercice.URLId,
tags,
exercice.Gain,
int64(float64(exercice.Gain) * GlobalScoreCoefficient),
exercice.Coefficient,
exercice.SolvedCount(),
exercice.TriedTeamCount(),