Skip to content

Commit

Permalink
Tweak some minor scoring bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
iangray001 committed Dec 10, 2023
1 parent 7c59b95 commit 4025be3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
26 changes: 23 additions & 3 deletions Quiz Server/Quiz Server/NumbersScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class NumbersScene: SKScene {
lastDist = teamDistances[teNo].distance
}
} else {
if teNo > teamDistances.count / 2 && teamDistances[teNo].distance != teamDistances[teNo-1].distance {
if teNo > (teamDistances.count / 2 - 1) && teamDistances[teNo].distance != teamDistances[teNo-1].distance {
break
}
}
Expand Down Expand Up @@ -378,9 +378,29 @@ class NumbersScene: SKScene {
teamGuess(teamid : 4, guess : 40)
teamGuess(teamid : 5, guess : 50)
teamGuess(teamid : 6, guess : 50)
teamGuess(teamid : 7, guess : 50)
teamGuess(teamid : 7, guess : 55)
teamGuess(teamid : 8, guess : 60)
teamGuess(teamid : 9, guess : 70)*/
teamGuess(teamid : 9, guess : 70)
teamGuess(teamid : 10, guess : 70)
teamGuess(teamid : 11, guess : 70)
teamGuess(teamid : 12, guess : 70)
teamGuess(teamid : 13, guess : 80)*/


/*teamGuess(teamid : 0, guess : 0)
teamGuess(teamid : 1, guess : 1)
teamGuess(teamid : 2, guess : 2)
teamGuess(teamid : 3, guess : 3)
teamGuess(teamid : 4, guess : 4)
teamGuess(teamid : 5, guess : 5)
teamGuess(teamid : 6, guess : 6)
teamGuess(teamid : 7, guess : 7)
teamGuess(teamid : 8, guess : 8)
teamGuess(teamid : 9, guess : 9)
teamGuess(teamid : 10, guess : 10)
teamGuess(teamid : 11, guess : 11)
teamGuess(teamid : 12, guess : 12)
teamGuess(teamid : 13, guess : 13)*/

}

Expand Down
25 changes: 19 additions & 6 deletions Quiz Server/Quiz Server/TextScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ class TextScene: SKScene {
self.webSocket = webSocket
self.numTeams = numTeams

teamGuesses = [(roundid: Int, guess: String)?]()

let bgImage = SKSpriteNode(imageNamed: "background2")
bgImage.zPosition = 0
bgImage.position = CGPoint(x:self.frame.midX, y:self.frame.midY)
Expand Down Expand Up @@ -230,10 +232,11 @@ class TextScene: SKScene {
func initUnique(file: String) {
uniques = []
do {
let data = try String(contentsOfFile:file, encoding: String.Encoding.utf8)
let data = try String(contentsOfFile:file, encoding: String.Encoding.ascii)
uniques = data.components(separatedBy: "\n")
uniques = uniques!.filter { $0 != "" }
uniques = uniques!.map { sanitiseString($0) }
print("Unique correct answers are: ", uniques!)
} catch let err as NSError {
print(err)
}
Expand Down Expand Up @@ -303,6 +306,12 @@ class TextScene: SKScene {
str = str.trimmingCharacters(in: .whitespacesAndNewlines)
str = str.trimmingCharacters(in: .punctuationCharacters)
str = str.trimmingCharacters(in: .symbols)
str = str.replacingOccurrences(of: "\"", with: "")
str = str.replacingOccurrences(of: "\'", with: "")
str = str.replacingOccurrences(of: "-", with: " ")
str = str.replacingOccurrences(of: "&", with: " ")
str = str.replacingOccurrences(of: "(", with: "")
str = str.replacingOccurrences(of: ")", with: "")
return str
}

Expand Down Expand Up @@ -365,14 +374,18 @@ class TextScene: SKScene {
emitters.removeAll()

//Quick dirty test code
/*teamGuess(teamid: 1, guess: "abc'", roundid: 1, showroundno: true);
teamGuess(teamid: 2, guess: "abc!", roundid: 2, showroundno: true);
teamGuess(teamid: 3, guess: "sss", roundid: 3, showroundno: true);
/*teamGuess(teamid: 0, guess: "let\"s dance", roundid: 3, showroundno: true);
teamGuess(teamid: 1, guess: "Sound and Vision", roundid: 1, showroundno: true);
teamGuess(teamid: 2, guess: "sound and vision", roundid: 2, showroundno: true);
teamGuess(teamid: 3, guess: "let's dance", roundid: 3, showroundno: true);
teamGuess(teamid: 4, guess: "sss", roundid: 3, showroundno: true);
teamGuess(teamid: 5, guess: "ddd", roundid: 3, showroundno: true);
teamGuess(teamid: 6, guess: "def", roundid: 3, showroundno: true);
teamGuess(teamid: 7, guess: "xxx", roundid: 4, showroundno: true);
teamGuess(teamid: 8, guess: "abc", roundid: 4, showroundno: true);*/
teamGuess(teamid: 7, guess: "drive-in saturday", roundid: 4, showroundno: true);
teamGuess(teamid: 8, guess: "Where Are We Now", roundid: 4, showroundno: true);
teamGuess(teamid: 11, guess: "Jean Genie", roundid: 3, showroundno: true);
teamGuess(teamid: 12, guess: "Jean Genie", roundid: 4, showroundno: true);
teamGuess(teamid: 13, guess: "abc", roundid: 4, showroundno: true);*/
}

}

0 comments on commit 4025be3

Please sign in to comment.