Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
mercury233 committed Aug 7, 2024
1 parent 3e94038 commit fcff680
Show file tree
Hide file tree
Showing 14 changed files with 5,975 additions and 44 deletions.
12 changes: 8 additions & 4 deletions libWindbot/Game/AI/CardContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,32 @@ public static ClientCard GetHighestAttackMonster(this IEnumerable<ClientCard> ca
{
return cards
.Where(card => card?.Data != null && card.HasType(CardType.Monster) && card.IsFaceup() && !(canBeTarget && card.IsShouldNotBeTarget()))
.OrderBy(card => card.Attack).FirstOrDefault();
.OrderByDescending(card => card.Attack)
.FirstOrDefault();
}

public static ClientCard GetHighestDefenseMonster(this IEnumerable<ClientCard> cards, bool canBeTarget = false)
{
return cards
.Where(card => card?.Data != null && card.HasType(CardType.Monster) && card.IsFaceup() && !(canBeTarget && card.IsShouldNotBeTarget()))
.OrderBy(card => card.Defense).FirstOrDefault();
.OrderByDescending(card => card.Defense)
.FirstOrDefault();
}

public static ClientCard GetLowestAttackMonster(this IEnumerable<ClientCard> cards, bool canBeTarget = false)
{
return cards
.Where(card => card?.Data != null && card.HasType(CardType.Monster) && card.IsFaceup() && !(canBeTarget && card.IsShouldNotBeTarget()))
.OrderByDescending(card => card.Attack).FirstOrDefault();
.OrderBy(card => card.Attack)
.FirstOrDefault();
}

public static ClientCard GetLowestDefenseMonster(this IEnumerable<ClientCard> cards, bool canBeTarget = false)
{
return cards
.Where(card => card?.Data != null && card.HasType(CardType.Monster) && card.IsFaceup() && !(canBeTarget && card.IsShouldNotBeTarget()))
.OrderByDescending(card => card.Defense).FirstOrDefault();
.OrderBy(card => card.Defense)
.FirstOrDefault();
}

public static bool ContainsMonsterWithLevel(this IEnumerable<ClientCard> cards, int level)
Expand Down
5,861 changes: 5,861 additions & 0 deletions libWindbot/Game/AI/Decks/AlbazExecutor.cs

Large diffs are not rendered by default.

65 changes: 44 additions & 21 deletions libWindbot/Game/AI/Decks/SuperheavySamuraiExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public class CardId
public SuperheavySamuraiExecutor(GameAI ai, Duel duel)
: base(ai, duel)
{
AddExecutor(ExecutorType.Activate, CardId.PSYFramelordOmega);
AddExecutor(ExecutorType.Repos, MonsterRepos);
AddExecutor(ExecutorType.Activate, CardId.PSYFramelordOmega,PSYFunction);
AddExecutor(ExecutorType.Activate, CardId.IP,IPFunction);
AddExecutor(ExecutorType.Activate, CardId.Sarutobi,SarutobiFunction);
AddExecutor(ExecutorType.Activate, CardId.Unicorn,UnicornFunction);
Expand All @@ -101,9 +102,8 @@ public SuperheavySamuraiExecutor(GameAI ai, Duel duel)
AddExecutor(ExecutorType.SpSummon, CardId.Scales);
AddExecutor(ExecutorType.Activate, CardId.Scales,ScalesFunction);

//Synchron
AddExecutor(ExecutorType.SpSummon, CardId.ASStardustDragon,ASStardustDragonSynchronFunction2);
AddExecutor(ExecutorType.SpSummon, CardId.Fleur,FleurSynchronFunction2);
//Synchron
AddExecutor(ExecutorType.SpSummon, CardId.PSYFramelordOmega,PSYFramelordOmegaSynchronFunction);

//Pendulum
AddExecutor(ExecutorType.Activate, CardId.Wakaushi,WakaushiFunction);
Expand Down Expand Up @@ -183,7 +183,6 @@ public SuperheavySamuraiExecutor(GameAI ai, Duel duel)
//Synchron
AddExecutor(ExecutorType.SpSummon, CardId.Masurawo,MasurawoSynchronFunction);
AddExecutor(ExecutorType.SpSummon, CardId.Sarutobi,DeSynchronFunction);
AddExecutor(ExecutorType.SpSummon, CardId.PSYFramelordOmega);

//equip Soulhorns
AddExecutor(ExecutorType.Activate, CardId.Soulhorns,SoulhornsEquipFunction);
Expand Down Expand Up @@ -219,6 +218,24 @@ public override bool OnSelectHand()
{
return true;
}
private bool MonsterRepos()
{
if (Card.IsFacedown())
return true;
if (Card.IsFaceup() && Card.IsAttack() && (Card.Id == CardId.Masurawo || Card.Id == CardId.Sarutobi))
return true;
return false;
}
public override CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions)
{
YGOSharp.OCGWrapper.NamedCard cardData = YGOSharp.OCGWrapper.NamedCard.Get(cardId);
if (cardData != null)
{
if (cardId == CardId.Masurawo || cardId == CardId.Sarutobi)
return CardPosition.FaceUpDefence;
}
return 0;
}
public override int OnSelectPlace(int cardId, int player, CardLocation location, int available)
{
if (player == 0 && location == CardLocation.MonsterZone)
Expand Down Expand Up @@ -597,14 +614,6 @@ private bool FleurSynchronFunction()
AI.SelectMaterials(materials_lists[0]);
return true;
}
private bool FleurSynchronFunction2()
{
var materials_lists = Util.GetSynchroMaterials(Bot.MonsterZone,10,1,1,false,false,null,
card => { return !FinalCards(card.Id); });
if (materials_lists.Count <= 0) return false;
AI.SelectMaterials(materials_lists[0]);
return true;
}
private bool DeSynchronFunction()
{
AI.SelectPosition(CardPosition.FaceUpDefence);
Expand All @@ -630,17 +639,26 @@ private bool ASStardustDragonSynchronFunction()
{
return (Bot.HasInExtra(CardId.Fleur) || Bot.HasInExtra(CardId.Masurawo));
}
return false;
}
private bool ASStardustDragonSynchronFunction2()
{
if (!activate_Scales || !activate_PSY) return false;
if (Bot.HasInGraveyard(CardId.Motorbike) || Bot.HasInGraveyard(CardId.PsyFramegearGamma))
else if (Bot.HasInMonstersZone(CardId.Motorbike))
{
return (Bot.HasInExtra(CardId.Fleur) || Bot.HasInExtra(CardId.Masurawo));
AI.SelectMaterials(CardId.Motorbike);
return true;
}
else if (Bot.HasInMonstersZone(CardId.PsyFramegearGamma))
{
AI.SelectMaterials(CardId.PsyFramegearGamma);
return true;
}
return false;
}
private bool PSYFramelordOmegaSynchronFunction()
{
if (Bot.HasInMonstersZone(CardId.Motorbike))
AI.SelectMaterials(CardId.Motorbike);
else if (Bot.HasInMonstersZone(CardId.PsyFramegearGamma))
AI.SelectMaterials(CardId.PsyFramegearGamma);
return activate_PSY || activate_Scales;
}
private bool SavageDragonFunction()
{
if (Duel.LastChainPlayer == 1)
Expand Down Expand Up @@ -1156,6 +1174,11 @@ private bool IPLinkFunction()
AI.SelectMaterials(materials);
return true;
}
private bool PSYFunction()
{
activate_PSY = true;
return true;
}
private bool IPFunction()
{
if (Duel.LastChainPlayer == 0) return false;
Expand Down Expand Up @@ -1193,4 +1216,4 @@ private bool SarutobiFunction()
return true;
}
}
}
}
17 changes: 15 additions & 2 deletions libWindbot/Game/AI/DefaultExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ protected class _CardId
public const int DuelDragonToken = 60025884;
public const int SeleneQueenOfTheMasterMagicians = 45819647;
public const int TheWingedDragonofRaSphereMode = 10000080;
public const int SelettriceVaalmonica = 23093373;

