Skip to content

Commit

Permalink
GetName helper for string.
Browse files Browse the repository at this point in the history
  • Loading branch information
devapromix committed Jan 12, 2018
1 parent 5ef98f1 commit 2571d5c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
6 changes: 3 additions & 3 deletions uHelpers.pas
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ TUIntHelper = record helper for UInt
type
TStringHelper = record helper for
string
function GetName(P: string): string;
function GetName(const Pref: string): string;
end;

type
Expand Down Expand Up @@ -90,9 +90,9 @@ function TItemHelper.DoIt: string;

{ TStringHelper }

function TStringHelper.GetName(P: string): string;
function TStringHelper.GetName(const Pref: string): string;
begin
Result := StringReplace(Self, P, '', [rfReplaceAll]);
Result := StringReplace(Self, Pref, '', [rfReplaceAll]);
Result := StringReplace(Result, '_', ' ', [rfReplaceAll]);
end;

Expand Down
4 changes: 2 additions & 2 deletions uSkill.pas
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ TSkills = class(TObject)
implementation

uses SysUtils, TypInfo, Math, uLanguage, uTerminal, uPlayer, uGame, uMsgLog,
uStatistic;
uStatistic, uHelpers;

{ TSkills }

Expand All @@ -74,7 +74,7 @@ constructor TSkills.Create;
Self.Clear;
P := TypeInfo(TSkillEnum);
for I := Low(TSkillEnum) to High(TSkillEnum) do
FSkillName[I] := StringReplace(GetEnumName(P, Ord(I)), 'sk', '', [rfReplaceAll]);
FSkillName[I] := GetEnumName(P, Ord(I)).GetName('sk');
end;

destructor TSkills.Destroy;
Expand Down
8 changes: 2 additions & 6 deletions uTalent.pas
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ TTalents = class(TObject)

implementation

uses SysUtils, TypInfo, uLanguage, uSkill, uGame, uScenes, uPlayer, uAttribute;
uses SysUtils, TypInfo, uLanguage, uSkill, uGame, uScenes, uPlayer, uAttribute, uHelpers;

const
TalentHint: array [TTalentEnum] of string = ('', 'Athletics', 'Dodge',
Expand Down Expand Up @@ -133,11 +133,7 @@ constructor TTalents.Create;
Self.Clear;
P := TypeInfo(TTalentEnum);
for I := Low(TTalentEnum) to High(TTalentEnum) do
begin
S := StringReplace(GetEnumName(P, Ord(I)), 'tl', '', [rfReplaceAll]);
S := StringReplace(S, '_', ' ', [rfReplaceAll]);
FTalentName[I] := S;
end;
FTalentName[I] := GetEnumName(P, Ord(I)).GetName('tl');
end;

function TTalents.Amount: UInt;
Expand Down

0 comments on commit 2571d5c

Please sign in to comment.