ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/Qzhteln/trunk/TELTest/Gamemodes/ClassicMP.cs
Revision: 2
Committed: Wed Feb 11 13:07:01 2026 UTC (8 weeks, 4 days ago) by figdor32
File size: 3134 byte(s)
Log Message:
Initial check-in

File Contents

# Content
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6
7 namespace TELTest.Gamemodes {
8 public class ClassicMP : QuizGamemode {
9 public ClassicMP() {
10 }
11 public ClassicMP(QuizContainer container, BaseQuizContext context) : base(container, context) {
12 }
13
14 public override String Name => "[MP] Klasyczny (multiplayer)";
15
16 public override String SystemName => "Classic_Multiplayer";
17
18 public override String Description => "Klasyczny quizhouse_poor, teraz w wersji multiplayer.";
19 public override QuizGamemode CreateInstance(QuizContainer quiz, BaseQuizContext context) => new ClassicMP(quiz, context);
20 public override async Task Begin() {
21 var lobby = await CreateJoinLobbyStandard();
22 if (lobby == null) return;
23 await Clear();
24 int score = 0;
25 await WriteLine("Tytul quizu: " + Quiz.Title);
26 await WriteLine("Autor quizu: " + Quiz.Author);
27 await WriteLine();
28 await WaitForPlayersReady(lobby);
29
30 Context.Handler.PlayerReady = false;
31
32 await Clear();
33 await WriteLine("Tytul quizu: " + Quiz.Title);
34 await WriteLine("Autor quizu: " + Quiz.Author);
35 await WriteLine();
36 for (int i = 0; i < Quiz.Questions.Length; i++) {
37 await WriteLine((i + 1) + ". " + Quiz.Questions[i].Content);
38 string correct = "";
39 for (int j = 0; j < Quiz.Questions[i].Answers.Length; j++) {
40 var itm = Quiz.Questions[i].Answers[j];
41 await WriteLine("{0}. {1}", Utilities.NumberToLetter(j).ToLower(), itm.Content);
42 if (itm.Correct) correct += Utilities.NumberToLetter(j).ToUpper()[0];
43 }
44 await Write("Twoja odpowiedz: ");
45 char ans = await ReadUppercaseKey();
46 await Flush();
47 await WriteLine();
48 if (correct.Contains(ans)) {
49 await WriteLine("Dobrze! Zdobywasz punkt.");
50 score++;
51 Context.Handler.SharedTempUserObject = score;
52 } else {
53 await WriteLine("Zle! Poprawna odpowiedz to: {0}", correct);
54 }
55 await Write("\r\n\r\n");
56 }
57
58
59 await WaitForPlayersReady(lobby);
60 await Clear();
61 StringBuilder sb = new StringBuilder();
62 await WriteLine("Twoj wynik: {0}/{1}\r\n", score, Quiz.Questions.Length);
63 foreach (var item in lobby.Players) {
64 if (item == Context.Handler) continue;
65 sb.AppendFormat("Wynik {0}: {1}/{2}\r\n", item.PlayerName, item.SharedTempUserObject, Quiz.Questions.Length);
66 }
67 await WriteLine(sb.ToString());
68 await Pause();
69
70 await DoScoreSubmission(score, true);
71 await EndMP(lobby);
72 }
73
74 }
75 }