Commit cde559d8 authored by perfectdicky's avatar perfectdicky

merge lllyasviel/YGOProUnity_V2 offline AI codes

parent 64ddcba4
Pipeline #21964 waiting for manual action with stage
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
/// <summary>
/// Allows processes to be automatically killed if this parent process unexpectedly quits.
/// This feature requires Windows 8 or greater. On Windows 7, nothing is done.</summary>
/// <remarks>References:
/// https://stackoverflow.com/a/37034966/5264011
/// https://stackoverflow.com/a/4657392/386091
/// https://stackoverflow.com/a/9164742/386091 </remarks>
public static class ChildProcessTracker
{
/// <summary>
/// Add the process to be tracked. If our current process is killed, the child processes
/// that we are tracking will be automatically killed, too. If the child process terminates
/// first, that's fine, too.</summary>
/// <param name="process"></param>
public static void AddProcess(Process process)
{
if (s_jobHandle != IntPtr.Zero)
{
bool success = AssignProcessToJobObject(s_jobHandle, process.Handle);
if (!success && !process.HasExited)
throw new Win32Exception();
}
}
static ChildProcessTracker()
{
// This feature requires Windows 8 or later. To support Windows 7 requires
// registry settings to be added if you are using Visual Studio plus an
// app.manifest change.
// https://stackoverflow.com/a/4232259/386091
// https://stackoverflow.com/a/9507862/386091
if (Environment.OSVersion.Version < new Version(6, 2))
return;
// The job name is optional (and can be null) but it helps with diagnostics.
// If it's not null, it has to be unique. Use SysInternals' Handle command-line
// utility: handle -a ChildProcessTracker
string jobName = "ChildProcessTracker" + Process.GetCurrentProcess().Id;
s_jobHandle = CreateJobObject(IntPtr.Zero, jobName);
var info = new JOBOBJECT_BASIC_LIMIT_INFORMATION();
// This is the key flag. When our process is killed, Windows will automatically
// close the job handle, and when that happens, we want the child processes to
// be killed, too.
info.LimitFlags = JOBOBJECTLIMIT.JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
var extendedInfo = new JOBOBJECT_EXTENDED_LIMIT_INFORMATION();
extendedInfo.BasicLimitInformation = info;
int length = Marshal.SizeOf(typeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION));
IntPtr extendedInfoPtr = Marshal.AllocHGlobal(length);
try
{
Marshal.StructureToPtr(extendedInfo, extendedInfoPtr, false);
if (!SetInformationJobObject(s_jobHandle, JobObjectInfoType.ExtendedLimitInformation,
extendedInfoPtr, (uint)length))
{
throw new Win32Exception();
}
}
finally
{
Marshal.FreeHGlobal(extendedInfoPtr);
}
}
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
static extern IntPtr CreateJobObject(IntPtr lpJobAttributes, string name);
[DllImport("kernel32.dll")]
static extern bool SetInformationJobObject(IntPtr job, JobObjectInfoType infoType,
IntPtr lpJobObjectInfo, uint cbJobObjectInfoLength);
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool AssignProcessToJobObject(IntPtr job, IntPtr process);
// Windows will automatically close any open job handles when our process terminates.
// This can be verified by using SysInternals' Handle utility. When the job handle
// is closed, the child processes will be killed.
private static readonly IntPtr s_jobHandle;
}
public enum JobObjectInfoType
{
AssociateCompletionPortInformation = 7,
BasicLimitInformation = 2,
BasicUIRestrictions = 4,
EndOfJobTimeInformation = 6,
ExtendedLimitInformation = 9,
SecurityLimitInformation = 5,
GroupInformation = 11
}
[StructLayout(LayoutKind.Sequential)]
public struct JOBOBJECT_BASIC_LIMIT_INFORMATION
{
public Int64 PerProcessUserTimeLimit;
public Int64 PerJobUserTimeLimit;
public JOBOBJECTLIMIT LimitFlags;
public UIntPtr MinimumWorkingSetSize;
public UIntPtr MaximumWorkingSetSize;
public UInt32 ActiveProcessLimit;
public Int64 Affinity;
public UInt32 PriorityClass;
public UInt32 SchedulingClass;
}
[Flags]
public enum JOBOBJECTLIMIT : uint
{
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE = 0x2000
}
[StructLayout(LayoutKind.Sequential)]
public struct IO_COUNTERS
{
public UInt64 ReadOperationCount;
public UInt64 WriteOperationCount;
public UInt64 OtherOperationCount;
public UInt64 ReadTransferCount;
public UInt64 WriteTransferCount;
public UInt64 OtherTransferCount;
}
[StructLayout(LayoutKind.Sequential)]
public struct JOBOBJECT_EXTENDED_LIMIT_INFORMATION
{
public JOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimitInformation;
public IO_COUNTERS IoInfo;
public UIntPtr ProcessMemoryLimit;
public UIntPtr JobMemoryLimit;
public UIntPtr PeakProcessMemoryUsed;
public UIntPtr PeakJobMemoryUsed;
}
\ No newline at end of file
fileFormatVersion: 2
guid: e6f01f5f8a85eb94e971006330b7192b
timeCreated: 1664152009
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -9,7 +9,7 @@ using UnityEngine.Networking; ...@@ -9,7 +9,7 @@ using UnityEngine.Networking;
public class Menu : WindowServantSP public class Menu : WindowServantSP
{ {
private static int lastTime; //private static int lastTime;
private bool msgPermissionShowed; private bool msgPermissionShowed;
private bool msgUpdateShowed; private bool msgUpdateShowed;
...@@ -26,7 +26,7 @@ public class Menu : WindowServantSP ...@@ -26,7 +26,7 @@ public class Menu : WindowServantSP
UIHelper.registEvent(gameObject, "online_", onClickOnline); UIHelper.registEvent(gameObject, "online_", onClickOnline);
UIHelper.registEvent(gameObject, "replay_", onClickReplay); UIHelper.registEvent(gameObject, "replay_", onClickReplay);
UIHelper.registEvent(gameObject, "single_", onClickPizzle); UIHelper.registEvent(gameObject, "single_", onClickPizzle);
UIHelper.registEvent(gameObject, "ai_", Program.gugugu); UIHelper.registEvent(gameObject, "ai_", onClickAI);
UIHelper.registEvent(gameObject, "exit_", onClickExit); UIHelper.registEvent(gameObject, "exit_", onClickExit);
Program.I().StartCoroutine(checkUpdate()); Program.I().StartCoroutine(checkUpdate());
} }
...@@ -117,10 +117,10 @@ public class Menu : WindowServantSP ...@@ -117,10 +117,10 @@ public class Menu : WindowServantSP
Program.I().shiftToServant(Program.I().selectServer); Program.I().shiftToServant(Program.I().selectServer);
} }
// private void onClickAI() private void onClickAI()
// { {
// Program.I().shiftToServant(Program.I().aiRoom); Program.I().shiftToServant(Program.I().aiRoom);
// } }
private void onClickPizzle() private void onClickPizzle()
{ {
...@@ -141,4 +141,133 @@ public class Menu : WindowServantSP ...@@ -141,4 +141,133 @@ public class Menu : WindowServantSP
{ {
Program.I().shiftToServant(Program.I().selectDeck); Program.I().shiftToServant(Program.I().selectDeck);
} }
public static void deleteShell()
{
try
{
if (File.Exists("commamd.shell") == true)
{
File.Delete("commamd.shell");
}
}
catch (Exception)
{
}
}
static int lastTime = 0;
public static void checkCommend()
{
if (Program.TimePassed() - lastTime > 1000)
{
lastTime = Program.TimePassed();
if (Program.I().selectDeck == null)
{
return;
}
if (Program.I().selectReplay == null)
{
return;
}
if (Program.I().puzzleMode == null)
{
return;
}
if (Program.I().selectServer == null)
{
return;
}
try
{
if (File.Exists("commamd.shell") == false)
{
File.Create("commamd.shell").Close();
}
}
catch (System.Exception e)
{
Program.noAccess = true;
UnityEngine.Debug.Log(e);
}
string all = "";
try
{
all = File.ReadAllText("commamd.shell", Encoding.UTF8);
char[] parmChars = all.ToCharArray();
bool inQuote = false;
for (int index = 0; index < parmChars.Length; index++)
{
if (parmChars[index] == '"')
{
inQuote = !inQuote;
parmChars[index] = '\n';
}
if (!inQuote && parmChars[index] == ' ')
parmChars[index] = '\n';
}
string[] mats = (new string(parmChars)).Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
if (mats.Length > 0)
{
switch (mats[0])
{
case "online":
if (mats.Length == 5)
{
UIHelper.iniFaces();//加载用户头像
Program.I().selectServer.KF_onlineGame(mats[1], mats[2], mats[3], mats[4]);
}
if (mats.Length == 6)
{
UIHelper.iniFaces();
Program.I().selectServer.KF_onlineGame(mats[1], mats[2], mats[3], mats[4], mats[5]);
}
break;
case "edit":
if (mats.Length == 2)
{
Program.I().selectDeck.KF_editDeck(mats[1]);//编辑卡组
}
break;
case "replay":
if (mats.Length == 2)
{
UIHelper.iniFaces();
Program.I().selectReplay.KF_replay(mats[1]);//编辑录像
}
break;
case "puzzle":
if (mats.Length == 2)
{
UIHelper.iniFaces();
Program.I().puzzleMode.KF_puzzle(mats[1]);//运行残局
}
break;
default:
break;
}
}
}
catch (System.Exception e)
{
Program.noAccess = true;
UnityEngine.Debug.Log(e);
}
try
{
if (all != "")
{
if (File.Exists("commamd.shell") == true)
{
File.WriteAllText("commamd.shell", "");
}
}
}
catch (System.Exception e)
{
Program.noAccess = true;
UnityEngine.Debug.Log(e);
}
}
}
} }
\ No newline at end of file
...@@ -192,7 +192,6 @@ public static class TcpHelper ...@@ -192,7 +192,6 @@ public static class TcpHelper
if (onDisConnected) if (onDisConnected)
{ {
onDisConnected = false; onDisConnected = false;
Program.I().ocgcore.returnServant = Program.I().selectServer;
if (tcpClient != null) if (tcpClient != null)
if (tcpClient.Connected) if (tcpClient.Connected)
{ {
...@@ -203,7 +202,13 @@ public static class TcpHelper ...@@ -203,7 +202,13 @@ public static class TcpHelper
tcpClient = null; tcpClient = null;
if (Program.I().ocgcore.isShowed == false) if (Program.I().ocgcore.isShowed == false)
{ {
if (Program.I().menu.isShowed == false) Program.I().shiftToServant(Program.I().selectServer); if (Program.I().menu.isShowed == false)
{
if (Program.I().ocgcore.returnServant != null)
Program.I().shiftToServant(Program.I().ocgcore.returnServant);
else
Program.I().shiftToServant(Program.I().selectServer);
}
Program.I().cardDescription.RMSshow_none(InterString.Get("连接被断开。")); Program.I().cardDescription.RMSshow_none(InterString.Get("连接被断开。"));
packagesInRecord.Clear(); packagesInRecord.Clear();
} }
......
...@@ -797,6 +797,7 @@ public class Ocgcore : ServantWithCardDescription ...@@ -797,6 +797,7 @@ public class Ocgcore : ServantWithCardDescription
if (Program.exitOnReturn && returnServant != Program.I().deckManager) if (Program.exitOnReturn && returnServant != Program.I().deckManager)
Program.I().menu.onClickExit(); Program.I().menu.onClickExit();
else if (returnServant != null) Program.I().shiftToServant(returnServant); else if (returnServant != null) Program.I().shiftToServant(returnServant);
else Program.I().shiftToServant(Program.I().selectServer);
} }
public void onExit() public void onExit()
...@@ -805,11 +806,10 @@ public class Ocgcore : ServantWithCardDescription ...@@ -805,11 +806,10 @@ public class Ocgcore : ServantWithCardDescription
{ {
if (TcpHelper.tcpClient.Connected) if (TcpHelper.tcpClient.Connected)
{ {
Program.I().ocgcore.returnServant = Program.I().selectServer;
TcpHelper.tcpClient.Client.Shutdown(0); TcpHelper.tcpClient.Client.Shutdown(0);
TcpHelper.tcpClient.Close(); TcpHelper.tcpClient.Close();
} }
Program.I().aiRoom.killServerProcess();
TcpHelper.tcpClient = null; TcpHelper.tcpClient = null;
} }
...@@ -6861,6 +6861,7 @@ public class Ocgcore : ServantWithCardDescription ...@@ -6861,6 +6861,7 @@ public class Ocgcore : ServantWithCardDescription
private void returnFromDeckEdit() private void returnFromDeckEdit()
{ {
TcpHelper.CtosMessage_UpdateDeck(Program.I().deckManager.getRealDeck()); TcpHelper.CtosMessage_UpdateDeck(Program.I().deckManager.getRealDeck());
returnServant = Program.I().selectServer;
} }
public override void show() public override void show()
......
...@@ -393,6 +393,7 @@ public class Program : MonoBehaviour ...@@ -393,6 +393,7 @@ public class Program : MonoBehaviour
initializeALLservants(); initializeALLservants();
loadResources(); loadResources();
readParams();
} }
private void readParams() private void readParams()
...@@ -716,7 +717,7 @@ public class Program : MonoBehaviour ...@@ -716,7 +717,7 @@ public class Program : MonoBehaviour
public SelectServer selectServer; public SelectServer selectServer;
public Book book; public Book book;
public puzzleMode puzzleMode; public puzzleMode puzzleMode;
// public AIRoom aiRoom; public AIRoom aiRoom;
private void initializeALLservants() private void initializeALLservants()
{ {
...@@ -741,8 +742,8 @@ public class Program : MonoBehaviour ...@@ -741,8 +742,8 @@ public class Program : MonoBehaviour
servants.Add(selectReplay); servants.Add(selectReplay);
puzzleMode = new puzzleMode(); puzzleMode = new puzzleMode();
servants.Add(puzzleMode); servants.Add(puzzleMode);
// aiRoom = new AIRoom(); aiRoom = new AIRoom();
// servants.Add(aiRoom); servants.Add(aiRoom);
} }
public void shiftToServant(Servant to) public void shiftToServant(Servant to)
...@@ -757,7 +758,7 @@ public class Program : MonoBehaviour ...@@ -757,7 +758,7 @@ public class Program : MonoBehaviour
if (to != selectServer && selectServer.isShowed) selectServer.hide(); if (to != selectServer && selectServer.isShowed) selectServer.hide();
if (to != selectReplay && selectReplay.isShowed) selectReplay.hide(); if (to != selectReplay && selectReplay.isShowed) selectReplay.hide();
if (to != puzzleMode && puzzleMode.isShowed) puzzleMode.hide(); if (to != puzzleMode && puzzleMode.isShowed) puzzleMode.hide();
// if (to != aiRoom && aiRoom.isShowed) aiRoom.hide(); if (to != aiRoom && aiRoom.isShowed) aiRoom.hide();
if (to == backGroundPic && backGroundPic.isShowed == false) backGroundPic.show(); if (to == backGroundPic && backGroundPic.isShowed == false) backGroundPic.show();
if (to == menu && menu.isShowed == false) menu.show(); if (to == menu && menu.isShowed == false) menu.show();
...@@ -769,7 +770,7 @@ public class Program : MonoBehaviour ...@@ -769,7 +770,7 @@ public class Program : MonoBehaviour
if (to == selectServer && selectServer.isShowed == false) selectServer.show(); if (to == selectServer && selectServer.isShowed == false) selectServer.show();
if (to == selectReplay && selectReplay.isShowed == false) selectReplay.show(); if (to == selectReplay && selectReplay.isShowed == false) selectReplay.show();
if (to == puzzleMode && puzzleMode.isShowed == false) puzzleMode.show(); if (to == puzzleMode && puzzleMode.isShowed == false) puzzleMode.show();
// if (to == aiRoom && aiRoom.isShowed == false) aiRoom.show(); if (to == aiRoom && aiRoom.isShowed == false) aiRoom.show();
} }
#endregion #endregion
...@@ -909,7 +910,7 @@ public class Program : MonoBehaviour ...@@ -909,7 +910,7 @@ public class Program : MonoBehaviour
public static bool noAccess = false; public static bool noAccess = false;
public static bool exitOnReturn; public static bool exitOnReturn = false;
private void OnApplicationQuit() private void OnApplicationQuit()
{ {
...@@ -928,6 +929,7 @@ public class Program : MonoBehaviour ...@@ -928,6 +929,7 @@ public class Program : MonoBehaviour
} }
foreach (var zip in GameZipManager.Zips) zip.Dispose(); foreach (var zip in GameZipManager.Zips) zip.Dispose();
aiRoom.killServerProcess();
} }
public void quit() public void quit()
......
// using System; using System;
// using System.IO; using System.Collections.Generic;
// using Random = UnityEngine.Random; using System.IO;
// using System.Text.RegularExpressions;
// public class AIRoom : WindowServantSP using System.Threading;
// { using UnityEngine;
// private PrecyOcg precy;
// public class AIRoom : WindowServantSP
// public void launch(string playerDek, string aiDeck, string aiScript, bool playerGo, bool suffle, int life, bool god, {
// int rule) #region ui
// { UIselectableList superScrollView = null;
// if (precy != null) precy.dispose(); string sort = "sortByTimeDeck";
// precy = new PrecyOcg(); System.Diagnostics.Process serverProcess;
// precy.startAI(playerDek, aiDeck, aiScript, playerGo, suffle, life, god, rule); System.Diagnostics.Process botProcess;
// RMSshow_none(InterString.Get("AI模式还在开发中,您在AI模式下遇到的BUG不会在联机的时候出现。"));
// } public class BotInfo
// {
// #region ui public string name;
// public string command;
// private UIselectableList superScrollView; public string desc;
// private readonly string sort = "sortByTimeDeck"; public string[] flags;
// private string suiji = ""; }
// private IList<BotInfo> Bots = new List<BotInfo>();
// private UIPopupList list_aideck; private void ReadBots(string confPath)
// private UIPopupList list_airank; {
// StreamReader reader = new StreamReader(new FileStream(confPath, FileMode.Open, FileAccess.Read));
// public override void initialize() while (!reader.EndOfStream)
// { {
// suiji = InterString.Get("随机卡组"); string line = reader.ReadLine().Trim();
// SetWindow(Program.I().new_ui_aiRoom); if (line.Length > 0 && line[0] == '!')
// superScrollView = gameObject.GetComponentInChildren<UIselectableList>(); {
// superScrollView.selectedAction = onSelected; BotInfo newBot = new BotInfo();
// list_aideck = UIHelper.getByName<UIPopupList>(gameObject, "aideck_"); newBot.name = line.TrimStart('!');
// list_airank = UIHelper.getByName<UIPopupList>(gameObject, "rank_"); newBot.command = reader.ReadLine().Trim();
// list_aideck.value = Config.Get("list_aideck", suiji); newBot.desc = reader.ReadLine().Trim();
// list_airank.value = Config.Get("list_airank", "ai"); line = reader.ReadLine().Trim();
// UIHelper.registEvent(gameObject, "aideck_", onSave); newBot.flags = line.Split(' ');
// UIHelper.registEvent(gameObject, "rank_", onSave); if (Array.IndexOf(newBot.flags, "SELECT_DECKFILE") < 0)
// UIHelper.registEvent(gameObject, "start_", onStart); Bots.Add(newBot);
// UIHelper.registEvent(gameObject, "exit_", onClickExit); }
// UIHelper.trySetLableText(gameObject, "percyHint", InterString.Get("人机模式")); }
// superScrollView.install(); }
// SetActiveFalse();
// } private string GetRandomBot(string flag)
// {
// private void onSelected() IList<BotInfo> foundBots = new List<BotInfo>();
// { foreach (var bot in Bots)
// Config.Set("deckInUse", superScrollView.selectedString); {
// } if (Array.IndexOf(bot.flags, flag) >= 0) foundBots.Add(bot);
// }
// private void onSave() if (foundBots.Count > 0)
// { {
// Config.Set("list_aideck", list_aideck.value); System.Random rand = new System.Random();
// Config.Set("list_airank", list_airank.value); BotInfo bot = foundBots[rand.Next(foundBots.Count)];
// } return bot.command;
// }
// private void onClickExit() return "";
// { }
// if (Program.exitOnReturn)
// Program.I().menu.onClickExit(); public override void initialize()
// else {
// Program.I().shiftToServant(Program.I().menu); CreateWindow(Program.I().new_ui_aiRoom);
// } superScrollView = gameObject.GetComponentInChildren<UIselectableList>();
// superScrollView.selectedAction = onSelected;
// private void onStart() UIHelper.registEvent(gameObject, "start_", onStart);
// { UIHelper.registEvent(gameObject, "exit_", onClickExit);
// if (!isShowed) return; UIHelper.trySetLableText(gameObject, "percyHint", InterString.Get("人机模式"));
// var l = 8000; UIHelper.trySetLableText(gameObject, "botdesc_", InterString.Get("请选择对手。"));
// try superScrollView.install();
// { ReadBots("config/bot.conf");
// l = int.Parse(UIHelper.getByName<UIInput>(gameObject, "life_").value); SetActiveFalse();
// } }
// catch (Exception)
// { void onSelected()
// } {
// int sel = superScrollView.selectedIndex;
// var aideck = ""; if (sel >= 0 && sel < Bots.Count)
// if (Config.Get("list_aideck", suiji) == suiji) UIHelper.trySetLableText(gameObject, "botdesc_", Bots[sel].desc);
// aideck = "ai/ydk/" + list_aideck.items[Random.Range(1, list_aideck.items.Count)] + ".ydk"; else
// else UIHelper.trySetLableText(gameObject, "botdesc_", InterString.Get("请选择对手。"));
// aideck = "ai/ydk/" + Config.Get("list_aideck", suiji) + ".ydk"; }
// launch("deck/" + Config.Get("deckInUse", "miaowu") + ".ydk", aideck,
// "ai/" + Config.Get("list_airank", "ai") + ".lua", UIHelper.getByName<UIToggle>(gameObject, "first_").value, void onSave()
// UIHelper.getByName<UIToggle>(gameObject, "unrand_").value, l, {
// UIHelper.getByName<UIToggle>(gameObject, "god_").value, //Config.Set("list_aideck", list_aideck.value);
// UIHelper.getByName<UIToggle>(gameObject, "mr4_").value ? 4 : 3); //Config.Set("list_airank", list_airank.value);
// } }
//
// private void printFile() void onClickExit()
// { {
// var deckInUse = Config.Get("deckInUse", "miaowu"); killServerProcess();
// superScrollView.clear(); if (Program.exitOnReturn)
// var fileInfos = new DirectoryInfo("deck").GetFiles(); Program.I().menu.onClickExit();
// if (Config.Get(sort, "1") == "1") else
// Array.Sort(fileInfos, UIHelper.CompareTime); Program.I().shiftToServant(Program.I().menu);
// else }
// Array.Sort(fileInfos, UIHelper.CompareName);
// for (var i = 0; i < fileInfos.Length; i++) public void killServerProcess()
// if (fileInfos[i].Name.Length > 4) {
// if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 4, 4) == ".ydk") if (serverProcess != null && !serverProcess.HasExited)
// if (fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4) == deckInUse) {
// superScrollView.add(fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4)); serverProcess.Kill();
// for (var i = 0; i < fileInfos.Length; i++) }
// if (fileInfos[i].Name.Length > 4) serverProcess = null;
// if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 4, 4) == ".ydk") }
// if (fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4) != deckInUse)
// superScrollView.add(fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4)); void onStart()
// list_aideck.Clear(); {
// fileInfos = new DirectoryInfo("ai/ydk").GetFiles(); if (!isShowed)
// Array.Sort(fileInfos, UIHelper.CompareName); {
// list_aideck.AddItem(suiji); return;
// for (var i = 0; i < fileInfos.Length; i++) }
// if (fileInfos[i].Name.Length > 4) int sel = superScrollView.selectedIndex;
// if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 4, 4) == ".ydk") if (sel < 0 || sel >= Bots.Count)
// list_aideck.AddItem(fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4)); {
// list_airank.Clear(); return;
// fileInfos = new DirectoryInfo("ai").GetFiles(); }
// Array.Sort(fileInfos, UIHelper.CompareName);
// for (var i = 0; i < fileInfos.Length; i++) string aiCommand = Bots[sel].command;
// if (fileInfos[i].Name.Length > 4) Match match = Regex.Match(aiCommand, "Random=(\\w+)");
// if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 4, 4) == ".lua") if (match.Success)
// list_airank.AddItem(fileInfos[i].Name.Substring(0, fileInfos[i].Name.Length - 4)); {
// } string randomFlag = match.Groups[1].Value;
// string command = GetRandomBot(randomFlag);
// public override void show() if (command != "")
// { {
// base.show(); aiCommand = command;
// printFile(); }
// superScrollView.selectedString = Config.Get("deckInUse", "miaowu"); }
// superScrollView.toTop();
// Program.charge(); launch(aiCommand, UIHelper.getByName<UIToggle>(gameObject, "lockhand_").value, UIHelper.getByName<UIToggle>(gameObject, "nocheck_").value, UIHelper.getByName<UIToggle>(gameObject, "noshuffle_").value);
// } }
//
// #endregion void printFile()
// } {
\ No newline at end of file superScrollView.clear();
foreach (var bot in Bots)
{
superScrollView.add(bot.name);
}
}
public override void show()
{
base.show();
printFile();
onSelected();
Program.charge();
}
#endregion
PrecyOcg precy;
public void launch(string command, bool lockhand, bool nocheck, bool noshuffle)
{
killServerProcess();
command = command.Replace("'", "\"");
if (lockhand) command += " Hand=1";
serverProcess = new System.Diagnostics.Process();
serverProcess.StartInfo.UseShellExecute = false;
serverProcess.StartInfo.FileName = "AI.Server.exe";
serverProcess.StartInfo.Arguments = "7911 -1 5 0 F " + (nocheck ? "T" : "F") + " " + (noshuffle ? "T" : "F") + " 8000 5 1 0 0";
serverProcess.StartInfo.CreateNoWindow = true;
serverProcess.StartInfo.RedirectStandardOutput = true;
serverProcess.Start();
string port = serverProcess.StandardOutput.ReadLine();
command += " Port=" + port;
botProcess = new System.Diagnostics.Process();
botProcess.StartInfo.UseShellExecute = false;
botProcess.StartInfo.FileName = "WindBot/WindBot.exe";
botProcess.StartInfo.WorkingDirectory = "WindBot";
botProcess.StartInfo.Arguments = command;
botProcess.StartInfo.CreateNoWindow = true;
botProcess.StartInfo.RedirectStandardOutput = true;
botProcess.Start();
botProcess.StandardOutput.ReadLine();
ChildProcessTracker.AddProcess(serverProcess);
ChildProcessTracker.AddProcess(botProcess);
string name = Config.Get("name", "一秒一咕机会");
Program.I().ocgcore.returnServant = Program.I().aiRoom;
(new Thread(() => { Thread.Sleep(500); TcpHelper.join("127.0.0.1", name, port, "", ""); })).Start();
RMSshow_none(InterString.Get("您在AI模式下遇到的BUG也极有可能会在联机的时候出现,所以请务必向我们报告。"));
}
public override void preFrameFunction()
{
base.preFrameFunction();
Menu.checkCommend();
}
}
\ No newline at end of file
...@@ -38,7 +38,6 @@ public class Room : WindowServantSP ...@@ -38,7 +38,6 @@ public class Room : WindowServantSP
public override void show() public override void show()
{ {
base.show(); base.show();
Program.I().ocgcore.returnServant = Program.I().selectServer;
Program.I().ocgcore.handler = handler; Program.I().ocgcore.handler = handler;
UIHelper.registEvent(toolBar, "input_", onChat); UIHelper.registEvent(toolBar, "input_", onChat);
Program.charge(); Program.charge();
...@@ -267,7 +266,6 @@ public class Room : WindowServantSP ...@@ -267,7 +266,6 @@ public class Room : WindowServantSP
public void StocMessage_DuelStart(BinaryReader r) public void StocMessage_DuelStart(BinaryReader r)
{ {
Program.I().ocgcore.returnServant = Program.I().selectServer;
needSide = false; needSide = false;
joinWithReconnect = true; joinWithReconnect = true;
if (Program.I().deckManager.isShowed) if (Program.I().deckManager.isShowed)
......
...@@ -32,7 +32,7 @@ public class WindowServantSP : Servant ...@@ -32,7 +32,7 @@ public class WindowServantSP : Servant
if (glass != null) glass.gameObject.SetActive(false); if (glass != null) glass.gameObject.SetActive(false);
} }
// resize(); resize();
} }
public void SetActiveFalse() public void SetActiveFalse()
...@@ -59,24 +59,24 @@ public class WindowServantSP : Servant ...@@ -59,24 +59,24 @@ public class WindowServantSP : Servant
if (glass != null) glass.gameObject.SetActive(true); if (glass != null) glass.gameObject.SetActive(true);
} }
// resize(); resize();
} }
// private void resize() private void resize()
// { {
// if (gameObject != null) if (gameObject != null)
// { {
// if (Program.I().setting.setting.resize.value) if (Program.I().setting.setting.resize.value)
// { {
// var f = Screen.height / 700f; var f = Screen.height / 700f;
// gameObject.transform.localScale = new Vector3(f, f, f); gameObject.transform.localScale = new Vector3(f, f, f);
// } }
// else else
// { {
// gameObject.transform.localScale = new Vector3(1, 1, 1); gameObject.transform.localScale = new Vector3(1, 1, 1);
// } }
// } }
// } }
public void SetWindow(GameObject mod) public void SetWindow(GameObject mod)
{ {
......
...@@ -62,28 +62,30 @@ public class PrecyOcg ...@@ -62,28 +62,30 @@ public class PrecyOcg
} }
} }
// public void startAI(string playerDek, string aiDeck, string aiScript, bool playerGo, bool unrand, int life, public void startAI(string playerDek, string aiDeck, string aiScript, bool playerGo, bool unrand, int life,
// bool god, int rule) bool god, int rule)
// { {
// if (Program.I().ocgcore.isShowed == false) if (Program.I().ocgcore.isShowed == false)
// { {
// Program.I().room.mode = 0; Program.I().room.mode = 0;
// Program.I().ocgcore.MasterRule = rule; Program.I().ocgcore.MasterRule = rule;
// godMode = god; godMode = god;
// prepareOcgcore(); prepareOcgcore();
// Program.I().ocgcore.lpLimit = life; Program.I().ocgcore.lpLimit = life;
// Program.I().ocgcore.isFirst = playerGo; Program.I().ocgcore.isFirst = playerGo;
// Program.I().ocgcore.returnServant = Program.I().aiRoom; Program.I().ocgcore.returnServant = Program.I().aiRoom;
// if (!ygopro.startAI(playerDek, aiDeck, aiScript, playerGo, unrand, life, god, rule)) if (!ygopro.startAI(playerDek, aiDeck, aiScript, playerGo, unrand, life, god, rule))
// { {
// Program.I().cardDescription.RMSshow_none(InterString.Get("游戏内部出错,请重试。")); Program.I().cardDescription.RMSshow_none(InterString.Get("游戏内部出错,请重试,文件名中不能包含中文。"));
// return; return;
// } }
// else
// //Config.ClientVersion = 0x233c; {
// Program.I().shiftToServant(Program.I().ocgcore); //Config.ClientVersion = 0x233c;
// } Program.I().shiftToServant(Program.I().ocgcore);
// } }
}
}
private void prepareOcgcore() private void prepareOcgcore()
{ {
......
...@@ -75,6 +75,7 @@ public class SelectServer : WindowServantSP ...@@ -75,6 +75,7 @@ public class SelectServer : WindowServantSP
Program.I().room.RMSshow_clear(); Program.I().room.RMSshow_clear();
printFile(true); printFile(true);
Program.charge(); Program.charge();
Program.I().ocgcore.returnServant = Program.I().selectServer;
} }
private void printFile(bool first) private void printFile(bool first)
......
...@@ -26,6 +26,22 @@ public class UIselectableList : MonoBehaviour { ...@@ -26,6 +26,22 @@ public class UIselectableList : MonoBehaviour {
} }
} }
} }
public int selectedIndex
{
get
{
for (int i = 0; i < selections.Count; i++)
{
if (selections[i].str == selectedString)
{
return i;
}
}
return -1;
}
}
public Action selectedAction; public Action selectedAction;
UIScrollView uIScrollView; UIScrollView uIScrollView;
float heightOfEach=20; float heightOfEach=20;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
#bots list
# !name
# command
# description
# flags (avail flags: SUPPORT_MASTER_RULE_3, SUPPORT_NEW_MASTER_RULE, SUPPORT_MASTER_RULE_2020, SELECT_DECKFILE)
!随机-非常简单
Random=AI_LV1
主要是一些沙包。
SUPPORT_MASTER_RULE_2020
!随机-简单
Random=AI_LV2
一些比较弱的卡组。
SUPPORT_MASTER_RULE_2020
!随机-普通
Random=AI_LV3
一些环境里可以看到的卡组。
SUPPORT_MASTER_RULE_2020
!随机-报社
Random=AI_ANTI_META
一些报复社会(针对主流卡组的弱点)的卡组。
SUPPORT_MASTER_RULE_2020
!P2-自选卡组
Name=P2 Deck=Lucky Dialog=gugugu.zh-CN
人机卡组由你选择。随缘出牌。
SELECT_DECKFILE SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!悠悠
Name=悠悠 Deck=MokeyMokey Dialog=mokey.zh-CN
沙包。
AI_LV1 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!悠悠王
Name=悠悠王 Deck=MokeyMokeyKing Dialog=mokey.zh-CN
大沙包。
AI_LV1 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!谜之剑士LV4-龙骑星爆
Name=谜之剑士LV4 Deck=Dragunity Dialog=swordsman.zh-CN
龙骑轴星尘龙爆裂体卡组。
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!谜之剑士LV4-L8
Name=谜之剑士LV4 Deck='Level VIII' Dialog=swordsman.zh-CN
8星同调卡组。
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!谜之剑士LV4-R5
Name=谜之剑士LV4 Deck='Rank V' Dialog=swordsman.zh-CN
5阶超量卡组。
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020
!谜之剑士LV4-异热同心武器
Name=谜之剑士LV4 Deck='Zexal Weapons' Dialog=swordsman.zh-CN
神装电光皇卡组。
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020
!琪露诺-彩虹
Name=琪露诺 Deck=Rainbow Dialog=cirno.zh-CN
全属性凡骨卡组。
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020
!琪露诺-饼蛙
Name=琪露诺 Deck='Toadally Awesome' Dialog=cirno.zh-CN
大师规则三的全盛饼蛙卡组。
SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020
!复制植物-青眼
Name=复制植物 Deck=Blue-Eyes Dialog=copy.zh-CN
青眼卡组。
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020
!复制植物-十二兽
Name=复制植物 Deck=Zoodiac Dialog=copy.zh-CN
大师规则三的十四兽卡组。
SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020
!尼亚-妖仙兽
Name=尼亚 Deck=Yosenju Dialog=near.zh-CN
妖仙兽卡组。
AI_ANTI_META SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!尼亚-机壳
Name=尼亚 Deck=Qliphort Dialog=near.zh-CN
机壳卡组。
AI_ANTI_META SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!尼亚-淘气仙星
Name=尼亚 Deck=Trickstar Dialog=near.zh-CN
旧式淘气仙星卡组。
AI_LV3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!尼亚-幻变骚灵
Name=尼亚 Deck=Altergeist Dialog=near.zh-CN
幻变骚灵卡组。
AI_LV3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!复制梁龙-闪刀姬
Name=复制梁龙 Deck=SkyStriker Dialog=anothercopy.zh-CN
旧式闪刀姬卡组。
AI_LV3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!复制梁龙-自奏圣乐
Name=复制梁龙 Deck=Orcust Dialog=anothercopy.zh-CN
旧式自奏圣乐卡组。
AI_LV3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!复制梁龙-转生炎兽
Name=复制梁龙 Deck=Salamangreat Dialog=anothercopy.zh-CN
转生炎兽卡组。
AI_LV3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!VI-1911-凭依装着
Name=VI-1911 Deck=FamiliarPossessed Dialog=VI-1911.zh-CN
凭依装着卡组。
AI_ANTI_META SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!VI-1911-时劫者
Name=VI-1911 Deck=TimeThief Dialog=VI-1911.zh-CN
时间潜行者卡组。
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!永远之魂-削血
Name=永远之魂 Deck=Burn Dialog=soul.zh-CN
老式削血卡组。
SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!永远之魂-青蛙
Name=永远之魂 Deck=Frog Dialog=soul.zh-CN
老式青蛙卡组。
AI_LV1 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!永远之魂-荷鲁斯
Name=永远之魂 Deck=Horus Dialog=soul.zh-CN
老式龙族卡组。
AI_LV1 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!比特机灵-微风
Name=比特机灵 Deck=PureWinds Dialog=zh-CN
风属性卡组。
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!试作型机器人1732
Name=试作型机器人1732 Deck=ST1732 Dialog=zh-CN
由三盒ST17和三盒SD32组成的卡组。
AI_LV2 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!奇異果
Name=奇異果 Deck=LightswornShaddoldinosour Dialog=kiwi.zh-TW
光道影依恐龙卡组。
AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!奇魔果
Name=奇魔果 Deck=DarkMagician Dialog=kiwi.zh-TW
黑魔术师卡组。
AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!MAX龍果
Name=MAX龍果 Deck=BlueEyesMaxDragon Dialog=kiwi.zh-TW
青眼混沌极龙卡组。
AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!幻煌果
Name=幻煌果 Deck=Phantasm Dialog=kiwi.zh-TW
幻煌龙卡组。
AI_ANTI_META SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!燃血鬥士
Name=燃血鬥士 Deck=ChainBurn Dialog=kiwi.zh-TW
连锁烧卡组。
AI_ANTI_META SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!報社鬥士
Name=報社鬥士 Deck=GrenMajuThunderBoarder Dialog=kiwi.zh-TW
红莲雷王滑板卡组。
AI_ANTI_META SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!我太帅了-真红眼龙骑士
Name=我太帅了 Deck=Dragun Dialog=smart.zh-CN
超魔导真红眼龙骑士卡组。
AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!我太帅了-水百凤凰勇者
Name=我太帅了 Deck=Brave Dialog=smart.zh-CN
水机百头龙凤凰人勇者卡组。
AI_LV3 SUPPORT_MASTER_RULE_2020
!玻璃女巫-魔女术
Name=玻璃女巫 Deck=Witchcraft Dialog=verre.zh-CN
魔女术卡组。
AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!玻璃女巫-救祓少女
Name=玻璃女巫 Deck=Exosister Dialog=verre.zh-CN
救祓少女卡组。
AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020
!神数不神-刹帝利
Name=神数不神 Deck=Kashtira Dialog=Zefra.zh-CN
俱舍怒威族卡组。
AI_LV3 SUPPORT_MASTER_RULE_2020
![狂野模式]神数不神-雷龙
Name=神数不神 Deck=ThunderDragon Dialog=Zefra.zh-CN
深渊混沌雷龙卡组。(普通模式的人机的卡组会符合其使用的卡池对应的环境的禁限卡表,但在狂野模式中,人机的卡组不符合任何禁限卡表。)
SUPPORT_MASTER_RULE_2020
!神数不神-珠泪哀歌
Name=神数不神 Deck=Tearlaments Dialog=Zefra.zh-CN
旧式地天使珠泪哀歌族卡组。
AI_LV3 SUPPORT_MASTER_RULE_2020
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment