Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom dialog config #168

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions Dialogs/verre.zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,18 @@
"发动{0}!",
"等一下,我发动{0}。",
"要不是有{0},我都快睡着了。"
],
"custom": [
"臣服于本小姐的伟大吧!",
"{0},最后一击!",
"该跑路咯~",
"可爱而无敌的本小姐,降临!",
"海涅,先来帮我顶着!",
"……来帮我一把,海涅!",
"发动本小姐的强大效果,封印你的所有怪兽!",
"发动本小姐的强大效果,提升攻击力!",
"魔力再生!",
"{0},变身!",
"噫,是蟑螂!"
]
}
64 changes: 64 additions & 0 deletions Game/AI/Decks/ExosisterExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using WindBot;
using WindBot.Game;
using WindBot.Game.AI;
using WindBot.Game.AI.Enums.Dialogs;
using System.Linq;
using System;

Expand Down Expand Up @@ -170,6 +171,7 @@ public ExosisterExecutor(GameAI ai, Duel duel)
bool enemyMoveGrave = false;
bool paxCallToField = false;
List<int> infiniteImpermanenceList = new List<int>();
bool customDialogFlag = false;

bool summoned = false;
bool elisEffect1Activated = false;
Expand Down Expand Up @@ -728,6 +730,7 @@ public override void OnChaining(int player, ClientCard card)
{
if (card.IsCode(_CardId.MaxxC) && CheckCalledbytheGrave(_CardId.MaxxC) == 0)
{
AI.Dialogs.SendCustomChat((int)VerreDialogs.MaxxCResponse);
enemyActivateMaxxC = true;
}
if (card.IsCode(_CardId.LockBird) && CheckCalledbytheGrave(_CardId.LockBird) == 0)
Expand Down Expand Up @@ -1105,6 +1108,55 @@ public override int OnSelectOption(IList<int> options)
return base.OnSelectOption(options);
}

public override void SendActivateDialog(ClientCard card)
{
if (customDialogFlag)
{
customDialogFlag = false;
return;
}
base.SendActivateDialog(card);
}

public override void SendChainingDialog(ClientCard card)
{
if (customDialogFlag)
{
customDialogFlag = false;
return;
}
base.SendChainingDialog(card);
}

public override void SendDirectAttackDialog(ClientCard card)
{
if (card.Attack >= Enemy.LifePoints)
{
AI.Dialogs.SendCustomDirectAttack((int)VerreDialogs.LastAttack, card.Name);
return;
}
base.SendDirectAttackDialog(card);
}

public override void SendEndTurnDialog()
{
// check whether duel going to end
if (Duel.Turn > 1)
{
if (Bot.GetMonsterCount() > 0 && Enemy.GetMonsterCount() == 0 && Bot.LifePoints > Enemy.LifePoints)
{
AI.Dialogs.SendCustomEndTurn((int)VerreDialogs.DuelNearEnd);
return;
}
if (Bot.GetMonsterCount() == 0 && Enemy.GetMonsterCount() > 0 && Bot.LifePoints < Enemy.LifePoints)
{
AI.Dialogs.SendCustomEndTurn((int)VerreDialogs.DuelNearEnd);
return;
}
}
base.SendEndTurnDialog();
}

public bool AshBlossomActivate()
{
if (CheckWhetherNegated(true) || !CheckLastChainShouldNegated()) return false;
Expand Down Expand Up @@ -1647,6 +1699,17 @@ public bool ExosisterMarthaActivate()
}

public bool DefaultExosisterTransform()
{
if (DefaultExosisterTransformInner())
{
AI.Dialogs.SendCustomActivate((int)VerreDialogs.ExosisterTransformActivate, Card.Name);
customDialogFlag = true;
return true;
}
return false;
}

