public FishHistoryDBSummaryFishModel(FishHistoryDBFishModel iFish) { this.FishName = iFish.FishName; this.FishType = iFish.FishType; this.Count = 1; this.Percent = 0; this.TotalPercent = 0; }
/// <summary> /// 魚を履歴に追加 /// </summary> /// <param name="iPlayername">プレイヤー名</param> /// <param name="iFish">FishHistoryDBFishModel</param> /// <returns>True:成功</returns> public bool AddFish(string iPlayername, int iTimeElapsed, FishHistoryDBFishModel iFish) { FishHistoryDBModel historydb = GetHistoryDB(iPlayername, DateTime.Parse(iFish.EarthTime)); historydb.Version = VERSION; historydb.PlayerName = iPlayername; historydb.EarthDate = DateTime.Parse(iFish.EarthTime).ToShortDateString(); historydb.Uploaded = false; historydb.TimeElapsed = iTimeElapsed; historydb.Fishes.Add(iFish); return PutHistoryDB(iPlayername, historydb); }
/// <summary> /// 魚を履歴に追加 /// </summary> /// <param name="iPlayername">プレイヤー名</param> /// <param name="iFish">FishHistoryDBFishModel</param> /// <returns>True:成功</returns> public bool AddFish(string iPlayername, int iTimeElapsed, FishHistoryDBFishModel iFish) { FishHistoryDBModel historydb = GetHistoryDB(iPlayername, DateTime.Parse(iFish.EarthTime)); historydb.Version = VERSION; historydb.PlayerName = iPlayername; historydb.EarthDate = DateTime.Parse(iFish.EarthTime).ToShortDateString(); historydb.Uploaded = false; historydb.TimeElapsed = iTimeElapsed; historydb.Fishes.Add(iFish); return(PutHistoryDB(iPlayername, historydb)); }
public void Add(FishHistoryDBFishModel iFish) { this.Count += 1; foreach (FishHistoryDBSummaryResultModel v in this.Results) { if (v.Result == iFish.Result) { v.Add(iFish); } } foreach (FishHistoryDBSummaryResultModel result in this.Results) { if (this.Count != 0) { result.TotalPercent = (int)Math.Round(((double)result.Count / (double)this.Count) * 100d); } else { result.TotalPercent = 0; } foreach (FishHistoryDBSummaryFishModel fish in result.Fishes) { if (result.Count != 0) { fish.Percent = (int)Math.Round(((double)fish.Count / (double)result.Count) * 100d); } else { result.Percent = 0; } if (this.Count != 0) { fish.TotalPercent = (int)Math.Round(((double)fish.Count / (double)this.Count) * 100d); } else { result.TotalPercent = 0; } } } }
public void Add(FishHistoryDBFishModel iFish) { this.Count += 1; bool foundFlg = false; foreach (FishHistoryDBSummaryFishModel fish in this.Fishes) { if (fish.FishName == iFish.FishName) { foundFlg = true; fish.Add(iFish); break; } } if (!foundFlg) { FishHistoryDBSummaryFishModel fish = new FishHistoryDBSummaryFishModel(iFish); fish.FishName = iFish.FishName; fish.FishType = iFish.FishType; this.Fishes.Add(fish); } this.Fishes.Sort(FishHistoryDBSummaryFishModel.SortTypeName); }
public void Add(FishHistoryDBFishModel iFish) { this.Count += 1; foreach (FishHistoryDBSummaryResultModel v in this.Results) { if (v.Result == iFish.Result) { v.Add(iFish); } } foreach (FishHistoryDBSummaryResultModel result in this.Results) { if (this.Count != 0) result.TotalPercent = (int)Math.Round(((double)result.Count / (double)this.Count) * 100d); else result.TotalPercent = 0; foreach (FishHistoryDBSummaryFishModel fish in result.Fishes) { if (result.Count != 0) fish.Percent = (int)Math.Round(((double)fish.Count / (double)result.Count) * 100d); else result.Percent = 0; if (this.Count != 0) fish.TotalPercent = (int)Math.Round(((double)fish.Count / (double)this.Count) * 100d); else result.TotalPercent = 0; } } }
public void Add(FishHistoryDBFishModel iFish) { this.Count += 1; }
/// <summary> /// xmlファイルをコンバートする(1.0.5→1.1.0) /// </summary> /// <returns></returns> private void convert1_0_5to1_1_0(string iXmlFileName, string iPlayerName, DateTime iYmd) { FishHistoryDBModel1_0_5 history1_0_5 = GetHistoryDB1_0_5(iPlayerName, iYmd); FishHistoryDBModel history1_1_0 = new FishHistoryDBModel(); history1_1_0.Version = "1.1.0"; history1_1_0.PlayerName = history1_0_5.PlayerName; history1_1_0.EarthDate = history1_0_5.EarthDate; history1_1_0.Uploaded = false; history1_1_0.TimeElapsed = history1_0_5.TimeElapsed; foreach (FishHistoryDBFishModel1_0_5 fish1_0_5 in history1_0_5.Fishes) { FishHistoryDBFishModel fish1_1_0 = new FishHistoryDBFishModel(); fish1_1_0.FishName = fish1_0_5.FishName; fish1_1_0.ZoneName = fish1_0_5.ZoneName; fish1_1_0.RodName = fish1_0_5.RodName; fish1_1_0.BaitName = fish1_0_5.BaitName; fish1_1_0.ID1 = fish1_0_5.ID1; fish1_1_0.ID2 = fish1_0_5.ID2; fish1_1_0.ID3 = fish1_0_5.ID3; fish1_1_0.ID4 = fish1_0_5.ID4; fish1_1_0.Critical = fish1_0_5.Critical; fish1_1_0.FishCount = fish1_0_5.FishCount; fish1_1_0.ItemType = fish1_0_5.ItemType; fish1_1_0.FishType = fish1_0_5.FishType; fish1_1_0.Result = fish1_0_5.Result; fish1_1_0.EarthTime = fish1_0_5.EarthTime; fish1_1_0.VanaTime = fish1_0_5.VanaTime; fish1_1_0.VanaWeekDay = fish1_0_5.VanaWeekDay; fish1_1_0.MoonPhase = fish1_0_5.MoonPhase; fish1_1_0.X = fish1_0_5.X; fish1_1_0.Y = fish1_0_5.Y; fish1_1_0.Z = fish1_0_5.Z; fish1_1_0.H = fish1_0_5.H; fish1_1_0.Skill = fish1_0_5.Skill; fish1_1_0.SerpentRumors = fish1_0_5.SerpentRumors; fish1_1_0.AnglersAlmanac = fish1_0_5.AnglersAlmanac; fish1_1_0.FrogFishing = fish1_0_5.FrogFishing; fish1_1_0.Mooching = fish1_0_5.Mooching; history1_1_0.Fishes.Add(fish1_1_0); } foreach (FishHistoryDBHarakiriModel1_0_5 harakiri1_0_5 in history1_0_5.Harakiri) { FishHistoryDBHarakiriModel harakiri1_1_0 = new FishHistoryDBHarakiriModel(); harakiri1_1_0.EarthTime = harakiri1_0_5.EarthTime; harakiri1_1_0.VanaTime = harakiri1_0_5.VanaTime; harakiri1_1_0.FishName = harakiri1_0_5.FishName; harakiri1_1_0.ItemName = harakiri1_0_5.ItemName; history1_1_0.Harakiri.Add(harakiri1_1_0); } //バックアップ string backupFileName = iXmlFileName + ".bak"; if (File.Exists(backupFileName)) File.Delete(backupFileName); File.Copy(iXmlFileName, backupFileName); //xml書き込み PutHistoryDB(iPlayerName, history1_1_0); }
/// <summary> /// メインスレッド /// </summary> private void threadFishing() { bool firstTime = true; interrupt = new FishingInterrupt(false, false, false, false, false); noCatchCount = 0; lastRodName = string.Empty; lastBaitName = string.Empty; lastZoneName = string.Empty; chat.CurrentIndex = chat.MaxIndex; setFishingStatus(FishingStatusKind.Normal); FishHistoryDBFishModel fish = new FishHistoryDBFishModel(); logger.Output(LogLevelKind.DEBUG, "釣りスレッド開始"); setMessage("開始しました"); //メニュー開いていたら閉じる if (!control.CloseDialog()) { setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Error); setMessage("メニューが閉じられない"); return; } //着替え setEquipGear(); //魚リスト更新 EventFished(FishResultStatusKind.Unknown); //釣りメインループ while (this.RunningStatus == RunningStatusKind.Running) { //日付が変わったら経過時間クリア if (DateTime.Now.Date != lastCastDate.Date) { fishHistoryDB = new FishHistoryDB(this.PlayerName, this.EarthDateTime, logger); FishHistoryDBModel history = fishHistoryDB.SelectDayly(this.PlayerName, this.EarthDateTime); this.TimeElapsed = history.TimeElapsed; } lastCastDate = DateTime.Now.Date; //チャット処理 FFACE.ChatTools.ChatLine cl = new FFACE.ChatTools.ChatLine(); while (chat.GetNextChatLine(out cl)) { List<string> chatKbnArgs = new List<string>(); ChatKbnKind chatKbn = getChatKbnFromChatline(cl, out chatKbnArgs); logger.Output(LogLevelKind.DEBUG, string.Format("Chat:{0} ChatKbn:{1}", cl.Text, chatKbn)); } //敵からの攻撃感知 if (this.RunningStatus != RunningStatusKind.Running) break; if (interrupt.EnemyAttack) { setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Error); setMessage("敵から攻撃されたので停止"); //コマンド実行 if (settings.Fishing.EnemyAttackCmd) { fface.Windower.SendString(settings.Fishing.EnemyAttackCmdLine); } break; } //チャット感知 if (this.RunningStatus != RunningStatusKind.Running) break; if (interrupt.ChatReceive) { if (settings.Fishing.ChatRestart) { setFishingStatus(FishingStatusKind.Wait); double waitSec = (double)(settings.Fishing.ChatRestartMinute * 60); DateTime restartTime = DateTime.Now.AddMinutes(settings.Fishing.ChatRestartMinute); setMessage(string.Format("チャット感知:再始動待ち {0}(地球時間)まで待機", restartTime.ToString("HH:mm:ss"))); wait(waitSec, waitSec); //チャットバッファをクリア FFACE.ChatTools.ChatLine waitCl = new FFACE.ChatTools.ChatLine(); while (chat.GetNextChatLine(out waitCl)) { Thread.Sleep(10); } //チャット受信フラグクリア interrupt.ChatReceive = false; setFishingStatus(FishingStatusKind.Normal); } else { setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Normal); setMessage("チャットを感知したので停止"); break; } } //入港警告感知 if (this.RunningStatus != RunningStatusKind.Running) break; if (settings.Fishing.EntryPort) { if (interrupt.ShipWarning) { setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Normal); setMessage("入港するので停止"); break; } } //エミネンスクリア if (this.RunningStatus != RunningStatusKind.Running) break; if (settings.Fishing.EminenceClear) { if (interrupt.ClearEminence) { setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Normal); setMessage("エミネンスをクリアしたので停止"); break; } } //エリア切り替わり感知 if (this.RunningStatus != RunningStatusKind.Running) break; if (this.lastZoneName.Length > 0 && this.lastZoneName != this.ZoneName) { setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Error); setMessage("エリアが切り替わったので停止"); break; } //釣果数 if (this.RunningStatus != RunningStatusKind.Running) break; if (settings.Fishing.MaxCatch) { if (this.fishHistoryDB.CatchCount >= settings.Fishing.MaxCatchCount) { setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Normal); setMessage("本日の釣果数が規定値になったので停止"); break; } } //釣果無し if (this.RunningStatus != RunningStatusKind.Running) break; if (settings.Fishing.MaxNoCatch) { if (noCatchCount >= settings.Fishing.MaxNoCatchCount) { setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Normal); setMessage("連続釣果無しが規定値になったので停止"); break; } } //釣りスキル if (this.RunningStatus != RunningStatusKind.Running) break; if (settings.Fishing.MaxSkill) { if (this.FishingSkill >= settings.Fishing.MaxSkillValue) { setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Normal); setMessage("釣りスキルが規定値になったので停止"); break; } } //スニーク if (this.RunningStatus != RunningStatusKind.Running) break; if (settings.Fishing.SneakFishing && settings.UseCancel) { if (interrupt.SneakWarning || !control.IsBuff(StatusEffect.Sneak)) { setMessage("スニークをかけます"); castSneak(); interrupt.SneakWarning = false; } } //鞄1 if (this.RunningStatus != RunningStatusKind.Running) break; if (this.InventoryCount >= this.InventoryMax) { if (!putFish()) { if (settings.Fishing.InventoryFullCmd) { fface.Windower.SendString(settings.Fishing.InventoryFullCmdLine); } setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Normal); setMessage("鞄がいっぱいなので停止"); break; } } //竿 if (this.RunningStatus != RunningStatusKind.Running) break; if (this.RodName == string.Empty) { if (!string.IsNullOrEmpty(lastRodName) && !control.IsExistItem(lastRodName, FFACETools.InventoryType.Inventory) && !control.IsExistItem(lastRodName, FFACETools.InventoryType.Wardrobe)) { //予備の竿を鞄へ移動 if (!getRodBaitItem(lastRodName)) { //竿の修理 if (settings.Fishing.RepairRod && settings.UseItemizer) { if (!repairRod(lastRodName)) { setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Error); break; } Thread.Sleep(2000); } } } if (!setRod(lastRodName)) { setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Error); setMessage("釣り竿を装備していないので停止"); //コマンド実行 if (settings.Fishing.NoBaitNoRodCmd) { fface.Windower.SendString(settings.Fishing.NoBaitNoRodCmdLine); } break; } } //エサ if (this.RunningStatus != RunningStatusKind.Running) break; if (this.BaitName == string.Empty) { if (!string.IsNullOrEmpty(lastBaitName) && !control.IsExistItem(lastBaitName, FFACETools.InventoryType.Inventory) && !control.IsExistItem(lastBaitName, FFACETools.InventoryType.Wardrobe)) { getRodBaitItem(lastBaitName); } if (!setBait(lastBaitName)) { setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Error); setMessage("エサを装備していないので停止"); //コマンド実行 if (settings.Fishing.NoBaitNoRodCmd) { fface.Windower.SendString(settings.Fishing.NoBaitNoRodCmdLine); } break; } } //鞄2 if (this.RunningStatus != RunningStatusKind.Running) break; if (this.InventoryCount >= this.InventoryMax) { if (!putFish()) { if (settings.Fishing.InventoryFullCmd) { fface.Windower.SendString(settings.Fishing.InventoryFullCmdLine); } setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Normal); setMessage("鞄がいっぱいなので停止"); break; } } //エンチャントアイテム使用 if (this.RunningStatus != RunningStatusKind.Running) break; if (!useEnchantedItem()) { setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Error); setMessage("エンチャントアイテムが使用できなかったので停止"); break; } //食事 if (this.RunningStatus != RunningStatusKind.Running) break; if (!useFood()) { setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Error); setMessage("食事アイテムが使用できなかったので停止"); break; } //ヴァナ時間 if (this.RunningStatus != RunningStatusKind.Running) break; while (settings.Fishing.VanaTime && this.RunningStatus == RunningStatusKind.Running && !isHourInRange(this.VanaDateTime, settings.Fishing.VanaTimeFrom, settings.Fishing.VanaTimeTo)) { setFishingStatus(FishingStatusKind.Wait); setMessage(string.Format("{0}時(ヴァナ時間)になるまで待機中", settings.Fishing.VanaTimeFrom)); Thread.Sleep(settings.Global.WaitBase); } setFishingStatus(FishingStatusKind.Normal); //地球時間 if (this.RunningStatus != RunningStatusKind.Running) break; while (settings.Fishing.EarthTime && this.RunningStatus == RunningStatusKind.Running && !isHourInRange(this.EarthDateTime, settings.Fishing.EarthTimeFrom, settings.Fishing.EarthTimeTo)) { setFishingStatus(FishingStatusKind.Wait); setMessage(string.Format("{0}時(地球時間)になるまで待機中", settings.Fishing.EarthTimeFrom)); Thread.Sleep(settings.Global.WaitBase); } setFishingStatus(FishingStatusKind.Normal); //リキャスト時間待機(初回は判定しない) if (!firstTime && settings.Fishing.RecastTime) { wait(settings.Fishing.RecastTimeMin, settings.Fishing.RecastTimeMax, "リキャスト待機中:{0:0.0}s"); } //メニュー開いていたら閉じる if (this.RunningStatus != RunningStatusKind.Running) break; if (!control.CloseDialog()) { setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Error); setMessage("メニューが閉じられない"); break; } //魚を釣る if (this.RunningStatus != RunningStatusKind.Running) break; if (!FishingOnce(out fish)) { //エラー発生時処理 setRunningStatus(RunningStatusKind.Stop); setFishingStatus(FishingStatusKind.Error); break; } firstTime = false; Thread.Sleep(settings.Global.WaitBase); } logger.Output(LogLevelKind.DEBUG, "釣りスレッド終了"); }
/// <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; }
/// <summary> /// 魚を1回釣る /// </summary> /// <param name="oFish"></param> /// <param name="oMessage"></param> /// <returns></returns> private bool FishingOnce(out FishHistoryDBFishModel oFish) { //戻り値初期化 oFish = new FishHistoryDBFishModel(); oFish.FishName = string.Empty; oFish.FishCount = 0; oFish.ZoneName = this.ZoneName; oFish.RodName = this.RodName; oFish.BaitName = this.BaitName; oFish.ID1 = 0; oFish.ID2 = 0; oFish.ID3 = 0; oFish.ID4 = 0; oFish.Critical = false; oFish.ItemType = FishDBItemTypeKind.Unknown; oFish.FishType = FishDBFishTypeKind.Unknown; oFish.Result = FishResultStatusKind.NoBite; oFish.EarthTime = this.EarthDateTime.ToString("yyyy/MM/dd HH:mm:ss"); oFish.VanaTime = this.VanaDateTimeYmdhms; oFish.VanaWeekDay = this.DayType; oFish.MoonPhase = this.MoonPhase; oFish.X = (float)Math.Round(this.Position.X, 1, MidpointRounding.AwayFromZero); oFish.Y = (float)Math.Round(this.Position.Y, 1, MidpointRounding.AwayFromZero); oFish.Z = (float)Math.Round(this.Position.Z, 1, MidpointRounding.AwayFromZero); oFish.H = (float)Math.Round(this.Position.H, 1, MidpointRounding.AwayFromZero); oFish.Skill = this.FishingSkill; oFish.SerpentRumors = this.HasSerpentRumors; oFish.AnglersAlmanac = this.HasAnglersAlmanac; oFish.Mooching = this.HasMooching; oFish.FrogFishing = this.HasFrogFishing; bool fishedFlg = false; setFishingStatus(FishingStatusKind.Normal); setMessage(string.Format("キャスト中:{0}x{1}", this.RodNameWithRemain, this.BaitNameWithRemain)); //キャスト while (this.RunningStatus == RunningStatusKind.Running && fface.Player.Status != FFACETools.Status.Fishing) { fface.Windower.SendString("/fish"); Thread.Sleep(2000);//wait FFACE.ChatTools.ChatLine cl = new FFACE.ChatTools.ChatLine(); while (chat.GetNextChatLine(out cl)) { //チャット区分の取得 List<string> chatKbnArgs = new List<string>(); ChatKbnKind chatKbn = getChatKbnFromChatline(cl, out chatKbnArgs); logger.Output(LogLevelKind.DEBUG, string.Format("Chat:{0} ChatKbn:{1}", cl.Text, chatKbn)); //エラーチェック if (chatKbn == ChatKbnKind.CanNotFishing) { setFishingStatus(FishingStatusKind.Error); setMessage("釣りができない場所だったので停止"); return false; } else if (chatKbn == ChatKbnKind.NotEquipRod) { setFishingStatus(FishingStatusKind.Error); setMessage("竿を装備していないので停止"); return false; } else if (chatKbn == ChatKbnKind.NotEquipBait) { setFishingStatus(FishingStatusKind.Error); setMessage("エサを装備していないので停止"); return false; } else if (lastZoneName.Length > 0 && lastZoneName != this.ZoneName)//エリア切り替わり感知 { setFishingStatus(FishingStatusKind.Error); setMessage("エリアが切り替わったので停止"); return false; } else if (interrupt.ChatReceive) //チャット感知 { while (this.PlayerStatus != FFACETools.Status.Standing) { fface.Windower.SendKeyPress(FFACETools.KeyCode.EscapeKey); Thread.Sleep(settings.Global.WaitBase); } return true; } else if (interrupt.EnemyAttack) //敵の攻撃感知 { return true; } } } this.lastRodName = this.RodName; this.lastBaitName = this.BaitName; this.lastZoneName = this.ZoneName; while (this.RunningStatus == RunningStatusKind.Running) { FFACETools.FFACE.ChatTools.ChatLine cl = new FFACE.ChatTools.ChatLine(); //エリア切り替わり感知 if (lastZoneName.Length > 0 && lastZoneName != this.ZoneName) { setFishingStatus(FishingStatusKind.Error); setMessage("エリアが切り替わったので停止"); return false; } while (chat.GetNextChatLine(out cl)) { //チャット区分の取得 List<string> chatKbnArgs = new List<string>(); ChatKbnKind chatKbn = getChatKbnFromChatline(cl, out chatKbnArgs); logger.Output(LogLevelKind.DEBUG, string.Format("Chat:{0} ChatKbn:{1}", cl.Text, chatKbn)); if (chatKbn == ChatKbnKind.BaitSmallFish || chatKbn == ChatKbnKind.BaitLargeFish || chatKbn == ChatKbnKind.BaitItem || chatKbn == ChatKbnKind.BaitMonster)//魚がかかった { //プレイヤステータスがFishBiteになるまで待つ while (this.PlayerStatus != FFACETools.Status.FishBite) { Thread.Sleep(settings.Global.WaitBase); } Thread.Sleep(500); //IDの設定 oFish.ID1 = fface.Fish.ID.ID1; oFish.ID2 = fface.Fish.ID.ID2; oFish.ID3 = fface.Fish.ID.ID3; oFish.ID4 = fface.Fish.ID.ID4; //魚名称・タイプの設定 FishDBFishModel fish = FishDB.SelectFishFromIDZone(oFish.RodName, oFish.ID1, oFish.ID2, oFish.ID3, oFish.ID4, oFish.ZoneName, false); if (!string.IsNullOrEmpty(fish.FishName)) { oFish.FishName = fish.FishName; oFish.FishType = fish.FishType; oFish.FishCount = fish.GetId(oFish.ID1, oFish.ID2, oFish.ID3, oFish.ID4).Count; oFish.Critical = fish.GetId(oFish.ID1, oFish.ID2, oFish.ID3, oFish.ID4).Critical; oFish.ItemType = fish.GetId(oFish.ID1, oFish.ID2, oFish.ID3, oFish.ID4).ItemType; } else { oFish.FishType = getTmpFishTypeFromChat(cl.Text); oFish.FishName = FishDB.GetTmpFishNameFromFishType(oFish.FishType, oFish.ID1, oFish.ID2, oFish.ID3, oFish.ID4); } setMessage(string.Format("格闘中:{0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType))); logger.Output(LogLevelKind.INFO, string.Format("魚ID:{0:000}-{1:000}-{2:000}-{3:000} 魚タイプ:{4} アイテムタイプ:{5}", oFish.ID1, oFish.ID2, oFish.ID3, oFish.ID4, oFish.FishType, oFish.ItemType)); //日時の設定 oFish.EarthTime = this.EarthDateTime.ToString("yyyy/MM/dd HH:mm:ss"); oFish.VanaTime = this.VanaDateTimeYmdhms; oFish.VanaWeekDay = this.DayType; oFish.MoonPhase = this.MoonPhase; //HP0の設定 int waitHP0 = MiscTool.GetRandomNumber(settings.Fishing.HP0Min, settings.Fishing.HP0Max); //反応時間待機 if (settings.Fishing.ReactionTime && !settings.Fishing.WaitTimeout) { wait(settings.Fishing.ReactionTimeMin, settings.Fishing.ReactionTimeMax, "反応待機中:{0:0.0}s " + GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType)); } else { //HP0になった瞬間釣り上げると、HP残ったように表示されてしまうので、ウェイトを入れる Thread.Sleep(settings.Global.WaitChat); //wait } //リリース判定 if (!isWantedFish(oFish.RodName, oFish.ID1, oFish.ID2, oFish.ID3, oFish.ID4, oFish.ZoneName, oFish.FishType)) { //リリースする logger.Output(LogLevelKind.DEBUG, string.Format("リリースする {0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType))); while (this.PlayerStatus == FFACETools.Status.FishBite) { fface.Windower.SendKeyPress(FFACETools.KeyCode.EscapeKey); Thread.Sleep(settings.Global.WaitBase); } continue; } setMessage(string.Format("格闘中:{0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType))); //釣り格闘 while (fface.Fish.HPCurrent > 0 && fface.Player.Status == FFACETools.Status.FishBite) { //強制HP0 if (settings.Fishing.HP0) { if (isExecHp0(DateTime.Parse(oFish.EarthTime), waitHP0)) { logger.Output(LogLevelKind.INFO,"制限時間を過ぎたので、魚のHPを強制的にゼロにします"); fface.Fish.SetHP(0); Thread.Sleep(1000); } } //格闘 fface.Fish.FightFish(); Thread.Sleep(settings.Global.WaitBase); } //HP0になった瞬間に釣り上げるとFFの画面上ではHPが残ったままになるのでウェイト Thread.Sleep(500); //チャット処理 //while(chat.GetNextChatLine(out cl)) //{ // ChatKbnKind fightingChatKbn = getChatKbnFromChatline(cl, out chatKbnArgs, ref oChatReceive, ref oEnemyAttack, ref oSneakWarning, ref oShipWarning); // logger.Output(LogLevelKind.DEBUG, string.Format("Chat:{0} ChatKbn:{1}", cl.Text, fightingChatKbn)); // if (fightingChatKbn == ChatKbnKind.BaitCritical)//クリティカル // { // oFish.Critical = true; // } //} //時間切れのログが表示されるまで待機 if (settings.Fishing.WaitTimeout) { logger.Output(LogLevelKind.DEBUG, "時間切れ待機中"); setMessage(string.Format("時間切れ待機中:{0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType))); int startIndex = chat.CurrentIndex; bool timeUpOkFlg = false; for (int i = 0; i < 1200; i++)//2分間チャットを監視 { if (timeUpOkFlg) break; //釣りが中止された場合、待機処理を中止する if (this.PlayerStatus != FFACETools.Status.FishBite) break; //チャット監視 var cl2 = chat.GetChatLine(startIndex, false); foreach (var c in cl2) { List<string> chatKbnTimeoutArgs = new List<string>(); ChatKbnKind chatKbnTimeout = getChatKbnFromChatline(c, out chatKbnTimeoutArgs); //logger.Output(LogLevelKind.DEBUG, string.Format("Chat:{0} ChatKbn:{1}", c.Text, chatKbn)); if (chatKbnTimeout == ChatKbnKind.Timeout || chatKbnTimeout == ChatKbnKind.NoCatch) { //反応時間待機 if (settings.Fishing.ReactionTime) { float reactionTimeFrom = (settings.Fishing.ReactionTimeMin <= 4.0f) ? settings.Fishing.ReactionTimeMin : 4.0f; float reactionTimeTo = (settings.Fishing.ReactionTimeMax <= 4.0f) ? settings.Fishing.ReactionTimeMax : 4.0f; wait(reactionTimeFrom, reactionTimeTo, "反応待機中:{0:0.0}s " + GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType)); } timeUpOkFlg = true; break; } else if ( chatKbnTimeout == ChatKbnKind.CatchSingle || //{0}は(.*)を手にいれた!" chatKbnTimeout == ChatKbnKind.CatchMultiple ||//{0}は(.*)を([0-9]*)尾手にいれた!" chatKbnTimeout == ChatKbnKind.CatchMonster || //{0}はモンスターを釣り上げた!" chatKbnTimeout == ChatKbnKind.CatchKeyItem || //だいじなもの:(.*)を手にいれた!" chatKbnTimeout == ChatKbnKind.CatchTempItem ||//テンポラリアイテム:(.*)を手にいれた!" chatKbnTimeout == ChatKbnKind.LineBreak || //釣り糸が切れてしまった。" chatKbnTimeout == ChatKbnKind.RodBreak || //釣り竿が折れてしまった。" chatKbnTimeout == ChatKbnKind.Timeout || //そろそろ逃げられそうだ……!" chatKbnTimeout == ChatKbnKind.InventoryFull ||//{0}は見事に(.*)を釣り上げたが、これ以上持てないので、仕方なくリリースした。" chatKbnTimeout == ChatKbnKind.NoBait || //何も釣れなかった。" chatKbnTimeout == ChatKbnKind.Release || //あきらめて仕掛けをたぐり寄せた。" chatKbnTimeout == ChatKbnKind.NoCatch) //獲物に逃げられてしまった。" { timeUpOkFlg = true; break; } } Thread.Sleep(100);//wait } } //釣り上げる //プレイヤステータスがFishBite以外になるまで待つ while (this.PlayerStatus == FFACETools.Status.FishBite) { fishedFlg = true; fface.Windower.SendKeyPress(FFACETools.KeyCode.EnterKey); Thread.Sleep(settings.Global.WaitBase); } } else if (chatKbn == ChatKbnKind.CatchSingle)//釣れた { if (!fishedFlg) continue;//釣り上げていない場合は登録しない oFish.FishName = chatKbnArgs[0]; oFish.FishCount = 1; oFish.ItemType = FishDBItemTypeKind.Common; oFish.Result = FishResultStatusKind.Catch; //データベースへの登録 if (!putDatabase(oFish)) return false; //連続釣果無しカウントクリア noCatchCount = 0; setMessage(string.Format("釣果:{0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType))); //イベント発生 EventFished(oFish.Result); //プレイヤステータスがStandingになるまで待つ waitChangePlayerStatus(FFACETools.Status.Standing); return true; } else if (chatKbn == ChatKbnKind.CatchMultiple)//複数釣れた { if (!fishedFlg) continue;//釣り上げていない場合は登録しない oFish.FishName = chatKbnArgs[0]; oFish.FishCount = int.Parse(chatKbnArgs[1]); oFish.ItemType = FishDBItemTypeKind.Common; oFish.Result = FishResultStatusKind.Catch; //データベースへの登録 if (!putDatabase(oFish)) return false; //連続釣果無しカウントクリア noCatchCount = 0; setMessage(string.Format("釣果:{0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType))); //イベント発生 EventFished(oFish.Result); //プレイヤステータスがStandingになるまで待つ waitChangePlayerStatus(FFACETools.Status.Standing); return true; } else if (chatKbn == ChatKbnKind.CatchMonster)//モンスター釣れた { //oFish.FishName = chatKbnArgs[0]; oFish.FishCount = 1; oFish.Result = FishResultStatusKind.Catch; //データベースへの登録 if (!putDatabase(oFish)) return false; //連続釣果無しカウントクリア noCatchCount = 0; setMessage(string.Format("釣果:{0}", oFish.FishName)); //イベント発生 EventFished(oFish.Result); //プレイヤステータスがStandingになるまで待つ waitChangePlayerStatus(FFACETools.Status.Standing); return true; } else if (chatKbn == ChatKbnKind.CatchTempItem)//テンポラリアイテム釣れた { if (!fishedFlg) continue;//釣り上げていない場合は登録しない oFish.FishName = chatKbnArgs[0]; oFish.FishCount = 1; oFish.ItemType = FishDBItemTypeKind.Temporary; oFish.Result = FishResultStatusKind.Catch; //データベースへの登録 if (!putDatabase(oFish)) return false; //連続釣果無しカウントクリア noCatchCount = 0; setMessage(string.Format("釣果:{0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType))); //イベント発生 EventFished(oFish.Result); //プレイヤステータスがStandingになるまで待つ waitChangePlayerStatus(FFACETools.Status.Standing); return true; } else if (chatKbn == ChatKbnKind.CatchKeyItem)//だいじなもの釣れた { if (!fishedFlg) continue;//釣り上げていない場合は登録しない oFish.FishName = chatKbnArgs[0]; oFish.FishCount = 1; oFish.ItemType = FishDBItemTypeKind.Key; oFish.Result = FishResultStatusKind.Catch; //データベースへの登録 if (!putDatabase(oFish)) return false; //連続釣果無しカウントクリア noCatchCount = 0; setMessage(string.Format("釣果:{0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType))); //イベント発生 EventFished(oFish.Result); //プレイヤステータスがStandingになるまで待つ waitChangePlayerStatus(FFACETools.Status.Standing); return true; } else if (chatKbn == ChatKbnKind.InventoryFull)//鞄いっぱい { oFish.FishName = chatKbnArgs[0]; oFish.FishCount = 1; oFish.Result = FishResultStatusKind.Release; //データベースへの登録 if (!putDatabase(oFish)) return false; //連続釣果無しカウントクリア noCatchCount = 0; setMessage(string.Format("釣果:鞄いっぱいでリリース {0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType))); //イベント発生 EventFished(oFish.Result); //プレイヤステータスがStandingになるまで待つ waitChangePlayerStatus(FFACETools.Status.Standing); return true; } else if (chatKbn == ChatKbnKind.NoBait)//何も釣れなかった { oFish.Result = FishResultStatusKind.NoBite; //データベースへの登録 if (!putDatabase(oFish)) return false; //連続釣果無しカウントアップ noCatchCount++; setMessage(string.Format("釣果:何も釣れなかった {0}連続", noCatchCount)); //イベント発生 EventFished(oFish.Result); //プレイヤステータスがStandingになるまで待つ waitChangePlayerStatus(FFACETools.Status.Standing); return true; } else if (chatKbn == ChatKbnKind.Release)//リリース { oFish.Result = FishResultStatusKind.Release; //データベースへの登録 if (!putDatabase(oFish)) return false; //連続釣果無しカウントクリア noCatchCount = 0; setMessage(string.Format("釣果:リリース {0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType))); //イベント発生 EventFished(oFish.Result); //プレイヤステータスがStandingになるまで待つ waitChangePlayerStatus(FFACETools.Status.Standing); return true; } else if (chatKbn == ChatKbnKind.NoCatch)//逃げられた { oFish.Result = FishResultStatusKind.NoCatch; //データベースへの登録 if (!putDatabase(oFish)) return false; //連続釣果無しカウントクリア noCatchCount = 0; setMessage(string.Format("釣果:逃げられた {0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType))); //イベント発生 EventFished(oFish.Result); //プレイヤステータスがStandingになるまで待つ waitChangePlayerStatus(FFACETools.Status.Standing); return true; } else if (chatKbn == ChatKbnKind.LineBreak)//糸切れ { oFish.Result = FishResultStatusKind.LineBreak; //データベースへの登録 if (!putDatabase(oFish)) return false; //連続釣果無しカウントクリア noCatchCount = 0; setMessage(string.Format("釣果:糸切れ {0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType))); //イベント発生 EventFished(oFish.Result); //プレイヤステータスがStandingになるまで待つ waitChangePlayerStatus(FFACETools.Status.Standing); return true; } else if (chatKbn == ChatKbnKind.RodBreak)//竿折れ { oFish.Result = FishResultStatusKind.RodBreak; //データベースへの登録 if (!putDatabase(oFish)) return false; //連続釣果無しカウントクリア noCatchCount = 0; setMessage(string.Format("釣果:竿折れ {0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType))); //イベント発生 EventFished(oFish.Result); //プレイヤステータスがStandingになるまで待つ waitChangePlayerStatus(FFACETools.Status.Standing); return true; } else if (chatKbn == ChatKbnKind.BaitCritical)//クリティカル { oFish.Critical = true; } else if (interrupt.ChatReceive) //チャット感知 { //プレイヤステータスがStandingになるまで待つ while (this.PlayerStatus != FFACETools.Status.Standing) { fface.Windower.SendKeyPress(FFACETools.KeyCode.EscapeKey); Thread.Sleep(settings.Global.WaitBase); } return true; } else if (interrupt.EnemyAttack) //敵の攻撃感知 { //プレイヤステータスがStandingになるまで待つ while (this.PlayerStatus != FFACETools.Status.Standing) { fface.Windower.SendKeyPress(FFACETools.KeyCode.EscapeKey); Thread.Sleep(settings.Global.WaitBase); } return true; } } Thread.Sleep(settings.Global.WaitChat); } return true; }
/// <summary> /// xmlファイルをコンバートする(1.0.5→1.1.0) /// </summary> /// <returns></returns> private void convert1_0_5to1_1_0(string iXmlFileName, string iPlayerName, DateTime iYmd) { FishHistoryDBModel1_0_5 history1_0_5 = GetHistoryDB1_0_5(iPlayerName, iYmd); FishHistoryDBModel history1_1_0 = new FishHistoryDBModel(); history1_1_0.Version = "1.1.0"; history1_1_0.PlayerName = history1_0_5.PlayerName; history1_1_0.EarthDate = history1_0_5.EarthDate; history1_1_0.Uploaded = false; history1_1_0.TimeElapsed = history1_0_5.TimeElapsed; foreach (FishHistoryDBFishModel1_0_5 fish1_0_5 in history1_0_5.Fishes) { FishHistoryDBFishModel fish1_1_0 = new FishHistoryDBFishModel(); fish1_1_0.FishName = fish1_0_5.FishName; fish1_1_0.ZoneName = fish1_0_5.ZoneName; fish1_1_0.RodName = fish1_0_5.RodName; fish1_1_0.BaitName = fish1_0_5.BaitName; fish1_1_0.ID1 = fish1_0_5.ID1; fish1_1_0.ID2 = fish1_0_5.ID2; fish1_1_0.ID3 = fish1_0_5.ID3; fish1_1_0.ID4 = fish1_0_5.ID4; fish1_1_0.Critical = fish1_0_5.Critical; fish1_1_0.FishCount = fish1_0_5.FishCount; fish1_1_0.ItemType = fish1_0_5.ItemType; fish1_1_0.FishType = fish1_0_5.FishType; fish1_1_0.Result = fish1_0_5.Result; fish1_1_0.EarthTime = fish1_0_5.EarthTime; fish1_1_0.VanaTime = fish1_0_5.VanaTime; fish1_1_0.VanaWeekDay = fish1_0_5.VanaWeekDay; fish1_1_0.MoonPhase = fish1_0_5.MoonPhase; fish1_1_0.X = fish1_0_5.X; fish1_1_0.Y = fish1_0_5.Y; fish1_1_0.Z = fish1_0_5.Z; fish1_1_0.H = fish1_0_5.H; fish1_1_0.Skill = fish1_0_5.Skill; fish1_1_0.SerpentRumors = fish1_0_5.SerpentRumors; fish1_1_0.AnglersAlmanac = fish1_0_5.AnglersAlmanac; fish1_1_0.FrogFishing = fish1_0_5.FrogFishing; fish1_1_0.Mooching = fish1_0_5.Mooching; history1_1_0.Fishes.Add(fish1_1_0); } foreach (FishHistoryDBHarakiriModel1_0_5 harakiri1_0_5 in history1_0_5.Harakiri) { FishHistoryDBHarakiriModel harakiri1_1_0 = new FishHistoryDBHarakiriModel(); harakiri1_1_0.EarthTime = harakiri1_0_5.EarthTime; harakiri1_1_0.VanaTime = harakiri1_0_5.VanaTime; harakiri1_1_0.FishName = harakiri1_0_5.FishName; harakiri1_1_0.ItemName = harakiri1_0_5.ItemName; history1_1_0.Harakiri.Add(harakiri1_1_0); } //バックアップ string backupFileName = iXmlFileName + ".bak"; if (File.Exists(backupFileName)) { File.Delete(backupFileName); } File.Copy(iXmlFileName, backupFileName); //xml書き込み PutHistoryDB(iPlayerName, history1_1_0); }