美文网首页
为谁炼金数据合并

为谁炼金数据合并

作者: Lohengriny | 来源:发表于2018-01-19 15:37 被阅读0次

    弄了个 Mathematica 脚本方便将自己的本体数据写入原本的 masterParam, 本地数据按照 masterParam 的格式写即可。

    masterParam=ImportString[FromCharacterCode@ToCharacterCode[Import["path\\49744fd6.txt"],"UTF-8"],"RawJSON"];
    customParam=ImportString[FromCharacterCode@ToCharacterCode[Import["path\\customParam.txt"],"UTF-8"],"RawJSON"];
    mergeParam[type_String]:=Block[
    {list},
    list=masterParam[[Key[type]]];
    list=Join[list,customParam[[Key[type]]]];
    list=Reverse[list];
    list=DeleteDuplicatesBy[list,#iname&];
    list=Reverse[list];
    masterParam[[Key[type]]]=list;
    ]
    mergeParam["Skill"];mergeParam["Buff"];mergeParam["Ability"];
    Button["Export Master Param",
    Export["path\\49744fd6.txt",masterParam,"RawJSON"];Print["OK!"]]
    

    修改版

    jsonOverwrite[json_, object_] := Module[
      {pos, iname = object["iname"]},
      pos = FirstPosition[json, _Association?(#["iname"] == iname &), 
        Null];
      If[ListQ[pos], Part[json, (Sequence @@ pos)] = object,
       Switch[StringSplit[iname, "_"][[1]],
        "SK", AppendTo[json["Skill"], object],
        "BUFF", AppendTo[json["Buff"], object],
        "AB", AppendTo[json["Ability"], object]
        ]
       ]
      ]
    SetAttributes[jsonOverwrite, HoldFirst]
    

    相关文章

      网友评论

          本文标题:为谁炼金数据合并

          本文链接:https://www.haomeiwen.com/subject/qnoooxtx.html