public static bool Attack(Card attacker, Card enemy) { try { GameState.Get().GetGameEntity().NotifyOfCardGrabbed(attacker.GetEntity()); if (InputManager.Get().DoNetworkResponse(attacker.GetEntity())) { EnemyActionHandler.Get().NotifyOpponentOfCardPickedUp(attacker); System.Threading.Thread.Sleep(500); EnemyActionHandler.Get().NotifyOpponentOfTargetModeBegin(attacker); System.Threading.Thread.Sleep(500); GameState.Get().GetGameEntity().NotifyOfBattlefieldCardClicked(enemy.GetEntity(), true); if (InputManager.Get().DoNetworkResponse(enemy.GetEntity())) { EnemyActionHandler.Get().NotifyOpponentOfTargetEnd(); GameState.Get().GetCurrentPlayer().GetHandZone().UpdateLayout(-1, true); GameState.Get().GetCurrentPlayer().GetBattlefieldZone().UpdateLayout(); return(true); } } return(false); } catch (Exception ex) { Graphics.AddErrorMsg("Attacking Failed" + ex.StackTrace.ToString()); return(false); } finally { System.Threading.Thread.Sleep(1000 * 2); } }
/* void Game.PlayCard(string type, Card card, [optional] Card target) * Plays a card from player hand, TYPES = "Minion", "Spell" * TODO: Improve this function and add support for Secret, Weapon Zones */ public static void PlayCard(string type, Card card, Card target = null) { Entity cEntity = card.GetEntity(); switch (type) { case "Minion": Zone destZone = MyPlayer().GetBattlefieldZone(); int slot = destZone.GetCards().Count + 1; GameState.Get().GetGameEntity().NotifyOfCardDropped(cEntity); GameState.Get().SetSelectedOptionPosition(slot); if (InputManager.Get().DoNetworkResponse(cEntity)) { int zonePos = cEntity.GetZonePosition(); ZoneMgr.Get().AddLocalZoneChange(card, destZone, slot); MyPlayer().GetHandZone().UpdateLayout(-1, true); MyPlayer().GetBattlefieldZone().SortWithSpotForHeldCard(-1); if (GameState.Get().GetResponseMode() != GameState.ResponseMode.SUB_OPTION) { EnemyActionHandler.Get().NotifyOpponentOfCardDropped(); } } break; case "Spell": if (card.GetActor().GetActorStateType() == ActorStateType.CARD_PLAYABLE) { GameState.Get().GetGameEntity().NotifyOfCardDropped(cEntity); if (InputManager.Get().DoNetworkResponse(cEntity)) { ZoneMgr.Get().AddLocalZoneChange(card, TAG_ZONE.PLAY); MyPlayer().GetHandZone().UpdateLayout(-1, true); MyPlayer().GetBattlefieldZone().SortWithSpotForHeldCard(-1); if (GameState.Get().GetResponseMode() != GameState.ResponseMode.SUB_OPTION) { EnemyActionHandler.Get().NotifyOpponentOfCardDropped(); } } } break; } if (target != null && GameState.Get().IsInTargetMode()) { GameState.Get().GetGameEntity().NotifyOfBattlefieldCardClicked(target.GetEntity(), true); if (InputManager.Get().DoNetworkResponse(target.GetEntity())) { EnemyActionHandler.Get().NotifyOpponentOfTargetEnd(); MyPlayer().GetHandZone().UpdateLayout(-1, true); MyPlayer().GetBattlefieldZone().UpdateLayout(); } } }
/* void Game.Attack(Card Attacker, Card enemy) * Attacks enemy card with attacker card */ public static void Attack(Card attacker, Card enemy) { GameState.Get().GetGameEntity().NotifyOfCardGrabbed(attacker.GetEntity()); if (InputManager.Get().DoNetworkResponse(attacker.GetEntity())) { EnemyActionHandler.Get().NotifyOpponentOfCardPickedUp(attacker); EnemyActionHandler.Get().NotifyOpponentOfTargetModeBegin(attacker); GameState.Get().GetGameEntity().NotifyOfBattlefieldCardClicked(enemy.GetEntity(), true); if (InputManager.Get().DoNetworkResponse(enemy.GetEntity())) { EnemyActionHandler.Get().NotifyOpponentOfTargetEnd(); GameState.Get().GetCurrentPlayer().GetHandZone().UpdateLayout(-1, true); GameState.Get().GetCurrentPlayer().GetBattlefieldZone().UpdateLayout(); } } }
public bool DoAttack(Card attacker, Card attackee) { Log.log("Attack " + attacker.GetEntity().GetName() + " -> " + attackee.GetEntity().GetName()); try { // pick up minion gs.GetGameEntity().NotifyOfCardGrabbed(attacker.GetEntity()); if (InputManager.Get().DoNetworkResponse(attacker.GetEntity())) { EnemyActionHandler.Get().NotifyOpponentOfCardPickedUp(attacker); Thread.Sleep(500); Log.log("attacking with picked up minion"); // attack with picked up minion EnemyActionHandler.Get().NotifyOpponentOfTargetModeBegin(attacker); Thread.Sleep(500); gs.GetGameEntity().NotifyOfBattlefieldCardClicked(attackee.GetEntity(), true); if (InputManager.Get().DoNetworkResponse(attackee.GetEntity())) { EnemyActionHandler.Get().NotifyOpponentOfTargetEnd(); myPlayer.GetHandZone().UpdateLayout(-1, true); myPlayer.GetBattlefieldZone().UpdateLayout(); Log.log("DoAttack succeeded"); return(true); } } return(false); } catch (Exception ex) { Log.log("DoAttack failed" + ex.StackTrace.ToString()); return(false); } finally { Thread.Sleep(1000 * 2); } }
public override void Execute() { var slot = Game.MyPlayer.FieldZone.GetCards().Count + 1; _source.PickUp(); _source.Drop(); if (!_source.DoReposponse) { return; } ZoneMgr.Get().AddLocalZoneChange(_source.Source, Game.MyPlayer.FieldZone, slot); Game.MyPlayer.UpdateMana(_source.RealTimeCost); Game.MyPlayer.HandZone.UpdateLayout(-1, true); Game.MyPlayer.FieldZone.SortWithSpotForHeldCard(-1); if (GameState.Get().GetResponseMode() == GameState.ResponseMode.SUB_OPTION) { return; } EnemyActionHandler.Get().NotifyOpponentOfCardDropped(); ActionQueue.Remove(this); }
public override void Execute() { if (Game.IsAttacking()) { return; } _attacker.Grab(); if (!_attacker.DoReposponse) { return; } _attacker.PickUp(); EnemyActionHandler.Get().NotifyOpponentOfTargetModeBegin(_attacker.Source); GameState.Get().GetGameEntity().NotifyOfBattlefieldCardClicked(_target.Source.GetEntity(), true); if (!_target.DoReposponse) { return; } EnemyActionHandler.Get().NotifyOpponentOfTargetEnd(); Game.MyPlayer.FieldZone.UpdateLayout(); ActionQueue.Remove(this); }
public bool DoDropMinion(Card c) { Log.log("Dropping minion " + c.GetEntity().GetName()); try { var destZone = myPlayer.GetBattlefieldZone(); int slot = destZone.GetCards().Count + 1; gs.GetGameEntity().NotifyOfCardDropped(c.GetEntity()); gs.SetSelectedOptionPosition(slot); if (InputManager.Get().DoNetworkResponse(c.GetEntity())) { int zonePos = c.GetEntity().GetZonePosition(); ZoneMgr.Get().AddLocalZoneChange(c, destZone, slot); myPlayer.GetHandZone().UpdateLayout(-1, true); myPlayer.GetBattlefieldZone().SortWithSpotForHeldCard(-1); if (gs.GetResponseMode() != GameState.ResponseMode.SUB_OPTION) { EnemyActionHandler.Get().NotifyOpponentOfCardDropped(); } Log.log("Dropping minion succeeded"); return(true); // TARGETTING - perhaps spin this off to a separate step /* * if (gs.EntityHasTargets(c.GetEntity())) * { * // do targetting * EnemyActionHandler.Get().NotifyOpponentOfTargetModeBegin(c); * Thread.Sleep(500); * gs.GetGameEntity().NotifyOfBattlefieldCardClicked(target.GetEntity(), true); * if (InputManager.Get().DoNetworkResponse(target.GetEntity())) * { * EnemyActionHandler.Get().NotifyOpponentOfTargetEnd(); * return true; * } * return false; * } * else if (gs.GetResponseMode() != GameState.ResponseMode.SUB_OPTION) * { * EnemyActionHandler.Get().NotifyOpponentOfCardDropped(); * return true; * } * else * { * // TODO: unsure when this happens * return true; * } */ } Log.log("Dropping minion failed (network response)"); return(false); } catch (Exception ex) { Log.log("Dropping minion failed (exception): " + ex.StackTrace.ToString()); return(false); } finally { Thread.Sleep(1000 * 2); } }
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); }