git_game_show 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,57 @@
1
+ module GitGameShow
2
+ class MiniGame
3
+ class << self
4
+ # Keep track of all subclasses (mini games)
5
+ def descendants
6
+ @descendants ||= []
7
+ end
8
+
9
+ def inherited(subclass)
10
+ descendants << subclass
11
+ end
12
+
13
+ attr_accessor :name, :description, :questions_per_round
14
+ end
15
+
16
+ # Default number of questions per round
17
+ self.questions_per_round = 5
18
+
19
+ # Default name and description
20
+ self.name = "Base Mini Game"
21
+ self.description = "This is a base mini game class. You should not see this in the actual game."
22
+
23
+ # Method to generate questions based on Git repo data
24
+ # This should be overridden by subclasses
25
+ def generate_questions(repo)
26
+ raise NotImplementedError, "#{self.class} must implement #generate_questions"
27
+ end
28
+
29
+ # Method to evaluate player answers and return results
30
+ # This should be overridden by subclasses
31
+ def evaluate_answers(question, player_answers)
32
+ raise NotImplementedError, "#{self.class} must implement #evaluate_answers"
33
+ end
34
+
35
+ # Helper method to get all commits from a repo
36
+ def get_all_commits(repo)
37
+ # Get a larger number of commits to ensure more diversity
38
+ repo.log(1000).each.to_a
39
+ end
40
+
41
+ # Helper method to get unique authors from commits
42
+ def get_commit_authors(commits)
43
+ commits.map { |commit| commit.author.name }.uniq
44
+ end
45
+
46
+ # Helper method to get commit messages
47
+ def get_commit_messages(commits)
48
+ commits.map(&:message)
49
+ end
50
+
51
+ # Helper method to shuffle an array with the option to exclude certain items
52
+ def shuffled_excluding(array, exclude = nil)
53
+ items = exclude ? array.reject { |item| item == exclude } : array.dup
54
+ items.shuffle
55
+ end
56
+ end
57
+ end