Ejemplo n.º 1
0
        public void SetTag(int x, int y, CodeTag tag, bool force = false)
        {
            BefungeCommand cmd = this[x, y];

            if (cmd.HasTag() && !force)
            {
                throw new InvalidCodeManipulationException("Tryed to remove existing Tag: " + cmd.Tag + " with: " + tag);
            }

            BefungeCommand newcmd = new BefungeCommand(cmd.Type, cmd.Param, tag);

            ForceSet(x, y, newcmd);
        }
Ejemplo n.º 2
0
        private void ForceSet(int x, int y, BefungeCommand value)         // Suppresses CodeModificationException
        {
            if (!IsIncluded(x, y))
            {
                Expand(x, y);
            }

            BefungeCommand prev = commandArr[x - MinX][y - MinY];

            if (prev.HasTag())
            {
                tagCache.Remove(prev.Tag);
            }

            commandArr[x - MinX][y - MinY] = value;

            if (value.HasTag())
            {
                tagCache.Add(value.Tag);
            }
        }
Ejemplo n.º 3
0
        private void Set(int x, int y, BefungeCommand value)
        {
            if (!IsIncluded(x, y))
            {
                Expand(x, y);
            }

            if (commandArr[x - MinX][y - MinY].Type != BefungeCommandType.NOP)
            {
                throw new InvalidCodeManipulationException("Modification of CodePiece : " + x + "|" + y);
            }

            if (HasTag(value.Tag))
            {
                throw new InvalidCodeManipulationException(string.Format("Duplicate Tag in CodePiece : [{0},{1}] = '{2}' = [{3},{4}])", x, y, value.Tag.ToString(), FindTag(value.Tag).X, FindTag(value.Tag).Y));
            }

            commandArr[x - MinX][y - MinY] = value;

            if (value.HasTag())
            {
                tagCache.Add(value.Tag);
            }
        }
Ejemplo n.º 4
0
 public bool EqualsTagLess(BefungeCommand c)
 {
     return(!HasTag() && !c.HasTag() && this.Type == c.Type && this.Param == c.Param);
 }