private void gameplay_mode() { GameState gs = GameState.Get(); // If we're in mulligan if (gs.IsMulliganPhase()) { if (mulligan_state == MulliganState.BEGIN) { if (gs.IsMulliganManagerActive() && PrivateHacker.get_m_UIbuttons() != null) { mulligan(); mulligan_state = MulliganState.DO_END; Delay(2000); } } else if (mulligan_state == MulliganState.DO_END) { MulliganManager.Get().AutomaticContinueMulligan(); mulligan_state = MulliganState.DONE; } return; } // If the game is over else if (gs.IsGameOver()) { game_over(); } // If it's our turn else if (gs.IsLocalPlayerTurn()) { // If it was not our turn last tick if (!was_my_turn) { // Wait extra time for turn to start was_my_turn = true; Delay(5000); return; } run_ai(); } else { was_my_turn = false; } // Reset variables mulligan_state = MulliganState.BEGIN; }
public bool drop_card(Card c, bool pickup) { Log.log("Dropped card: " + c.GetEntity().GetName()); if (pickup) { PrivateHacker.GrabCard(c); } else { return(drop_held_card()); } return(false); }
// Called to invoke AI private void run_ai() { // Temporarily disable reticle so mouse doesn't have to stay in window TargetReticleManager trm = TargetReticleManager.Get(); PrivateHacker.set_TargetReticleManager_s_instance(null); try { // Perform queued actions first if (queuedActions.Count > 0) { // Dequeue first execution and perform it Action action = queuedActions[0]; queuedActions.RemoveAt(0); int delay = api.PerformAction(action); // Delay between each action Delay(delay); return; } // Get hand cards var cards = API.getOurPlayer().GetHandZone().GetCards().ToList <Card>(); // Get initial actions to perform var actions = api.turn(cards); // Queue up these actions queuedActions.AddRange(actions); if (queuedActions.Count == 0) { // Done with turn actions Log.log("Ending turn"); end_turn(); } } catch (Exception e) { Log.error("Exception in run_ai: " + e.Message); Log.error(e.ToString()); } // Re-enable TargetReticleManager PrivateHacker.set_TargetReticleManager_s_instance(trm); }
// Run a single AI tick private void update() { // Avoid InactivePlayerKicker PrivateHacker.set_m_activityDetected(true); // Get current scene mode SceneMgr.Mode scene_mode = SceneMgr.Get().GetMode(); // If scene changes let's wait a few seconds if (scene_mode != last_scene_mode) { last_scene_mode = scene_mode; Delay(5000); return; } // Switch upon the mode switch (scene_mode) { // Unsupported modes case SceneMgr.Mode.STARTUP: case SceneMgr.Mode.COLLECTIONMANAGER: case SceneMgr.Mode.PACKOPENING: case SceneMgr.Mode.FRIENDLY: case SceneMgr.Mode.DRAFT: case SceneMgr.Mode.CREDITS: // Enter MainMenu SceneMgr.Get().SetNextMode(SceneMgr.Mode.HUB); break; // Errors, nothing to do case SceneMgr.Mode.INVALID: case SceneMgr.Mode.FATAL_ERROR: case SceneMgr.Mode.RESET: Log.say("Fatal Error, in AI.tick()", true); Log.say("Force closing game!", true); Plugin.destroy(); // Kill it the bad way Environment.FailFast(null); //Plugin.setRunning(false); break; // Login screen case SceneMgr.Mode.LOGIN: // Click through quests login_mode(); break; // Main Menu case SceneMgr.Mode.HUB: switch (game_mode) { case Mode.PRACTICE_NORMAL: case Mode.PRACTICE_EXPERT: // Enter PRACTICE Mode SceneMgr.Get().SetNextMode(SceneMgr.Mode.ADVENTURE); break; case Mode.TOURNAMENT_RANKED: case Mode.TOURNAMENT_UNRANKED: // Enter Turnament Mode SceneMgr.Get().SetNextMode(SceneMgr.Mode.TOURNAMENT); Tournament.Get().NotifyOfBoxTransitionStart(); break; default: throw new Exception("Unknown Game Mode!"); } break; // In game case SceneMgr.Mode.GAMEPLAY: // Handle Gamplay gameplay_mode(); just_joined = false; break; // In PRACTICE Sub Menu case SceneMgr.Mode.ADVENTURE: bool expert = false; switch (game_mode) { case Mode.PRACTICE_NORMAL: expert = false; break; case Mode.PRACTICE_EXPERT: expert = true; break; case Mode.TOURNAMENT_RANKED: case Mode.TOURNAMENT_UNRANKED: // Leave to the Hub Log.say("Inside wrong sub-menu!"); SceneMgr.Get().SetNextMode(SceneMgr.Mode.HUB); return; default: throw new Exception("Unknown Game Mode!"); } // Play against AI practice_mode(expert); break; // In Play Sub Menu case SceneMgr.Mode.TOURNAMENT: bool ranked = false; switch (game_mode) { case Mode.PRACTICE_NORMAL: case Mode.PRACTICE_EXPERT: // Leave to the Hub Log.say("Inside wrong sub-menu!"); SceneMgr.Get().SetNextMode(SceneMgr.Mode.HUB); return; case Mode.TOURNAMENT_RANKED: ranked = true; break; case Mode.TOURNAMENT_UNRANKED: ranked = false; break; default: throw new Exception("Unknown Game Mode!"); } // Play against humans (or bots) tournament_mode(ranked); break; default: Log.say("Unknown SceneMgr State!", true); break; } }
public bool drop_held_card_worker(int requested_zone_position) { PegCursor.Get().SetMode(PegCursor.Mode.STOPDRAG); InputManager input_man = InputManager.Get(); if (input_man.heldObject == null) { Log.log("Nothing held, when trying to drop"); return(false); } Card component = input_man.heldObject.GetComponent <Card>(); ZonePlay m_myPlayZone = PrivateHacker.get_m_myPlayZone(); ZoneHand m_myHandZone = PrivateHacker.get_m_myHandZone(); component.SetDoNotSort(false); iTween.Stop(input_man.heldObject); Entity entity = component.GetEntity(); component.NotifyLeftPlayfield(); GameState.Get().GetGameEntity().NotifyOfCardDropped(entity); m_myPlayZone.UnHighlightBattlefield(); DragCardSoundEffects component2 = component.GetComponent <DragCardSoundEffects>(); if (component2) { component2.Disable(); } UnityEngine.Object.Destroy(input_man.heldObject.GetComponent <DragRotator>()); input_man.heldObject = null; ProjectedShadow componentInChildren = component.GetActor().GetComponentInChildren <ProjectedShadow>(); if (componentInChildren != null) { componentInChildren.DisableShadow(); } // Check that the card is on the hand Zone card_zone = component.GetZone(); if ((card_zone == null) || card_zone.m_ServerTag != TAG_ZONE.HAND) { return(false); } bool does_target = false; bool is_minion = entity.IsMinion(); bool is_weapon = entity.IsWeapon(); if (is_minion || is_weapon) { Zone zone = (!is_weapon) ? (Zone)m_myPlayZone : (Zone)PrivateHacker.get_m_myWeaponZone(); if (zone) { GameState gameState = GameState.Get(); int card_position = Network.NoPosition; if (is_minion) { card_position = ZoneMgr.Get().PredictZonePosition(zone, requested_zone_position); gameState.SetSelectedOptionPosition(card_position); } if (input_man.DoNetworkResponse(entity)) { if (is_weapon) { PrivateHacker.set_m_lastZoneChangeList(ZoneMgr.Get().AddLocalZoneChange(component, zone, zone.GetLastPos())); } else { PrivateHacker.set_m_lastZoneChangeList(ZoneMgr.Get().AddPredictedLocalZoneChange(component, zone, requested_zone_position, card_position)); } PrivateHacker.ForceManaUpdate(entity); if (is_minion && gameState.EntityHasTargets(entity)) { does_target = true; if (TargetReticleManager.Get()) { bool showArrow = true; TargetReticleManager.Get().CreateFriendlyTargetArrow(entity, entity, true, showArrow, null); } PrivateHacker.set_m_battlecrySourceCard(component); } } else { gameState.SetSelectedOptionPosition(Network.NoPosition); } } } // Spell support else { if (entity.IsSpell()) { if (GameState.Get().EntityHasTargets(entity)) { input_man.heldObject = null; EnemyActionHandler.Get().NotifyOpponentOfCardDropped(); m_myHandZone.UpdateLayout(-1, true); m_myPlayZone.SortWithSpotForHeldCard(-1); return(true); } if (!GameState.Get().HasResponse(entity)) { PlayErrors.DisplayPlayError(PlayErrors.GetPlayEntityError(entity), entity); } else { input_man.DoNetworkResponse(entity); if (entity.IsSecret()) { ZoneSecret m_mySecretZone = PrivateHacker.get_m_mySecretZone(); PrivateHacker.set_m_lastZoneChangeList(ZoneMgr.Get().AddLocalZoneChange(component, m_mySecretZone, m_mySecretZone.GetLastPos())); } else { PrivateHacker.set_m_lastZoneChangeList(ZoneMgr.Get().AddLocalZoneChange(component, TAG_ZONE.PLAY)); } PrivateHacker.ForceManaUpdate(entity); PrivateHacker.PlayPowerUpSpell(component); PrivateHacker.PlayPlaySpell(component); } } } m_myHandZone.UpdateLayout(-1, true); m_myPlayZone.SortWithSpotForHeldCard(-1); if (does_target) { if (EnemyActionHandler.Get()) { EnemyActionHandler.Get().NotifyOpponentOfTargetModeBegin(component); } } else { if (GameState.Get().GetResponseMode() != GameState.ResponseMode.SUB_OPTION) { EnemyActionHandler.Get().NotifyOpponentOfCardDropped(); } } return(true); }
public void attack(Card c) { Log.log("Attack: " + c.GetEntity().GetName()); PrivateHacker.HandleClickOnCardInBattlefield(c); }