RemoveMarker() private method

private RemoveMarker ( Octgn.Play.Marker marker, ushort count ) : int
marker Octgn.Play.Marker
count ushort
return int
Example #1
0
 internal void SetCount(ushort value)
 {
     if (value == 0)
     {
         _card.RemoveMarker(this);
     }
     else if (value != _count)
     {
         _count = value;
         OnPropertyChanged("Count");
         OnPropertyChanged("Description");
     }
 }
Example #2
0
        public void RemoveMarker(Player player, Card card, string id, string name, ushort count, ushort oldCount, bool isScriptChange)
        {
            WriteReplayAction(player.Id);
            var marker = card.FindMarker(id, name);

            if (!IsLocalPlayer(player))
            {
                if (marker == null)
                {
                    Program.GameMess.Warning("Inconsistent state. Marker not found on card.");
                    return;
                }
                if (marker.Count != oldCount)
                {
                    Program.GameMess.Warning("Inconsistent state. Missing markers to remove");
                }
            }
            if (count != 0)
            {
                var newCount = oldCount - count;
                if (!IsLocalPlayer(player))
                {
                    card.RemoveMarker(marker, count);
                }
                Program.GameMess.PlayerEvent(player, "removes {0} {1} marker(s) from {2}", count, name, card);
                if (IsLocalPlayer(player) && marker == null)
                {
                    var markerString = new StringBuilder();
                    markerString.AppendFormat("('{0}','{1}')", name, id);
                    if (isScriptChange == false)
                    {
                        Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_0(card, markerString.ToString(), oldCount, newCount, isScriptChange);
                        Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_1(card, markerString.ToString(), oldCount, newCount, isScriptChange);
                    }
                    Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_2(card, name, id.ToString(), oldCount, isScriptChange);
                }
                else
                {
                    if (isScriptChange == false)
                    {
                        Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_0(card, marker.Model.ModelString(), oldCount, newCount, isScriptChange);
                        Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_1(card, marker.Model.ModelString(), oldCount, newCount, isScriptChange);
                    }
                    Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_2(card, name, id.ToString(), oldCount, isScriptChange);
                }
            }
        }
Example #3
0
        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);
                    model.Name = markerName;
                    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));
                    }
                }
            });
        }
Example #4
0
        public void TransferMarker(Player player, Card from, Card to, Guid id, string name, ushort count, ushort oldCount, bool isScriptChange)
        {
            var marker = from.FindMarker(id, name);

            if (player == null)
            {
                Program.GameMess.Warning("Inconsistent state. Cannot transfer marker to unknown player.");
                return;
            }
            if (player != Player.LocalPlayer)
            {
                if (marker == null)
                {
                    Program.GameMess.Warning("Inconsistent state. Marker not found on card.");
                    return;
                }
                if (marker.Count != oldCount)
                {
                    Program.GameMess.Warning("Inconsistent state. Missing markers to remove");
                }
            }
            var newMarker  = to.FindMarker(id, name);
            var toOldCount = 0;

            if (newMarker != null)
            {
                toOldCount = newMarker.Count - 1;
            }
            var fromNewCount = oldCount - count;
            var toNewCount   = toOldCount + count;

            if (player != Player.LocalPlayer)
            {
                from.RemoveMarker(marker, count);
                to.AddMarker(marker.Model, count);
            }
            Program.GameMess.PlayerEvent(player, "moves {0} {1} marker(s) from {2} to {3}", count, name, from, to);
            if (marker == null)
            {
                marker = from.FindRemovedMarker(id, name);
            }
            if (marker != null)
            {
                if (isScriptChange == false)
                {
                    Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_0(
                        from,
                        marker.Model.ModelString(),
                        oldCount,
                        fromNewCount,
                        isScriptChange);
                    Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_0(
                        to,
                        marker.Model.ModelString(),
                        toOldCount,
                        toNewCount,
                        isScriptChange);
                    Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_1(
                        from,
                        marker.Model.ModelString(),
                        oldCount,
                        fromNewCount,
                        isScriptChange);
                    Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_1(
                        to,
                        marker.Model.ModelString(),
                        toOldCount,
                        toNewCount,
                        isScriptChange);
                }
                Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_2(
                    from,
                    marker.Model.Name,
                    marker.Model.Id.ToString(),
                    oldCount,
                    isScriptChange);
                Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_2(
                    to,
                    marker.Model.Name,
                    marker.Model.Id.ToString(),
                    toOldCount,
                    isScriptChange);
            }
        }
