Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="matchData"></param>
        /// <param name="laddermatch"></param>
        void Fight(BaseMatchData matchData, CrossladderMatchEntity laddermatch)
        {
            if (laddermatch.HomeIsBot && laddermatch.AwayIsBot)
            {
                laddermatch.HomeScore = 0;
                laddermatch.AwayScore = 0;
                laddermatch.Status    = (int)EnumLadderStatus.End;

                //保存比赛
                CrossladderMatchMgr.Insert(laddermatch);
                return;
            }
            else
            {
                try
                {
                    MatchCore.CreateMatch(matchData);

                    if (matchData.ErrorCode == (int)MessageCode.Success)
                    {
                        laddermatch.HomeScore = matchData.Home.Score;
                        laddermatch.AwayScore = matchData.Away.Score;
                        laddermatch.Status    = (int)EnumLadderStatus.End;
                        CalPrizePoint(laddermatch);

                        int returnCode = -1;
                        //保存比赛
                        CrossladderMatchMgr.SaveMatch(laddermatch.DomainId, laddermatch.LadderId, laddermatch.HomeId, laddermatch.AwayId, laddermatch.HomeName, laddermatch.AwayName,
                                                      laddermatch.HomeLogo, laddermatch.AwayLogo,
                                                      laddermatch.HomeSiteId, laddermatch.AwaySiteId,
                                                      laddermatch.HomeLadderScore, laddermatch.AwayLadderScore, laddermatch.HomeScore, laddermatch.AwayScore, laddermatch.HomeCoin, laddermatch.AwayCoin, laddermatch.HomeExp, laddermatch.AwayExp,
                                                      laddermatch.HomeIsBot, laddermatch.AwayIsBot, laddermatch.GroupIndex, laddermatch.PrizeHomeScore, laddermatch.PrizeAwayScore,
                                                      laddermatch.RowTime, laddermatch.Idx, ref returnCode);

                        if (!laddermatch.HomeIsBot)
                        {
                            WebServerHandler.AddManagerData(laddermatch.HomeId, laddermatch.HomeExp, laddermatch.HomeCoin, 0, laddermatch.HomeSiteId);
                            MatchCore.SaveMatchStat(laddermatch.HomeId, EnumMatchType.CrossLadder, laddermatch.HomeScore, laddermatch.AwayScore, laddermatch.HomeScore, laddermatch.HomeSiteId);
                            if (laddermatch.HomeIsHook)
                            {
                                CrossLadderManager.Instance.UpdateHookScore(laddermatch.HomeSiteId, laddermatch.HomeId, laddermatch.PrizeHomeScore,
                                                                            laddermatch.HomeScore > laddermatch.AwayScore, laddermatch.HomeScore,
                                                                            laddermatch.AwayScore, laddermatch.HomeName, laddermatch.AwayName,
                                                                            laddermatch.HomeCoin);
                            }
                        }
                        if (!laddermatch.AwayIsBot)
                        {
                            WebServerHandler.AddManagerData(laddermatch.AwayId, laddermatch.AwayExp, laddermatch.AwayCoin, 0, laddermatch.AwaySiteId);
                            MatchCore.SaveMatchStat(laddermatch.AwayId, EnumMatchType.CrossLadder, laddermatch.AwayScore, laddermatch.HomeScore, laddermatch.AwayScore, laddermatch.AwaySiteId);
                            if (laddermatch.AwayIsHook)
                            {
                                CrossLadderManager.Instance.UpdateHookScore(laddermatch.AwaySiteId, laddermatch.AwayId, laddermatch.PrizeAwayScore,
                                                                            laddermatch.AwayScore < laddermatch.HomeScore, laddermatch.HomeScore,
                                                                            laddermatch.AwayScore, laddermatch.HomeName, laddermatch.AwayName,
                                                                            laddermatch.AwayCoin);
                            }
                        }
                    }
                    MemcachedFactory.LadderMatchClient.Set(laddermatch.Idx, laddermatch);
                }
                catch (Exception ex)
                {
                    SystemlogMgr.Error("CrossLadderProcess-Fight", ex);
                }
            }
            matchData   = null;
            laddermatch = null;
        }