public override string Verify(string data, string fallback) { Debug.Log($"Verifying {data}"); int value; if (int.TryParse(data, out value)) { if (value > 0) { return(MahjongLogic.ToNextUnit(value, 100).ToString()); } } return(fallback); }
public PointInfo(int fu, IList <YakuValue> yakuValues, bool 青天井, int dora, int uraDora, int redDora, int beiDora) { Fu = fu; Yakus = yakuValues.ToArray(); Fan = 0; IsQTJ = 青天井; Dora = dora; UraDora = uraDora; RedDora = redDora; BeiDora = beiDora; Doras = Dora + UraDora + RedDora + BeiDora; IsYakuman = false; if (青天井) { foreach (var yaku in yakuValues) { Fan += yaku.Type == YakuType.Yakuman ? yaku.Value * MahjongConstants.YakumanBaseFan : yaku.Value; if (yaku.Type == YakuType.Yakuman) { IsYakuman = true; } } } else { foreach (var yaku in yakuValues) { Fan += yaku.Value; if (yaku.Type == YakuType.Yakuman) { IsYakuman = true; } } } FanWithoutDora = yakuValues.Sum(y => y.Type == YakuType.Yakuman ? y.Value * MahjongConstants.YakumanBaseFan : y.Value); if (yakuValues.Count == 0) { BasePoint = 0; TotalFan = 0; return; } if (青天井) { TotalFan = Fan + Doras; int point = Fu * (int)Math.Pow(2, TotalFan + 2); BasePoint = MahjongLogic.ToNextUnit(point, 100); } else if (IsYakuman) { BasePoint = Fan * MahjongConstants.Yakuman; TotalFan = Fan; } else { TotalFan = Fan + Doras; if (TotalFan >= 13) { BasePoint = MahjongConstants.Yakuman; } else if (TotalFan >= 11) { BasePoint = MahjongConstants.Sanbaiman; } else if (TotalFan >= 8) { BasePoint = MahjongConstants.Baiman; } else if (TotalFan >= 6) { BasePoint = MahjongConstants.Haneman; } else if (TotalFan >= 5) { BasePoint = MahjongConstants.Mangan; } else { int point = Fu * (int)Math.Pow(2, TotalFan + 2); point = MahjongLogic.ToNextUnit(point, 100); BasePoint = Math.Min(MahjongConstants.Mangan, point); } } Array.Sort(Yakus); }