public void RemoteEnterInteraction(Interactions.BaseInteraction io) { System.Diagnostics.Debug.Assert(m_remoteInteraction == null); m_remoteInteraction = io; if (m_interactionMessageQueue.Count != 0) { var msg = m_interactionMessageQueue.Dequeue(); ProcessInteractionMessage(msg); } }
private void InterpretMessageSelectNumber(XDocument xmlMessage) { var selectNumber = m_remoteInteraction as Interactions.SelectNumber; if (selectNumber == null) { throw new Exception("Wrong Phase"); } string num = ExtXML.GetFirstDescendantsValue<string, XDocument>(xmlMessage, "Number"); if (string.IsNullOrEmpty(num)) { selectNumber.Respond(null); } else { int number; if (!Int32.TryParse(num, out number)) { throw new InvalidCastException("Invalid Number"); } selectNumber.Respond(number); } m_remoteInteraction = null; }
private void InterpretMessageSelectCards(XDocument xmlMessage) { var selectCards = m_remoteInteraction as Interactions.SelectCards; if (selectCards == null) { throw new Exception("Wrong Phase"); } List<int> indexes = ExtXML.GetDescendantsValues<Int32, XDocument>(xmlMessage, "Index"); if (indexes.Count() == 0) { selectCards.Respond(Indexable.Empty<CardInstance>()); } else { var selectedCards = new List<CardInstance>(); for (int i = 0; i < indexes.Count; i++) { var selectedCard = selectCards.Candidates[indexes[i]]; selectedCards.Add(selectedCard); } selectCards.Respond(selectedCards.ToIndexable()); } m_remoteInteraction = null; }
private void InterpretMessageRedeem(XDocument xmlMessage) { var tacticalPhase = m_remoteInteraction as Interactions.TacticalPhase; if (tacticalPhase == null) { throw new Exception("Wrong Phase"); } var redeemedCard = tacticalPhase.RedeemCandidates[ExtXML.GetFirstDescendantsValue<Int32, XDocument>(xmlMessage, "RedeemIndex")]; tacticalPhase.RespondRedeem(redeemedCard); m_remoteInteraction = null; }
private void InterpretMessageCastSpell(XDocument xmlMessage) { var tacticalPhase = m_remoteInteraction as Interactions.TacticalPhase; if (tacticalPhase == null) { throw new Exception("Wrong Phase"); } var spell = tacticalPhase.CastSpellCandidates[ExtXML.GetFirstDescendantsValue<Int32, XDocument>(xmlMessage, "CastSpellIndex")]; tacticalPhase.RespondCast(spell); m_remoteInteraction = null; }
private void InterpretMessageActivateAssist(XDocument xmlMessage) { var tacticalPhase = m_remoteInteraction as Interactions.TacticalPhase; if (tacticalPhase == null) { throw new Exception("Wrong Phase"); } var assistCard = tacticalPhase.ActivateAssistCandidates[ExtXML.GetFirstDescendantsValue<Int32, XDocument>(xmlMessage, "AssistIndex")]; tacticalPhase.RespondActivate(assistCard); m_remoteInteraction = null; }
private void InterpretMessageAttackPlayer(XDocument xmlMessage) { var tacticalPhase = m_remoteInteraction as Interactions.TacticalPhase; if (tacticalPhase == null) { throw new Exception("Wrong Phase"); } var attackerCard = tacticalPhase.AttackerCandidates[ExtXML.GetFirstDescendantsValue<Int32, XDocument>(xmlMessage, "AttackerIndex")]; var playerBeingAttacked = tacticalPhase.Game.Players[ExtXML.GetFirstDescendantsValue<Int32, XDocument>(xmlMessage, "PlayerIndex")]; tacticalPhase.RespondAttackPlayer(attackerCard, playerBeingAttacked); m_remoteInteraction = null; }
private void InterpretMessageSwitchTurn(XDocument xmlMessage) { var tacticalPhase = m_remoteInteraction as Interactions.TacticalPhase; if (tacticalPhase == null) { throw new Exception("Wrong Phase"); } tacticalPhase.RespondPass(); m_remoteInteraction = null; }