Example #5
0
        public void TransferMarker(Player player, Card from, Card to, Guid id, string name, ushort count)
        {
            // Ignore markers moved by oneself (already moved for responsiveness issues)
            if (player != Player.LocalPlayer)
            {
                Marker marker = from.FindMarker(id, name);
                if (marker == null)
                {
                    Program.Trace.TraceEvent(TraceEventType.Warning, EventIds.NonGame, "Inconsistent state. Marker not found on card.");
                    return;
                }
                if (marker.Count < count)
                    Program.Trace.TraceEvent(TraceEventType.Warning, EventIds.NonGame, "Inconsistent state. Missing markers to remove");

                from.RemoveMarker(marker, count);
                to.AddMarker(marker.Model, count);
            }
            Program.Trace.TraceEvent(TraceEventType.Information, EventIds.Event | EventIds.PlayerFlag(player), "{0} moves {1} {2} marker(s) from {3} to {4}", player, count, name, from, to);
        }
Example #6
0
 public void TransferMarker(Player player, Card from, Card to, Guid id, string name, ushort count, ushort oldCount, bool isScriptChange)
 {
     Marker marker = from.FindMarker(id, name);
     if (player == null)
     {
         Program.GameMess.Warning("Inconsistent state. Cannot transfer marker to unknown player.");
         return;
     }
     if (player != Player.LocalPlayer)
     {
         if (marker == null)
         {
             Program.GameMess.Warning("Inconsistent state. Marker not found on card.");
             return;
         }
         if (marker.Count != oldCount)
             Program.GameMess.Warning("Inconsistent state. Missing markers to remove");
     }
     Marker newMarker = to.FindMarker(id, name);
     int toOldCount = 0;
     if (newMarker != null)
         toOldCount = newMarker.Count - 1;
     int fromNewCount = oldCount - count;
     int toNewCount = toOldCount + count;
     if (player != Player.LocalPlayer)
     {
         from.RemoveMarker(marker, count);
         to.AddMarker(marker.Model, count);
     }
     Program.GameMess.PlayerEvent(player, "moves {0} {1} marker(s) from {2} to {3}", count, name, from, to);
     if (marker == null)
     {
         marker = from.FindRemovedMarker(id, name);
     }
     if (marker != null)
     {
         if (isScriptChange == false)
         {
             Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_0(
                 from,
                 marker.Model.ModelString(),
                 oldCount,
                 fromNewCount,
                 isScriptChange);
             Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_0(
                 to,
                 marker.Model.ModelString(),
                 toOldCount,
                 toNewCount,
                 isScriptChange);
             Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_1(
                 from,
                 marker.Model.ModelString(),
                 oldCount,
                 fromNewCount,
                 isScriptChange);
             Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_1(
                 to,
                 marker.Model.ModelString(),
                 toOldCount,
                 toNewCount,
                 isScriptChange);
         }
         Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_2(
             from,
             marker.Model.Name,
             marker.Model.Id.ToString(),
             oldCount,
             isScriptChange);
         Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_2(
             to,
             marker.Model.Name,
             marker.Model.Id.ToString(),
             toOldCount,
             isScriptChange);
     }
 }
Example #7
0
        public void RemoveMarker(Player player, Card card, Guid id, string name, ushort count, ushort oldCount, bool isScriptChange)
        {
            Marker marker = card.FindMarker(id, name);
            if (player != Player.LocalPlayer)
            {
                if (marker == null)
                {
                    Program.GameMess.Warning("Inconsistent state. Marker not found on card.");
                    return;
                }
                if (marker.Count != oldCount)
                    Program.GameMess.Warning("Inconsistent state. Missing markers to remove");
            }
            if (count != 0)
            {
                int newCount = oldCount - count;
                if (player != Player.LocalPlayer)
                {
                    card.RemoveMarker(marker, count);
                }
                Program.GameMess.PlayerEvent(player, "removes {0} {1} marker(s) from {2}", count, name, card);
                if (player == Player.LocalPlayer && marker == null)
                {
                    StringBuilder markerString = new StringBuilder();
                    markerString.AppendFormat("('{0}','{1}')", name, id);
                    if (isScriptChange == false)
                    {
                        Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_0(card, markerString.ToString(), oldCount, newCount, isScriptChange);
                        Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_1(card, markerString.ToString(), oldCount, newCount, isScriptChange);
                    }
                    Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_2(card, name, id.ToString(), oldCount, isScriptChange);
                }
                else
                {
                    if (isScriptChange == false)
                    {
                        Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_0(card, marker.Model.ModelString(), oldCount, newCount, isScriptChange);
                        Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_1(card, marker.Model.ModelString(), oldCount, newCount, isScriptChange);
                    }
                    Program.GameEngine.EventProxy.OnMarkerChanged_3_1_0_2(card, name, id.ToString(), oldCount, isScriptChange);
                }

            }

        }