Commit f27eccae authored by SherryChaos's avatar SherryChaos

windbot update

parent f29e4875
......@@ -221,8 +221,7 @@ namespace WindBot.Game.AI.Decks
public bool isAltergeist(ClientCard card)
{
return card.IsCode(CardId.Marionetter, CardId.Hexstia, CardId.Protocol, CardId.Multifaker, CardId.Meluseek,
CardId.Kunquery, CardId.Manifestation, CardId.Silquitous);
return card != null && card.HasSetcode(0x103);
}
public int GetSequence(ClientCard card)
......@@ -391,6 +390,7 @@ namespace WindBot.Game.AI.Decks
public bool spell_trap_activate(bool isCounter = false, ClientCard target = null)
{
if (target == null) target = Card;
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (target.Location != CardLocation.SpellZone && target.Location != CardLocation.Hand) return true;
if (Enemy.HasInMonstersZone(CardId.NaturalExterio, true) && !Bot.HasInHandOrHasInMonstersZone(CardId.GO_SR) && !isCounter && !Bot.HasInSpellZone(CardId.SolemnStrike)) return false;
if (target.IsSpell())
......@@ -664,7 +664,7 @@ namespace WindBot.Game.AI.Decks
public bool G_activate()
{
return (Duel.Player == 1);
return (Duel.Player == 1) && !DefaultCheckWhetherCardIsNegated(Card);
}
public bool NaturalExterio_eff()
......@@ -821,6 +821,7 @@ namespace WindBot.Game.AI.Decks
public bool Hand_act_eff()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Card.IsCode(CardId.AB_JS) && Util.GetLastChainCard().HasSetcode(0x11e) && Util.GetLastChainCard().Location == CardLocation.Hand) // Danger! archtype hand effect
return false;
if (Card.IsCode(CardId.GO_SR) && Card.Location == CardLocation.Hand && Bot.HasInMonstersZone(CardId.GO_SR)) return false;
......@@ -901,6 +902,7 @@ namespace WindBot.Game.AI.Decks
public bool GR_WC_activate()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
int warrior_count = 0;
int pendulum_count = 0;
int link_count = 0;
......@@ -1263,7 +1265,7 @@ namespace WindBot.Game.AI.Decks
if (linked_card != null && linked_card.IsCode(CardId.Hexstia))
{
int next_seq = get_Hexstia_linkzone(this_seq);
if (next_seq != -1 && Bot.MonsterZone[next_seq] != null && isAltergeist(Bot.MonsterZone[next_seq].Id)) return false;
if (next_seq != -1 && Bot.MonsterZone[next_seq] != null && isAltergeist(Bot.MonsterZone[next_seq])) return false;
}
}
return true;
......@@ -1690,7 +1692,7 @@ namespace WindBot.Game.AI.Decks
if (target.IsCode(CardId.Hexstia))
{
int next_index = get_Hexstia_linkzone(i);
if (next_index != -1 && Bot.MonsterZone[next_index] != null && Bot.MonsterZone[next_index].IsFaceup() && isAltergeist(Bot.MonsterZone[next_index].Id)) continue;
if (next_index != -1 && Bot.MonsterZone[next_index] != null && Bot.MonsterZone[next_index].IsFaceup() && isAltergeist(Bot.MonsterZone[next_index])) continue;
}
if (!get_linked_by_Hexstia(i))
{
......@@ -2669,6 +2671,7 @@ namespace WindBot.Game.AI.Decks
ss_other_monster = false;
Impermanence_list.Clear();
attacked_Meluseek.Clear();
base.OnNewTurn();
}
public override void OnChaining(int player, ClientCard card)
......@@ -2890,16 +2893,16 @@ namespace WindBot.Game.AI.Decks
if (cardId == CardId.Hexstia)
{
// ex zone
if ((Zones.z5 & available) > 0 && Bot.MonsterZone[1] != null && isAltergeist(Bot.MonsterZone[1].Id)) return Zones.z5;
if ((Zones.z6 & available) > 0 && Bot.MonsterZone[3] != null && isAltergeist(Bot.MonsterZone[3].Id)) return Zones.z6;
if ( ((Zones.z6 & available) > 0 && Bot.MonsterZone[3] != null && !isAltergeist(Bot.MonsterZone[3].Id))
if ((Zones.z5 & available) > 0 && Bot.MonsterZone[1] != null && isAltergeist(Bot.MonsterZone[1])) return Zones.z5;
if ((Zones.z6 & available) > 0 && Bot.MonsterZone[3] != null && isAltergeist(Bot.MonsterZone[3])) return Zones.z6;
if ( ((Zones.z6 & available) > 0 && Bot.MonsterZone[3] != null && !isAltergeist(Bot.MonsterZone[3]))
|| ((Zones.z5 & available) > 0 && Bot.MonsterZone[1] == null) ) return Zones.z5;
if (((Zones.z5 & available) > 0 && Bot.MonsterZone[1] != null && !isAltergeist(Bot.MonsterZone[1].Id))
if (((Zones.z5 & available) > 0 && Bot.MonsterZone[1] != null && !isAltergeist(Bot.MonsterZone[1]))
|| ((Zones.z6 & available) > 0 && Bot.MonsterZone[3] == null)) return Zones.z6;
// main zone
for (int i = 1; i < 5; ++i)
{
if (Bot.MonsterZone[i] != null && isAltergeist(Bot.MonsterZone[i].Id))
if (Bot.MonsterZone[i] != null && isAltergeist(Bot.MonsterZone[i]))
{
if ((available & (int)System.Math.Pow(2, i - 1)) > 0) return (int)System.Math.Pow(2, i - 1);
}
......
......@@ -131,6 +131,7 @@ namespace WindBot.Game.AI.Decks
UsedGalaxyEyesCipherDragon = null;
AlternativeWhiteDragonSummoned = false;
SoulChargeUsed = false;
base.OnNewTurn();
}
public override IList<ClientCard> OnSelectCard(IList<ClientCard> cards, int min, int max, int hint, bool cancelable)
......
......@@ -121,6 +121,7 @@ namespace WindBot.Game.AI.Decks
private bool MaxxCeff()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
return Duel.Player == 1;
}
......@@ -464,6 +465,7 @@ namespace WindBot.Game.AI.Decks
private bool Linkuriboheff()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Duel.LastChainPlayer == 0 && Util.GetLastChainCard().IsCode(CardId.Linkuriboh)) return false;
return true;
}
......
......@@ -180,6 +180,7 @@ namespace WindBot.Game.AI.Decks
FusionDestinyUsed = false;
PhoenixTarget = null;
PhoenixSelectingTarget = 0;
base.OnNewTurn();
}
public override CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions)
......@@ -479,6 +480,7 @@ namespace WindBot.Game.AI.Decks
private bool AquamancerOfTheSanctuarySearchEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Card.Location == CardLocation.Grave)
{
AI.SelectCard(CardLocation.Deck);
......@@ -626,6 +628,7 @@ namespace WindBot.Game.AI.Decks
private bool JetSynchronEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
int[] materials = new[] {
CardId.MechaPhantomBeastToken
};
......@@ -786,6 +789,7 @@ namespace WindBot.Game.AI.Decks
private bool PredaplantVerteAnacondaEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (ActivateDescription == Util.GetStringId(CardId.PredaplantVerteAnaconda, 0))
return false;
FusionDestinyUsed = true;
......@@ -858,6 +862,7 @@ namespace WindBot.Game.AI.Decks
private bool DestinyHeroCelestialEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (!Bot.HasInGraveyard(CardId.DestinyHeroDasher))
return false;
AI.SelectCard(CardId.DestinyHeroDasher);
......@@ -971,6 +976,7 @@ namespace WindBot.Game.AI.Decks
private bool VirtualWorldKyubiShenshenEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Card.Location == CardLocation.MonsterZone && Bot.HasInBanished(CardId.AquamancerOfTheSanctuary))
{
AI.SelectCard(CardId.AquamancerOfTheSanctuary);
......
......@@ -265,6 +265,7 @@ namespace WindBot.Game.AI.Decks
prevent_used = false;
Linkuribohused = true;
Timelord_check = false;
base.OnNewTurn();
}
public override void OnNewPhase()
{
......
......@@ -316,6 +316,7 @@ namespace WindBot.Game.AI.Decks
big_attack = false;
big_attack_used = false;
soul_used = false;
base.OnNewTurn();
}
public int GetTotalATK(IList<ClientCard> list)
{
......@@ -496,11 +497,13 @@ namespace WindBot.Game.AI.Decks
{
if (Bot.LifePoints > 1500 && Duel.LastChainPlayer == 1)
return true;
if (DefaultOnlyHorusSpSummoning()) return false;
return false;
}
private bool ChainEnemy()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Util.GetLastChainCard() != null &&
Util.GetLastChainCard().IsCode(CardId.UpstartGoblin))
return false;
......@@ -519,6 +522,7 @@ namespace WindBot.Game.AI.Decks
private bool MaxxCeff()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
return Duel.Player == 1;
}
/*
......@@ -1417,6 +1421,7 @@ namespace WindBot.Game.AI.Decks
}
else
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Bot.HasInMonstersZone(CardId.VentriloauistsClaraAndLucika))
{
AI.SelectCard(CardId.VentriloauistsClaraAndLucika);
......
......@@ -123,6 +123,7 @@ namespace WindBot.Game.AI.Decks
{
BeastOLionUsed = false;
RedEyesFusionUsed = false;
base.OnNewTurn();
}
public override CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions)
......@@ -198,6 +199,7 @@ namespace WindBot.Game.AI.Decks
private bool TourGuideFromTheUnderworldSummon()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Bot.GetRemainingCount(CardId.TourGuideFromTheUnderworld, 2) == 0 && Bot.GetRemainingCount(CardId.Sangan, 2) == 0)
return false;
return true;
......@@ -307,6 +309,7 @@ namespace WindBot.Game.AI.Decks
private bool MagiciansSoulsEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Card.Location == CardLocation.Hand)
{
if (RedEyesFusionUsed)
......@@ -375,6 +378,7 @@ namespace WindBot.Game.AI.Decks
private bool PredaplantVerteAnacondaEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (ActivateDescription == Util.GetStringId(CardId.PredaplantVerteAnaconda, 0))
return false;
AI.SelectCard(CardId.RedEyesFusion);
......
......@@ -456,6 +456,7 @@ namespace WindBot.Game.AI.Decks
private bool AssaultBeast()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (!Bot.HasInSpellZone(CardId.AssaultModeActivate))
return true;
return false;
......
......@@ -164,7 +164,7 @@ namespace WindBot.Game.AI.Decks
};
List<int> ExosisterSpellTrapList = new List<int>{CardId.ExosisterPax, CardId.ExosisterArment, CardId.ExosisterVadis, CardId.ExosisterReturnia};
Dictionary<int, int> calledbytheGraveCount = new Dictionary<int, int>();
List<int> currentNegatingIdList = new List<int>();
bool enemyActivateMaxxC = false;
bool enemyActivateLockBird = false;
bool enemyMoveGrave = false;
......@@ -410,11 +410,9 @@ namespace WindBot.Game.AI.Decks
/// </summary>
public int CheckCalledbytheGrave(int id)
{
if (!calledbytheGraveCount.ContainsKey(id))
{
return 0;
}
return calledbytheGraveCount[id];
if (currentNegatingIdList.Contains(id)) return 1;
if (DefaultCheckWhetherCardIdIsNegated(id)) return 1;
return 0;
}
public void CheckEnemyMoveGrave()
......@@ -470,24 +468,6 @@ namespace WindBot.Game.AI.Decks
return true;
}
/// <summary>
/// Check whether negate opposite's effect and clear flag
/// </summary>
public void CheckDeactiveFlag()
{
if (Util.GetLastChainCard() != null && Duel.LastChainPlayer == 1)
{
if (Util.GetLastChainCard().IsCode(_CardId.MaxxC))
{
enemyActivateMaxxC = false;
}
if (Util.GetLastChainCard().IsCode(_CardId.LockBird))
{
enemyActivateLockBird = false;
}
}
}
/// <summary>
/// Check whether opposite use Maxx-C, and thus make less operation.
/// </summary>
......@@ -777,13 +757,6 @@ namespace WindBot.Game.AI.Decks
ClientCard card = Util.GetLastChainCard();
if (player == 1)
{
if (card != null && card.IsCode(_CardId.CalledByTheGrave))
{
foreach (ClientCard targetCard in Duel.LastChainTargets) {
Logger.DebugWriteLine("===Exosister: " + targetCard?.Name + " is targeted by called by the grave.");
calledbytheGraveCount[targetCard.Id] = 2;
}
}
foreach (ClientCard targetCard in Duel.LastChainTargets) {
if (targetCard.Location == CardLocation.Grave)
{
......@@ -796,6 +769,30 @@ namespace WindBot.Game.AI.Decks
base.OnSelectChain(cards);
}
public override void OnChainSolved(int chainIndex)
{
ClientCard currentCard = Duel.GetCurrentSolvingChainCard();
if (currentCard != null && !Duel.IsCurrentSolvingChainNegated() && currentCard.Controller == 1)
{
if (currentCard.IsCode(_CardId.MaxxC))
enemyActivateMaxxC = true;
if (currentCard.IsCode(_CardId.LockBird))
enemyActivateLockBird = true;
if (currentCard.IsCode(_CardId.InfiniteImpermanence))
{
for (int i = 0; i < 5; ++i)
{
if (Enemy.SpellZone[i] == currentCard)
{
infiniteImpermanenceList.Add(4 - i);
break;
}
}
}
}
}
/// <summary>
/// clear chain information
/// </summary>
......@@ -833,19 +830,10 @@ namespace WindBot.Game.AI.Decks
public override void OnNewTurn()
{
if (Duel.Turn <= 1) calledbytheGraveCount.Clear();
enemyActivateMaxxC = false;
enemyActivateLockBird = false;
infiniteImpermanenceList.Clear();
// CalledbytheGrave refresh
List<int> key_list = calledbytheGraveCount.Keys.ToList();
foreach (int dic in key_list)
{
if (calledbytheGraveCount[dic] > 1)
{
calledbytheGraveCount[dic] -= 1;
}
}
currentNegatingIdList.Clear();
summoned = false;
elisEffect1Activated = false;
......@@ -1133,7 +1121,6 @@ namespace WindBot.Game.AI.Decks
return false;
}
}
CheckDeactiveFlag();
return DefaultAshBlossomAndJoyousSpring();
}
......@@ -1192,7 +1179,6 @@ namespace WindBot.Game.AI.Decks
{
ClientCard target = GetProblematicEnemyMonster(canBeTarget: true);
List<ClientCard> enemyMonsters = Enemy.GetMonsters();
CheckDeactiveFlag();
AI.SelectCard(target);
infiniteImpermanenceList.Add(this_seq);
return true;
......@@ -1227,7 +1213,6 @@ namespace WindBot.Game.AI.Decks
{
if (card.IsFaceup() && !card.IsShouldNotBeTarget() && !card.IsShouldNotBeSpellTrapTarget())
{
CheckDeactiveFlag();
AI.SelectCard(card);
return true;
}
......@@ -1244,7 +1229,7 @@ namespace WindBot.Game.AI.Decks
// negate
if (Util.GetLastChainCard().IsMonster())
{
int code = Util.GetLastChainCard().Id;
int code = Util.GetLastChainCard().GetOriginCode();
if (code == 0) return false;
if (CheckCalledbytheGrave(code) > 0) return false;
if (Util.GetLastChainCard().IsCode(_CardId.MaxxC) && CheckAtAdvantage())
......@@ -1255,15 +1240,15 @@ namespace WindBot.Game.AI.Decks
{
return false;
}
if (Enemy.Graveyard.GetFirstMatchingCard(card => card.IsMonster() && card.IsOriginalCode(code)) != null)
ClientCard targetCard = Enemy.Graveyard.GetFirstMatchingCard(card => card.IsMonster() && card.IsOriginalCode(code));
if (targetCard != null)
{
if (!(Card.Location == CardLocation.SpellZone))
{
SelectSTPlace(null, true);
}
AI.SelectCard(code);
calledbytheGraveCount[code] = 2;
CheckDeactiveFlag();
AI.SelectCard(targetCard);
currentNegatingIdList.Add(code);
return true;
}
}
......@@ -1275,7 +1260,7 @@ namespace WindBot.Game.AI.Decks
{
int code = cards.Id;
AI.SelectCard(cards);
calledbytheGraveCount[code] = 2;
currentNegatingIdList.Add(code);
return true;
}
}
......@@ -1290,7 +1275,7 @@ namespace WindBot.Game.AI.Decks
enemyMonsters.Reverse();
int code = enemyMonsters[0].Id;
AI.SelectCard(code);
calledbytheGraveCount[code] = 2;
currentNegatingIdList.Add(code);
return true;
}
}
......@@ -1300,13 +1285,13 @@ namespace WindBot.Game.AI.Decks
if (Duel.LastChainPlayer == 1) return false;
List<ClientCard> targets = CheckDangerousCardinEnemyGrave(true);
if (targets.Count() > 0) {
int code = targets[0].Id;
int code = targets[0].GetOriginCode();
if (!(Card.Location == CardLocation.SpellZone))
{
SelectSTPlace(null, true);
}
AI.SelectCard(code);
calledbytheGraveCount[code] = 2;
AI.SelectCard(targets);
currentNegatingIdList.Add(code);
return true;
}
......
......@@ -135,6 +135,7 @@ namespace WindBot.Game.AI.Decks
private bool Ronintoadin()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
List<ClientCard> monsters = Bot.GetGraveyardMonsters();
if (monsters.Count > 2)
{
......
......@@ -128,6 +128,7 @@ namespace WindBot.Game.AI.Decks
{
eater_eff = false;
CardOfDemiseeff_used = false;
base.OnNewTurn();
}
public override void OnNewPhase()
......@@ -437,6 +438,7 @@ namespace WindBot.Game.AI.Decks
private bool ThunderKingRaiOheff()
{
if (DefaultOnlyHorusSpSummoning()) return false;
if(Duel.SummoningCards.Count > 0)
{
foreach(ClientCard m in Duel.SummoningCards)
......@@ -570,6 +572,7 @@ namespace WindBot.Game.AI.Decks
private bool MetalSnakesp()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (ActivateDescription == Util.GetStringId(CardId.MetalSnake, 0) && !Bot.HasInMonstersZone(CardId.MetalSnake))
{
if(Duel.Player == 1 && Duel.Phase >= DuelPhase.BattleStart )
......
......@@ -175,6 +175,7 @@ namespace WindBot.Game.AI.Decks
opt_2 = false;
if (flag >= 0) ++flag;
if (flag >= 2) { flag = -1; activate_DimensionShifter = false; }
base.OnNewTurn();
}
public override bool OnSelectYesNo(int desc)
{
......
......@@ -179,7 +179,6 @@ namespace WindBot.Game.AI.Decks
};
List<int> notToDestroySpellTrap = new List<int> { 50005218, 6767771 };
Dictionary<int, int> calledbytheGraveCount = new Dictionary<int, int>();
bool enemyActivateMaxxC = false;
List<int> infiniteImpermanenceList = new List<int>();
bool summoned = false;
......@@ -455,11 +454,8 @@ namespace WindBot.Game.AI.Decks
/// </summary>
public int CheckCalledbytheGrave(int id)
{
if (!calledbytheGraveCount.ContainsKey(id))
{
return 0;
}
return calledbytheGraveCount[id];
if (DefaultCheckWhetherCardIdIsNegated(id)) return 1;
return 0;
}
public bool CheckCanBeTargeted(ClientCard card, bool canBeTarget, CardType selfType)
......@@ -1593,7 +1589,6 @@ namespace WindBot.Game.AI.Decks
{
if (Duel.Turn <= 1)
{
calledbytheGraveCount.Clear();
dimensionShifterCount = 0;
enemySpSummonFromExLastTurn = 0;
......@@ -1605,11 +1600,6 @@ namespace WindBot.Game.AI.Decks
enemySpSummonFromExThisTurn = 0;
rollbackCopyCardId = 0;
List<int> keyList = calledbytheGraveCount.Keys.ToList();
foreach (int dic in keyList)
{
if (calledbytheGraveCount[dic] > 1) calledbytheGraveCount[dic] -= 1;
}
if (dimensionShifterCount > 0) dimensionShifterCount--;
if (banSpSummonExceptFiendCount > 0) banSpSummonExceptFiendCount--;
infiniteImpermanenceList.Clear();
......@@ -1622,6 +1612,7 @@ namespace WindBot.Game.AI.Decks
enemySetThisTurn.Clear();
dimensionalBarrierAnnouced.Clear();
summonInChainList.Clear();
base.OnNewTurn();
}
public override void OnChaining(int player, ClientCard card)
......@@ -1742,14 +1733,6 @@ namespace WindBot.Game.AI.Decks
summonThisTurn.Add(card);
if (currentSolvingChain != null) summonInChainList.Add(card);
}
if (previousLocation == (int)CardLocation.Grave && currentLocation == (int)CardLocation.Removed)
{
if (currentSolvingChain != null && currentSolvingChain.Controller == 1 && currentSolvingChain.IsCode(_CardId.CalledByTheGrave))
{
Logger.DebugWriteLine("*** " + (card.Name ?? "UnknowCard") + " is banished by CallByTheGrave");
calledbytheGraveCount[card.Id] = 2;
}
}
}
}
......
......@@ -217,11 +217,12 @@ namespace WindBot.Game.AI.Decks
JetSynchronUsed = false;
ScrapWyvernUsed = false;
MaskedChameleonUsed = false;
base.OnNewTurn();
}
public override void OnChainEnd()
{
base.OnChainEnd();
}
public override CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions)
......
......@@ -274,6 +274,7 @@ namespace WindBot.Game.AI.Decks
ShaddollSquamata_used = false;
ShaddollDragon_used = false;
ShaddollHedgehog_used = false;
base.OnNewTurn();
}
private bool Luminasummon()
......@@ -290,6 +291,7 @@ namespace WindBot.Game.AI.Decks
}
private bool Luminaeff()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Bot.HasInGraveyard(CardId.Raiden))
{
AI.SelectCard(Useless_List());
......@@ -555,6 +557,7 @@ namespace WindBot.Game.AI.Decks
private bool GlowUpBulbeff()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
IList<ClientCard> check = Bot.GetMonstersInExtraZone();
foreach (ClientCard monster in check)
if (monster.HasType(CardType.Fusion)) return false;
......@@ -627,6 +630,7 @@ namespace WindBot.Game.AI.Decks
private bool MaxxC()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
return Duel.Player == 1;
}
......@@ -977,6 +981,7 @@ namespace WindBot.Game.AI.Decks
public bool Hand_act_eff()
{
//if (Card.IsCode(CardId.Urara) && Bot.HasInHand(CardId.LockBird) && Bot.HasInSpellZone(CardId.Re)) return false;
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Card.IsCode(CardId.GhostOgre) && Card.Location == CardLocation.Hand && Bot.HasInMonstersZone(CardId.GhostOgre)) return false;
return (Duel.LastChainPlayer == 1);
}
......@@ -998,6 +1003,7 @@ namespace WindBot.Game.AI.Decks
if (Card.Location == CardLocation.Grave)
return true;
if (Bot.LifePoints <= 1000) return false;
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
ClientCard select = Util.GetBestEnemyCard();
if (select == null) return false;
if(select!=null)
......
......@@ -219,11 +219,13 @@ namespace WindBot.Game.AI.Decks
private bool ImFeelingLucky()
{
if (Type == ExecutorType.Activate && DefaultCheckWhetherCardIsNegated(Card)) return false;
return Program.Rand.Next(10) >= 5 && DefaultDontChainMyself();
}
private bool ImFeelingUnlucky()
{
if (Type == ExecutorType.Activate && DefaultCheckWhetherCardIsNegated(Card)) return false;
return DefaultDontChainMyself();
}
......
......@@ -214,11 +214,13 @@ namespace WindBot.Game.AI.Decks
CymbalSkeletonUsed = false;
BorrelswordDragonUsed = false;
RustyBardicheTarget = null;
base.OnNewTurn();
}
public override void OnChainEnd()
{
RustyBardicheTarget = null;
base.OnChainEnd();
}
public override CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions)
......@@ -465,6 +467,7 @@ namespace WindBot.Game.AI.Decks
private bool JetSynchronEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
AI.SelectCard(HandCosts);
return true;
}
......@@ -488,6 +491,7 @@ namespace WindBot.Game.AI.Decks
private bool DestrudoSummon()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
return Bot.GetMonsterCount() < 3 && Bot.HasInExtra(new[] { CardId.CrystronNeedlefiber, CardId.KnightmarePhoenix });
}
......@@ -659,6 +663,7 @@ namespace WindBot.Game.AI.Decks
private bool KnightmarePhoenixEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
int costcount = Bot.Hand.GetMatchingCardsCount(card => card.IsCode(HandCosts));
ClientCard target = Enemy.SpellZone.GetFloodgate();
ClientCard anytarget = Enemy.SpellZone.GetFirstMatchingCard(card => !card.OwnTargets.Any(cont => cont.IsCode(CardId.TrickstarLightStage)));
......@@ -685,6 +690,7 @@ namespace WindBot.Game.AI.Decks
private bool KnightmareMermaidEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
AI.SelectCard(HandCosts);
return true;
}
......@@ -703,6 +709,7 @@ namespace WindBot.Game.AI.Decks
private bool OrcustKnightmareEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (!Bot.HasInGraveyard(CardId.OrcustHarpHorror))
{
AI.SelectCard(Util.GetBestBotMonster());
......@@ -726,6 +733,7 @@ namespace WindBot.Game.AI.Decks
private bool HarpHorrorEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
HarpHorrorUsed = true;
AI.SelectCard(CardId.OrcustCymbalSkeleton);
return true;
......@@ -733,6 +741,7 @@ namespace WindBot.Game.AI.Decks
private bool WorldWandEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
AI.SelectCard(CardId.OrcustCymbalSkeleton);
return true;
}
......@@ -783,6 +792,7 @@ namespace WindBot.Game.AI.Decks
private bool CymbalSkeletonEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
int[] botTurnTargets = new[] { CardId.GalateaTheOrcustAutomaton, CardId.SheorcustDingirsu };
int[] emenyTurnTargets = new[] { CardId.SheorcustDingirsu, CardId.GalateaTheOrcustAutomaton };
if (Duel.Player == 0 && Bot.HasInGraveyard(CardId.GalateaTheOrcustAutomaton) && !Bot.HasInMonstersZone(CardId.GalateaTheOrcustAutomaton) && Bot.HasInExtra(CardId.SheorcustDingirsu) && !SheorcustDingirsuSummoned)
......@@ -867,6 +877,7 @@ namespace WindBot.Game.AI.Decks
private bool AncientCloakEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Bot.HasInMonstersZone(CardId.SalamangreatAlmiraj) && Bot.HasInExtra(CardId.KnightmarePhoenix))
AI.SelectCard(CardId.ThePhantomKnightsofShadeBrigandine);
else
......@@ -881,6 +892,7 @@ namespace WindBot.Game.AI.Decks
private bool SilentBootsEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Bot.HasInMonstersZone(CardId.SalamangreatAlmiraj) && Bot.HasInExtra(CardId.KnightmarePhoenix))
AI.SelectCard(CardId.ThePhantomKnightsofShadeBrigandine);
else
......@@ -1033,6 +1045,7 @@ namespace WindBot.Game.AI.Decks
{
if (Card.Location == CardLocation.Grave)
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
IList<ClientCard> costCards = Bot.Hand.GetMatchingCards(card => card.IsCode(HandCosts));
if (costCards.Count > 0)
{
......@@ -1113,6 +1126,7 @@ namespace WindBot.Game.AI.Decks
}
else if (Bot.HasInGraveyard(CardId.ThePhantomKnightsofRustyBardiche) || Bot.GetMonsterCount() < 2)
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
AI.SelectCard(CardId.ThePhantomKnightsofRustyBardiche);
return true;
}
......
......@@ -555,6 +555,7 @@ namespace WindBot.Game.AI.Decks
}
private bool SpeedroidTaketomborgeff()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if ((Bot.GetRemainingCount(CardId.SpeedroidRedEyedDice, 1) >= 1) &&
Bot.HasInMonstersZone(CardId.SpeedroidTerrortop))
{
......
......@@ -130,6 +130,7 @@ namespace WindBot.Game.AI.Decks
public override void OnNewTurn()
{
CardOfDemiseUsed = false;
base.OnNewTurn();
}
public override IList<ClientCard> OnSelectPendulumSummon(IList<ClientCard> cards, int max)
......@@ -281,6 +282,7 @@ namespace WindBot.Game.AI.Decks
{
if (Card.Location == CardLocation.Hand)
return false;
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
int count = 0;
int handcount = 0;
int fieldcount = 0;
......
......@@ -142,6 +142,7 @@ namespace WindBot.Game.AI.Decks
public override void OnNewTurn()
{
NormalSummoned = false;
base.OnNewTurn();
}
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
......@@ -210,6 +211,7 @@ namespace WindBot.Game.AI.Decks
private bool RescueRabbitSummon()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
return Util.GetBotAvailZonesFromExtraDeck() > 0
|| !Enemy.MonsterZone.IsExistingMatchingCard(card => card.GetDefensePower() >= 1900)
|| Enemy.MonsterZone.GetMatchingCardsCount(card => card.GetDefensePower() < 1900) > Bot.MonsterZone.GetMatchingCardsCount(card => card.Attack >= 1900);
......
......@@ -116,6 +116,7 @@ namespace WindBot.Game.AI.Decks
DoubleSummonUsed = false;
CyberDragonInfinitySummoned = false;
Number61VolcasaurusUsed = false;
base.OnNewTurn();
}
public override IList<ClientCard> OnSelectXyzMaterial(IList<ClientCard> cards, int min, int max)
......
......@@ -153,6 +153,7 @@ namespace WindBot.Game.AI.Decks
{
// reset
BalancerLordUsed = false;
base.OnNewTurn();
}
public override int OnSelectOption(IList<int> options)
......
......@@ -594,6 +594,7 @@ namespace WindBot.Game.AI.Decks
}
else
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Bot.HasInHand(CardId.Spinny) || FalcoToGY(false))
{
if (Bot.HasInHand(CardId.Spinny) && !Bot.HasInGraveyard(CardId.Spinny))
......@@ -779,10 +780,12 @@ namespace WindBot.Game.AI.Decks
public bool G_activate()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
return (Duel.Player == 1);
}
public bool Hand_act_eff()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
return (Duel.LastChainPlayer == 1);
}
......
......@@ -146,6 +146,7 @@ namespace WindBot.Game.AI.Decks
ShizukuSummoned = false;
HayateSummoned = false;
WidowAnchorTarget = null;
base.OnNewTurn();
}
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
......@@ -194,6 +195,7 @@ namespace WindBot.Game.AI.Decks
private bool MaxxCEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
return Duel.Player == 1;
}
......@@ -667,6 +669,7 @@ namespace WindBot.Game.AI.Decks
private bool JetSynchronEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Bot.HasInMonstersZone(CardId.Raye) || Bot.HasInMonstersZone(CardId.CrystronNeedlefiber))
{
AI.SelectCard(GetDiscardHand());
......
......@@ -182,8 +182,8 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.Activate, CardId.BaronnedeFleur, BaronnedeFleurEffect);
AddExecutor(ExecutorType.Activate, CardId.ElderEntityNtss, ElderEntityNtssEffect);
AddExecutor(ExecutorType.Activate, CardId.PredaplantDragostapelia, PredaplantDragostapeliaEffect);
AddExecutor(ExecutorType.Activate, CardId.HeraldofOrangeLight);
AddExecutor(ExecutorType.Activate, CardId.HeraldofGreenLight);
AddExecutor(ExecutorType.Activate, CardId.HeraldofOrangeLight, DefaultTrap);
AddExecutor(ExecutorType.Activate, CardId.HeraldofGreenLight, DefaultTrap);
AddExecutor(ExecutorType.Activate, CardId.TearlamentsRulkallos, TearlamentsRulkallosEffect);
AddExecutor(ExecutorType.Activate, CardId.FADawnDragster);
AddExecutor(ExecutorType.Activate, CardId.PrimevalPlanetPerlereino, PrimevalPlanetPerlereinoEffect);
......@@ -275,6 +275,7 @@ namespace WindBot.Game.AI.Decks
spsummoned = false;
summon_SprightElf = false;
TearlamentsKitkallos_summoned = false;
base.OnNewTurn();
}
private List<ClientCard> GetZoneCards(CardLocation loc, ClientField player)
{
......@@ -2172,6 +2173,7 @@ namespace WindBot.Game.AI.Decks
}
private bool EvaEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
List<ClientCard> cards = Bot.GetGraveyardMonsters().Where(card => card != null && card.HasAttribute(CardAttribute.Light) && card.HasRace(CardRace.Fairy) && card != Card).ToList();
if (cards.Count <= 0) return false;
activate_Eva = true;
......@@ -2207,6 +2209,7 @@ namespace WindBot.Game.AI.Decks
}
private bool MudoratheSwordOracleEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Card.Location == CardLocation.Hand)
{
if ((Bot.Hand.Count(card => card != null && card.Id == CardId.AgidotheAncientSentinel) <= 0 || activate_AgidotheAncientSentinel_2)
......
......@@ -278,6 +278,8 @@ namespace WindBot.Game.AI.Decks
for (int i = 0; i < selectAtt.Count; i++)
selectAtt[i] = false;
base.OnNewTurn();
}
private bool IsAvailableZone(int seq)
{
......@@ -889,6 +891,7 @@ namespace WindBot.Game.AI.Decks
}
private bool AshBlossomEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
return Duel.CurrentChain.Count > 0 && Duel.LastChainPlayer != 0;
}
public int CompareCardLink(ClientCard cardA, ClientCard cardB)
......@@ -1053,6 +1056,7 @@ namespace WindBot.Game.AI.Decks
}
private bool GEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
return Duel.Player != 0;
}
private bool ThunderDragonColossusSummon_2()
......@@ -1101,6 +1105,7 @@ namespace WindBot.Game.AI.Decks
{
if (ActivateDescription == Util.GetStringId(CardId.PredaplantVerteAnaconda, 1))
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (CheckRemainInDeck(CardId.ThunderDragonFusion) <= 0) return false;
if (Bot.GetMonstersInMainZone().Count > 4 && Bot.GetMonstersInMainZone().Count(card => card != null && !card.IsExtraCard() && card.HasSetcode(0x11c) && card.HasType(CardType.Monster) && card.IsFaceup()) <= 0) return false;
List<ClientCard> g_card = Bot.Graveyard.ToList();
......@@ -1148,6 +1153,7 @@ namespace WindBot.Game.AI.Decks
}
private bool KnightmareUnicornEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
List<ClientCard> cards = new List<ClientCard>();
cards.AddRange(Enemy.SpellZone);
cards.AddRange(Enemy.MonsterZone);
......@@ -1598,6 +1604,7 @@ namespace WindBot.Game.AI.Decks
{
if (Card.Location == CardLocation.Hand)
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
List<ClientCard> banish_cards = new List<ClientCard>();
List<ClientCard> grave_cards = new List<ClientCard>();
foreach (var card in Bot.Banished)
......@@ -1792,6 +1799,7 @@ namespace WindBot.Game.AI.Decks
{
if (Card.Location == CardLocation.Hand)
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (handActivated) return false;
handActivated = true;
activate_ThunderDragonroar = true;
......@@ -2035,6 +2043,7 @@ namespace WindBot.Game.AI.Decks
{
if (Card.Location == CardLocation.Hand)
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Duel.Player == 0)
{
if (IsShouldChainTunder())
......@@ -2243,6 +2252,7 @@ namespace WindBot.Game.AI.Decks
{
if (Card.Location == CardLocation.Hand)
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (HasInZoneNoActivate(CardId.BystialMagnamhut,CardLocation.Deck) && !Bot.HasInHand(CardId.BystialMagnamhut))
AI.SelectCard(CardId.BystialMagnamhut);
else if(HasInZoneNoActivate(CardId.BystialDruiswurm, CardLocation.Deck) && !Bot.HasInHand(CardId.BystialDruiswurm))
......@@ -2420,6 +2430,7 @@ namespace WindBot.Game.AI.Decks
{
if (Card.Location == CardLocation.Hand)
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Duel.Player == 0)
{
if (IsShouldChainTunder())
......@@ -2498,6 +2509,7 @@ namespace WindBot.Game.AI.Decks
}
private bool NormalThunderDragonEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
handActivated = true;
ResetFlag();
selectFlag[(int)Select.NormalThunderDragon] = true;
......
......@@ -192,6 +192,7 @@ namespace WindBot.Game.AI.Decks
{
if (Card.Location == CardLocation.MonsterZone)
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
AI.SelectCard(Monsters.TimeThiefCronocorder);
AI.SelectCard(Monsters.TimeThiefWinder);
return true;
......@@ -370,6 +371,7 @@ namespace WindBot.Game.AI.Decks
}
private bool ThunderKingRaiOheff()
{
if (DefaultOnlyHorusSpSummoning()) return false;
if (Duel.SummoningCards.Count > 0)
{
foreach (ClientCard m in Duel.SummoningCards)
......
......@@ -231,6 +231,7 @@ namespace WindBot.Game.AI.Decks
}
else
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (Bot.HasInHand(CardId.DupeFrog))
{
AI.SelectCard(
......@@ -267,6 +268,7 @@ namespace WindBot.Game.AI.Decks
private bool RonintoadinEffect()
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
AI.SelectPosition(CardPosition.FaceUpDefence);
return true;
}
......@@ -297,6 +299,7 @@ namespace WindBot.Game.AI.Decks
{
if (Duel.CurrentChain.Count > 0)
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
// negate effect, select a cost for it
List<ClientCard> monsters = Bot.GetMonsters();
IList<int> suitableCost = new[] {
......@@ -381,6 +384,7 @@ namespace WindBot.Game.AI.Decks
}
else if (Duel.Phase == DuelPhase.Standby)
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
SelectXYZDetach(Card.Overlays);
if (Duel.Player == 0)
{
......
......@@ -155,6 +155,7 @@ namespace WindBot.Game.AI.Decks
public override void OnNewTurn()
{
CardOfDemiseUsed = false;
base.OnNewTurn();
}
public override bool OnSelectYesNo(int desc)
......
......@@ -573,6 +573,7 @@ namespace WindBot.Game.AI.Decks
activate_count = 0;
summon_count = 0;
enemy_activate = false;
base.OnNewTurn();
}
private bool ZefraProvidenceEffect()
{
......
......@@ -127,6 +127,7 @@ namespace WindBot.Game.AI.Decks
TigermortarSpsummoned = false;
ChakanineSpsummoned = false;
BroadbullSpsummoned = false;
base.OnNewTurn();
}
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
......@@ -150,6 +151,7 @@ namespace WindBot.Game.AI.Decks
{
if (Card.Location == CardLocation.Hand)
{
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
if (!(Duel.Phase == DuelPhase.BattleStep
|| Duel.Phase == DuelPhase.BattleStart
|| Duel.Phase == DuelPhase.Damage))
......@@ -429,8 +431,7 @@ namespace WindBot.Game.AI.Decks
{
if (Duel.Phase == DuelPhase.Main1 || Duel.Phase == DuelPhase.Main2)
return false;
if (Card.IsDisabled())
return false;
if (DefaultCheckWhetherCardIsNegated(Card)) return false;
ClientCard target = null;
List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters)
......
......@@ -15,6 +15,7 @@ namespace WindBot.Game
public int Position { get; set; }
public int Sequence { get; set; }
public CardLocation Location { get; set; }
public CardLocation LastLocation { get; set; }
public int Alias { get; private set; }
public int Level { get; private set; }
public int Rank { get; private set; }
......@@ -70,6 +71,7 @@ namespace WindBot.Game
ActionIndex = new int[16];
ActionActivateIndex = new Dictionary<int, int>();
Location = loc;
LastLocation = 0;
}
public void SetId(int id)
......@@ -346,7 +348,7 @@ namespace WindBot.Game
public bool IsOriginalCode(int id)
{
return Id == id || Alias - Id < 10 && Alias == id;
return Id == id || Alias - Id < 20 && Alias == id;
}
public bool HasXyzMaterial()
......@@ -369,6 +371,17 @@ namespace WindBot.Game
return IsAttack() ? Attack : Defense;
}
public int GetOriginCode()
{
int code = Id;
if (Data != null)
{
if (Data.Alias > 0) code = Data.Alias;
else code = Data.Id;
}
return code;
}
public bool Equals(ClientCard card)
{
return ReferenceEquals(this, card);
......
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using WindBot.Game.AI;
using YGOSharp.Network;
using YGOSharp.Network.Enums;
......@@ -284,6 +285,7 @@ namespace WindBot.Game
private void OnDuelEnd(BinaryReader packet)
{
Thread.Sleep(500);
Connection.Close();
}
......@@ -376,15 +378,10 @@ namespace WindBot.Game
_duel.Fields[GetLocalPlayer(1)].Init(deck, extra);
// in case of ending duel in chain's solving
_duel.LastChainPlayer = -1;
_duel.LastChainLocation = 0;
_duel.CurrentChain.Clear();
_duel.ChainTargets.Clear();
_duel.LastChainTargets.Clear();
_duel.ChainTargetOnly.Clear();
_duel.LastSummonPlayer = -1;
_duel.SummoningCards.Clear();
_duel.LastSummonedCards.Clear();
_duel.SolvingChainIndex = 0;
_duel.NegatedChainIndexList.Clear();
......@@ -615,6 +612,10 @@ namespace WindBot.Game
packet.ReadInt32(); // reason
ClientCard card = _duel.GetCard(previousControler, (CardLocation)previousLocation, previousSequence);
if (card != null)
{
card.LastLocation = (CardLocation)previousLocation;
}
if ((previousLocation & (int)CardLocation.Overlay) != 0)
{
previousLocation = previousLocation & 0x7f;
......@@ -803,6 +804,7 @@ namespace WindBot.Game
_duel.ChainTargetOnly.Clear();
_duel.SolvingChainIndex = 0;
_duel.NegatedChainIndexList.Clear();
_duel.SummoningCards.Clear();
}
private void OnCardSorting(BinaryReader packet)
......
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