Moved the constants in UFloorWillBeLava below the types so that they can be together in a single const block

This commit is contained in:
Stefan Müller 2023-12-19 13:15:46 +01:00 committed by Stefan Müller
parent 58c677f409
commit e9737f0265
1 changed files with 20 additions and 27 deletions

View File

@ -24,10 +24,6 @@ interface
uses uses
Classes, SysUtils, Generics.Collections, USolver; Classes, SysUtils, Generics.Collections, USolver;
const
CNoDirection: TPoint = (X: 0; Y: 0);
CEmptyChar = '.';
type type
{ TBeam } { TBeam }
@ -36,10 +32,6 @@ type
Position, Direction: TPoint; Position, Direction: TPoint;
end; end;
const
CStartingBeam: TBeam = (Position: (X: 0; Y: 0); Direction: (X: 1; Y: 0));
type
TEnergyState = (esNone, esWestOrHorizontal, esEastOrVertical, esBoth); TEnergyState = (esNone, esWestOrHorizontal, esEastOrVertical, esBoth);
{ TTransition } { TTransition }
@ -50,7 +42,27 @@ type
EnergyChange: TEnergyState; EnergyChange: TEnergyState;
end; end;
{ TFloorWillBeLava }
TFloorWillBeLava = class(TSolver)
private
FLines: TStringList;
function IsBeamOutOfBounds(constref ABeam: TBeam; const AWidth, AHeight: Integer): Boolean;
function GetTile(constref APosition: TPoint): Char;
function GetNewBeam(constref APosition, ADirection: TPoint): TBeam;
public
constructor Create;
destructor Destroy; override;
procedure ProcessDataLine(const ALine: string); override;
procedure Finish; override;
function GetDataFileName: string; override;
function GetPuzzleName: string; override;
end;
const const
CNoDirection: TPoint = (X: 0; Y: 0);
CEmptyChar = '.';
CStartingBeam: TBeam = (Position: (X: 0; Y: 0); Direction: (X: 1; Y: 0));
CTransitions: array of TTransition = ( CTransitions: array of TTransition = (
(IncomingDirection: (X: 1; Y: 0); OutgoingDirection: (X: 0; Y: -1); SplitDirection: (X: 0; Y: 0); Tile: '/'; (IncomingDirection: (X: 1; Y: 0); OutgoingDirection: (X: 0; Y: -1); SplitDirection: (X: 0; Y: 0); Tile: '/';
EnergyChange: esWestOrHorizontal), EnergyChange: esWestOrHorizontal),
@ -78,25 +90,6 @@ const
EnergyChange: esBoth) EnergyChange: esBoth)
); );
type
{ TFloorWillBeLava }
TFloorWillBeLava = class(TSolver)
private
FLines: TStringList;
function IsBeamOutOfBounds(constref ABeam: TBeam; const AWidth, AHeight: Integer): Boolean;
function GetTile(constref APosition: TPoint): Char;
function GetNewBeam(constref APosition, ADirection: TPoint): TBeam;
public
constructor Create;
destructor Destroy; override;
procedure ProcessDataLine(const ALine: string); override;
procedure Finish; override;
function GetDataFileName: string; override;
function GetPuzzleName: string; override;
end;
implementation implementation
{ TFloorWillBeLava } { TFloorWillBeLava }