feat: add unlock system with 3 unlockable contents

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-25 16:06:40 +09:00
parent 253d1f80d3
commit 8f899a5afd
2 changed files with 94 additions and 0 deletions

47
store/unlocks_test.go Normal file
View File

@@ -0,0 +1,47 @@
package store
import (
"testing"
)
func TestUnlockContent(t *testing.T) {
dir := t.TempDir()
db, err := Open(dir + "/test_unlocks.db")
if err != nil {
t.Fatal(err)
}
defer db.Close()
// Initially not unlocked
if db.IsUnlocked("fp1", "fifth_class") {
t.Error("should not be unlocked initially")
}
// Unlock returns true for new unlock
newlyUnlocked, err := db.UnlockContent("fp1", "fifth_class")
if err != nil {
t.Fatal(err)
}
if !newlyUnlocked {
t.Error("should be newly unlocked")
}
// Now it should be unlocked
if !db.IsUnlocked("fp1", "fifth_class") {
t.Error("should be unlocked after UnlockContent")
}
// Second unlock returns false (already unlocked)
newlyUnlocked2, err := db.UnlockContent("fp1", "fifth_class")
if err != nil {
t.Fatal(err)
}
if newlyUnlocked2 {
t.Error("should not be newly unlocked on second call")
}
// Different player still not unlocked
if db.IsUnlocked("fp2", "fifth_class") {
t.Error("different player should not have unlock")
}
}