public static void SolveSimpleWires(BombManager bombData, ref SimpleWiresModule moduleData) { switch (moduleData.GetConnectedWires()) { case 3: if (moduleData.FrequencyOf(SimpleWireColors.Red) == 0) { moduleData.SetSolution(2); } else if (moduleData.Wires[2] == SimpleWireColors.White) { moduleData.SetSolution(3); } else if (moduleData.FrequencyOf(SimpleWireColors.Blue) > 1) { moduleData.SetSolution(moduleData.FindLastOf(SimpleWireColors.Blue, 3)); } else { moduleData.SetSolution(3); } break; case 4: if (moduleData.FrequencyOf(SimpleWireColors.Red) > 0 && bombData.IsLastSerialDigitOdd()) { moduleData.SetSolution(moduleData.FindLastOf(SimpleWireColors.Red, 4)); moduleData.RaiseDependencyFlag(DependencyFlag.SerialNumber); } else if (moduleData.Wires[3] == SimpleWireColors.Yellow && moduleData.FrequencyOf(SimpleWireColors.Red) == 0) { moduleData.SetSolution(1); } else if (moduleData.FrequencyOf(SimpleWireColors.Blue) == 1) { moduleData.SetSolution(1); } else if (moduleData.FrequencyOf(SimpleWireColors.Yellow) > 1) { moduleData.SetSolution(4); } else { moduleData.SetSolution(2); } break; case 5: if (moduleData.Wires[4] == SimpleWireColors.Black && bombData.IsLastSerialDigitOdd()) { moduleData.SetSolution(4); moduleData.RaiseDependencyFlag(DependencyFlag.SerialNumber); } else if (moduleData.FrequencyOf(SimpleWireColors.Red) == 1 && moduleData.FrequencyOf(SimpleWireColors.Yellow) > 1) { moduleData.SetSolution(1); } else if (moduleData.FrequencyOf(SimpleWireColors.Black) == 0) { moduleData.SetSolution(2); } else { moduleData.SetSolution(1); } break; case 6: if (moduleData.FrequencyOf(SimpleWireColors.Yellow) == 0 && bombData.IsLastSerialDigitOdd()) { moduleData.SetSolution(3); moduleData.RaiseDependencyFlag(DependencyFlag.SerialNumber); } else if (moduleData.FrequencyOf(SimpleWireColors.Yellow) == 1 && moduleData.FrequencyOf(SimpleWireColors.White) > 1) { moduleData.SetSolution(4); } else if (moduleData.FrequencyOf(SimpleWireColors.Red) == 0) { moduleData.SetSolution(6); } else { moduleData.SetSolution(4); } break; default: moduleData.SetSolution(-1); break; } }
public static void SolveComplicatedWires(BombManager bombData, ref ComplicatedWiresModule moduleData) { bool output; if (moduleData.RedColoring) { if (moduleData.BlueColoring) { if (moduleData.Star) { if (moduleData.LED) { output = false; } else { output = bombData.ParallelPort; moduleData.RaiseDependencyFlag(DependencyFlag.ParallelPort); } } else { output = !bombData.IsLastSerialDigitOdd(); moduleData.RaiseDependencyFlag(DependencyFlag.SerialNumber); } } else { if (moduleData.LED) { output = bombData.Batteries > 1; moduleData.RaiseDependencyFlag(DependencyFlag.Batteries); } else { if (moduleData.Star) { output = true; } else { output = !bombData.IsLastSerialDigitOdd(); moduleData.RaiseDependencyFlag(DependencyFlag.SerialNumber); } } } } else { if (moduleData.BlueColoring) { if (moduleData.LED) { output = bombData.ParallelPort; moduleData.RaiseDependencyFlag(DependencyFlag.ParallelPort); } else { if (moduleData.Star) { output = false; } else { output = !bombData.IsLastSerialDigitOdd(); moduleData.RaiseDependencyFlag(DependencyFlag.SerialNumber); } } } else { if (moduleData.Star) { if (moduleData.LED) { output = bombData.Batteries > 1; moduleData.RaiseDependencyFlag(DependencyFlag.Batteries); } else { output = true; } } else { if (moduleData.LED) { output = false; } else { output = true; } } } } moduleData.SetSolution(output); }