Ejemplo n.º 1
0
        public static bool UseGoods(Session session, Models.User user, int item_id, int item_count, LogReason reason)
        {
            var game_item_data = ACDC.GameItemData[item_id];

            if (game_item_data == null || game_item_data == default(JGameItemData))
            {
                Log.Error($"cannot find item:{item_id}, user_name:{session.user_name}");
                return(false);
            }

            if (user[item_id] < item_count)
            {
                return(false);
            }

            user[item_id] -= item_count;

            user.IsDirty = true;
            //History.Info(session.member_no, session.user_no, session.character_no, HistoryLogAction.UseItem, (byte)reason, (int)item_id, (int)item_count, "", "");

            if (reason != null)
            {
                _ = LogProxy.writeResourceLog(session, reason.paid, item_id.ToString(), -1 * item_count, 0, user[item_id], "sub", reason.reason, reason.sub_reason).ConfigureAwait(false);
            }

            return(true);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public static async Task <bool> Insert(Session session, Models.User user, Models.Character character, int item_id, int item_count, LogReason reason, GameService.ItemList item = null, string sParam1 = "", string sParam2 = "")
        {
            var game_item_data = ACDC.GameItemData[item_id];

            if (game_item_data == null || game_item_data == default(JGameItemData))
            {
                Log.Error($"cannot find item:{item_id}, user_name:{session.user_name}");
                return(false);
            }

            switch ((GameItemType)game_item_data.Item_Type)
            {
            case GameItemType.Goods:
            {
                user[item_id] += item_count;

                user.IsDirty = true;

                if (item != null)
                {
                    item.Items.Add(new GameService.ItemInfo()
                        {
                            ItemId = item_id, ItemCount = item_count
                        });
                }
            }
            break;

            case GameItemType.Medal_Charging:
            {
                user.medal_charge      = (int)MedalChargeConst.MaxCharge;
                user.medal_charge_time = DateTime.UtcNow;

                user.IsDirty = true;

                if (item != null)
                {
                    item.Items.Add(new GameService.ItemInfo()
                        {
                            ItemId = item_id, ItemCount = item_count
                        });
                }
            }
            break;

            case GameItemType.Character:
            {
                if (await CharacterManager.InsertCharacter(session.member_no, session.user_no, session.user_name, session.player_id, game_item_data.LinkId) == null)
                {
                    return(false);
                }

                if (item != null)
                {
                    item.Items.Add(new GameService.ItemInfo()
                        {
                            ItemId = item_id, ItemCount = item_count
                        });
                }

                _ = LogProxy.writeActionLog(session, "캐릭터", "획득", game_item_data.LinkId.ToString()).ConfigureAwait(false);
            }
            break;

            case GameItemType.CharacterPiece:
            {
                if (await CharacterManager.AddCharacterPiece(session, character, game_item_data.LinkId, item_count) == false)
                {
                    return(false);
                }

                if (item != null)
                {
                    item.Items.Add(new GameService.ItemInfo()
                        {
                            ItemId = item_id, ItemCount = item_count
                        });
                }

                _ = LogProxy.writeActionLog(session, "캐릭터", "조각획득", game_item_data.LinkId.ToString()).ConfigureAwait(false);
            }
            break;

            case GameItemType.Gacha:
            {
                if (await GachaBox.Progress(session, user, character, game_item_data, item, reason) == false)
                {
                    return(false);
                }
            }
            break;

            default:
                return(false);
            }

            await MissionManager.OnTrigger(session, MissionUserAction.GetItem, item_id, item_count);

            //History.Info(session.member_no, session.user_no, session.character_no, HistoryLogAction.GainItem, (byte)reason, (int)item_id, (int)item_count, sParam1, sParam2);

            if (reason != null)
            {
                if ((GameItemType)game_item_data.Item_Type == GameItemType.Goods)
                {
                    _ = LogProxy.writeResourceLog(session, reason.paid, item_id.ToString(), item_count, 0, user[item_id], "add", reason.reason, reason.sub_reason).ConfigureAwait(false);
                }
                else
                {
                    _ = LogProxy.writeItemLog(session, game_item_data.Item_Type.ToString(), item_id.ToString(), "y", "", item_count, "", 0, 0, "add", reason.reason, reason.sub_reason, "").ConfigureAwait(false);
                }
            }

            return(true);
        }