Skip to content

Commit

Permalink
#226 SIGame: support complex answer combined with answer options
Browse files Browse the repository at this point in the history
Also upgrade all built-in packages to format version 5
  • Loading branch information
VladimirKhil committed May 13, 2024
1 parent 5223502 commit 1003946
Show file tree
Hide file tree
Showing 60 changed files with 17 additions and 24 deletions.
9 changes: 1 addition & 8 deletions src/Common/SIPackages/Question.cs
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,6 @@ private static string GetPlacement(string type) =>
public bool Equals(Question? other) =>
other is not null
&& Price.Equals(other.Price)
&& Type.Equals(other.Type)
&& Scenario.Equals(other.Scenario)
&& Equals(Script, other.Script)
&& Equals(Parameters, other.Parameters)
&& Right.Equals(other.Right)
Expand All @@ -594,18 +592,13 @@ other is not null
public override bool Equals(object? obj) => Equals(obj as Question);

/// <inheritdoc />
public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), Price, Type, Scenario, Script, Parameters, Right, Wrong);
public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), Price, Script, Parameters, Right, Wrong);

/// <summary>
/// Gets question text part.
/// </summary>
public string GetText()
{
if (Scenario.Any())
{
return GetTextFromScenario();
}

if (Script == null)
{
if (Parameters == null)
Expand Down
28 changes: 16 additions & 12 deletions src/SICore/SICore/Clients/Game/GameLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ private bool OnDecisionAnswerValidating()
if (_data.Answerer.AnswerIsRight)
{
answerResult.IsRight = true;
var showmanReplic = IsFinalRound() || _data.Question.Type.Name == QuestionTypes.Stake ? nameof(R.Bravo) : nameof(R.Right);
var showmanReplic = IsFinalRound() || _data.Question?.TypeName == QuestionTypes.Stake ? nameof(R.Bravo) : nameof(R.Right);

var s = new StringBuilder(GetRandomString(LO[showmanReplic]));

Expand Down Expand Up @@ -1370,12 +1370,7 @@ public void ContinueQuestion()
_data.Decision = DecisionType.Pressing;
}

private bool IsSpecialQuestion()
{
var questTypeName = _data.Question.TypeName ?? _data.Question.Type.Name;

return questTypeName != QuestionTypes.Simple;
}
private bool IsSpecialQuestion() => _data.Question?.TypeName != QuestionTypes.Simple;

private bool OnDecisionNextPersonStakeMaking()
{
Expand Down Expand Up @@ -3244,12 +3239,12 @@ private void AskAnswer()
return;
}

if (_data.Question.Type.Name == QuestionTypes.Simple)
if (_data.Question?.TypeName == QuestionTypes.Simple)
{
_gameActions.SendMessageWithArgs(Messages.EndTry, _data.AnswererIndex);
}

var time1 = _data.Question.Type.Name != QuestionTypes.Simple
var waitAnswerTime = _data.Question?.TypeName != QuestionTypes.Simple
? timeSettings.TimeForThinkingOnSpecial * 10
: timeSettings.TimeForPrintingAnswer * 10;

Expand Down Expand Up @@ -3305,8 +3300,8 @@ private void AskAnswer()
}

_data.AnswerCount = 1;
ScheduleExecution(Tasks.WaitAnswer, time1);
WaitFor(DecisionType.Answering, time1, _data.AnswererIndex);
ScheduleExecution(Tasks.WaitAnswer, waitAnswerTime);
WaitFor(DecisionType.Answering, waitAnswerTime, _data.AnswererIndex);
}

private void AskToDelete()
Expand Down Expand Up @@ -4427,10 +4422,19 @@ internal void OnComplexAnswer()
if (last == null || !last.IsRight) // There has been no right answer
{
var printedAnswer = answer != null ? $"{LO[nameof(R.RightAnswer)]}: {answer}" : LO[nameof(R.RightAnswerInOnTheScreen)];

_gameActions.ShowmanReplic(printedAnswer);
}

if (_data.QuestionPlayState.AnswerOptions != null)
{
var answerIndex = Array.FindIndex(_data.QuestionPlayState.AnswerOptions, o => o.Label == answer);

if (answerIndex > -1)
{
_gameActions.SendMessageWithArgs(Messages.ContentState, ContentPlacements.Screen, answerIndex + 1, ItemState.Right);
}
}

_gameActions.SendMessageWithArgs(Messages.RightAnswerStart, ContentTypes.Text, answer ?? "");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,6 @@ public void OnQuestionStart()

switch (_data.QuestionType)
{
case QuestionTypes.Auction: // deprecated
case QuestionTypes.Stake:
{
TInfo.Text = _localizer[nameof(R.Label_Auction)];
Expand All @@ -1394,8 +1393,6 @@ public void OnQuestionStart()
break;
}

case QuestionTypes.Cat: // deprecated
case QuestionTypes.BagCat: // deprecated
case QuestionTypes.Secret:
case QuestionTypes.SecretNoQuestion:
case QuestionTypes.SecretPublicPrice:
Expand All @@ -1416,7 +1413,6 @@ public void OnQuestionStart()
break;
}

case QuestionTypes.Sponsored: // deprecated
case QuestionTypes.NoRisk:
{
TInfo.Text = _localizer[nameof(R.Label_Sponsored)];
Expand Down
Binary file modified src/SIGame/SIGame/Data/1.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/2.1.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/2.2.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/2.3.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Pack3_0.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Pack3_1.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Pack3_2.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package4_1.siq
Binary file not shown.
Binary file removed src/SIGame/SIGame/Data/Package4_2.siq
Binary file not shown.
Binary file removed src/SIGame/SIGame/Data/Package4_3.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package4_4.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package5_1.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package5_10.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package5_11.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package5_12.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package5_2.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package5_3.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package5_4.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package5_5.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package5_6.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package5_7.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package5_8.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package5_9.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_1.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_10.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_11.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_12.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_13.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_14.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_15.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_16.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_17.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_18.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_19.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_2.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_20.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_21.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_22.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_23.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_3.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_4.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_5.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_6.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_7.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_8.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Package_2010_9.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/Petrov_questions.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/pack1-07.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/pack2-07.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/pack3-07.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/pack4-07.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/pack5-07.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/pack6-07.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/pack7-07.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/pack8-07.siq
Binary file not shown.
Binary file removed src/SIGame/SIGame/Data/pack_kot.siq
Binary file not shown.
Binary file modified src/SIGame/SIGame/Data/packf-07.siq
Binary file not shown.

0 comments on commit 1003946

Please sign in to comment.