public bool DefaultExosisterTransformInner()
{
List<int> canTransformList = new List<int>
{
Expand Down Expand Up @@ -1716,6 +1779,7 @@ public bool DefaultExosisterTransform()
return false;
}


public bool ExosisterMikailisActivate()
{
// banish
Expand Down
196 changes: 148 additions & 48 deletions Game/AI/Decks/WitchcraftExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using WindBot;
using WindBot.Game;
using WindBot.Game.AI;
using WindBot.Game.AI.Enums.Dialogs;
using System.Linq;


namespace WindBot.Game.AI.Decks
{
[Deck("Witchcraft", "AI_Witchcraft")]
Expand Down Expand Up @@ -197,6 +197,7 @@ public WitchcraftExecutor(GameAI ai, Duel duel)
bool MagicianRightHand_used = false;
ClientCard MagiciansLeftHand_negate = null;
ClientCard MagicianRightHand_negate = null;
bool customDialogFlag = false;

// go first
public override bool OnSelectHand()
Expand Down Expand Up @@ -246,6 +247,7 @@ public override void OnChaining(int player, ClientCard card)

if (player == 1 && card.Id == CardId.MaxxC && CheckCalledbytheGrave(CardId.MaxxC) == 0)
{
AI.Dialogs.SendCustomChat((int)VerreDialogs.MaxxCResponse);
enemy_activate_MaxxC = true;
}
if (player == 1 && card.Id == CardId.DimensionShifter && CheckCalledbytheGrave(CardId.DimensionShifter) == 0)
Expand Down Expand Up @@ -422,6 +424,19 @@ public override CardPosition OnSelectPosition(int cardId, IList<CardPosition> po
{
return base.OnSelectPosition(cardId, positions);
}
if (cardId == CardId.MadameVerre)
{
AI.Dialogs.SendCustomChat((int)VerreDialogs.VerreSpSummon);
}
if (cardId == CardId.Haine) {
if (Bot.HasInMonstersZone(CardId.MadameVerre, false, false, true))
{
AI.Dialogs.SendCustomChat((int)VerreDialogs.HaineSpSummonWithVerre);
} else
{
AI.Dialogs.SendCustomChat((int)VerreDialogs.HaineSpSummonWithoutVerre);
}
}
if (!Enemy.HasInMonstersZone(_CardId.BlueEyesChaosMAXDragon)
&& (Duel.Player == 1 && (cardId == CardId.MadameVerre ||
Util.GetOneEnemyBetterThanValue(Data.Attack + 1) != null))
Expand All @@ -436,6 +451,70 @@ public override CardPosition OnSelectPosition(int cardId, IList<CardPosition> po
return base.OnSelectPosition(cardId, positions);
}

public override void SendActivateDialog(ClientCard card)
{
if (customDialogFlag)
{
customDialogFlag = false;
return;
}
if (Duel.Phase == DuelPhase.End && card.HasSetcode(Witchcraft_setcode) && card.Location == CardLocation.Grave)
{
AI.Dialogs.SendCustomActivate((int)VerreDialogs.SpellRecycleActivate, card.Name);
return;
}
base.SendActivateDialog(card);
}

public override void SendChainingDialog(ClientCard card)
{
if (customDialogFlag)
{
customDialogFlag = false;
return;
}
if (Duel.Phase == DuelPhase.End && card.HasSetcode(Witchcraft_setcode) && card.Location == CardLocation.Grave)
{
AI.Dialogs.SendCustomChaining((int)VerreDialogs.SpellRecycleActivate, card.Name);
return;
}
base.SendChainingDialog(card);
}

public override void SendDirectAttackDialog(ClientCard card)
{
if (card.Id == CardId.MadameVerre)
{
AI.Dialogs.SendCustomDirectAttack((int)VerreDialogs.VerreDirectAttack, card.Name);
return;
}
if (card.Attack >= Enemy.LifePoints)
{
AI.Dialogs.SendCustomDirectAttack((int)VerreDialogs.LastAttack, card.Name);
return;
}
base.SendDirectAttackDialog(card);
}

public override void SendEndTurnDialog()
{
// check whether duel going to end
if (Duel.Turn > 1)
{
if (Bot.GetMonsterCount() > 0 && Enemy.GetMonsterCount() == 0 && Bot.LifePoints > Enemy.LifePoints)
{
AI.Dialogs.SendCustomEndTurn((int)VerreDialogs.DuelNearEnd);
return;
}
if (Bot.GetMonsterCount() == 0 && Enemy.GetMonsterCount() > 0 && Bot.LifePoints < Enemy.LifePoints)
{
AI.Dialogs.SendCustomEndTurn((int)VerreDialogs.DuelNearEnd);
return;
}
}
base.SendEndTurnDialog();
}

// shuffle List<ClientCard>
public List<ClientCard> CardListShuffle(List<ClientCard> list)
{
Expand Down Expand Up @@ -1352,71 +1431,92 @@ public bool MadameVerreActivate()
// negate
if (ActivateDescription == Util.GetStringId(CardId.MadameVerre, 1))
{
if (Card.IsDisabled()) return false;
if (CheckLastChainNegated()) return false;

// negate before activate
if (Enemy.MonsterZone.GetFirstMatchingCard(card => card.IsMonsterShouldBeDisabledBeforeItUseEffect() && !card.IsDisabled()) != null)
if (MadameVerreActivateForNegate())
{
SelectDiscardSpell();
AI.Dialogs.SendCustomActivate((int)VerreDialogs.VerreNegateActivate, Card.Name);
customDialogFlag = true;
return true;
}

// chain check
ClientCard LastChainCard = Util.GetLastChainCard();
if ((LastChainCard != null && LastChainCard.Controller == 1 && LastChainCard.Location == CardLocation.MonsterZone))
}
// gain ATK
else
{
if (MadameVerreActivateForGainAttack())
{
// negate monsters' activate
SelectDiscardSpell();
AI.Dialogs.SendCustomActivate((int)VerreDialogs.VerreGainAttackActivate, Card.Name);
customDialogFlag = true;
return true;
}
}
return false;
}

public bool MadameVerreActivateForNegate()
{
if (Card.IsDisabled()) return false;
if (CheckLastChainNegated()) return false;

// negate before activate
if (Enemy.MonsterZone.GetFirstMatchingCard(card => card.IsMonsterShouldBeDisabledBeforeItUseEffect() && !card.IsDisabled()) != null)
{
SelectDiscardSpell();
return true;
}

// negate battle related effect
if (Duel.Phase > DuelPhase.Main1 && Duel.Phase < DuelPhase.Main2)
// chain check
ClientCard LastChainCard = Util.GetLastChainCard();
if ((LastChainCard != null && LastChainCard.Controller == 1 && LastChainCard.Location == CardLocation.MonsterZone))
{
// negate monsters' activate
SelectDiscardSpell();
return true;
}

// negate battle related effect
if (Duel.Phase > DuelPhase.Main1 && Duel.Phase < DuelPhase.Main2)
{
if (Enemy.MonsterZone.GetFirstMatchingCard(card =>
card.IsMonsterDangerous() || (Duel.Player == 0) && card.IsMonsterInvincible()) != null)
{
if (Enemy.MonsterZone.GetFirstMatchingCard(card =>
card.IsMonsterDangerous() || (Duel.Player == 0) && card.IsMonsterInvincible()) != null)
{
SelectDiscardSpell();
return true;
}
SelectDiscardSpell();
return true;
}

return false;
}
// gain ATK
else

return false;
}

public bool MadameVerreActivateForGainAttack()
{
ClientCard self_card = Bot.BattlingMonster;
ClientCard enemy_card = Enemy.BattlingMonster;
if (self_card != null && enemy_card != null)
{
ClientCard self_card = Bot.BattlingMonster;
ClientCard enemy_card = Enemy.BattlingMonster;
if (self_card != null && enemy_card != null)
int power_cangain = CheckPlusAttackforMadameVerre();
int diff = enemy_card.GetDefensePower() - self_card.GetDefensePower();
Logger.DebugWriteLine("power: " + power_cangain.ToString());
Logger.DebugWriteLine("diff: " + diff.ToString());
if (diff > 0)
{
int power_cangain = CheckPlusAttackforMadameVerre();
int diff = enemy_card.GetDefensePower() - self_card.GetDefensePower();
Logger.DebugWriteLine("power: " + power_cangain.ToString());
Logger.DebugWriteLine("diff: " + diff.ToString());
if (diff > 0)
// avoid useless effect
if (self_card.IsDefense() && power_cangain < diff)
{
// avoid useless effect
if (self_card.IsDefense() && power_cangain < diff)
{
return false;
}
AI.SelectCard(Bot.Hand.GetMatchingCards(card => card.IsSpell()));
MadameVerreGainedATK = true;
return true;
}
else if (Enemy.GetMonsterCount() == 1 || (enemy_card.IsAttack() && Enemy.LifePoints <= diff + power_cangain))
{
AI.SelectCard(Bot.Hand.GetMatchingCards(card => card.IsSpell()));
MadameVerreGainedATK = true;
return true;
return false;
}
AI.SelectCard(Bot.Hand.GetMatchingCards(card => card.IsSpell()));
MadameVerreGainedATK = true;
return true;
}
else if (Enemy.GetMonsterCount() == 1 || (enemy_card.IsAttack() && Enemy.LifePoints <= diff + power_cangain))
{
AI.SelectCard(Bot.Hand.GetMatchingCards(card => card.IsSpell()));
MadameVerreGainedATK = true;
return true;
}
}
return false;
}

// activate of Haine
public bool HaineActivate()
{
Expand Down
Loading