⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basic.pas

📁 大六壬
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit MetaphysicsBasic; //玄学基本元素和类

interface

//uses Classes;

Type

  //阴阳
  TYinYang=(yyYin,yyYang);
  //性别
  TXingBie=TYinYang;
  //五行顺序
  TWuXingShunXu=(wxShui, wxMu, wxHuo, wxTu, wxJin);
  //天干顺序
  TTianGanShunXu=(tgJia,tgYi,tgBing,tgDing,tgWu,tgJi,tgGeng,tgXin,tgRen,tgGui);
  //地支顺序
  TDiZhiShunXu=(dzZi,dzChou,dzYin,dzMao,dzChen,dzSi,dzWu,dzWei,dzShen,dzYou,dzXu,dzHai);
  //方位
  TFangWei=(fwBei, fwDong, fwNan, fwXi, fwZhong);
  //活力
  THuoLi=(hlMeng, hlZhong, hlJi);//孟 仲 季
  //贵人天将顺序
  TTianJiangShunXu=(tjGuiRen, tjTengShe, tjZhuQue, tjLiuHe, tjGouChen, tjQingLong, tjTianKong, tjBaiHu, tjTaiChang, tjXuanWu, tjTaiYin, tjTianHou);//非 0 起始

  //五行元素
  TWuXingYuanSu=class
  protected
    FOrder:TWuXingShunXu; //顺序
    FCaption:string; //名称
    FFangWei:TFangWei; //方位
  public
//    constructor Create;//创建
    property Order:TWuXingShunXu read FOrder;//顺序
    property Caption:string read FCaption;//名称
    property FangWei:TFangWei read FFangWei;//方位
  end;

  //五行链
  TAWuXingYuanSu=Array[wxShui..wxJin] of TWuXingYuanSu;//五行元素数组

  TWuXingLian=class
  private
    FItems:TAWuXingYuanSu;//五行元素数组
    FIndex:TWuXingShunXu;//索引
//    FShui, FMu, FHuo, FTu, FJin:TWuXingYuanSu; //元素变量
    function Get(TheIndex: TWuXingShunXu):TWuXingYuanSu;//获取元素
    procedure SetIndex(Value:TWuXingShunXu);
    function GetCurrentItem: TWuXingYuanSu;//当前索引的元素
  protected
  public
    destructor Destroy; override; //销毁
    constructor Create;//创建
    Function First:TWuXingShunXu;//链首
    function Last:TWuXingShunXu;//链尾
    function Step(StepLen:Integer):TWuXingShunXu;//步进 正负均可
    property Index_:TWuXingShunXu read FIndex write SetIndex;//当前元素索引
    property Items[TheIndex: TWuXingShunXu]:TWuXingYuanSu read Get;//元素
    property CurrItem:TWuXingYuanSu read GetCurrentItem;//当前索引的元素
  end;


  //天干元素
  TTianGanYuanSu=class
  protected
    FOrder:TTianGanShunXU;//顺序
    FCaption:string;//名称
    FFangWei:TFangWei;//方位
    FYinYnag:TYinYang;//阴阳
    FWuXing:TWuXingYuanSu;//五行属性
    FDiGong:TDiZhiShunXu;//天干所寄地宫
  public
    property Order:TTianGanShunXu read FOrder;//顺序
    property Caption:string read FCaption;//名称
    property FangWei:TFangWei read FFangWei;//方位
    property YinYang:TYinYang read FYinYnag;//阴阳
    property WuXing:TWuXingYuanSu read FWuXing; //五行属性
    property DiGong:TDiZhiShunXu read FDiGong; //天干所寄地宫
  end;

  //天干链
  TATianGanYuanSu=Array[tgJia..tgGui] of TTianGanYuanSu;//天干元素数组

  TTianGanLian=class
  private
    FItems:TATianGanYuanSu;//天干元素数组
    FIndex:TTianGanShunXU;//索引
    FWuXingLian:TWuXingLian;//五行链
    function Get(TheIndex: TTianGanShunXu):TTianGanYuanSu;//获取元素
    procedure SetIndex(Value:TTianGanShunXU);
    function GetCurrentItem: TTianGanYuanSu;//索引的元素
  protected
  public
    destructor Destroy; override; //销毁
    constructor Create;//创建
    function First:TTianGanShunXU;//链首
    function Last:TTianGanShunXU;//链尾
    function Step(StepLen:Integer):TTianGanShunXU;//步进 正负均可
    property Index_:TTianGanShunXU read FIndex write SetIndex;//当前元素索引
    property Items[TheIndex: TTianGanShunXU]:TTianGanYuanSu read Get;//元素
    property CurrItem:TTianGanYuanSu read GetCurrentItem;//当前索引的元素
  end;


  //地支元素
  TDiZhiYuanSu=class
  protected
    FOrder:TDiZhiShunXU;//顺序
    FCaption:string;//名称
    FFangWei:TFangWei;//方位
    FYinYnag:TYinYang;//阴阳
    FWuXing:TWuXingYuanSu;//五行属性
    FHuoLi:THuoLi;//活力 孟、仲、季
  public
    property Order:TDiZhiShunXu read FOrder;//顺序
    property Caption:string read FCaption;//名称
    property FangWei:TFangWei read FFangWei;//方位
    property YinYang:TYinYang read FYinYnag;//阴阳
    property WuXing:TWuXingYuanSu read FWuXing;//五行
    property HuoLi:THuoLi read FHuoLi;//活力 孟、仲、季
  end;

  //地支链
  TADiZhiYuanSu=Array[dzZi..dzHai] of TDiZhiYuanSu;//地支元素数组

  TDiZhiLian=class
  private
    FItems:TADiZhiYuanSu;//地支元素数组
    FIndex:TDiZhiShunXU;//索引
    FWuXingLian:TWuXingLian;//五行链
    function Get(TheIndex: TDiZhiShunXu):TDiZhiYuanSu;//获取元素
    procedure SetIndex(Value:TDiZhiShunXu);
    function GetCurrentItem: TDiZhiYuanSu;//索引的元素
  protected
  public
    destructor Destroy; override; //销毁
    constructor Create;//创建
    function First:TDiZhiShunXU;//链首
    function Last:TDiZhiShunXU;//链尾
    function Step(StepLen:Integer):TDiZhiShunXu;//步进 正负均可
    property Index_:TDiZhiShunXu read FIndex write SetIndex;//当前元素索引
    property Items[TheIndex: TDiZhiShunXU]:TDiZhiYuanSu read Get;//元素
    property CurrItem:TDiZhiYuanSu read GetCurrentItem;//当前索引的元素
  end;