public const int RockOfTheVanquisher = 28168628;
public const int SpiralDischarge = 29477860;
Expand Down Expand Up @@ -302,7 +303,8 @@ protected DefaultExecutor(GameAI ai, Duel duel)
{_CardId.DuelLinkDragonTheDuelDragon, (defender, list) => list.Any(monster => monster.IsCode(_CardId.DuelDragonToken))},
{_CardId.SeleneQueenOfTheMasterMagicians, (defender, list) => list.Any(monster => monster.HasSetcode(_Setcode.Endymion))},

{_CardId.TheWingedDragonofRaSphereMode, (defender, list) => true}
{_CardId.TheWingedDragonofRaSphereMode, (defender, list) => true},
{_CardId.SelettriceVaalmonica, (defender, list) => list.Any(monster => !monster.IsCode(_CardId.SelettriceVaalmonica))}
};

/// <summary>
Expand Down Expand Up @@ -1127,6 +1129,15 @@ protected bool DefaultOnBecomeTarget()
_CardId.EvenlyMatched,
_CardId.DivineArsenalAAZEUS_SkyThunder
};
int[] destroyAllMonsterList =
{
_CardId.DarkHole,
_CardId.InterruptedKaijuSlumber
};
int[] destroyAllOpponentMonsterList =
{
_CardId.Raigeki
};
int[] destroyAllOpponentSpellList =
{
_CardId.HarpiesFeatherDuster,
Expand All @@ -1135,6 +1146,8 @@ protected bool DefaultOnBecomeTarget()

if (Util.ChainContainsCard(destroyAllList)) return true;
if (Enemy.HasInSpellZone(destroyAllOpponentSpellList, true) && Card.Location == CardLocation.SpellZone) return true;
if (Util.ChainContainsCard(destroyAllMonsterList) && Card.Location == CardLocation.MonsterZone) return true;
if (Duel.CurrentChain.Any(c => c.Controller == 1 && c.IsCode(destroyAllOpponentMonsterList)) && Card.Location == CardLocation.MonsterZone) return true;
if (lightningStormOption == 0 && Card.Location == CardLocation.MonsterZone && Card.IsAttack()) return true;
if (lightningStormOption == 1 && Card.Location == CardLocation.SpellZone) return true;
// TODO: ChainContainsCard(id, player)
Expand Down Expand Up @@ -1577,7 +1590,7 @@ protected bool DefaultCheckWhetherCardIsNegated(ClientCard card)
if (originId == 0) originId = card.Data.Id;
return crossoutDesignatorIdList.Contains(originId)
|| (calledbytheGraveIdCountMap.ContainsKey(originId) && calledbytheGraveIdCountMap[originId] > 0)
|| card.IsDisabled();
|| (card.IsDisabled() && ((int)card.Location & (int)CardLocation.Onfield) > 0);
}

