Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
767a1e6
Add ai "ThunderDragon"
YSPplayer Nov 7, 2022
e0b1b72
fix
mercury233 Nov 15, 2022
f9e3680
Merge remote-tracking branch 'upstream/master' into Temp2
YSPplayer Nov 15, 2022
6c50179
Merge remote-tracking branch 'origin/Temp2' into Temp2
YSPplayer Nov 15, 2022
fa770ee
fix "ThunderDragon"
YSPplayer Nov 16, 2022
8bf1928
Merge remote-tracking branch 'upstream/master' into Temp3
YSPplayer Nov 29, 2022
fe779ce
fix bot
YSPplayer Nov 29, 2022
6669842
fix GalaxyTomahawkSummon
mercury233 Nov 29, 2022
9ed2566
merge remote-tracking branch 'upstream/master' into Temp3
YSPplayer Feb 7, 2023
9937161
add bot Tearlaments
YSPplayer Feb 7, 2023
d4552d5
fix proj
mercury233 Feb 7, 2023
c28d069
rename YGO_SCRIPT to IS_YGOPRO
mercury233 Feb 7, 2023
b667262
always go first for YSPplayer bots
mercury233 Feb 7, 2023
2aedc25
Merge remote-tracking branch 'upstream/master' into Temp3
YSPplayer Feb 9, 2023
35b3567
fix Tearlaments
YSPplayer Feb 9, 2023
c3a1325
Update key card id
YSPplayer Feb 9, 2023
1688584
Merge remote-tracking branch 'upstream/master' into Temp3
YSPplayer Jun 2, 2023
0069e26
Add Bot Zefra
YSPplayer Jun 2, 2023
5adfbaa
Fix Bot Zefra
YSPplayer Jun 12, 2023
0628dc1
Merge remote-tracking branch 'upstream/master' into Temp3
YSPplayer Jun 18, 2023
f1837f3
Update dialog and bot Zefra
YSPplayer Jun 18, 2023
5db1aeb
fix
YSPplayer Jun 18, 2023
4d71d1e
format
mercury233 Jun 18, 2023
bdca512
Merge remote-tracking branch 'upstream/master' into Temp3
YSPplayer Jul 10, 2023
d171931
Support windbot link core
YSPplayer Jul 30, 2023
b4a78b2
fix
YSPplayer Jul 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,098 changes: 4,098 additions & 0 deletions Game/AI/CoreFunction.cs

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions Game/AI/Executor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public abstract class Executor
public IList<CardExecutor> Executors { get; private set; }
public GameAI AI { get; private set; }
public AIUtil Util { get; private set; }
public CoreFunction CoreFunction { get; private set; }

protected MainPhase Main { get; private set; }
protected BattlePhase Battle { get; private set; }
Expand All @@ -32,6 +33,7 @@ protected Executor(GameAI ai, Duel duel)
AI = ai;
Util = new AIUtil(duel);
Executors = new List<CardExecutor>();
CoreFunction = AI.CoreFunction;

Bot = Duel.Fields[0];
Enemy = Duel.Fields[1];
Expand Down Expand Up @@ -276,5 +278,20 @@ private bool DefaultNoExecutor()
{
return Executors.All(exec => exec.Type != Type || exec.CardId != Card.Id);
}

public int ClientFieldToPlayer(ClientField field)
{
int player = Duel.IsFirst ? 0 : 1;
if (field == Bot)
{
return player;
}
if (field == Enemy)
{
return 1 - player;
}
return 2;
}

}
}
15 changes: 15 additions & 0 deletions Game/ClientCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ public void SetId(int id)
}
}

public void SetLocation(CardLocation location)
{
Location = location;
}

public void SetController(int controller)
{
Controller = controller;
}

public void SetSequence(int sequence)
{
Sequence = sequence;
}

public void Update(BinaryReader packet, Duel duel)
{
int flag = packet.ReadInt32();
Expand Down
5 changes: 3 additions & 2 deletions Game/GameAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ public class GameAI
{
public GameClient Game { get; private set; }
public Duel Duel { get; private set; }
public CoreFunction CoreFunction { get; private set; }
public Executor Executor { get; set; }

private Dialogs _dialogs;

// record activated count to prevent infinite actions
private Dictionary<int, int> _activatedCards;

public GameAI(GameClient game, Duel duel)
public GameAI(GameClient game, Duel duel, CoreFunction coreFunction)
{
Game = game;
Duel = duel;

CoreFunction = coreFunction;
_dialogs = new Dialogs(game);
_activatedCards = new Dictionary<int, int>();
}
Expand Down
10 changes: 9 additions & 1 deletion Game/GameBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class GameBehavior
public Deck Deck { get; private set; }

private GameAI _ai;
private CoreFunction _coreFunction;

private IDictionary<StocMessage, Action<BinaryReader>> _packets;
private IDictionary<GameMessage, Action<BinaryReader>> _messages;
Expand All @@ -43,7 +44,8 @@ public GameBehavior(GameClient game)
_room = new Room();
_duel = new Duel();

_ai = new GameAI(Game, _duel);
_coreFunction = new CoreFunction(_duel, Connection);
_ai = new GameAI(Game, _duel, _coreFunction);
_ai.Executor = DecksManager.Instantiate(_ai, _duel);
Deck = Deck.Load(Game.DeckFile ?? _ai.Executor.Deck);

Expand Down Expand Up @@ -84,6 +86,7 @@ private void RegisterPackets()
_packets.Add(StocMessage.Chat, OnChat);
_packets.Add(StocMessage.ChangeSide, OnChangeSide);
_packets.Add(StocMessage.ErrorMsg, OnErrorMsg);
_packets.Add(StocMessage.AiReceive, OnAiReceive);

_messages.Add(GameMessage.Retry, OnRetry);
_messages.Add(GameMessage.Start, OnStart);
Expand Down Expand Up @@ -146,6 +149,11 @@ private void RegisterPackets()
_messages.Add(GameMessage.FlipSummoned, OnSummoned);
}

private void OnAiReceive(BinaryReader packet)
{
_coreFunction.Data = packet.ReadBytes((int)packet.BaseStream.Length);
}

private void OnJoinGame(BinaryReader packet)
{
/*int lflist = (int)*/ packet.ReadUInt32();
Expand Down
1 change: 1 addition & 0 deletions WindBot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<Compile Include="Game\AI\CardExecutor.cs" />
<Compile Include="Game\AI\CardExtension.cs" />
<Compile Include="Game\AI\CardSelector.cs" />
<Compile Include="Game\AI\CoreFunction.cs" />
<Compile Include="Game\AI\DeckAttribute.cs" />
<Compile Include="Game\AI\DecksManager.cs" />
<Compile Include="Game\AI\Decks\AltergeistExecutor.cs" />
Expand Down
Binary file modified YGOSharp.Network.dll
Binary file not shown.
Binary file modified YGOSharp.OCGWrapper.Enums.dll
Binary file not shown.
Binary file modified YGOSharp.OCGWrapper.dll
Binary file not shown.
Binary file modified sqlite3.dll
Binary file not shown.