exercism.org/csharp/annalyns-infiltration/AnnalynsInfiltration.cs

34 lines
841 B
C#

using System;
static class QuestLogic
{
public static bool CanFastAttack(bool knightIsAwake)
{
return !knightIsAwake;
}
public static bool CanSpy(bool knightIsAwake, bool archerIsAwake, bool prisonerIsAwake)
{
return knightIsAwake || archerIsAwake || prisonerIsAwake;
}
public static bool CanSignalPrisoner(bool archerIsAwake, bool prisonerIsAwake)
{
return !archerIsAwake && prisonerIsAwake;
}
public static bool CanFreePrisoner(bool knightIsAwake, bool archerIsAwake, bool prisonerIsAwake, bool petDogIsPresent)
{
if (petDogIsPresent && !archerIsAwake)
{
return true;
}
if (!petDogIsPresent && !archerIsAwake && !knightIsAwake && prisonerIsAwake)
{
return true;
}
return false;
}
}