// パーティー分析 private async Task PartyAnalysisAsync( CaptureImageManegementModel captureImageManegementModel, PartyManegementModel partyManegementModel, PartyWaitStateModel partyWaitStateModel) { // ポケモンIDコンバーター PokemonIdConverterModel pokemonIdConverterModel = new PokemonIdConverterModel(); // パーティー初期化 partyManegementModel.PartyReset(); for (int i = PartyConst.FIRST; i <= PartyConst.SIXTH; i++) { // 待機演出開始 partyWaitStateModel.Start(i); // 画像切り取り Bitmap myBitmap = await Task.Run(() => captureImageManegementModel.PartyPokemonImage(i)); // 画像分析 int pokemonId = Analysis(myBitmap); // ポケモンIDをオリジナルに変換 int originalPokemonId = pokemonIdConverterModel.ToOriginalPokemonId(pokemonId); // 待機演出終了 bool a = await partyWaitStateModel.End(i); Console.WriteLine("OriginalPokemonID = " + originalPokemonId.ToString()); // 分析結果からポケモンイメージを表示 partyManegementModel.ChangePokemonId(i, originalPokemonId); } }
// パーティー整合性チェック private bool PrepareParty(PartyManegementModel party) { List <int> partyList = new List <int>(); for (int i = 0; i < 6; i++) { partyList.Add(party.GetPokemonId(i)); } // 存在するポケモンが3匹未満の場合保存できない var partyExistList = partyList.Where(pokemonId => ImageFactoryModel.ExistPokemonImage(pokemonId)).ToArray(); if (partyExistList.Length < 3) { _mainWindowModel.AddLog("パーティーには3匹ポケモンが必要です。"); return(false); } // ポケモン重複チェック var duplicatedList = partyExistList.GroupBy(pokemonId => pokemonId).Where(g => g.Count() > 1).ToArray(); if (duplicatedList.Length > 0) { _mainWindowModel.AddLog("パーティーのポケモンが重複しています。"); return(false); } return(true); }
public PartyControllViewModel(PartyManegementModel partyManegementModel) { _partyManegementModel = partyManegementModel; // ポケモンIdの変更 PokemonImage0 = _partyManegementModel .ObserveProperty(m => m.PokemonId0) .Select(x => ImageFactoryModel.CreatePokemonImage(x)).ToReactiveProperty(); PokemonImage1 = _partyManegementModel .ObserveProperty(m => m.PokemonId1) .Select(x => ImageFactoryModel.CreatePokemonImage(x)).ToReactiveProperty(); PokemonImage2 = _partyManegementModel .ObserveProperty(m => m.PokemonId2) .Select(x => ImageFactoryModel.CreatePokemonImage(x)).ToReactiveProperty(); PokemonImage3 = _partyManegementModel .ObserveProperty(m => m.PokemonId3) .Select(x => ImageFactoryModel.CreatePokemonImage(x)).ToReactiveProperty(); PokemonImage4 = _partyManegementModel .ObserveProperty(m => m.PokemonId4) .Select(x => ImageFactoryModel.CreatePokemonImage(x)).ToReactiveProperty(); PokemonImage5 = _partyManegementModel .ObserveProperty(m => m.PokemonId5) .Select(x => ImageFactoryModel.CreatePokemonImage(x)).ToReactiveProperty(); // コマンド ShowPokemonSearchWindowCommand = new DelegateCommand <object>(ShowPokemonSearchWindow); }
public PartyWindowViewModel( PartyWindowModel partyWindowModel, PartyManegementModel partyManegementModel, PartyWaitStateModel partyWaitStateModel ) : base(partyWindowModel) { // ウィンドウクローズ IsShowWindow.Where(x => !x).Subscribe(_ => CloseWindowRequest.Raise(new Notification())); // ウィンドウアクティブ紐づけ WindowEnabled = ModelConnector.Analysis.ObserveProperty(m => m.IsAnalyzing).Select(x => !x).ToReactiveProperty(); PokemonId0 = partyManegementModel.ObserveProperty(m => m.PokemonId0).ToReactiveProperty(); PokemonId1 = partyManegementModel.ObserveProperty(m => m.PokemonId1).ToReactiveProperty(); PokemonId2 = partyManegementModel.ObserveProperty(m => m.PokemonId2).ToReactiveProperty(); PokemonId3 = partyManegementModel.ObserveProperty(m => m.PokemonId3).ToReactiveProperty(); PokemonId4 = partyManegementModel.ObserveProperty(m => m.PokemonId4).ToReactiveProperty(); PokemonId5 = partyManegementModel.ObserveProperty(m => m.PokemonId5).ToReactiveProperty(); PokemonOrder0 = partyManegementModel.ObserveProperty(m => m.PokemonOrder0).ToReactiveProperty(); PokemonOrder1 = partyManegementModel.ObserveProperty(m => m.PokemonOrder1).ToReactiveProperty(); PokemonOrder2 = partyManegementModel.ObserveProperty(m => m.PokemonOrder2).ToReactiveProperty(); PokemonOrder3 = partyManegementModel.ObserveProperty(m => m.PokemonOrder3).ToReactiveProperty(); PokemonOrder4 = partyManegementModel.ObserveProperty(m => m.PokemonOrder4).ToReactiveProperty(); PokemonOrder5 = partyManegementModel.ObserveProperty(m => m.PokemonOrder5).ToReactiveProperty(); PokemonImage0 = PokemonId0 .CombineLatest(PokemonOrder0, (pokemonId, order) => ImageFactoryModel.CreatePokemonImage(pokemonId, order)).ToReactiveProperty(); PokemonImage1 = PokemonId1 .CombineLatest(PokemonOrder1, (pokemonId, order) => ImageFactoryModel.CreatePokemonImage(pokemonId, order)).ToReactiveProperty(); PokemonImage2 = PokemonId2 .CombineLatest(PokemonOrder2, (pokemonId, order) => ImageFactoryModel.CreatePokemonImage(pokemonId, order)).ToReactiveProperty(); PokemonImage3 = PokemonId3 .CombineLatest(PokemonOrder3, (pokemonId, order) => ImageFactoryModel.CreatePokemonImage(pokemonId, order)).ToReactiveProperty(); PokemonImage4 = PokemonId4 .CombineLatest(PokemonOrder4, (pokemonId, order) => ImageFactoryModel.CreatePokemonImage(pokemonId, order)).ToReactiveProperty(); PokemonImage5 = PokemonId5 .CombineLatest(PokemonOrder5, (pokemonId, order) => ImageFactoryModel.CreatePokemonImage(pokemonId, order)).ToReactiveProperty(); // 待機イメージ紐づけ WaitImage0 = partyWaitStateModel.ObserveProperty(m => m.WaitState0).Select(x => ImageFactoryModel.CreateWaitImage(x)).ToReactiveProperty(); WaitImage1 = partyWaitStateModel.ObserveProperty(m => m.WaitState1).Select(x => ImageFactoryModel.CreateWaitImage(x)).ToReactiveProperty(); WaitImage2 = partyWaitStateModel.ObserveProperty(m => m.WaitState2).Select(x => ImageFactoryModel.CreateWaitImage(x)).ToReactiveProperty(); WaitImage3 = partyWaitStateModel.ObserveProperty(m => m.WaitState3).Select(x => ImageFactoryModel.CreateWaitImage(x)).ToReactiveProperty(); WaitImage4 = partyWaitStateModel.ObserveProperty(m => m.WaitState4).Select(x => ImageFactoryModel.CreateWaitImage(x)).ToReactiveProperty(); WaitImage5 = partyWaitStateModel.ObserveProperty(m => m.WaitState5).Select(x => ImageFactoryModel.CreateWaitImage(x)).ToReactiveProperty(); }
private bool SaveBattleParty(int battleRecordId, int battleResult, int trainerId, PartyManegementModel party) { // パーティー保存 int battlePartyId = _battleRecordDatabaseModel.InsertBattleParty(battleRecordId, battleResult, trainerId); // ポケモン保存 for (int i = PartyConst.FIRST; i <= PartyConst.SIXTH; i++) { int insertId = _battleRecordDatabaseModel.InsertBattlePokemon(battlePartyId, party.GetOrder(i), party.GetPokemonId(i)); } return(true); }