{
  //十二宫轮盘
  TDiPanGong=class //地盘宫
  private
  protected
    FDiZhi:TDiZhiYuanSu;//地支元素变量
  public
    property DiZhi:TDiZhiYuanSu read FDiZhi;//地支元素
  end;

  TTianPanGong=class(TDiPanGong) //天盘宫
  protected
    FDiZhi:TDiZhiYuanSu;//地支元素变量
    FTianJiang:TTianJiang; //所乘天将
  public
    property TianJiang:TTianJiang read FTianJiang;//天将
    property DiZhi:TDiZhiYuanSu read FDiZhi;//地支元素
  end;

  //地盘宫链
  TDiPanGongLian = array[dzZi..dzHai] of TDiPanGong;

  //地盘
  TDiPan=class
  private
    FItems:TDiPanGongLian;
    function GetItem(Index: TDiZhiShunXu):TDiPanGong;
  protected
  public
    property Items[Index: TDiZhiShunXu]:TDiPanGong read GetItem;
    destructor Destroy; override;
    constructor Create;
  end;

  //天盘
}

var
  I, II, III:Integer;

implementation

{ TWuXingLian }//五行链

constructor TWuXingLian.Create;
begin
  //创建五行元素变量,初始化
  FItems[wxShui]:=TWuXingYuanSu.Create;
  FItems[wxShui].FOrder:=wxShui;
  FItems[wxShui].FCaption:='水';
  FItems[wxShui].FFangWei:=fwBei;

  FItems[wxMu]:=TWuXingYuanSu.Create;
  FItems[wxMu].FOrder:=wxMu;
  FItems[wxMu].FCaption:='木';
  FItems[wxMu].FFangWei:=fwDong;

  FItems[wxHuo]:=TWuXingYuanSu.Create;
  FItems[wxHuo].FOrder:=wxHuo;
  FItems[wxHuo].FCaption:='火';
  FItems[wxHuo].FFangWei:=fwNan;

  FItems[wxTu]:=TWuXingYuanSu.Create;
  FItems[wxTu].FOrder:=wxTu;
  FItems[wxTu].FCaption:='土';
  FItems[wxTu].FFangWei:=fwZhong;

  FItems[wxJin]:=TWuXingYuanSu.Create;
  FItems[wxJin].FOrder:=wxJin;
  FItems[wxJin].FCaption:='金';
  FItems[wxJin].FFangWei:=fwXi;

  FIndex:=Low(TWuXingShunXu);

end;

destructor TWuXingLian.Destroy;
begin
  //释放元素变量
  FItems[wxShui].Free;
  FItems[wxMu].Free;
  FItems[wxHuo].Free;
  FItems[wxTu].Free;
  FItems[wxJin].Free;
  inherited;
end;

function TWuXingLian.First: TWuXingShunXu;
begin
  FIndex:=Low(TWuXingShunXu);//0起始值,要加1;
  Result:=FIndex;
end;

function TWuXingLian.Get(TheIndex: TWuXingShunXu): TWuXingYuanSu;
begin
  FIndex:=TheIndex;
  Result:=FItems[FIndex];
end;

function TWuXingLian.GetCurrentItem: TWuXingYuanSu;
begin
  Result:=FItems[Findex];
end;

function TWuXingLian.Last: TWuXingShunXu;
begin
  FIndex:=High(TWuXingShunXu);//最大值即可
  Result:=FIndex;
end;

procedure TWuXingLian.SetIndex(Value: TWuXingShunXu);
begin
  if (Value<=Low(TWuXingShunXu)) or (Value>High(TWuXingShunXu)) then
    Exit//超过范围
  else
    FIndex:=TWuXingShunXu(Value);
end;

function TWuXingLian.Step(StepLen: Integer): TWuXingShunXu;
begin
  I:=Integer(FIndex);
  I:=(I+StepLen) mod 5;//取 5 的余数
  if I<0 then I:=5+I;//变补码
  FIndex:=TWuXingShunXu(I);
  Result:=FIndex;
end;
{ /TWuXingLian }//五行链


{ TTianGanLian }//天干链
constructor TTianGanLian.Create;
begin
  FWuXingLian:=TWuXingLian.Create;//内置五行链
  
  FItems[tgJia]:=TTianGanYuansu.Create;
  FItems[tgJia].FOrder:=tgJia;
  FItems[tgJia].FCaption:='甲';
  FItems[tgJia].FFangWei:=fwDong;
  FItems[tgJia].FYinYnag:=yyYang;
  FItems[tgJia].FWuXing:=FWuXingLian.Items[wxMu];
  FItems[tgJia].FDiGong:=dzYin;

  FItems[tgYi]:=TTianGanYuansu.Create;
  FItems[tgYi].FOrder:=tgYi;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -