Exemple #1
0
 public static IMatch CreateMatch(MatchInput input)
 {
     using (var watch = new LogWatch())
     {
         return(CreateMatchCore(input, watch));
     }
 }
Exemple #2
0
 public static IMatch CreateMatchFromBin(byte[] rawInput)
 {
     using (var watch = new LogWatch())
     {
         var input = MatchFromBin(rawInput, watch);
         return(CreateMatchCore(input, watch));
     }
 }
Exemple #3
0
 public static byte[] CreateMatchBin(byte[] rawInput)
 {
     if (null == rawInput || rawInput.Length < 2)
     {
         return(ERRORBytes);
     }
     using (var watch = new LogWatch())
     {
         var input = MatchFromBin(rawInput, watch);
         var match = CreateMatchCore(input, watch);
         return(MatchToBin(match, watch));
     }
 }
Exemple #4
0
        static byte[] MatchToBin(IMatch match, LogWatch watch = null)
        {
            if (null == match)
            {
                return(ERRORBytes);
            }
            if (null == watch)
            {
                watch = new LogWatch(true);
            }
            var bytes = IOUtil.BinWrite(match.Report, ReportAsset.RPTVerNo);

            watch.LogCostTime(string.Format("Home:{0}[{1}] vs Away:{2}[{3}]. End)",
                                            match.Input.HomeManager.Mid, match.Input.HomeManager.Name,
                                            match.Input.AwayManager.Mid, match.Input.AwayManager.Name));
            return(bytes);
        }
Exemple #5
0
        static IMatch CreateMatchCore(MatchInput input, LogWatch watch = null)
        {
            if (null == watch)
            {
                watch = new LogWatch(true);
            }
            if (input.ForceType == EnumForceWinType.HomeWin)
            {
                input.HomeManager.BuffFact = 110;
                input.AwayManager.BuffFact = 90;
            }
            else if (input.ForceType == EnumForceWinType.AwayWin)
            {
                input.HomeManager.BuffFact = 90;
                input.AwayManager.BuffFact = 110;
            }
            int         loop = 0;
            const int   end  = 30;
            MatchEntity match;

            do
            {
                match = new MatchEntity(input);
                MainLoop(match);
                watch.LogCostTime(string.Format("Id:{0} Type:{1} Force:{2} Home:{3}[{4}] vs Away:{5}[{6}]. Result {7}:{8})",
                                                input.MatchId, input.MatchType, input.ForceType,
                                                match.Input.HomeManager.Mid, match.Input.HomeManager.Name,
                                                match.Input.AwayManager.Mid, match.Input.AwayManager.Name,
                                                match.HomeScore, match.AwayScore));
                if (input.ForceType == EnumForceWinType.None ||
                    input.ForceType == EnumForceWinType.HomeWin && match.HomeScore > match.AwayScore ||
                    input.ForceType == EnumForceWinType.NoDraw && match.HomeScore != match.AwayScore ||
                    input.ForceType == EnumForceWinType.AwayWin && match.HomeScore < match.AwayScore)
                {
                    break;
                }
                loop++;
                if (input.ForceType == EnumForceWinType.NoDraw && loop >= 3)
                {
                    input.HomeManager.BuffFact = 110;
                    input.AwayManager.BuffFact = 90;
                }
            }while (loop < end && input.ForceType != EnumForceWinType.None);
            return(match);
        }
Exemple #6
0
 public static byte[] CreateMatchToBin(MatchInput input)
 {
     if (null == input)
     {
         return(ERRORBytes);
     }
     try
     {
         using (var watch = new LogWatch())
         {
             var match = CreateMatchCore(input, watch);
             return(MatchToBin(match, watch));
         }
     }
     catch (Exception ex)
     {
         Log.LogHelper.Insert(ex);
         return(ERRORBytes);
     }
 }
Exemple #7
0
        static MatchInput MatchFromBin(byte[] rawInput, LogWatch watch = null)
        {
            if (null == watch)
            {
                watch = new LogWatch(true);
            }
            MatchInput input = null;

            using (var ms = new System.IO.MemoryStream(rawInput))
            {
                var bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                input = bf.Deserialize(ms) as MatchInput;
            }
            if (null == input)
            {
                return(null);
            }
            watch.LogCostTime(string.Format("Home:{0}[{1}] vs Away:{2}[{3}]. Start)",
                                            input.HomeManager.Mid, input.HomeManager.Name,
                                            input.AwayManager.Mid, input.AwayManager.Name));
            return(input);
        }