Changeset 51 for trunk/UGame.pas
- Timestamp:
- Nov 3, 2019, 6:20:02 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r50 r51 94 94 end; 95 95 96 TTileSkin = (tsLinear, tsPowerOfTwo );96 TTileSkin = (tsLinear, tsPowerOfTwo, tsAlpha); 97 97 98 98 { TGame } … … 145 145 procedure SaveToRegistry(RegContext: TRegistryContext); 146 146 procedure LoadFromRegistry(RegContext: TRegistryContext); 147 function GetTileSkinValue(Value: Integer): Integer; 147 function GetTileSkinValue(Value: Integer): string; 148 function GetTileSkinScore(Value: Integer): Integer; 148 149 constructor Create; 149 150 destructor Destroy; override; … … 176 177 SSkinLinear = 'Linear'; 177 178 SSkinPowerOfTwo = 'Power of two'; 179 SSkinAlpha = 'Alpha'; 178 180 STileShouldBeEmpty = 'Tile should be empty'; 181 179 182 180 183 procedure Translate; … … 190 193 SkinText[tsLinear] := SSkinLinear; 191 194 SkinText[tsPowerOfTwo] := SSkinPowerOfTwo; 195 SkinText[tsAlpha] := SSkinAlpha; 192 196 end; 193 197 … … 694 698 Board.Tiles[P.Y, P.X].Value := 0; 695 699 Board.Tiles[P.Y, P.X].Merged := False; 696 Score := Score + GetTileSkin Value(Board.Tiles[PNew.Y, PNew.X].Value);700 Score := Score + GetTileSkinScore(Board.Tiles[PNew.Y, PNew.X].Value); 697 701 end; 698 702 end; … … 715 719 Canvas.RoundRect(TileRect, ScaleX(TileRect.Width div 20, 96), ScaleY(TileRect.Height div 20, 96)); 716 720 if WithText and (Tile.Value <> 0) then begin 717 ValueStr := IntToStr(GetTileSkinValue(Tile.Value));721 ValueStr := GetTileSkinValue(Tile.Value); 718 722 Canvas.Brush.Style := bsClear; 719 723 Canvas.Font.Height := Trunc(TileRect.Height * 0.7); … … 859 863 Board.Tiles[P.Y, P.X].NewValue := 0; 860 864 Board.Tiles[P.Y, P.X].Merged := False; 861 Score := Score + GetTileSkin Value(Board.Tiles[PNew.Y, PNew.X].NewValue);865 Score := Score + GetTileSkinScore(Board.Tiles[PNew.Y, PNew.X].NewValue); 862 866 TileMoved := True; 863 867 end; … … 918 922 end; 919 923 920 function TGame.GetTileSkinValue(Value: Integer): Integer; 921 begin 922 if FSkin = tsPowerOfTwo then Result := 1 shl Value 923 else Result := Value; 924 function TGame.GetTileSkinValue(Value: Integer): string; 925 begin 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; 932 end; 933 934 function TGame.GetTileSkinScore(Value: Integer): Integer; 935 begin 936 case FSkin of 937 tsLinear: Result := Value; 938 tsPowerOfTwo: Result := 1 shl Value; 939 tsAlpha: Result := Value; 940 else Result := Value; 941 end; 924 942 end; 925 943 … … 1083 1101 end; 1084 1102 1103 initialization 1104 Translate; 1105 1085 1106 end. 1086 1107
Note:
See TracChangeset
for help on using the changeset viewer.