protected bool DefaultCheckWhetherCardIdIsNegated(int cardId)
Expand Down
13 changes: 12 additions & 1 deletion libWindbot/Game/AI/Enums/Floodgate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@ public enum Floodgate
StellarNemesisTPHON_DoomsdayStar = 93039339,
SPLittleKnight = 29301450,
AngelRing = 40678060,
SkullGuardianTheSilenforcingProtector = 10774240
SkullGuardianProtectorOfTheVoicelessVoice = 10774240,
FloweringEtoileTheMelodiousMagnificat = 83793721,
EnlightenmentDragon = 46186135,
GoldPrideEradicator = 45464587,
VarudrasTheFinalBringerOfTheEndTimes = 70636044,
RagnaraikaStagSovereign = 42307760,
DrytronMeteonisAlphaDraconids = 56863746,
TheUnstoppableExodiaIncarnate = 83257450,
LightAndDarknessDragonLord = 19652159,
FiendsmithDiesIrae = 82135803,
MementomictlanTecuhtlicaCombinedConqueror = 14529511,
MadolcheQueenTiaraalaFraise = 49689480
}
}
4 changes: 3 additions & 1 deletion libWindbot/Game/AI/Enums/FusionSpell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public enum FusionSpell
FusionReproduction = 43331750,
ChimeraFusion = 63136489,
HarmonicSynchroFusion = 7473735,
SouloftheSupremeCelestialKing = 76840111
SouloftheSupremeCelestialKing = 76840111,
MelodiousConcerto = 31458630,
MementotlanFusion = 66518509
}
}
11 changes: 10 additions & 1 deletion libWindbot/Game/AI/Enums/InvincibleMonster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ public enum InvincibleEnemyMonster
DarkGuardian = 26746975,
EnvoyOfTheWaxState = 87462901,
Fluffyfluff = 85401123,
YubelDasEwigLiebeWachter = 47172959
YubelDasEwigLiebeWachter = 47172959,
TenpaiDragonFadra = 65326118,
GolgoilTheSteelSeismicSmasher = 59369430,
TalonsOfShurilane = 74150658,
NightmareApprentice = 58143852,
MillenniumoonMaiden = 37552929,
MillenniumFiendReflection = 63947968,
HereticalPhoboscobos = 76078185,
TopHatHareTheSilhouetteMagician = 1528054,
Silhouhatte = 24440742
}
}
6 changes: 1 addition & 5 deletions libWindbot/Game/AI/Enums/PreventActivationEffectInBattle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ public enum PreventActivationEffectInBattle
SamuraiDestroyer = 40509732,
ArmadesKeeperOfBoundaries = 88033975,
NumberS39UtopiaTheLightning = 56832966,
DualAvatarEmpoweredKonGyo = 33026283,
GGolemRockHammer = 98875863,
WishDragon = 64583600,
ChaosWitch = 30327674,
FissioningMotherSpider = 34034150
DualAvatarEmpoweredKonGyo = 33026283
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public enum ShouldBeDisabledBeforeItUseEffectMonster
ThreeEyedGhost = 31464658,
UrsarcticPolarStar = 62714453,
BattlinBoxerPromoter = 83315222,
TGRocketSalamander = 77392987
TGRocketSalamander = 77392987,
GGolemRockHammer = 98875863,
WishDragon = 64583600,
ChaosWitch = 30327674,
FissioningMotherSpider = 34034150
}
}
3 changes: 2 additions & 1 deletion libWindbot/Game/AI/Enums/ShouldNotBeMonsterTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public enum ShouldNotBeMonsterTarget
BorreloadDragon = 31833038,
BorrelendDragon = 98630720,
DrytronMeteonisDraconids = 69815951,
MyutantBeast = 34695290
MyutantBeast = 34695290,
VeidosTheDragonOfEndlessDarkness = 8540986
}
}
5 changes: 2 additions & 3 deletions libWindbot/Game/ClientCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ public void SetId(int id)
if (Data != null)
{
Name = Data.Name;
if (Data.Alias != 0)
Alias = Data.Alias;
Alias = Data.Alias;
} else {
Name = null;
Alias = 0;
Expand Down Expand Up @@ -387,4 +386,4 @@ public bool Equals(ClientCard card)
return ReferenceEquals(this, card);
}
}
}
}
2 changes: 1 addition & 1 deletion libWindbot/Game/GameAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1162,14 +1162,14 @@ public BattlePhaseAction ToMainPhase2()

