├── Image
├── p1.png
└── p2.png
├── GeniusInvokationAutoToy
├── Raiden.ico
├── Resources
│ └── Raiden.ico
├── Strategy
│ ├── Model
│ │ ├── CharacterStatusEnum.cs
│ │ ├── Skill.cs
│ │ ├── Old
│ │ │ └── CurrentCharacterStatus.cs
│ │ ├── RoundStrategy.cs
│ │ ├── ActionEnum.cs
│ │ ├── ActionCommand.cs
│ │ ├── Character.cs
│ │ └── Duel.cs
│ ├── Script
│ │ └── ScriptParser.cs
│ ├── KeqingRaidenGanyuStrategy.cs
│ └── MonaSucroseJeanStrategy.cs
├── Core
│ ├── MyException
│ │ ├── DuelEndException.cs
│ │ └── RetryException.cs
│ ├── Model
│ │ ├── RollPhaseDice.cs
│ │ └── ElementalType.cs
│ ├── ImageCapture.cs
│ ├── YuanShenWindow.cs
│ ├── ImageResCollections.cs
│ └── ImageRecognition.cs
├── Properties
│ ├── Settings.settings
│ ├── AssemblyInfo.cs
│ ├── Settings.Designer.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── packages.config
├── Utils
│ ├── Extension
│ │ ├── RetryExtension.cs
│ │ └── RectangleExtension.cs
│ ├── Retry.cs
│ ├── MyLogger.cs
│ ├── MouseUtils.cs
│ ├── PrimaryScreen.cs
│ ├── GAHelper.cs
│ ├── Device.cs
│ └── Native.cs
├── Nlog.config
├── FormMask.Designer.cs
├── App.config
├── FormMask1.Designer.cs
├── app.manifest
├── Forms
│ └── HotKey
│ │ ├── HotkeyTextBox.cs
│ │ ├── Hotkey.cs
│ │ └── HotkeyHook.cs
├── Program.cs
├── FormMask1.cs
├── FormMask.resx
├── FormMask1.resx
├── FormMain.cs
├── FormMain.Designer.cs
├── GeniusInvokationAutoToy.csproj
└── FormMask.cs
├── .gitignore
├── GeniusInvokationAutoToy.sln
└── README.md
/Image/p1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babalae/genius-invokation-auto-toy/HEAD/Image/p1.png
--------------------------------------------------------------------------------
/Image/p2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babalae/genius-invokation-auto-toy/HEAD/Image/p2.png
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy/Raiden.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babalae/genius-invokation-auto-toy/HEAD/GeniusInvokationAutoToy/Raiden.ico
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy/Resources/Raiden.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babalae/genius-invokation-auto-toy/HEAD/GeniusInvokationAutoToy/Resources/Raiden.ico
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy/Strategy/Model/CharacterStatusEnum.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace GeniusInvokationAutoToy.Strategy.Model
8 | {
9 | public enum CharacterStatusEnum
10 | {
11 | Frozen, Dizziness
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # User-specific files
2 | *.suo
3 | *.user
4 | *.userosscache
5 | *.sln.docstates
6 | .vs/
7 |
8 | # User-specific files (MonoDevelop/Xamarin Studio)
9 | *.userprefs
10 |
11 | # Build results
12 | [Dd]ebug/
13 | [Dd]ebugPublic/
14 | [Rr]elease/
15 | [Rr]eleases/
16 | x64/
17 | x86/
18 | bld/
19 | [Bb]in/
20 | [Oo]bj/
21 | [Ll]og/
22 |
23 | # Mine
24 | Tmp/
25 | /packages/
26 | node_modules/
27 |
28 | .idea
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy/Core/MyException/DuelEndException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace GeniusInvokationAutoToy.Core.MyException
8 | {
9 | public class DuelEndException: System.Exception
10 | {
11 | public DuelEndException(string message) : base(message)
12 | {
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy/Core/MyException/RetryException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Forms;
7 |
8 | namespace GeniusInvokationAutoToy.Core.MyException
9 | {
10 | public class RetryException : System.Exception
11 | {
12 | public RetryException() : base()
13 | {
14 | }
15 |
16 | public RetryException(string message) : base(message)
17 | {
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | False
7 |
8 |
9 | 0
10 |
11 |
12 | 0
13 |
14 |
15 |
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy/Strategy/Model/Skill.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using GeniusInvokationAutoToy.Core.Model;
7 |
8 | namespace GeniusInvokationAutoToy.Strategy.Model
9 | {
10 | public class Skill
11 | {
12 | ///
13 | /// 1-4 和数组下标一致,游戏中是从右往左开始数的!
14 | ///
15 | public short Index { get; set; }
16 | public ElementalType Type { get; set; }
17 | ///
18 | /// 消耗指定元素骰子数量
19 | ///
20 | public int SpecificElementCost { get; set; }
21 |
22 | ///
23 | /// 消耗杂色骰子数量
24 | ///
25 | public int AnyElementCost { get; set; } = 0;
26 | ///
27 | /// 消耗指定元素骰子数量 + 消耗杂色骰子数量 = 消耗总骰子数量
28 | ///
29 | public int AllCost { get; set; }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy/Utils/Extension/RetryExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 |
8 | namespace GeniusInvokationAutoToy.Utils.Extension
9 | {
10 | public static class RetryExtension
11 | {
12 | public static void InvokeWithRetries(this Action @this, ushort numberOfRetries, TimeSpan sleepPeriod, string throwsMessage)
13 | {
14 | try
15 | {
16 | @this();
17 | }
18 | catch
19 | {
20 | if (numberOfRetries == 0)
21 | {
22 | throw new Exception(throwsMessage);
23 | }
24 |
25 | Thread.Sleep(sleepPeriod);
26 |
27 | InvokeWithRetries(@this, --numberOfRetries, sleepPeriod, throwsMessage);
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy/Nlog.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
14 |
15 |
16 |
20 |
21 |
22 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy/Strategy/Model/Old/CurrentCharacterStatus.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace GeniusInvokationAutoToy.Strategy.Model.Old
8 | {
9 | public class CurrentCharacterStatus
10 | {
11 | ///
12 | /// 0-2 和所在数组下标一致
13 | ///
14 | public int ArrayIndex { get; set; }
15 | public int EnergyNum { get; set; }
16 |
17 | public List NegativeStatusList { get; set; } = new List();
18 |
19 | public override string ToString()
20 | {
21 | StringBuilder sb = new StringBuilder();
22 | sb.Append($"当前出战角色{ArrayIndex+1},");
23 | sb.Append($"充能={EnergyNum},");
24 | if (NegativeStatusList.Count > 0)
25 | {
26 | sb.Append($"负面状态:{string.Join(",", NegativeStatusList)}");
27 | }
28 | return sb.ToString();
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy/Utils/Extension/RectangleExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace GeniusInvokationAutoToy.Utils.Extension
9 | {
10 | public static class RectangleExtension
11 | {
12 | public static OpenCvSharp.Rect ToCvRect(this Rectangle rectangle)
13 | {
14 | return new OpenCvSharp.Rect(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
15 | }
16 |
17 | public static Rectangle ToRectangle(this OpenCvSharp.Rect rectangle)
18 | {
19 | return new Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
20 | }
21 |
22 | public static Point GetCenterPoint(this Rectangle rectangle)
23 | {
24 | if (rectangle.IsEmpty)
25 | {
26 | throw new ArgumentException("rectangle is empty");
27 | }
28 | return new Point(rectangle.X + rectangle.Width / 2, rectangle.Y + rectangle.Height / 2);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("GeniusInvokationAutoToy")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("GeniusInvokationAutoToy")]
13 | [assembly: AssemblyCopyright("Copyright © 2021")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("f17be4c5-926c-456d-9cc0-606dae304ed8")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.4.0.0")]
36 | [assembly: AssemblyFileVersion("1.4.0.0")]
37 |
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy/Strategy/Model/RoundStrategy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using GeniusInvokationAutoToy.Core.Model;
7 |
8 | namespace GeniusInvokationAutoToy.Strategy.Model
9 | {
10 | public class RoundStrategy
11 | {
12 | public List RawCommandList { get; set; } = new List();
13 |
14 | public List ActionCommands { get; set; } = new List();
15 |
16 | public List MaybeNeedElement(Duel duel)
17 | {
18 | List result = new List();
19 |
20 | for (int i = 0; i < ActionCommands.Count; i++)
21 | {
22 | if (ActionCommands[i].Action == ActionEnum.SwitchLater
23 | && i != ActionCommands.Count-1
24 | && ActionCommands[i+1].Action == ActionEnum.UseSkill)
25 | {
26 | result.Add(duel.Characters[ActionCommands[i].TargetIndex].Element);
27 | }
28 | }
29 | return result;
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy/Core/Model/RollPhaseDice.cs:
--------------------------------------------------------------------------------
1 | using GeniusInvokationAutoToy.Utils;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Drawing;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace GeniusInvokationAutoToy.Core.Model
10 | {
11 | ///
12 | /// 投掷期间骰子
13 | ///
14 | public class RollPhaseDice
15 | {
16 | ///
17 | /// 元素类型
18 | ///
19 | public ElementalType Type { get; set; }
20 |
21 | ///
22 | /// 中心点位置
23 | ///
24 | public Point CenterPosition { get; set; }
25 |
26 | public RollPhaseDice(ElementalType type, Point centerPosition)
27 | {
28 | Type = type;
29 | CenterPosition = centerPosition;
30 | }
31 |
32 | public RollPhaseDice()
33 | {
34 | }
35 |
36 | public override string ToString()
37 | {
38 | return $"Type:{Type},CenterPosition:{CenterPosition}";
39 | }
40 |
41 | public void Click()
42 | {
43 | MouseUtils.Click(CenterPosition.X, CenterPosition.Y);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.1.32228.430
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeniusInvokationAutoToy", "GeniusInvokationAutoToy\GeniusInvokationAutoToy.csproj", "{F17BE4C5-926C-456D-9CC0-606DAE304ED8}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {F17BE4C5-926C-456D-9CC0-606DAE304ED8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {F17BE4C5-926C-456D-9CC0-606DAE304ED8}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {F17BE4C5-926C-456D-9CC0-606DAE304ED8}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {F17BE4C5-926C-456D-9CC0-606DAE304ED8}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {DFA8F1CD-513D-45D7-856D-378146C4D367}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy/Core/ImageCapture.cs:
--------------------------------------------------------------------------------
1 | using GeniusInvokationAutoToy.Utils;
2 | using System;
3 | using System.Drawing;
4 |
5 | namespace GeniusInvokationAutoToy.Core
6 | {
7 | public class ImageCapture
8 | {
9 | IntPtr hwnd;
10 | IntPtr hdc;
11 |
12 | public int X { get; set; }
13 | public int Y { get; set; }
14 | public int W { get; set; }
15 | public int H { get; set; }
16 |
17 | public void Start(int x, int y, int w, int h)
18 | {
19 | hwnd = Native.GetDesktopWindow();
20 | hdc = Native.GetDC(hwnd);
21 |
22 | this.X = x;
23 | this.Y = y;
24 | this.W = w;
25 | this.H = h;
26 | }
27 |
28 | public Bitmap Capture()
29 | {
30 | Bitmap bmp = new Bitmap(W, H);
31 | Graphics bmpGraphic = Graphics.FromImage(bmp);
32 | //get handle to source graphic
33 | IntPtr bmpHdc = bmpGraphic.GetHdc();
34 |
35 | //copy it
36 | bool res = Native.StretchBlt(bmpHdc, 0, 0, W, H,
37 | hdc, X, Y, W, H, Native.CopyPixelOperation.SourceCopy);
38 | bmpGraphic.ReleaseHdc();
39 | return bmp;
40 | }
41 |
42 | public void Stop()
43 | {
44 | Native.ReleaseDC(hwnd, hdc);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/GeniusInvokationAutoToy/Utils/Retry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 |
8 | namespace GeniusInvokationAutoToy.Utils
9 | {
10 | ///
11 | /// https://stackoverflow.com/questions/1563191/cleanest-way-to-write-retry-logic
12 | ///
13 | public static class Retry
14 | {
15 | public static void Do(
16 | Action action,
17 | TimeSpan retryInterval,
18 | int maxAttemptCount = 3)
19 | {
20 | Do