summaryrefslogtreecommitdiff
path: root/Analizator9000/Analizator9000/Contract.cs
blob: e6c49781390ac328969708d2d84529ee04bc0115 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Analizator9000
{
    /// <summary>
    /// Tuple describing contract parameters. Created only because .NET 3.5 doesn't have Tuple type yet.
    /// </summary>
    class Contract: IEquatable<Contract>
    {
        /// <summary>
        /// Level of the contract.
        /// </summary>
        public int Level;
        /// <summary>
        /// Trump denomination, in numeric format.
        /// </summary>
        /// <see cref="BCalcWrapper"/>
        public int Denomination;
        /// <summary>
        /// Modifiers - double or redouble.
        /// </summary>
        public int Modifiers;
        /// <summary>
        /// Declaring player, in numeric format.
        /// </summary>
        /// <see cref="BCalcWrapper"/>
        public int Declarer;
        
        /// <summary>
        /// Constructor for contract without full information (just general trick-taking in a denomination).
        /// </summary>
        /// <param name="denom">Trump denomination.</param>
        /// <param name="decl">Declaring player.</param>
        public Contract(int denom, int decl)
        {
            this.Denomination = denom;
            this.Declarer = decl;
        }

        /// <summary>
        /// Constructor with full contract information.
        /// </summary>
        /// <param name="level">Contract level.</param>
        /// <param name="denom">Trump denomination.</param>
        /// <param name="decl">Declaring player.</param>
        /// <param name="modifiers">Modifiers: 1 = X, 2 = XX</param>
        public Contract(int level, int denom, int decl, int modifiers = 0)
        {
            this.Level = level;
            this.Denomination = denom;
            this.Declarer = decl;
            this.Modifiers = modifiers;
        }

        /// <summary>
        /// IEquatable method for comparing (checking equality) of two tuples.
        /// </summary>
        /// <param name="other">Tuple to compare to.</param>
        /// <returns>TRUE if both tuple components are equal.</returns>
        public bool Equals(Contract other)
        {
            return this.Denomination == other.Denomination && this.Declarer == other.Declarer &&
                this.Level == other.Level && this.Modifiers == other.Modifiers;
        }
    }
}