/// <summary> /// 等価判定を行う /// </summary> /// <param name="obj">比較対象</param> /// <returns>オブジェクトの内容が等しいかどうか</returns> public override bool Equals(object obj) { if (obj == null || this.GetType() != obj.GetType()) { return(false); } OjamaPairPuyo ojama = (OjamaPairPuyo)obj; if (OjamaRow != ojama.OjamaRow) { return(false); } if (ojamaBit.Count != ojama.ojamaBit.Count) { return(false); } for (int i = 0; i < OjamaBit.Length; i++) { if (ojamaBit[i] != ojama.OjamaBit[i]) { return(false); } } return(true); }
/// <summary> /// Fコード値を譜情報に変換する /// </summary> /// <param name="stepValues">Fコード値リスト</param> /// <returns>譜情報</returns> private List <PairPuyo> ConvertValuesToSteps(List <int> stepValues) { List <PairPuyo> steps = new List <PairPuyo>(); foreach (int value in stepValues) { int v1 = value >> 9; if (v1 == 7) { // お邪魔ぷよ OjamaPairPuyo ojama = new OjamaPairPuyo(); ojama.OjamaRow = (value >> 6) & 0x7; ojama.OjamaBit = DecimalToBinary(value & 0x3f); steps.Add(ojama); } else { // 色ぷよ ColorPairPuyo pp = new ColorPairPuyo(); int v2 = value & 0x3f; int p2 = v2 % 5; int p1 = (v2 - p2) / 5; pp.Pivot = PUYO_TYPE_CONV[p1]; pp.Satellite = PUYO_TYPE_CONV[p2]; pp.Dir = DIR_CONV[((value >> 7) & 0x3)]; pp.Pos = v1; steps.Add(pp); } } return(steps); }
public void 指定列のお邪魔数が正しく計算されること() { OjamaPairPuyo pp = new OjamaPairPuyo(); pp.OjamaRow = 3; BitArray ojamaBit = pp.OjamaBit; ojamaBit[0] = true; ojamaBit[5] = false; pp.OjamaBit = ojamaBit; Assert.AreEqual(4, pp.OjamaAt(0)); Assert.AreEqual(3, pp.OjamaAt(4)); }
public void お邪魔ぷよと判定されること() { OjamaPairPuyo pp = new OjamaPairPuyo(); Assert.IsTrue(pp.IsOjama); }