public static int CompareCardAttack(ClientCard cardA, ClientCard cardB) { if (cardA.Attack < cardB.Attack) return -1; if (cardA.Attack == cardB.Attack) return 0; return 1; }
public virtual bool OnPreBattleBetween(ClientCard attacker, ClientCard defender) { if (defender.IsMonsterInvincible()) { if (defender.IsMonsterDangerous() || defender.IsDefense()) return false; } return true; }
public static int CompareDefensePower(ClientCard cardA, ClientCard cardB) { if (cardA == null && cardB == null) return 0; if (cardA == null) return -1; if (cardB == null) return 1; int powerA = cardA.GetDefensePower(); int powerB = cardB.GetDefensePower(); if (powerA < powerB) return -1; if (powerA == powerB) return 0; return 1; }
private bool RebornEffect() { if (Duel.Player == 0 && Duel.CurrentChain.Count > 0) { // Silver's Cry spsummon Dragon Spirit at chain 2 will miss the timing return(false); } if (Duel.Player == 0 && (Duel.Phase == DuelPhase.Draw || Duel.Phase == DuelPhase.Standby)) { // Let Azure-Eyes spsummon first return(false); } IList <int> targets = new[] { CardId.HopeHarbingerDragonTitanicGalaxy, CardId.GalaxyEyesDarkMatterDragon, CardId.AlternativeWhiteDragon, CardId.AzureEyesSilverDragon, CardId.BlueEyesSpiritDragon, CardId.WhiteDragon, CardId.DragonSpiritOfWhite }; if (!Bot.HasInGraveyard(targets)) { return(false); } ClientCard floodgate = Enemy.SpellZone.GetFloodgate(); if (floodgate != null && Bot.HasInGraveyard(CardId.DragonSpiritOfWhite)) { AI.SelectCard(CardId.DragonSpiritOfWhite); } else { AI.SelectCard(targets); } return(true); }
public override BattlePhaseAction OnSelectAttackTarget(ClientCard attacker, IList <ClientCard> defenders) { if (attacker.IsCode(CardId.BlueEyesChaosMaxDragon) && !attacker.IsDisabled() && this.Enemy.HasInMonstersZone(new[] { CardId.DeviritualTalismandra, CardId.DevirrtualCandoll })) { for (int i = 0; i < defenders.Count; i++) { ClientCard defender = defenders[i]; attacker.RealPower = attacker.Attack; defender.RealPower = defender.GetDefensePower(); if (!this.OnPreBattleBetween(attacker, defender)) { continue; } if (defender.IsCode(CardId.DevirrtualCandoll, CardId.DeviritualTalismandra)) { return(this.AI.Attack(attacker, defender)); } } } return(base.OnSelectAttackTarget(attacker, defenders)); }
private bool CrossoutDesignatorEffect() { ClientCard LastChainCard = Util.GetLastChainCard(); if (LastChainCard == null || Duel.LastChainPlayer != 1) { return(false); } return(CrossoutDesignatorCheck(LastChainCard, CardId.AquamancerOfTheSanctuary, 3) || CrossoutDesignatorCheck(LastChainCard, CardId.Sangan, 3) || CrossoutDesignatorCheck(LastChainCard, CardId.AshBlossomJoyousSpring, 3) || CrossoutDesignatorCheck(LastChainCard, CardId.MaxxC, 2) || CrossoutDesignatorCheck(LastChainCard, CardId.EffectVeiler, 1) || CrossoutDesignatorCheck(LastChainCard, CardId.RiteofAramesia, 3) || CrossoutDesignatorCheck(LastChainCard, CardId.HarpiesFeatherDuster, 1) || CrossoutDesignatorCheck(LastChainCard, CardId.FusionDestiny, 3) || CrossoutDesignatorCheck(LastChainCard, CardId.FoolishBurial, 1) || CrossoutDesignatorCheck(LastChainCard, CardId.MonsterReborn, 1) || CrossoutDesignatorCheck(LastChainCard, CardId.CalledByTheGrave, 2) || CrossoutDesignatorCheck(LastChainCard, CardId.CrossoutDesignator, 3) || CrossoutDesignatorCheck(LastChainCard, CardId.InfiniteImpermanence, 3) ); }
private bool ScoutActivate() { if (Card.Location != CardLocation.Hand) { return(false); } ClientCard l = Util.GetPZone(0, 0); ClientCard r = Util.GetPZone(0, 1); if (l == null && r == null) { return(true); } if (l == null && r.RScale != Card.LScale) { return(true); } if (r == null && l.LScale != Card.RScale) { return(true); } return(false); }
public int GetBestAttack(ClientField field, bool onlyatk) { int bestAtk = -1; for (int i = 0; i < 7; ++i) { ClientCard card = field.MonsterZone[i]; if (card == null) { continue; } if (onlyatk && card.IsDefense()) { continue; } int ennemyValue = card.GetDefensePower(); if (ennemyValue > bestAtk) { bestAtk = ennemyValue; } } return(bestAtk); }
/// <summary> /// Return problematic monster, and if this card become target, return any enemy monster. /// </summary> protected bool DefaultCompulsoryEvacuationDevice() { ClientCard target = AI.Utils.GetProblematicMonsterCard(); if (target != null) { AI.SelectCard(target); return(true); } foreach (ClientCard card in Duel.ChainTargets) { if (Card.Equals(card)) { ClientCard monster = AI.Utils.GetAnyEnemyMonster(); if (monster != null) { AI.SelectCard(monster); return(true); } } } return(false); }
private bool S5sssww() { if (Card.Location == CardLocation.Grave) { AI.SelectCard(CardId.S14); return(true); } else if (Card.Location == CardLocation.Hand && (Bot.HasInHand(CardId.S4) || Bot.HasInHand(CardId.S7) || Bot.HasInHand(CardId.S5))) { ClientCard target = Util.GetProblematicEnemyMonster(Card.GetDefensePower()); if (target != null) { AI.SelectCard( CardId.S5, CardId.S7, CardId.S4 ); AI.SelectNextCard(target); return(true); } } return(false); }
/// <summary> /// Get the best ATK or DEF power of the field. /// </summary> /// <param name="field">Bot or Enemy.</param> /// <param name="onlyATK">Only calculate attack.</param> public int GetBestPower(ClientField field, bool onlyATK = false) { int bestPower = -1; for (int i = 0; i < 7; ++i) { ClientCard card = field.MonsterZone[i]; if (card == null || card.Data == null) { continue; } if (onlyATK && card.IsDefense()) { continue; } int newPower = card.GetDefensePower(); if (newPower > bestPower) { bestPower = newPower; } } return(bestPower); }
private bool 应进行灵摆召唤() { ClientCard l = AI.Utils.GetPZone(0, 0); ClientCard r = AI.Utils.GetPZone(0, 1); if (l != null && r != null && l.LScale != r.RScale) { int count = 0; foreach (ClientCard card in Bot.Hand.GetMonsters()) { count++; } foreach (ClientCard card in Bot.ExtraDeck.GetMonsters()) { if (card.HasType(CardType.Pendulum) && card.IsFaceup()) { count++; } } return(count > 1); } return(false); }
private bool 应进行灵摆召唤() { ClientCard l = Duel.Fields[0].SpellZone[6]; ClientCard r = Duel.Fields[0].SpellZone[7]; if (l != null && r != null && l.LScale != r.RScale) { int count = 0; foreach (ClientCard card in Duel.Fields[0].Hand.GetMonsters()) { count++; } foreach (ClientCard card in Duel.Fields[0].ExtraDeck.GetMonsters()) { if (card.HasType(CardType.Pendulum) && card.IsFaceup()) { count++; } } return(count > 1); } return(false); }
private bool 机壳工具丑恶发动() { if (Card.Location != CardLocation.Hand) { return(false); } ClientCard l = Duel.Fields[0].SpellZone[6]; ClientCard r = Duel.Fields[0].SpellZone[7]; if (l == null && r == null) { return(true); } if (l == null && r.RScale != Card.LScale) { return(true); } if (r == null && l.LScale != Card.RScale) { return(true); } return(false); }
private bool AttackUpEffect() { ClientCard bestMy = this.Bot.GetMonsters().GetHighestAttackMonster(); ClientCard bestEnemyATK = this.Enemy.GetMonsters().GetHighestAttackMonster(); ClientCard bestEnemyDEF = this.Enemy.GetMonsters().GetHighestDefenseMonster(); if (bestMy == null || (bestEnemyATK == null && bestEnemyDEF == null)) { return(false); } if (bestEnemyATK != null && bestMy.Attack < bestEnemyATK.Attack) { return(true); } if (bestEnemyDEF != null && bestMy.Attack < bestEnemyDEF.Defense) { return(true); } return(false); }
public bool Ring_act() { if (Duel.LastChainPlayer == 0 && AI.Utils.GetLastChainCard() != null) { return(false); } ClientCard target = AI.Utils.GetProblematicEnemyMonster(); if (target == null && AI.Utils.IsChainTarget(Card)) { target = AI.Utils.GetBestEnemyMonster(true, true); } if (target != null) { if (Bot.LifePoints <= target.Attack) { return(false); } AI.SelectCard(target); return(true); } return(false); }
private bool 机壳工具丑恶发动() { if (Card.Location != CardLocation.Hand) { return(false); } ClientCard l = AI.Utils.GetPZone(0, 0); ClientCard r = AI.Utils.GetPZone(0, 1); if (l == null && r == null) { return(true); } if (l == null && r.RScale != Card.LScale) { return(true); } if (r == null && l.LScale != Card.RScale) { return(true); } return(false); }
private bool DragoEff() { // summon to negate ClientCard chainCard = Util.GetLastChainCard(); if (Duel.LastChainPlayer == 1 && chainCard != null && !chainCard.IsShouldNotBeMonsterTarget()) // NOTE: Can check for already has counter? { AI.SelectCard(chainCard); return(true); } if (Duel.Phase == DuelPhase.End) { ClientCard enemyMon = Util.GetBestEnemyMonster(true, true); if (enemyMon != null) { AI.SelectCard(enemyMon); } return(true); } return(false); }
private bool DridentEffect() { if (Duel.LastChainPlayer == 0) { return(false); } ClientCard target = Util.GetBestEnemyCard(true); if (target == null) { return(false); } AI.SelectCard( CardId.Broadbull, CardId.Tigermortar, CardId.Chakanine, CardId.Thoroughblade, CardId.Ratpier, CardId.Whiptail ); AI.SelectNextCard(target); return(true); }
public IActionResult SaveDatabase([FromBody] ClientCardFromBody clientCardFromBody) { ClientCard clientCard; try { clientCard = ClientCard.ConvertToClientCard(clientCardFromBody); } catch (EntitiesException ex) { return(this.StatusCode(406, ex.Message)); } try { this.dbService.AddClientCardWithContext(clientCard, this.context); return(this.Ok("Saved")); } catch (DatabaseException ex) { return(this.StatusCode(208, ex.Message)); } }
private bool AlmirajSummon() { if (SkipSummonforKnightmare()) { return(false); } if (Bot.GetMonsterCount() > 1) { return(false); } ClientCard mat = Bot.GetMonsters().First(); if (mat.IsCode(new[] { CardId.JetSynchron, CardId.ThePhantomKnightsofAncientCloak, CardId.ThePhantomKnightsofSilentBoots })) { AI.SelectMaterials(mat); return(true); } return(false); }
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender) { if (attacker.IsCode(CardId.CrystalWingSynchroDragon)) { if (defender.Level >= 5) { attacker.RealPower = attacker.Attack + defender.Attack; } return(true); } else if (attacker.IsCode(CardId.DaigustoSphreez)) { attacker.RealPower = attacker.Attack + defender.Attack + defender.Defense; return(true); } else if (Bot.HasInMonstersZone(CardId.DaigustoSphreez) && attacker.IsCode(CardId.DaigustoSphreez, CardId.GustoGulldo, CardId.GustoEgul, CardId.WindaPriestessOfGusto, CardId.PilicaDescendantOfGusto, CardId.DaigustoGulldos)) { attacker.RealPower = attacker.Attack + defender.Attack + defender.Defense; return(true); } return(base.OnPreBattleBetween(attacker, defender)); }
protected bool DefaultCompulsoryEvacuationDevice() { ClientCard target = AI.Utils.GetProblematicMonsterCard(); if (target != null) { AI.SelectCard(target); return(true); } foreach (ClientCard card in Duel.ChainTargets) { if (Card.Equals(card)) { List <ClientCard> monsters = Duel.Fields[1].GetMonsters(); foreach (ClientCard monster in monsters) { AI.SelectCard(monster); return(true); } } } return(false); }
private async Task <string> CheckClient(ClientCard clientCard) { var model = _repository.ClientCard.FirstOrDefault(m => m.ClientId == clientCard.ClientId); if (model == null) { try { string src = await _repository.AddClientCardAsync(clientCard); if (src != null) { logger.Error(src); return(src); } } catch (System.Exception ex) { logger.Error("error: {0}", ex.Message); } } return(null); }
private bool WidowAnchorEffect() { if (DefaultBreakthroughSkill()) { WidowAnchorTarget = Util.GetLastChainCard(); return(true); } if (!HaveThreeSpellsInGrave() || Duel.Player == 1 || Duel.Phase < DuelPhase.Main1 || Duel.Phase >= DuelPhase.Main2 || Util.ChainContainsCard(CardId.WidowAnchor)) { return(false); } ClientCard target = Util.GetBestEnemyMonster(true, true); if (target != null && !target.IsDisabled() && !target.HasType(CardType.Normal)) { WidowAnchorTarget = target; AI.SelectCard(target); return(true); } return(false); }
/// <summary> /// Destroy face-down cards first, in our turn. /// </summary> protected bool DefaultMysticalSpaceTyphoon() { if (this.Duel.CurrentChain.Any(card => card.IsCode(CardId.MysticalSpaceTyphoon))) { return(false); } List <ClientCard> spells = this.Enemy.GetSpells(); if (spells.Count == 0) { return(false); } ClientCard selected = this.Enemy.SpellZone.GetFloodgate(); if (selected == null) { if (this.Duel.Player == 0) { selected = spells.FirstOrDefault(card => card.IsFacedown()); } if (this.Duel.Player == 1) { selected = spells.FirstOrDefault(card => card.HasType(CardType.Continuous) || card.HasType(CardType.Equip) || card.HasType(CardType.Field)); } } if (selected == null) { return(false); } this.AI.SelectCard(selected); return(true); }
private bool 机壳别名愚钝效果() { if (Card.Location == CardLocation.Hand) { return(false); } ClientCard target = AI.Utils.GetProblematicCard(); if (target != null) { AI.SelectCard(target); return(true); } List <ClientCard> monsters = Duel.Fields[1].GetMonsters(); foreach (ClientCard monster in monsters) { AI.SelectCard(monster); return(true); } List <ClientCard> spells = Duel.Fields[1].GetSpells(); foreach (ClientCard spell in spells) { if (spell.IsFacedown()) { AI.SelectCard(spell); return(true); } } foreach (ClientCard spell in spells) { AI.SelectCard(spell); return(true); } return(false); }
public virtual BattlePhaseAction OnBattle(IList <ClientCard> attackers, IList <ClientCard> defenders) { if (attackers.Count == 0) { return(AI.ToMainPhase2()); } if (defenders.Count == 0) { return(AI.Attack(attackers[0], null)); } for (int i = defenders.Count - 1; i >= 0; --i) { ClientCard defender = defenders[i]; int value = defender.GetDefensePower(); for (int j = 0; j < attackers.Count; ++j) { ClientCard attacker = attackers[j]; if (!OnPreBattleBetween(attacker, defender)) { continue; } if (attacker.Attack > value || (attacker.Attack >= value && j == attackers.Count - 1)) { return(AI.Attack(attacker, defender)); } } } if (!Battle.CanMainPhaseTwo) { return(AI.Attack(attackers[attackers.Count - 1], defenders[0])); } return(AI.ToMainPhase2()); }
private bool CyberDragonInfinityEffect() { if (CurrentChain.Count > 0) { return(LastChainPlayer == 1); } else { ClientCard bestmonster = null; foreach (ClientCard monster in Enemy.GetMonsters()) { if (monster.IsAttack() && (bestmonster == null || monster.Attack >= bestmonster.Attack)) { bestmonster = monster; } } if (bestmonster != null) { AI.SelectCard(bestmonster); return(true); } } return(false); }
/// <summary> /// Decide which card should the attacker attack. /// </summary> /// <param name="attacker">Card that attack.</param> /// <param name="defenders">Cards that defend.</param> /// <returns>BattlePhaseAction including the target, or null (in this situation, GameAI will check the next attacker)</returns> public override BattlePhaseAction OnSelectAttackTarget(ClientCard attacker, IList <ClientCard> defenders) { foreach (ClientCard defender in defenders) { attacker.RealPower = attacker.Attack; defender.RealPower = defender.GetDefensePower(); if (!OnPreBattleBetween(attacker, defender)) { continue; } if (attacker.RealPower > defender.RealPower || (attacker.RealPower >= defender.RealPower && attacker.IsLastAttacker && defender.IsAttack())) { return(AI.Attack(attacker, defender)); } } if (attacker.CanDirectAttack) { return(AI.Attack(attacker, null)); } return(null); }
private bool UnendingNightmareeff() { ClientCard card = null; foreach (ClientCard check in Enemy.GetSpells()) { if (check.HasType(CardType.Continuous) || check.HasType(CardType.Field)) { card = check; } break; } int count = 0; foreach (ClientCard check in Enemy.GetSpells()) { if (check.Type == 16777218) { count++; } } if (count == 2) { if (Util.GetPZone(1, 1) != null && Util.GetPZone(1, 1).Type == 16777218) { card = Util.GetPZone(1, 1); } } if (card != null && Bot.LifePoints > 1000) { AI.SelectCard(card); return(true); } return(false); }
public ClientCard GetBestEnemySpell(bool onlyFaceup = false) { ClientCard card = GetProblematicEnemySpell(); if (card != null) { return(card); } var spells = Enemy.GetSpells(); card = spells.FirstOrDefault(ecard => ecard.IsFaceup() && (ecard.HasType(CardType.Continuous) || ecard.HasType(CardType.Field))); if (card != null) { return(card); } if (spells.Count > 0 && !onlyFaceup) { return(spells[0]); } return(null); }
public void SelectSTPlace(ClientCard card = null, bool avoid_Impermanence = false, List <int> avoid_list = null) { List <int> list = new List <int> { 0, 1, 2, 3, 4 }; int n = list.Count; while (n-- > 1) { int index = Program._rand.Next(n + 1); int temp = list[index]; list[index] = list[n]; list[n] = temp; } foreach (int seq in list) { int zone = (int)System.Math.Pow(2, seq); if (this.Bot.SpellZone[seq] == null) { if (card != null && card.Location == CardLocation.Hand && avoid_Impermanence) { continue; } if (avoid_list != null && avoid_list.Contains(seq)) { continue; } this.AI.SelectPlace(zone); return; } ; } this.AI.SelectPlace(0); }
public void SetCard(ExecutorType type, ClientCard card, int description) { Type = type; Card = card; ActivateDescription = description; }
public virtual void OnChaining(int player, ClientCard card) { CurrentChain.Add(card); LastChainPlayer = player; }
private bool IsExodiaPart(ClientCard card) { if (ExodiaParts.Contains(card.Id)) return true; return false; }
public override void OnChaining(int player, ClientCard card) { base.OnChaining(player, card); LastChainer = player; if (card.Id == (int)CardId.Ryko) RykoEffect(); else if (card.Id == (int)CardId.EclipseWyvern) WyvernEffect(card); }
private bool WyvernEffect(ClientCard Card) { if (Card.Location == CardLocation.Grave) { ClientField field = Duel.Fields[0]; //Search for Red-Eyes Darkness Metal Dragon bool redmdsearch = true; if (field.HasInHand((int)CardId.REDMD)) redmdsearch = false; else if (field.HasInGraveyard((int)CardId.REDMD)) redmdsearch = false; else if (field.HasInMonstersZone((int)CardId.REDMD)) redmdsearch = false; else foreach (ClientCard card in field.Banished) if (card.Id == (int)CardId.REDMD) redmdsearch = false; if (redmdsearch) { AI.SelectCard((int)CardId.REDMD); return true; } //Search for Galaxy-Eyes Photon Dragon int GEPD = (int)CardId.GalaxyEyesPhotonDragon; int remaining = 3; foreach (ClientCard card in field.Hand) if (card.Id == GEPD) remaining--; foreach (ClientCard card in field.Graveyard) if (card.Id == GEPD) remaining--; foreach (ClientCard card in field.Banished) if (card.Id == GEPD) remaining--; foreach (ClientCard card in field.MonsterZone) if (card != null && card.Id == GEPD) remaining--; if (remaining > 0) { AI.SelectCard(GEPD); return true; } //Search for Dark Armed Dragon bool dadsearch = true; if (field.HasInHand((int)CardId.DAD)) dadsearch = false; else if (field.HasInGraveyard((int)CardId.DAD)) dadsearch = false; else if (field.HasInMonstersZone((int)CardId.DAD)) dadsearch = false; else foreach (ClientCard card in field.Banished) if (card.Id == (int)CardId.DAD) dadsearch = false; if (dadsearch == true) { AI.SelectCard((int)CardId.DAD); return true; } //Else return False return false; } else if (Card.Location == CardLocation.Removed) return true; return false; }
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender) { if (defender.IsMonsterInvincible() && !defender.IsMonsterDangerous() && attacker.Id == 83104731) return true; return base.OnPreBattleBetween(attacker, defender); }
private bool IsCounterCard(ClientCard card) { if (CounterCards.Contains(card.Id)) return true; return false; }
public override bool OnPreBattleBetween(ClientCard attacker, ClientCard defender) { if (attacker.Id == (int)CardId.Unifrog || attacker.Id == (int)CardId.DewdarkOfTheIceBarrier) return true; if (defender.IsMonsterInvincible() && !defender.IsMonsterDangerous() && attacker.Id == (int)CardId.SubmarineFrog) return true; return base.OnPreBattleBetween(attacker, defender); }
public CardSelector(ClientCard card) { _type = SelectType.Card; _card = card; }