Add global score coefficient
This commit is contained in:
parent
cd73622cae
commit
105034ec8c
|
@ -60,6 +60,7 @@ func ApplySettings(config settings.FICSettings) {
|
|||
fic.SubmissionCostBase = config.SubmissionCostBase
|
||||
fic.HintCoefficient = config.HintCurCoefficient
|
||||
fic.WChoiceCoefficient = config.WChoiceCurCoefficient
|
||||
fic.GlobalScoreCoefficient = config.GlobalScoreCoefficient
|
||||
fic.SubmissionCostBase = config.SubmissionCostBase
|
||||
fic.SubmissionUniqueness = config.SubmissionUniqueness
|
||||
fic.CountOnlyNotGoodTries = config.CountOnlyNotGoodTries
|
||||
|
@ -74,6 +75,7 @@ func ResetSettings() error {
|
|||
ExerciceCurCoefficient: 1,
|
||||
HintCurCoefficient: 1,
|
||||
WChoiceCurCoefficient: 1,
|
||||
GlobalScoreCoefficient: 1,
|
||||
AllowRegistration: false,
|
||||
CanJoinTeam: false,
|
||||
DenyTeamCreation: false,
|
||||
|
|
|
@ -60,7 +60,11 @@
|
|||
<hr>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="exercicecurcoefficient" class="col-sm-3 col-form-label col-form-label-sm"><strong>Coefficients</strong></label>
|
||||
<label for="globalScoreCoefficient" class="col-sm-2 col-form-label col-form-label-sm"><strong>Coefficients</strong></label>
|
||||
<div class="col-sm-1">
|
||||
<input type="text" class="form-control form-control-sm" id="globalScoreCoefficient" ng-model="config.globalScoreCoefficient" float>
|
||||
</div>
|
||||
|
||||
<label for="hintcoefficient" class="col-sm-2 col-form-label col-form-label-sm text-right">incides</label>
|
||||
<div class="col-sm-1">
|
||||
<input type="text" class="form-control form-control-sm" id="hintcoefficient" ng-model="config.hintCurrentCoefficient" float>
|
||||
|
|
|
@ -83,6 +83,7 @@ func reloadSettings(config settings.FICSettings) {
|
|||
fic.FirstBlood = config.FirstBlood
|
||||
fic.SubmissionCostBase = config.SubmissionCostBase
|
||||
fic.SubmissionUniqueness = config.SubmissionUniqueness
|
||||
fic.GlobalScoreCoefficient = config.GlobalScoreCoefficient
|
||||
fic.CountOnlyNotGoodTries = config.CountOnlyNotGoodTries
|
||||
|
||||
if !skipInitialGeneration {
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -48,6 +48,8 @@ type FICSettings struct {
|
|||
HintCurCoefficient float64 `json:"hintCurrentCoefficient"`
|
||||
// WChoiceCurCoefficient is the current coefficient applied to wanted choices.
|
||||
WChoiceCurCoefficient float64 `json:"wchoiceCurrentCoefficient"`
|
||||
// GlobalScoreCoefficient is a coefficient to apply on display scores, not considered bonus.
|
||||
GlobalScoreCoefficient float64 `json:"globalScoreCoefficient"`
|
||||
|
||||
// AllowRegistration permits unregistered Team to register themselves.
|
||||
AllowRegistration bool `json:"allowRegistration,omitempty"`
|
||||
|
|
Loading…
Reference in New Issue