Skip to content

Commit

Permalink
Merge pull request #21 from IceYGO/master
Browse files Browse the repository at this point in the history
9-4
  • Loading branch information
OhnkytaBlabdey authored Sep 4, 2018
2 parents 94b7a54 + 9897132 commit f2d65d3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Game/AI/AIFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public bool IsOneEnemyBetterThanValue(int value, bool onlyATK)

public bool IsAllEnemyBetterThanValue(int value, bool onlyATK)
{
return Enemy.MonsterZone.GetMonsters()
List<ClientCard> monsters = Enemy.MonsterZone.GetMonsters();
return monsters.Count > 0 && monsters
.All(card => card.GetDefensePower() > value && (!onlyATK || card.IsAttack()));
}

Expand Down
46 changes: 32 additions & 14 deletions Game/AI/Decks/AltergeistExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ public AltergeistExecutor(GameAI ai, Duel duel)
// effect
AddExecutor(ExecutorType.Activate, CardId.Spoofing, Spoofing_eff);
AddExecutor(ExecutorType.Activate, CardId.Kunquery, Kunquery_eff);
AddExecutor(ExecutorType.Activate, CardId.Marionetter, Marionetter_eff);
AddExecutor(ExecutorType.Activate, CardId.Multifaker, Multifaker_deckss);

// summon
AddExecutor(ExecutorType.SpSummon, CardId.Hexstia, Hexstia_ss);
AddExecutor(ExecutorType.SpSummon, CardId.Linkuriboh, Linkuriboh_ss);
AddExecutor(ExecutorType.Activate, CardId.Linkuriboh, Linkuriboh_eff);
AddExecutor(ExecutorType.Activate, CardId.Marionetter, Marionetter_eff);
AddExecutor(ExecutorType.Activate, CardId.OneForOne, OneForOne_activate);
AddExecutor(ExecutorType.Summon, CardId.Meluseek, Meluseek_summon);
AddExecutor(ExecutorType.Summon, CardId.Marionetter, Marionetter_summon);
Expand All @@ -176,6 +176,7 @@ public AltergeistExecutor(GameAI ai, Duel duel)
AddExecutor(ExecutorType.Summon, CardId.Silquitous, Silquitous_summon);
AddExecutor(ExecutorType.Summon, CardId.Multifaker, Multifaker_summon);
AddExecutor(ExecutorType.Repos, MonsterRepos);
AddExecutor(ExecutorType.Summon, MonsterSummon);
AddExecutor(ExecutorType.MonsterSet, MonsterSet);
AddExecutor(ExecutorType.SpellSet, SpellSet);
}
Expand Down Expand Up @@ -931,6 +932,11 @@ public bool GR_WC_activate()
AI.SelectCard(CardId.Needlefiber);
return true;
}
if (has_level_1 && !Enemy.HasInHandOrInMonstersZoneOrInGraveyard(CardId.Linkuriboh) && !Enemy.HasInBanished(CardId.Linkuriboh) && Bot.HasInExtra(CardId.Linkuriboh))
{
AI.SelectCard(CardId.Linkuriboh);
return true;
}
if (altergeis_count > 0 && !Enemy.HasInBanished(CardId.Hexstia) && Bot.HasInExtra(CardId.Hexstia))
{
AI.SelectCard(CardId.Hexstia);
Expand All @@ -949,11 +955,6 @@ public bool GR_WC_activate()
return true;
}
}
if (has_level_1 && !Enemy.HasInHandOrInMonstersZoneOrInGraveyard(CardId.Linkuriboh) && !Enemy.HasInBanished(CardId.Linkuriboh) && Bot.HasInExtra(CardId.Linkuriboh))
{
AI.SelectCard(CardId.Linkuriboh);
return true;
}

return false;
}
Expand Down Expand Up @@ -1298,7 +1299,8 @@ public bool Hexstia_eff()

