| 1234567891011121314151617181920212223242526272829303132333435 |
- using System;
- namespace DevilLink2.Gameplay
- {
- /// <summary>Immutable single-level configuration, using display columns/rows.</summary>
- public sealed class LevelDefinition
- {
- public GameMode Mode { get; }
- public int Level { get; }
- public int Columns { get; }
- public int Rows { get; }
- public bool HasTimer { get; }
- public int TimeLimitSeconds { get; }
- public int ClearCoinReward { get; }
- public int ClearTicketReward { get; }
- public LevelDefinition(GameMode mode, int level, int columns, int rows,
- int timeLimitSeconds, int clearCoinReward, int clearTicketReward)
- {
- GameModeGuard.Validate(mode);
- if (level < 1 || level > 20) throw new ArgumentOutOfRangeException(nameof(level));
- if (columns <= 0) throw new ArgumentOutOfRangeException(nameof(columns));
- if (rows <= 0) throw new ArgumentOutOfRangeException(nameof(rows));
- long count = (long)columns * rows;
- if (count > int.MaxValue || count % 2 != 0) throw new ArgumentException("Board cell count must be even and representable.");
- bool hasTimer = mode != GameMode.Zen;
- if (hasTimer ? timeLimitSeconds <= 0 : timeLimitSeconds != 0)
- throw new ArgumentOutOfRangeException(nameof(timeLimitSeconds), "Zen has no timer; timed modes require positive seconds.");
- if (clearCoinReward < 0) throw new ArgumentOutOfRangeException(nameof(clearCoinReward));
- if (clearTicketReward < 0) throw new ArgumentOutOfRangeException(nameof(clearTicketReward));
- Mode = mode; Level = level; Columns = columns; Rows = rows; HasTimer = hasTimer;
- TimeLimitSeconds = timeLimitSeconds; ClearCoinReward = clearCoinReward; ClearTicketReward = clearTicketReward;
- }
- }
- }
|