Changeset 51 for trunk/UGame.pas


Ignore:
Timestamp:
Nov 3, 2019, 6:20:02 PM (5 years ago)
Author:
chronos
Message:
  • Added: New tile skip alpha for alpha letters.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UGame.pas

    r50 r51  
    9494  end;
    9595
    96   TTileSkin = (tsLinear, tsPowerOfTwo);
     96  TTileSkin = (tsLinear, tsPowerOfTwo, tsAlpha);
    9797
    9898  { TGame }
     
    145145    procedure SaveToRegistry(RegContext: TRegistryContext);
    146146    procedure LoadFromRegistry(RegContext: TRegistryContext);
    147     function GetTileSkinValue(Value: Integer): Integer;
     147    function GetTileSkinValue(Value: Integer): string;
     148    function GetTileSkinScore(Value: Integer): Integer;
    148149    constructor Create;
    149150    destructor Destroy; override;
     
    176177  SSkinLinear = 'Linear';
    177178  SSkinPowerOfTwo = 'Power of two';
     179  SSkinAlpha = 'Alpha';
    178180  STileShouldBeEmpty = 'Tile should be empty';
     181
    179182
    180183procedure Translate;
     
    190193  SkinText[tsLinear] := SSkinLinear;
    191194  SkinText[tsPowerOfTwo] := SSkinPowerOfTwo;
     195  SkinText[tsAlpha] := SSkinAlpha;
    192196end;
    193197
     
    694698              Board.Tiles[P.Y, P.X].Value := 0;
    695699              Board.Tiles[P.Y, P.X].Merged := False;
    696               Score := Score + GetTileSkinValue(Board.Tiles[PNew.Y, PNew.X].Value);
     700              Score := Score + GetTileSkinScore(Board.Tiles[PNew.Y, PNew.X].Value);
    697701            end;
    698702          end;
     
    715719  Canvas.RoundRect(TileRect, ScaleX(TileRect.Width div 20, 96), ScaleY(TileRect.Height div 20, 96));
    716720  if WithText and (Tile.Value <> 0) then begin
    717     ValueStr := IntToStr(GetTileSkinValue(Tile.Value));
     721    ValueStr := GetTileSkinValue(Tile.Value);
    718722    Canvas.Brush.Style := bsClear;
    719723    Canvas.Font.Height := Trunc(TileRect.Height * 0.7);
     
    859863              Board.Tiles[P.Y, P.X].NewValue := 0;
    860864              Board.Tiles[P.Y, P.X].Merged := False;
    861               Score := Score + GetTileSkinValue(Board.Tiles[PNew.Y, PNew.X].NewValue);
     865              Score := Score + GetTileSkinScore(Board.Tiles[PNew.Y, PNew.X].NewValue);
    862866              TileMoved := True;
    863867            end;
     
    918922end;
    919923
    920 function TGame.GetTileSkinValue(Value: Integer): Integer;
    921 begin
    922   if FSkin = tsPowerOfTwo then Result := 1 shl Value
    923   else Result := Value;
     924function TGame.GetTileSkinValue(Value: Integer): string;
     925begin
     926  case FSkin of
     927    tsLinear: Result := IntToStr(Value);
     928    tsPowerOfTwo: Result := IntToStr(1 shl Value);
     929    tsAlpha: Result := Chr(Ord('A') + Value - 1);
     930    else Result := IntToStr(Value);
     931  end;
     932end;
     933
     934function TGame.GetTileSkinScore(Value: Integer): Integer;
     935begin
     936  case FSkin of
     937    tsLinear: Result := Value;
     938    tsPowerOfTwo: Result := 1 shl Value;
     939    tsAlpha: Result := Value;
     940    else Result := Value;
     941  end;
    924942end;
    925943
     
    10831101end;
    10841102
     1103initialization
     1104  Translate;
     1105
    10851106end.
    10861107
Note: See TracChangeset for help on using the changeset viewer.