Esempio n. 1
0
        public static int CalcMedal(Models.User user, Session session, bool IsDraw, ServerCommon.PlayerResult player, bool is_character_rank_level_up, JGameModeData game_mode, ref int win_medal, ref int lose_medal, ref int draw_medal, ref int mvp_medal, ref int rankup_medal)
        {
            var    reason     = $"A_PLAY_{game_mode.LogName}";
            string sub_reason = "";

            int medal_count = 0;

            // 메달 수량 체크
            // 승패
            if (IsDraw)
            {
                medal_count += game_mode.RewardDrawMedal;
                sub_reason   = "3";
            }
            else if (player.IsWin)
            {
                medal_count += game_mode.RewardWinMedal;
                sub_reason   = "1";
            }
            else if (player.IsLose)
            {
                medal_count += game_mode.RewardLoseMedal;
                sub_reason   = "2";
            }

            // 메달 획득 허용치 체크 및 조정
            medal_count = GetAvailableMedalCount(user, session, medal_count);
            _           = LogProxy.writeResourceLog(session, "n", ((int)GameItemId.Medal).ToString(), medal_count, 0, user.medal + medal_count, "add", reason, sub_reason).ConfigureAwait(false);

            if (IsDraw)
            {
                draw_medal += medal_count;
            }
            else if (player.IsWin)
            {
                win_medal += medal_count;
            }
            else if (player.IsLose)
            {
                lose_medal += medal_count;
            }

            // MVP
            if (player.IsMvp)
            {
                medal_count += game_mode.RewardMVPMedal;
                mvp_medal   += game_mode.RewardMVPMedal;
                _            = LogProxy.writeResourceLog(session, "n", ((int)GameItemId.Medal).ToString(), game_mode.RewardMVPMedal, 0, user.medal + medal_count, "add", reason, "4").ConfigureAwait(false);
            }
            // 케릭터 랭크 레벨업
            if (is_character_rank_level_up)
            {
                medal_count  += game_mode.RewardRankupMedal;
                rankup_medal += game_mode.RewardRankupMedal;
                reason        = $"A_PLAY_RANKUP";
                _             = LogProxy.writeResourceLog(session, "n", ((int)GameItemId.Medal).ToString(), game_mode.RewardRankupMedal, 0, user.medal + medal_count, "add", reason, "").ConfigureAwait(false);
            }

            return(medal_count);
        }
Esempio n. 2
0
        protected override void EndGameServerside(Team winTeam, bool isDraw, long matchId, CloseType closeType)
        {
            try
            {
                ServerCommon.GameResult gameResult = new ServerCommon.GameResult();
                gameResult.player_result = new Dictionary <string, ServerCommon.PlayerResult>();

                gameResult.win_team                = (int)winTeam;
                gameResult.is_draw                 = isDraw;
                gameResult.match_id                = matchId;
                gameResult.statistics              = statistics;
                gameResult.statistics.map_id       = mMapData.ID;
                gameResult.statistics.leave_player = GetEntries().Where(x => x.Leave).Count();
                gameResult.statistics.clear        = closeType == CloseType.Clear ? 1 : 0;
                gameResult.statistics.play_time    = (int)(Timing.sInstance.GetFrameStartTime() - StartTime);
                gameResult.statistics.start_time   = StartEpochTime;
                gameResult.statistics.end_time     = DateTime.UtcNow.ToEpochTime();

                foreach (var player in GetEntries())
                {
                    var playerResult = new ServerCommon.PlayerResult();
                    playerResult.play_point = player.GetScore();
                    if (isDraw)
                    {
                        playerResult.battle_point = mGameModeData.RewardBattleScoreDraw;
                    }
                    else if (player.GetTeam() == winTeam)
                    {
                        playerResult.IsWin        = true;
                        playerResult.battle_point = mGameModeData.RewardBattleScoreWin;
                        player.Missions.Increment((int)MissionType.Mission_Victory, 1);
                    }
                    else
                    {
                        playerResult.IsLose       = true;
                        playerResult.battle_point = mGameModeData.RewardBattleScoreLose;
                    }

                    if (player.GetPlayerId() == MVPPlayerId)
                    {
                        playerResult.IsMvp         = true;
                        playerResult.battle_point += mGameModeData.RewardBattleScoreMvp;
                    }

                    if (player.Pause)
                    {
                        playerResult.battle_point = mGameModeData.AbuseBattleScore;
                    }
                    else
                    {
                        // 어뷰징이 아닌 유저만 나감 처리
                        playerResult.IsLeave = player.Leave;
                    }

                    playerResult.missions = player.Missions;

                    gameResult.player_result.Add(player.GetSessionId(), playerResult);
                }

                if (channel_id != "")
                {
#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_IOS || UNITY_ANDROID
#else
                    string key = $"game_result:{channel_id}";
                    Cache.sInstance.cache.GetSubscriber().PublishAsync(key, JsonConvert.SerializeObject(gameResult)).ConfigureAwait(false);
                    Log.Information($"PubGameRessult {key}");
#endif
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
        }