public bool Meluseek_eff()
{
if (ActivateDescription == AI.Utils.GetStringId(CardId.Meluseek,0))
if (ActivateDescription == AI.Utils.GetStringId(CardId.Meluseek,0)
|| (ActivateDescription == -1 && Card.Location == CardLocation.MonsterZone))
{
attacked_Meluseek.Add(Card);
ClientCard target = GetProblematicEnemyCard_Alter(true);
Expand Down Expand Up @@ -1388,13 +1390,15 @@ public bool Multifaker_deckss()
{
if (Card.Location != CardLocation.Hand)
{
ClientCard Silquitous_target = GetProblematicEnemyCard_Alter(true);
if (Duel.Player == 1 && Duel.Phase >= DuelPhase.Main2 && GetProblematicEnemyCard_Alter(true) == null && Bot.GetRemainingCount(CardId.Meluseek,3) > 0)
{
AI.SelectCard(CardId.Meluseek);
Multifaker_ssfromdeck = true;
return true;
}
else if (!Silquitous_bounced && !Bot.HasInMonstersZone(CardId.Silquitous) && Bot.GetRemainingCount(CardId.Silquitous,2) > 0)
else if (!Silquitous_bounced && !Bot.HasInMonstersZone(CardId.Silquitous) && Bot.GetRemainingCount(CardId.Silquitous,2) > 0
&& !(Duel.Player == 0 && Silquitous_target==null))
{
AI.SelectCard(CardId.Silquitous);
Multifaker_ssfromdeck = true;
Expand Down Expand Up @@ -1624,6 +1628,8 @@ public bool Manifestation_eff()
foreach(int id in choose_list)
{
if (Bot.HasInGraveyard(id)){
if (id == CardId.Kunquery
&& (!Bot.HasInHand(CardId.Multifaker) || !Multifaker_candeckss())) continue;
AI.SelectCard(id);
return true;
}
Expand Down Expand Up @@ -1810,6 +1816,7 @@ public void Spoofing_select(IList<int> list)
public bool Spoofing_eff()
{
if (AI.Utils.ChainContainsCard(CardId.Spoofing)) return false;
if (Card.IsDisabled()) return false;
if (!AI.Utils.ChainContainPlayer(0) && !Multifaker_ssfromhand && Multifaker_candeckss() && Bot.HasInHand(CardId.Multifaker) && Card.HasPosition(CardPosition.FaceDown))
{
AI.SelectYesNo(false);
Expand Down Expand Up @@ -2633,19 +2640,20 @@ public bool MonsterRepos()
return Card.HasPosition(CardPosition.Defence);
}

if (isAltergeist(Card) && Bot.HasInHandOrInSpellZone(CardId.Protocol) && Card.IsFacedown()) return true;
if (isAltergeist(Card) && Bot.HasInHandOrInSpellZone(CardId.Protocol) && Card.IsFacedown())
return true;

bool enemyBetter = AI.Utils.IsAllEnemyBetter(true);
if (Card.IsAttack() && enemyBetter)
return true;
return true;
if (Card.IsDefense() && !enemyBetter)
return true;
return false;
}

public bool MonsterSet()
{
if (AI.Utils.GetOneEnemyBetterThanMyBest() == null) return false;
if (AI.Utils.GetOneEnemyBetterThanMyBest() == null && Bot.GetMonsterCount() > 0) return false;
if (Card.Level > 4) return false;
int rest_lp = Bot.LifePoints;
int count = Bot.GetMonsterCount();
Expand All @@ -2665,7 +2673,12 @@ public bool MonsterSet()
return false;
}

// just a test
public bool MonsterSummon()
{
if (Enemy.GetMonsterCount() + Bot.GetMonsterCount() > 0) return false;
return Card.Attack >= Enemy.LifePoints;
}

public override BattlePhaseAction OnSelectAttackTarget(ClientCard attacker, IList<ClientCard> defenders)
{
if (EvenlyMatched_ready())
Expand All @@ -2686,7 +2699,11 @@ public override BattlePhaseAction OnSelectAttackTarget(ClientCard attacker, ILis
ClientCard defender = defenders[i];
attacker.RealPower = attacker.Attack;
defender.RealPower = defender.GetDefensePower();
if (!OnPreBattleBetween(attacker, defender) && !(attacker.IsCode(CardId.Borrelsword) && !attacker.IsDisabled()))
if (attacker.IsCode(CardId.Borrelsword) && !attacker.IsDisabled())
return AI.Attack(attacker, defender);
if (!OnPreBattleBetween(attacker, defender))
continue;
if (attacker.RealPower == defender.RealPower && Bot.GetMonsterCount() < Enemy.GetMonsterCount())
continue;
if (attacker.RealPower > defender.RealPower || (attacker.RealPower >= defender.RealPower && attacker.IsLastAttacker && defender.IsAttack()))
return AI.Attack(attacker, defender);
Expand Down Expand Up @@ -2762,7 +2779,8 @@ public override IList<ClientCard> OnSelectCard(IList<ClientCard> cards, int min,

public override CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions)
{
if (AI.Utils.IsTurn1OrMain2())
if (AI.Utils.IsTurn1OrMain2()
&& (cardId == CardId.Meluseek || cardId == CardId.Silquitous))
{
return CardPosition.FaceUpDefence;
}
Expand Down

0 comments on commit f2d65d3

Please sign in to comment.