about summary refs log tree commit diff
path: root/src/challenge.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/challenge.go')
-rw-r--r--src/challenge.go24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/challenge.go b/src/challenge.go
index 991e4e5..1d0a210 100644
--- a/src/challenge.go
+++ b/src/challenge.go
@@ -1,10 +1,12 @@
 package main
 
+import "time"
+
 type Challenge struct {
 	Name string
 	Description string
 	Flag string // this should never leave the server
-	FoundFlag bool
+	FoundFlag time.Time
 	FlagTries uint
 	Container string // this could, but is not required as well
 	Category string
@@ -15,18 +17,34 @@ type StrippedChallenge struct {
 	Name string `json:"name"`
 	Description string `json:"description"`
 	Category string `json:"category"`
-	FoundFlag bool `json:"foundFlag"`
+	FoundFlag int64 `json:"foundFlag"`
+	FlagTries uint `json:"flagTries"`
 	ContainsLaunchable bool `json:"ContainsLaunchable"`
 	IPAddress string `json:"IPAddress"`
 }
 
+type StatsStrippedChallenge struct {
+	Name string `json:"name"`
+	FoundFlag int64 `json:"foundFlag"`
+	FlagTries uint `json:"flagTries"`
+}
+
 func stripChallenge(c Challenge) (StrippedChallenge) {
 	return StrippedChallenge{
 		Name: c.Name,
 		Description: c.Description,
 		Category: c.Category,
-		FoundFlag: c.FoundFlag,
+		FoundFlag: c.FoundFlag.Unix(),
+		FlagTries: c.FlagTries,
 		ContainsLaunchable: c.Container != "",
 		IPAddress: getAddressForChallengeContainer(c.Container),
 	}
 }
+
+func stripChallengeForStatistics(c Challenge) (StatsStrippedChallenge) {
+	return StatsStrippedChallenge{
+		Name: c.Name,
+		FoundFlag: c.FoundFlag.Unix(),
+		FlagTries: c.FlagTries,
+	}
+}