Merge branch 'phase/46-speech-home'

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	docs/phases/09-social/README.md
#	src/HSchool.Server/Game/SchoolWorker.cs
#	tests/HSchool.Ai.Tests/TalkCirclesTests.cs
#	tests/HSchool.Simulation.Tests/MorningOpinionsTests.cs
#	tests/HSchool.Simulation.Tests/TalkCircleTests.cs
This commit is contained in:
Leonid Pershin
2026-08-20 14:06:29 +03:00
35 changed files with 910 additions and 36 deletions
@@ -173,6 +173,75 @@ public class TalkCircleTests
}
}
[Fact]
public void PendingStudyOnlyToday_DoesNotChangeCurrentGamesCircle()
{
var (school, first, second) = TwoPupilsOnBreak();
using (school)
{
OpinionStore.Set(first, second.Id, 55);
OpinionStore.Set(second, first.Id, 55);
PlaceAt(school, first.Id, "corridor-1");
PlaceAt(school, second.Id, "corridor-1");
Assert.True(school.TryStartAction(first.Id, TalkActions.Chat));
var live = school.TalkCirclesById.Values.Single();
live.TopicId = "TopicGames";
school.SpeechRules = school.SpeechRules.WithPending(SpeechPolicies.StudyOnly, null);
Assert.Equal(SpeechPolicies.Free, school.SpeechRules.Students);
TalkCircleSystem.Apply(school, 0.5d);
Assert.Equal("TopicGames", school.TalkCircleOf(first.Id)?.TopicId);
Assert.Equal(SpeechPolicies.StudyOnly, school.SpeechRules.PendingStudents);
}
}
[Fact]
public void AfterWorkMorning_NoRudePolicy_StudentsDoNotStartRudeTopic()
{
var (school, first, second) = TwoPupilsOnBreak();
using (school)
{
school.SpeechRules = school.SpeechRules.WithPending(SpeechPolicies.NoRude, null);
MorningDress.Apply(school);
Assert.Equal(SpeechPolicies.NoRude, school.SpeechRules.Students);
Assert.Null(school.SpeechRules.PendingStudents);
TalkCircleSystem.Interrupt(school, first.Id);
TalkCircleSystem.Interrupt(school, second.Id);
PlaceAt(school, first.Id, "corridor-1");
PlaceAt(school, second.Id, "corridor-1");
OpinionStore.Set(first, second.Id, 55);
OpinionStore.Set(second, first.Id, 55);
var started = 0;
var classmates = school.Roster!.Classes.First(row => row.RoomId == "classroom-101").PupilIds
.Select(id => school.Roster.People.First(person => person.Id == id))
.ToArray();
foreach (var initiator in classmates)
{
TalkCircleSystem.Interrupt(school, initiator.Id);
PlaceAt(school, initiator.Id, "corridor-1");
PlaceAt(school, first.Id, "corridor-1");
PlaceAt(school, second.Id, "corridor-1");
if (!school.TryStartAction(initiator.Id, TalkActions.Chat))
{
continue;
}
started++;
var circle = school.TalkCircleOf(initiator.Id);
Assert.NotNull(circle);
Assert.False(
school.Catalog!.Topics[circle.TopicId].Tags.Contains(TopicTags.Rude, StringComparer.Ordinal),
circle.TopicId);
TalkCircleSystem.Interrupt(school, initiator.Id);
}
Assert.True(started > 0);
}
}
private static (School School, Person First, Person Second) TwoPupilsWithPhonesOnBreak()
{
var (catalog, map) = Vanilla();