Пример #1
0
 public static int SortTypeName(FishDBFishModel1_0_0 iFish1, FishDBFishModel iFish2)
 {
     //1番目のキー:FishTypeでソート
     if (iFish1.FishType > iFish2.FishType)
     {
         return(1);
     }
     else if (iFish1.FishType < iFish2.FishType)
     {
         return(-1);
     }
     else
     {
         //2番目のキー:FishNameでソート
         return(string.Compare(iFish1.FishName, iFish2.FishName));
     }
 }
Пример #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);
        }
Пример #3
0
        public bool AddFish(string iRodName, string iFishName, FishDBFishTypeKind iFishType, FishDBIdModel iID, string iZoneName, string iBaitName)
        {
            logger.Trace("RodName={0} Fish={1} Type={2} ID={3} Zone={4} Bait={5}", 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))
                    {
                        logger.Info("IDの追加 竿={0} 魚={1} ID={2}", iRodName, iFishName, iID);
                        fishDB.Fishes[fishIdx].IDs.Add(iID);
                    }
                    if (!fishDB.Fishes[fishIdx].ZoneNames.Contains(iZoneName))
                    {
                        logger.Info("エリアの追加 竿={0} 魚={1} エリア={2}", iRodName, iFishName, iZoneName);
                        fishDB.Fishes[fishIdx].ZoneNames.Add(iZoneName);
                    }
                    if (!fishDB.Fishes[fishIdx].BaitNames.Contains(iBaitName))
                    {
                        logger.Info("エサの追加 竿={0} 魚={1} エサ={2}", iRodName, iFishName, iBaitName);
                        fishDB.Fishes[fishIdx].BaitNames.Add(iBaitName);
                    }
                }
            }
            //新規追加処理
            if (!foundFlg)
            {
                logger.Info("魚の追加 竿={0} 魚={1} 魚タイプ={2} ID={3} エリア={4} エサ={5}", iRodName, iFishName, iFishType, iID, iZoneName, iBaitName);
                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);
        }