public void MarkerSetCount(int cardId, int count, string markerName, string markerId) { if (count < 0) { count = 0; } Card card = Card.Find(cardId); Guid guid = Guid.Parse(markerId); Marker marker = card.FindMarker(guid, markerName); int origCount = 0; /*if (card.Controller != Player.LocalPlayer) * Program.GameMess.Warning(String.Format("{0} Can't set markers on {1} because they don't control it.", Player.LocalPlayer.Name, card.Name)); */ // Will add in checks or controls to handle/allow this. -- DS QueueAction(() => { if (marker == null) { DataNew.Entities.Marker model = Program.GameEngine.GetMarkerModel(guid); DefaultMarkerModel defaultMarkerModel = model as DefaultMarkerModel; if (defaultMarkerModel != null) { (defaultMarkerModel).SetName(markerName); } //card.SetMarker(Player.LocalPlayer, guid, markerName, count); Program.Client.Rpc.AddMarkerReq(card, guid, markerName, (ushort)count, (ushort)origCount, true); card.AddMarker(model, (ushort)count); } else { origCount = marker.Count; if (origCount < count) { Program.Client.Rpc.AddMarkerReq(card, guid, markerName, (ushort)(count - origCount), (ushort)origCount, true); card.AddMarker(marker.Model, (ushort)(count - origCount)); } else if (origCount > count) { Program.Client.Rpc.RemoveMarkerReq(card, guid, markerName, (ushort)(origCount - count), (ushort)origCount, true); card.RemoveMarker(marker, (ushort)(origCount - count)); } } }); }
internal GameMarker GetMarkerModel(string id) { GameMarker model; // Try to find the marker model if (Definition.Markers.TryGetValue(id, out model)) { return(model.Clone() as GameMarker); } else { // Use a default marker model Program.GameMess.GameDebug("Marker model '{0}' not found, using default marker instead", id); DefaultMarkerModel defaultModel = Marker.DefaultMarkers.FirstOrDefault(x => x.Id == id) ?? Marker.DefaultMarkers[Crypto.Random(7)]; model = (DefaultMarkerModel)defaultModel.Clone(); model.Id = id; return(model); } }
public void AddMarker(Player player, Card card, Guid id, string name, ushort count) { DataNew.Entities.Marker model = Program.GameEngine.GetMarkerModel(id); DefaultMarkerModel defaultMarkerModel = model as DefaultMarkerModel; if (defaultMarkerModel != null) { (defaultMarkerModel).SetName(name); } // Ignore markers created by oneself (already created for responsiveness issues) if (player != Player.LocalPlayer) { card.AddMarker(model, count); } if (count != 0) { Program.Trace.TraceEvent(TraceEventType.Information, EventIds.Event | EventIds.PlayerFlag(player), "{0} adds {1} {2} marker(s) on {3}", player, count, model, card); } }
internal DataNew.Entities.Marker GetMarkerModel(Guid id) { DataNew.Entities.Marker model; if (id.CompareTo(new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10)) < 0) { // Get a standard model DefaultMarkerModel defaultModel = Marker.DefaultMarkers.First(x => x.Id == id); model = (DefaultMarkerModel)defaultModel.Clone(); model.Id = id; return(model); } // Try to find the marker model if (!_markersById.TryGetValue(id, out model)) { Program.GameMess.GameDebug("Marker model '{0}' not found, using default marker instead", id); DefaultMarkerModel defaultModel = Marker.DefaultMarkers[Crypto.Random(7)]; model = (DefaultMarkerModel)defaultModel.Clone(); model.Id = id; return(model); } return(model.Clone() as DataNew.Entities.Marker); }
internal MarkerModel GetMarkerModel(Guid id) { MarkerModel model; if (id.CompareTo(new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10)) < 0) { // Get a standard model DefaultMarkerModel defaultModel = Marker.DefaultMarkers.First(x => x.Id == id); model = defaultModel.Clone(); model.Id = id; return(model); } // Try to find the marker model if (!_markersById.TryGetValue(id, out model)) { Program.Trace.TraceEvent(TraceEventType.Verbose, EventIds.NonGame, "Marker model '{0}' not found, using default marker instead", id); DefaultMarkerModel defaultModel = Marker.DefaultMarkers[Crypto.Random(7)]; model = defaultModel.Clone(); model.Id = id; return(model); } return(model); }
public void AddMarker(Player player, Card card, Guid id, string name, ushort count, ushort oldCount, bool isScriptChange) { DataNew.Entities.Marker model = Program.GameEngine.GetMarkerModel(id); DefaultMarkerModel defaultMarkerModel = model as DefaultMarkerModel; if (defaultMarkerModel != null) { (defaultMarkerModel).SetName(name); } Marker marker = card.FindMarker(id, name); if (player != Player.LocalPlayer) { if (marker == null && oldCount != 0) { Program.GameMess.Warning("Inconsistent state. Cannot create a marker when that marker already exists."); return; } if (marker != null && oldCount != marker.Count) { Program.GameMess.Warning("Inconsistent state. Marker count invalid."); return; } card.AddMarker(model, count); } if (count != 0) { int newCount = oldCount + count; Program.GameMess.PlayerEvent(player, "adds {0} {1} marker(s) on {2}", count, model.Name, card); if (isScriptChange == false) { Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_0(card, model.ModelString(), oldCount, newCount, isScriptChange); Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_1(card, model.ModelString(), oldCount, newCount, isScriptChange); } } }