Hi all,
I'm still working away at this RPG, and have the need to create a new string type. Amongst my various objects I have string fields that will contain damage in the form of 'Fire:2D6,Edged:2D6+2'. For the curious, this means that the damage consists of 2-12 from fire, and 4-14 from an edged weapon. I want to force variables containing damage to go through separate methods ie
This code doesn't compile and causes an 'ambiguous overloaded call'. From the Delphi help file though, defining TDamage = type String should create it as a totally separate type, but it seems it's not enough.
Any clues on how I can do this? I know I could create a new TObject that can have handling built in and the rest, but I want to avoid having to Create and Destroy instances of TDamage.
I'm still working away at this RPG, and have the need to create a new string type. Amongst my various objects I have string fields that will contain damage in the form of 'Fire:2D6,Edged:2D6+2'. For the curious, this means that the damage consists of 2-12 from fire, and 4-14 from an edged weapon. I want to force variables containing damage to go through separate methods ie
Code:
interface
type
TDamage = type String;
procedure Concise(var AStr: String); overload;
procedure Concise(var AStr: TDamage); overload;
implementation
procedure Stuff;
var
x : TDamage;
begin
x := 'Fire:2D6,Edged:2D6+2,Fire:1D6';
Concise(x); // causes compilation error
end;
Any clues on how I can do this? I know I could create a new TObject that can have handling built in and the rest, but I want to avoid having to Create and Destroy instances of TDamage.