📄 uskills.pas
字号:
begin
inherited Update (CurTick);
end;
}
constructor TBuySellSkill.Create (aBasicObject : TBasicObject);
begin
BasicObject := aBasicObject;
BuyItemList := TList.Create;
SellItemList := TList.Create;
boLogItem := false;
LoadFromFile ('test.txt');
end;
destructor TBuySellSkill.Destroy;
begin
Clear;
if BuyItemList <> nil then BuyItemList.Free;
if SellItemList <> nil then SellItemList.Free;
inherited Destroy;
end;
procedure TBuySellSkill.Clear;
var
i : Integer;
pItemData : PTItemData;
begin
if BuyItemList <> nil then begin
for i := 0 to BuyItemList.Count - 1 do begin
pItemData := BuyItemList.Items [i];
if pItemData <> nil then Dispose (pItemData);
end;
BuyItemList.Clear;
end;
if SellItemList <> nil then begin
for i := 0 to SellItemList.Count - 1 do begin
pItemData := SellItemList.Items [i];
if pItemData <> nil then Dispose (pItemData);
end;
SellItemList.Clear;
end;
end;
function TBuySellSkill.LoadFromFile (aFileName : String) : Boolean;
var
i : Integer;
mStr, KindStr, ItemName : String;
StringList : TStringList;
ItemData : TItemData;
pItemData : PTItemData;
begin
Result := false;
if FileExists (aFileName) then begin
FileName := aFileName;
Clear;
StringList := TStringList.Create;
StringList.LoadFromFile (aFileName);
for i := 0 to StringList.Count - 1 do begin
mStr := StringList.Strings[i];
if mStr <> '' then begin
mStr := GetValidStr3 (mStr, KindStr, ':');
mStr := GetValidStr3 (mStr, ItemName, ':');
if (KindStr <> '') and (ItemName <> '') then begin
ItemClass.GetItemData (ItemName, ItemData);
if ItemData.rName[0] <> 0 then begin
New (pItemData);
Move (ItemData, pItemData^, sizeof (TItemData));
if UpperCase (KindStr) = 'SELLITEM' then
SellItemList.Add (pItemData)
else if UpperCase (KindStr) = 'BUYITEM' then
BuyItemList.Add (pItemData);
end;
end else if UpperCase (KindStr) = 'LOGITEM' then begin
boLogItem := true;
end;
end;
end;
StringList.Free;
Result := true;
end;
end;
function TBuySellSkill.DivHearing (aHearStr: string; var Sayer, aItemName: string; var aItemCount: integer): integer;
var
str: string;
str1, str2, str3: string;
begin
Result := DIVRESULT_NONE;
if not ReverseFormat (aHearStr, '%s: %s', str1, str2, str3, 2) then exit;
sayer := str1;
str := str2;
if Pos ('构颇聪', str) = 1 then Result := DIVRESULT_WHATSELL;
if Pos ('构荤聪', str) = 1 then Result := DIVRESULT_WHATBUY;
if Pos ('魂促', str) = 1 then Result := DIVRESULT_WHATSELL;
if Pos ('魄促', str) = 1 then Result := DIVRESULT_WHATBUY;
if Result <> DIVRESULT_NONE then exit;
if ReverseFormat (str, '%s 倔付', str1, str2, str3, 1) then begin
aItemName := str1;
Result := DIVRESULT_HOWMUCH;
exit;
end;
if ReverseFormat (str, '%s %s俺 魂促', str1, str2, str3, 2) then begin
aItemName := str1;
aItemCount := _StrToInt (str2);
Result := DIVRESULT_BUYITEM;
exit;
end;
if ReverseFormat (str, '%s %s俺 火聪促', str1, str2, str3, 2) then begin
aItemName := str1;
aItemCount := _StrToInt (str2);
Result := DIVRESULT_BUYITEM;
exit;
end;
if ReverseFormat (str, '%s %s俺 魄促', str1, str2, str3, 2) then begin
aItemName := str1;
aItemCount := _StrToInt(str2);
if aItemCount < 0 then aItemCount := 0;
Result := DIVRESULT_SELLITEM;
exit;
end;
if ReverseFormat (str, '%s %s俺 扑聪促', str1, str2, str3, 2) then begin
aItemName := str1;
aItemCount := _StrToInt(str2);
if aItemCount < 0 then aItemCount := 0;
Result := DIVRESULT_SELLITEM;
exit;
end;
if ReverseFormat (str, '%s 魂促', str1, str2, str3, 1) then begin
aItemName := str1;
aItemCount := 1;
Result := DIVRESULT_BUYITEM;
exit;
end;
if ReverseFormat (str, '%s 火聪促', str1, str2, str3, 1) then begin
aItemName := str1;
aItemCount := 1;
Result := DIVRESULT_BUYITEM;
exit;
end;
if ReverseFormat (str, '%s 魄促', str1, str2, str3, 1) then begin
aItemName := str1;
aItemCount := 1;
Result := DIVRESULT_SELLITEM;
exit;
end;
if ReverseFormat (str, '%s 扑聪促', str1, str2, str3, 1) then begin
aItemName := str1;
aItemCount := 1;
Result := DIVRESULT_SELLITEM;
exit;
end;
end;
function TBuySellSkill.ProcessMessage (aStr : String; SenderInfo : TBasicData) : Boolean;
var
i, icnt, ipos, ret : Integer;
str, sayer, iname, RetStr : String;
pItemData : PTItemData;
ItemData, MoneyItemData : TItemData;
SubData : TSubData;
User : TUser;
begin
Result := true;
ret := DivHearing (aStr, sayer, iname, icnt);
case ret of
{
DIVRESULT_ITEMLOG :
begin
User := UserList.GetUserPointer (StrPas (@SenderInfo.Name));
if User <> nil then begin
RetStr := User.ShowItemLogWindow;
if RetStr <> '' then begin
TLIfeObject (BasicObject).CommandSay (RetStr);
end;
end;
end;
}
DIVRESULT_HOWMUCH:
begin
ipos := -1;
for i := 0 to SellItemList.Count - 1 do begin
pitemdata := SellItemList[i];
if iname = Strpas (@pitemdata^.rname) then begin
ipos := i;
break;
end;
end;
if ipos = -1 then begin
TLifeObject (BasicObject).CommandSay (format ('%s篮 绝嚼聪促.',[iname]));
end else begin
ItemClass.GetItemData (iname, ItemData);
TLifeObject (BasicObject).CommandSay (format ('%s篮 %d傈 涝聪促.',[iname,ItemData.rPrice]));
end;
end;
DIVRESULT_SELLITEM:
begin
if icnt <= 0 then exit;
if icnt > 1000 then begin
TLifeObject(BasicObject).CommandSay ('荐樊捞 呈公 腹嚼聪促.');
exit;
end;
ipos := -1;
for i := 0 to BuyItemList.count-1 do begin
pitemdata := Buyitemlist[i];
if iname = Strpas (@pitemdata^.rname) then begin ipos := i; break; end;
end;
if ipos = -1 then begin
TLIfeObject (BasicObject).CommandSay (format ('%s篮 救火聪促.',[iname]));
exit;
end;
if TFieldPhone (BasicObject.Manager.Phone).SendMessage (SenderInfo.id, FM_ENOUGHSPACE, BasicObject.BasicData, SubData) = PROC_FALSE then begin
TLIfeObject (BasicObject).CommandSay ('啊柳 拱扒捞 呈公 腹嚼聪促.');
exit;
end;
ItemClass.GetItemData (INI_GOLD, MoneyItemData);
ItemClass.GetItemData (iname, ItemData);
SignToItem (ItemData, BasicObject.Manager.ServerID, BasicObject.BasicData, '');
SubData.ItemData := ItemData;
SubData.ItemData.rCount := icnt;
if TFieldPhone(BasicObject.Manager.Phone).SendMessage (SenderInfo.id, FM_DELITEM, BasicObject.BasicData, SubData) = PROC_FALSE then begin
TLIfeObject (BasicObject).CommandSay (format ('%s阑 啊瘤绊 乐瘤 臼嚼聪促.',[iname]));
exit;
end;
MoneyItemData.rCount := ItemData.rprice * icnt;
SignToItem (MoneyItemData, BasicObject.Manager.ServerID, BasicObject.BasicData, '');
SubData.ItemData := MoneyItemData;
SubData.ServerId := BasicObject.Manager.ServerId;
TFieldPhone(BasicObject.Manager.Phone).SendMessage (SenderInfo.id, FM_ADDITEM, BasicObject.BasicData, SubData);
TLIfeObject (BasicObject).CommandSay (format ('%s阑 或嚼聪促.',[iname]));
end;
DIVRESULT_BUYITEM:
begin
if icnt <= 0 then exit;
if icnt > 1000 then begin
TLIfeObject (BasicObject).CommandSay ('荐樊捞 呈公 腹嚼聪促.');
exit;
end;
ipos := -1;
for i := 0 to SellItemList.count-1 do begin
pitemdata := sellitemlist[i];
if iname = Strpas (@pitemdata^.rname) then begin ipos := i; break; end;
end;
if ipos = -1 then begin
TLIfeObject (BasicObject).CommandSay (format ('%s篮 绝嚼聪促.',[iname]));
exit;
end;
ItemClass.GetItemData (INI_GOLD, MoneyItemData);
ItemClass.GetItemData (iname, ItemData);
if (ItemData.rboDouble = false) and (icnt > 1) then begin
TLIfeObject (BasicObject).CommandSay (format ('%s篮(绰) 茄俺究父 扑聪促', [StrPas(@ItemData.rName)]));
exit;
end;
if TFieldPhone(BasicObject.Manager.Phone).SendMessage (SenderInfo.id, FM_ENOUGHSPACE, BasicObject.BasicData, SubData) = PROC_FALSE then begin
TLIfeObject (BasicObject).CommandSay ('啊柳 拱扒捞 呈公 腹嚼聪促.');
exit;
end;
SignToItem (MoneyItemData, BasicObject.Manager.ServerID, BasicObject.BasicData, '');
MoneyItemData.rCount := ItemData.rPrice * icnt;
SubData.ItemData := MoneyItemData;
if TFieldPhone(BasicObject.Manager.Phone).SendMessage (SenderInfo.id, FM_DELITEM, BasicObject.BasicData, SubData) = PROC_FALSE then begin
TLIfeObject (BasicObject).CommandSay ('啊柳 捣捞 利嚼聪促.');
exit;
end;
ItemData.rCount := icnt;
SignToItem (ItemData, BasicObject.Manager.ServerID, BasicObject.BasicData, '');
SubData.ItemData := ItemData;
SubData.ServerId := BasicObject.Manager.ServerId;
TFieldPhone(BasicObject.Manager.Phone).SendMessage (SenderInfo.id, FM_ADDITEM, BasicObject.BasicData, SubData);
TLIfeObject (BasicObject).CommandSay (format ('%s阑 迫疽嚼聪促.',[iname]));
end;
DIVRESULT_WHATSELL:
begin
str := '';
for i := 0 to SellItemList.count-1 do begin
pitemdata := sellitemlist[i];
if i < SellItemList.count-1 then str := str + Strpas (@pitemdata^.rname) + ','
else str := str + Strpas (@pitemdata^.rname);
end;
if SellItemList.Count <> 0 then
TLIfeObject (BasicObject).CommandSay (format ('%s阑 扑聪促.',[str]))
else
TLIfeObject (BasicObject).CommandSay ('傈 拱扒阑 迫瘤 臼嚼聪促.');
end;
DIVRESULT_WHATBUY:
begin
str := '';
for i := 0 to BuyItemList.count-1 do begin
pitemdata := Buyitemlist[i];
if i < BuyItemList.count-1 then str := str + Strpas (@pitemdata^.rname) + ','
else str := str + Strpas (@pitemdata^.rname);
end;
if BuyItemList.Count <> 0 then
TLIfeObject (BasicObject).CommandSay (format ('%s阑 火聪促.',[str]))
else
TLIfeObject (BasicObject).CommandSay ('傈 拱扒阑 荤瘤 臼嚼聪促.');
end;
else begin
Result := false;
end;
end;
end;
// TSpeechSkill
constructor TSpeechSkill.Create (aBasicObject : TBasicObject);
begin
BasicObject := aBasicObject;
SpeechList := TList.Create;
CurSpeechIndex := 0;
SpeechTick := 0;
end;
destructor TSpeechSkill.Destroy;
begin
if SpeechList <> nil then begin
Clear();
SpeechList.Free;
end;
end;
procedure TSpeechSkill.Clear;
var
i : Integer;
begin
for i := 0 to SpeechList.Count - 1 do dispose (SpeechList[i]);
SpeechList.Clear;
CurSpeechIndex := 0;
SpeechTick := 0;
end;
function TSpeechSkill.LoadFromFile (aFileName : String) : Boolean;
var
i : integer;
SpeechDB : TUserStringDB;
iname : String;
pd : PTSpeechData;
begin
Result := false;
if aFileName = '' then exit;
if FileExists(aFileName) = FALSE then exit;
Clear;
SpeechDB := TUserStringDb.Create;
SpeechDB.LoadFromFile (aFileName);
for i := 0 to SpeechDB.Count -1 do begin
iname := SpeechDB.GetIndexName (i);
if SpeechDB.GetFieldValueBoolean(iname, 'boSelfSay') = TRUE then begin
New (pd);
FillChar (pd^, sizeof(TSpeechData), 0);
pd^.rSayString := SpeechDB.GetFieldValueString (iname, 'SayString');
pd^.rDelayTime := SpeechDB.GetFieldValueInteger (iname, 'DelayTime');
pd^.rSpeechTick := pd^.rDelayTime;
SpeechList.Add(pd);
end;
end;
SpeechDB.Free;
end;
procedure TSpeechSkill.ProcessMessage (CurTick : Integer);
var
pd : PTSpeechData;
begin
if SpeechList.Count > 0 then begin
pd := SpeechList[CurSpeechIndex];
if SpeechTick + pd^.rDelayTime < CurTick then begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -