// Give to the parameter the same controller as this object internal void CopyControllersTo(ControllableObject other) { if (Controller == null) { return; } other.Controller = Controller; }
public void TakeFrom(ControllableObject obj, Player to) { obj.TakingControl(to); }
public void PassTo(Player who, ControllableObject obj, Player player, bool requested) { // Ignore message that we sent in the first place if (who != Player.LocalPlayer) obj.PassControlTo(player, who, false, requested); }
public void DontTake(ControllableObject obj) { obj.DontTakeError(); }
public void DontTakeReq(ControllableObject id, Player to) { //Log.Info("[ProtOut] DontTakeReq"); if(Program.Client == null)return; MemoryStream stream = new MemoryStream(512); stream.Seek(4, SeekOrigin.Begin); BinaryWriter writer = new BinaryWriter(stream); if (Program.Client.Muted != 0) writer.Write(Program.Client.Muted); else writer.Write(0); writer.Write((byte)62); writer.Write(id.Id); writer.Write(to.Id); writer.Flush(); writer.Seek(0, SeekOrigin.Begin); writer.Write((int)stream.Length); writer.Close(); Send(stream.ToArray()); }
public void PassToReq(ControllableObject id, Player to, bool requested) { MemoryStream stream = new MemoryStream(512); stream.Seek(4, SeekOrigin.Begin); BinaryWriter writer = new BinaryWriter(stream); if (Program.Client.Muted != 0) writer.Write(Program.Client.Muted); else writer.Write(0); writer.Write((byte)64); writer.Write(id.Id); writer.Write(to.Id); writer.Write(requested); writer.Flush(); writer.Seek(0, SeekOrigin.Begin); writer.Write((int)stream.Length); writer.Close(); Send(stream.ToArray()); }
public void TakeFromReq(ControllableObject id, Player from) { StringBuilder sb = new StringBuilder(); XmlWriter writer = XmlWriter.Create(sb, xmlSettings); writer.WriteStartElement("TakeFromReq"); if (Script.ScriptEngine.CurrentScript != null && Script.ScriptEngine.CurrentScript.muted) writer.WriteAttributeString("muted", Script.ScriptEngine.CurrentScript.GetUniqueId().ToString(CultureInfo.InvariantCulture)); else if (Program.Client.Muted != 0) writer.WriteAttributeString("muted", Program.Client.Muted.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("id", id.Id.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("from", from.Id.ToString(CultureInfo.InvariantCulture)); writer.WriteEndElement(); writer.Close(); Send(sb.ToString()); }
public void PassToReq(ControllableObject id, Player to, bool requested) { StringBuilder sb = new StringBuilder(); XmlWriter writer = XmlWriter.Create(sb, xmlSettings); writer.WriteStartElement("PassToReq"); if(Program.Client.Muted != 0) writer.WriteAttributeString("muted", Program.Client.Muted.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("id", id.Id.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("to", to.Id.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("requested", requested.ToString(CultureInfo.InvariantCulture)); writer.WriteEndElement(); writer.Close(); Send(sb.ToString()); }
public void TakeFromReq(ControllableObject id, Player from) { if(Program.Client == null)return; MemoryStream stream = new MemoryStream(512); stream.Seek(4, SeekOrigin.Begin); BinaryWriter writer = new BinaryWriter(stream); if (Program.Client.Muted != 0) writer.Write(Program.Client.Muted); else writer.Write(0); writer.Write((byte)66); writer.Write(id.Id); writer.Write(from.Id); writer.Flush(); writer.Seek(0, SeekOrigin.Begin); writer.Write((int)stream.Length); writer.Close(); Send(stream.ToArray()); }
// Give to the parameter the same controller as this object internal void CopyControllersTo(ControllableObject other) { if (Controller == null) return; other.Controller = Controller; }
/// <summary>Completely remove all aliases from a group, e.g. before performing a shuffle.</summary> /// <param name="group">The group to remove all aliases from.</param> //public void UnaliasGrp(Group group) //{ // // Get the group // Pile g = group as Pile; // if (g == null) // { Program.Trace.TraceEvent(TraceEventType.Warning, EventIds.NonGame, "[UnaliasGrp] Group is not a pile."); return; } // // Collect aliases which we p // List<int> cards = new List<int>(g.Count); // List<ulong> types = new List<ulong>(g.Count); // bool hasAlias = false; // foreach (Card t in g) // { // CardIdentity ci = t.Type; // if (ci == null) continue; //Hack, should this ever be null? Sometimes it happens for whatever reason. // if (!ci.Alias) continue; // hasAlias = true; // if (ci.MySecret) // { cards.Add(t.Id); types.Add(ci.Key); } // } // // Unalias cards that we know (if any) // if (cards.Count > 0) // Program.Client.Rpc.Unalias(cards.ToArray(), types.ToArray()); // // If there are no alias, we may be ready to shuffle // if (!hasAlias && g.WantToShuffle) // { g.DoShuffle(); return; } // // Mark the group for shuffling // g.PreparingShuffle = true; // // Notify the user // Program.TracePlayerEvent(group.Owner, "{0} is being prepared for shuffle.", g); // // Check for null because the chat can currently be muted (e.g. during a Mulligan scripted action) // if (Program.LastChatTrace != null) // g.ShuffledTrace += (new ShuffleTraceChatHandler { Line = Program.LastChatTrace }).ReplaceText; //} /// <summary>Unalias some Cards, e.g. before a shuffle</summary> /// <param name="card">An array containing the Card ids to unalias.</param> /// <param name="type">An array containing the corresponding revealed CardIdentity ids.</param> //public void Unalias(int[] card, ulong[] type) //{ // if (card.Length != type.Length) // { Program.TraceWarning("[Unalias] Card and type lengths don't match."); return; } // Pile g = null; // List<int> cards = new List<int>(card.Length); // List<ulong> types = new List<ulong>(card.Length); // for (int i = 0; i < card.Length; i++) // { // Card c = Card.Find(card[i]); // if (c == null) // { Program.TraceWarning("[Unalias] Card not found."); continue; } // if (g == null) g = c.Group as Pile; // else if (g != c.Group) // { Program.TraceWarning("[Unalias] Not all cards belong to the same group!"); continue; } // // Check nobody cheated // if (!c.Type.MySecret) // { // if (c.Type.Key != Crypto.ModExp(type[i])) // Program.TraceWarning("[Unalias] Card identity doesn't match."); // } // // Substitue the card's identity // CardIdentity ci = CardIdentity.Find((int)type[i]); // if (ci == null) // { Program.TraceWarning("[Unalias] Card identity not found."); continue; } // CardIdentity.Delete(c.Type.Id); c.Type = ci; // // Propagate unaliasing // if (ci.Alias && ci.MySecret) // cards.Add(c.Id); types.Add(ci.Key); // } // if (cards.Count > 0) // Program.Client.Rpc.Unalias(cards.ToArray(), types.ToArray()); // if (g == null) return; // if (!g.PreparingShuffle) // { Program.TraceWarning("[Unalias] Cards revealed are not in a group prepared for shuffle."); return; } // // If all cards are now revealed, one can proceed to shuffling // if (!g.WantToShuffle) return; // bool done = false; // for (int i = 0; !done && i < g.Count; i++) // done = g[i].Type.Alias; // if (!done) // g.DoShuffle(); //} public void PassTo(Player who, ControllableObject obj, Player player, bool requested) { // Ignore message that we sent in the first place if (who != Player.LocalPlayer) obj.PassControlTo(player, who, false, requested); if (obj is Card) Program.GameEngine.EventProxy.OnCardControllerChanged_3_1_0_2((Card)obj, who, player); }
// Give to the parameter the same controller as this object internal void CopyControllersTo(ControllableObject other) { other.Controller = Controller; }
public void TakeFromReq(ControllableObject id, Player from) { MemoryStream stream = new MemoryStream(512); stream.Seek(4, SeekOrigin.Begin); BinaryWriter writer = new BinaryWriter(stream); if (Script.ScriptEngine.CurrentScript != null && Script.ScriptEngine.CurrentScript.muted) writer.Write(Script.ScriptEngine.CurrentScript.GetUniqueId()); else if (Program.Client.Muted != 0) writer.Write(Program.Client.Muted); else writer.Write(0); writer.Write((byte)66); writer.Write(id.Id); writer.Write(from.Id); writer.Flush(); writer.Seek(0, SeekOrigin.Begin); writer.Write((int)stream.Length); writer.Close(); Send(stream.ToArray()); }
public void TakeFromReq(ControllableObject id, Player from) { var sb = new StringBuilder(); XmlWriter writer = XmlWriter.Create(sb, XmlSettings); writer.WriteStartElement("TakeFromReq"); if (Program.Client.Muted != 0) writer.WriteAttributeString("muted", Program.Client.Muted.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("id", id.Id.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("from", from.Id.ToString(CultureInfo.InvariantCulture)); writer.WriteEndElement(); writer.Close(); Send(sb.ToString()); }