Exemplo n.º 1
0
        public bool AddFish(string iRodName, string iFishName, FishDBFishTypeKind iFishType, FishDBIdModel iID, string iZoneName, string iBaitName)
        {
            logger.Output(LogLevelKind.DEBUG, string.Format("{0} RodName={1} FishName={2} FishType={3} ID={4} ZoneName={5} BaitName={6}",
                MethodBase.GetCurrentMethod().Name, iRodName, iFishName, iFishType, iID, iZoneName, iBaitName));
            FishDBModel fishDB = getFishDB(iRodName);
            fishDB.Version = VERSION;
            fishDB.RodName = iRodName;

            //不明魚として登録されている場合、削除する
            for (int fishIdx = 0; fishIdx < fishDB.Fishes.Count; fishIdx++)
            {
                if (fishDB.Fishes[fishIdx].IDs.Contains(iID) &&
                    fishDB.Fishes[fishIdx].ZoneNames.Contains(iZoneName) &&
                    (fishDB.Fishes[fishIdx].FishType == FishDBFishTypeKind.UnknownSmallFish ||
                     fishDB.Fishes[fishIdx].FishType == FishDBFishTypeKind.UnknownLargeFish ||
                     fishDB.Fishes[fishIdx].FishType == FishDBFishTypeKind.UnknownItem ||
                     fishDB.Fishes[fishIdx].FishType == FishDBFishTypeKind.UnknownMonster ||
                     fishDB.Fishes[fishIdx].FishType == FishDBFishTypeKind.Unknown))
                {
                    fishDB.Fishes[fishIdx].ZoneNames.Remove(iZoneName);
                    //エリア情報が無くなっった場合、魚情報を削除する
                    if (fishDB.Fishes[fishIdx].ZoneNames.Count == 0)
                    {
                        fishDB.Fishes.RemoveAt(fishIdx);
                    }
                    break;
                }

            }

            //更新処理
            bool foundFlg = false;
            for (int fishIdx = 0; fishIdx < fishDB.Fishes.Count; fishIdx++)
            {
                if (fishDB.Fishes[fishIdx].FishName == iFishName)
                {
                    foundFlg = true;
                    fishDB.Fishes[fishIdx].FishName = iFishName;
                    fishDB.Fishes[fishIdx].FishType = iFishType;
                    if (!fishDB.Fishes[fishIdx].IDs.Contains(iID)) fishDB.Fishes[fishIdx].IDs.Add(iID);
                    if (!fishDB.Fishes[fishIdx].ZoneNames.Contains(iZoneName)) fishDB.Fishes[fishIdx].ZoneNames.Add(iZoneName);
                    if (!fishDB.Fishes[fishIdx].BaitNames.Contains(iBaitName)) fishDB.Fishes[fishIdx].BaitNames.Add(iBaitName);
                }
            }
            //新規追加処理
            if (!foundFlg)
            {
                FishDBFishModel fish = new FishDBFishModel();
                fish.FishName = iFishName;
                fish.FishType = iFishType;
                fish.IDs.Add(iID);
                fish.ZoneNames.Add(iZoneName);
                fish.BaitNames.Add(iBaitName);
                fishDB.Fishes.Add(fish);
            }
            //ソート
            fishDB.Fishes.Sort(FishDBFishModel.SortTypeName);
            for (int i = 0; i < fishDB.Fishes.Count; i++)
            {
                fishDB.Fishes[i].IDs.Sort(FishDBIdModel.SortCountCritical);
            }
            //Rod.xmlへ出力する
            if (!putFishDB(iRodName, fishDB)) return false;
            return true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// xmlファイルをコンバートする(1.0.0→1.0.5)
        /// </summary>
        private void convert1_0_0to1_0_5(string iXmlFileName, string iRodName)
        {
            FishDBModel1_0_0 fishdb1_0_0 = getFishDB1_0_0(iRodName);
            FishDBModel fishdb1_0_5 = new FishDBModel();
            fishdb1_0_5.Version = "1.0.5";
            fishdb1_0_5.RodName = fishdb1_0_0.RodName;
            foreach (FishDBFishModel1_0_0 fish1_0_0 in fishdb1_0_0.Fishes)
            {
                FishDBFishModel fish1_0_5 = new FishDBFishModel();
                //FishDBFishTypeKind.Monster→FishDBFishTypeKind.UnknownMonster
                if (fish1_0_0.FishType == FishDBFishTypeKind.Monster)
                {
                    fish1_0_0.FishType = FishDBFishTypeKind.UnknownMonster;
                }
                fish1_0_5.FishType = fish1_0_0.FishType;
                //FishName
                if (fish1_0_0.FishType == FishDBFishTypeKind.UnknownSmallFish ||
                    fish1_0_0.FishType == FishDBFishTypeKind.UnknownLargeFish ||
                    fish1_0_0.FishType == FishDBFishTypeKind.UnknownItem ||
                    fish1_0_0.FishType == FishDBFishTypeKind.UnknownMonster ||
                    fish1_0_0.FishType == FishDBFishTypeKind.Unknown)
                {
                    if (fish1_0_0.IDs.Count > 0)
                    {
                        fish1_0_5.FishName = FishDB.GetTmpFishNameFromFishType(fish1_0_0.FishType, fish1_0_0.IDs[0].ID1, fish1_0_0.IDs[0].ID2, fish1_0_0.IDs[0].ID3, fish1_0_0.IDs[0].ID4);
                    }
                    else
                    {
                        fish1_0_5.FishName = fish1_0_0.FishName;
                    }
                }
                else
                {
                    fish1_0_5.FishName = fish1_0_0.FishName;
                }
                //ID
                foreach (FishDBIdModel1_0_0 id1_0_0 in fish1_0_0.IDs)
                {
                    FishDBIdModel id1_0_5 = new FishDBIdModel();
                    id1_0_5.ID1 = id1_0_0.ID1;
                    id1_0_5.ID2 = id1_0_0.ID2;
                    id1_0_5.ID3 = id1_0_0.ID3;
                    id1_0_5.ID4 = id1_0_0.ID4;
                    id1_0_5.Count = id1_0_0.Count;
                    id1_0_5.Critical = id1_0_0.Critical;
                    id1_0_5.ItemType = FishDBItemTypeKind.Common;
                    fish1_0_5.IDs.Add(id1_0_5);
                }
                //エリア 初期化する
                fish1_0_5.ZoneNames = new List<string>();
                //エサ
                fish1_0_5.BaitNames = fish1_0_0.BaitNames;

                fishdb1_0_5.Fishes.Add(fish1_0_5);
            }

            //バックアップ
            string backupFileName = iXmlFileName + ".bak";
            if (File.Exists(backupFileName)) File.Delete(backupFileName);
            File.Copy(iXmlFileName, backupFileName);
            //xml書き込み
            putFishDB(iRodName, fishdb1_0_5);
        }
Exemplo n.º 3
0
        /// <summary>
        /// FishDB・FishHistoryDBへの登録処理
        /// </summary>
        /// <param name="iFish">FishHistoryDBFishModel</param>
        /// <returns></returns>
        private bool putDatabase(FishHistoryDBFishModel iFish)
        {
            //FishDBに登録
            if (iFish.ID1 != 0 && iFish.ID2 != 0 && iFish.ID3 != 0 && iFish.ID4 != 0)
            {
                //FishTypeの設定
                if (!isTmpFishFromName(iFish.FishName))
                {
                    if (iFish.FishType == FishDBFishTypeKind.UnknownSmallFish) iFish.FishType = FishDBFishTypeKind.SmallFish;
                    if (iFish.FishType == FishDBFishTypeKind.UnknownLargeFish) iFish.FishType = FishDBFishTypeKind.LargeFish;
                    if (iFish.FishType == FishDBFishTypeKind.UnknownItem) iFish.FishType = FishDBFishTypeKind.Item;
                }
                FishDBIdModel id = new FishDBIdModel(iFish.ID1, iFish.ID2, iFish.ID3, iFish.ID4, iFish.FishCount, iFish.Critical, iFish.ItemType);
                if (!FishDB.AddFish(iFish.RodName, iFish.FishName, iFish.FishType, id, iFish.ZoneName, iFish.BaitName))
                {
                    setMessage("FishDBデータベースへの登録に失敗");
                    return false;
                }

            }
            //FishHistoryDBに登録
            if (!fishHistoryDB.AddFish(this.PlayerName, this.TimeElapsed, iFish))
            {
                setMessage("FishHistoryDBデータベースへの登録に失敗");
                return false;
            }
            //釣れた魚を登録
            if(iFish.Result== FishResultStatusKind.Catch &&
               (iFish.FishType == FishDBFishTypeKind.SmallFish || iFish.FishType == FishDBFishTypeKind.LargeFish)){
                   settings.CaughtFishesUpdate(iFish.FishName, true);
                   EventCaughtFishesUpdate(iFish.FishName);
            }
            return true;
        }