Skip to content

Commit

Permalink
Add ExecutorType GoToBattlePhase etc. (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
OhnkytaBlabdey authored and mercury233 committed Aug 20, 2018
1 parent 0d0f6f9 commit 702b093
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Game/AI/ExecutorType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ public enum ExecutorType
MonsterSet,
SpellSet,
Activate,
SummonOrSet
SummonOrSet,
GoToBattlePhase,
GoToMainPhase2,
GoToEndPhase
}
}
20 changes: 20 additions & 0 deletions Game/GameAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ public BattlePhaseAction OnSelectBattleCmd(BattlePhase battle)
Executor.SetBattle(battle);
foreach (CardExecutor exec in Executor.Executors)
{
if (exec.Type == ExecutorType.GoToMainPhase2 && battle.CanMainPhaseTwo && exec.Func()) // check if should enter main phase 2 directly
{
return ToMainPhase2();
}
if (exec.Type == ExecutorType.GoToEndPhase && battle.CanEndPhase && exec.Func()) // check if should enter end phase directly
{
return ToEndPhase();
}
for (int i = 0; i < battle.ActivableCards.Count; ++i)
{
ClientCard card = battle.ActivableCards[i];
Expand Down Expand Up @@ -383,6 +391,18 @@ public MainPhaseAction OnSelectIdleCmd(MainPhase main)
Executor.SetMain(main);
foreach (CardExecutor exec in Executor.Executors)
{
if (exec.Type == ExecutorType.GoToEndPhase && main.CanEndPhase && exec.Func()) // check if should enter end phase directly
{
_dialogs.SendEndTurn();
return new MainPhaseAction(MainPhaseAction.MainAction.ToEndPhase);
}
if (exec.Type==ExecutorType.GoToBattlePhase && main.CanBattlePhase && exec.Func()) // check if should enter battle phase directly
{
return new MainPhaseAction(MainPhaseAction.MainAction.ToBattlePhase);
}
// NOTICE: GoToBattlePhase and GoToEndPhase has no "card" can be accessed to ShouldExecute(), so instead use exec.Func() to check ...
// enter end phase and enter battle pahse is in higher priority.

for (int i = 0; i < main.ActivableCards.Count; ++i)
{
ClientCard card = main.ActivableCards[i];
Expand Down

0 comments on commit 702b093

Please sign in to comment.