Exemplo n.º 1
0
        // Create set attribute move
        internal static MovePartModel CreateSetAttribute(PlayerValue player, PositionValue position, PieceValue piece,
                                                         IdentValue ident, TypedValue value)
        {
            var mpm = Create(MoveKinds.Attrib, player, position, piece);

            mpm.Attribute = ident;
            mpm.Value     = value;
            return(mpm);
        }
Exemplo n.º 2
0
 internal void SetMoveFlag(IdentValue name, bool isset)
 {
     if (isset)
     {
         _move_flag_set.Add(name);
     }
     else
     {
         _move_flag_set.Remove(name);
     }
 }
Exemplo n.º 3
0
 internal void SetPositionFlag(IdentValue name, PositionValue position, bool isset)
 {
     if (isset)
     {
         _position_flag_set.Add(Pair.Create(position, name));
     }
     else
     {
         _position_flag_set.Remove(Pair.Create(position, name));
     }
 }
Exemplo n.º 4
0
        static internal long GetHash(IdentValue name)
        {
            long hash;

            if (_hashlookup.TryGetValue(name.Value, out hash))
            {
                return(hash);
            }
            hash = _rng.Next();
            hash = (hash << 32) | (long)_rng.Next();
            _hashlookup[name.Value] = hash;
            return(hash);
        }
Exemplo n.º 5
0
        // typed getters
        internal bool GetBoolProperty(string name)
        {
            var ret = GetProperty(IdentValue.Create(name));

            if (ret == null)
            {
                return(false);
            }
            if (ret.DataType == DataTypes.Bool)
            {
                return(ret == BoolValue.True);
            }
            if (ret.DataType == DataTypes.Text)
            {
                return(ret.AsString.ToLower() == "true");
            }
            if (ret.DataType == DataTypes.Number)
            {
                return((ret as NumberValue).Value != 0);
            }
            return(false);
        }
Exemplo n.º 6
0
 internal bool GetMoveFlag(IdentValue name)
 {
     return(_move_flag_set.Contains(name));
 }
Exemplo n.º 7
0
 internal TypedValue GetProperty(string name)
 {
     return(GetProperty(IdentValue.Create(name)));
 }
Exemplo n.º 8
0
 BoolValue s_PositionFlag_(IdentValue flag, PositionOrDirection posordir = null)
 {
     return(BoolValue.Create(_state.GetPositionFlag(flag, ToPosition(posordir))));
 }
Exemplo n.º 9
0
 // conditions codes
 BoolValue s_Flag_(IdentValue flag)
 {
     return(BoolValue.Create(_state.GetMoveFlag(flag)));
 }
Exemplo n.º 10
0
        internal int GetIntProperty(string name)
        {
            var ret = GetProperty(IdentValue.Create(name));

            return((ret == null) ? 0 : (int)(ret as NumberValue).Value);
        }
Exemplo n.º 11
0
        internal string GetStringProperty(string name)
        {
            var ret = GetProperty(IdentValue.Create(name));

            return((ret == null) ? null : ret.AsString);
        }
Exemplo n.º 12
0
 internal bool IsAttributeSet(IdentValue attribute, PositionValue position)
 {
     return(IsPlayed(position) && _playedpieces[position].IsSet(attribute));
 }
Exemplo n.º 13
0
 void s_SetFlag(IdentValue name, BoolValue value)
 {
     _state.SetMoveFlag(name, value.Value);
 }
Exemplo n.º 14
0
 internal bool GetPositionFlag(IdentValue name, PositionValue position)
 {
     return(_position_flag_set.Contains(Pair.Create(position, name)));
 }
Exemplo n.º 15
0
 internal void SetProperty(IdentValue ident, TypedValue value)
 {
     PropertyLookup[ident] = value;
 }
Exemplo n.º 16
0
 internal void SetProperty(string name, TypedValue value)
 {
     PropertyLookup[IdentValue.Create(name)] = value;
 }
Exemplo n.º 17
0
 BoolValue s_NotFlag_(IdentValue flag)
 {
     return(s_Not(s_Flag_(flag)));
 }
Exemplo n.º 18
0
 BoolValue s_NotPositionFlag_(IdentValue flag, PositionOrDirection posordir = null)
 {
     return(s_Not(s_PositionFlag_(flag, posordir)));
 }
Exemplo n.º 19
0
 internal void AddSetAttribute(IdentValue ident, BoolValue value)
 {
     _changes.Add(MovePartModel.CreateSetAttribute(Player, Position, Piece, ident, value));
 }
Exemplo n.º 20
0
        internal TypedValue GetProperty(IdentValue name)
        {
            var value = PropertyLookup.SafeLookup(name);

            return(value);
        }
Exemplo n.º 21
0
 internal bool IsSet(IdentValue attribute)
 {
     return(AttributeLookup.SafeLookup(attribute) == BoolValue.True);
 }
Exemplo n.º 22
0
 void s_SetPositionFlag(IdentValue ident, BoolValue value, PositionOrDirection posordir = null)
 {
     _state.SetPositionFlag(ident, ToPositionSafe(posordir), value.Value);
 }