private bool ShouldExecute(CardExecutor exec, ClientCard card, ExecutorType type, int desc = -1, int timing = -1)
{
Executor.SetCard(type, card, desc, timing);
if (card.Id != 0 && type == ExecutorType.Activate)
{
if (_activatedCards.ContainsKey(card.Id) && _activatedCards[card.Id] >= 9)
return false;
if (!Executor.OnPreActivate(card))
return false;
}
Executor.SetCard(type, card, desc, timing);
bool result = card != null && exec.Type == type &&
(exec.CardId == -1 || exec.CardId == card.Id) &&
(exec.Func == null || exec.Func());
Expand Down
12 changes: 10 additions & 2 deletions libWindbot/Game/GameBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ private void InternalOnSelectCard(BinaryReader packet, Func<IList<ClientCard>, i
card.Controller = player;
}
if (card == null) continue;
if (card.Id == 0)
if (card.Id == 0 || card.Location == CardLocation.Deck)
card.SetId(id);
cards.Add(card);
}
Expand Down Expand Up @@ -1090,7 +1090,7 @@ private void InternalOnSelectUnselectCard(BinaryReader packet, Func<IList<Client
else
card = _duel.GetCard(player, loc, seq);
if (card == null) continue;
if (card.Id == 0)
if (card.Id == 0 || card.Location == CardLocation.Deck)
card.SetId(id);
cards.Add(card);
}
Expand All @@ -1102,6 +1102,14 @@ private void InternalOnSelectUnselectCard(BinaryReader packet, Func<IList<Client
CardLocation loc = (CardLocation)packet.ReadByte();
int seq = packet.ReadByte();
packet.ReadByte(); // pos
ClientCard card;
if (((int)loc & (int)CardLocation.Overlay) != 0)
card = new ClientCard(id, CardLocation.Overlay, -1);
else
card = _duel.GetCard(player, loc, seq);
if (card == null) continue;
if (card.Id == 0 || card.Location == CardLocation.Deck)
card.SetId(id);
}
if (count2 == 0) cancelable = false;

Expand Down
2 changes: 1 addition & 1 deletion libWindbot/YGOSharp.OCGWrapper.Enums/CardRace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public enum CardRace
Thunder = 0x1000,
Dragon = 0x2000,
Beast = 0x4000,
BestWarrior = 0x8000,
BeastWarrior = 0x8000,
Dinosaur = 0x10000,
Fish = 0x20000,
SeaSerpent = 0x40000,
Expand Down

0 comments on commit fcff680

Please sign in to comment.