Ejemplo n.º 1
0
 //船ごとに集計してマップごとにクロスセクション
 public static DropDataSummarize SummarizeByShip(int shipid, int itemid, bool mergeByCell, bool exceptDropDisabled, int difficulty, WinRank winrank, DateTime startDate, DateTime endDate)
 {
     //日付けや勝利条件でまずフィルタリング
     List<DropRecord> filter = new List<DropRecord>();
     DateTime newDate = new DateTime();
     foreach(var x in Collection.DataBase)
     {
         if (difficulty != -1 && x.MapDifficulty != difficulty) continue;
         if (!winrank.HasFlag(ConverToWinRank(x.WinRank))) continue;
         if (startDate != newDate && x.DropDate < startDate) continue;
         if (endDate != newDate && x.DropDate > endDate) continue;
         filter.Add(x);
     }
     //編成をセル単位でマージした場合のハッシュ
     Func<int, int, int, int> maphash = (int areaid, int mapid, int cellid) =>
         {
             return (cellid + 1000 * mapid + 100000 * areaid);
         };
     //該当艦が含まれるハッシュを抽出する
     HashSet<int> hashset = new HashSet<int>();
     foreach(var x in filter)
     {
         if((shipid != -1 && x.DropShipID == shipid) || (itemid != -1 && x.DropItemID == itemid))
         {
             if (mergeByCell) hashset.Add(maphash(x.MapAreaID, x.MapInfoID, x.MapCellID));
             else hashset.Add(x.EnemyFleetLocalShortID);
         }
     }
     //ハッシュが含まれるセル・IDでフィルタリング
     var query = filter
         .Where(x => hashset.Any(h => h == (mergeByCell ? maphash(x.MapAreaID, x.MapInfoID, x.MapCellID) : x.EnemyFleetLocalShortID)));
     //勝利ごとに集計
     Dictionary<string, SummarizeByWinRank> table = new Dictionary<string, SummarizeByWinRank>();
     foreach(var x in query)
     {
         string key = mergeByCell ? string.Format("{0}-{1}-{2}", x.MapAreaID, x.MapInfoID, x.MapCellID) : x.EnemyFleetLocalShortID.ToString();
         bool dropnothing = false;
         if (shipid != -1) dropnothing = x.DropShipID != shipid;//該当艦以外はドロップなしとみなす
         if (itemid != -1) dropnothing = x.DropItemID != itemid;
         if(!table.ContainsKey(key))
         {
             table[key] = new SummarizeByWinRank();
             table[key].Records = new List<DropRecord>();
         }
         table[key].AddValue(x.WinRank, dropnothing);
         table[key].Records.Add(x);
     }
     //サンプル数合計
     var cnttotal = table.Values.Select(x => x.Total).Sum();
     //サマリーの出力
     var summary = table.Values.Select(delegate(SummarizeByWinRank row)
     {
         DropRecord first = row.Records[0];
         string enemyfleetname = Collection.MasterMapHeader.ChildrenAreas[first.MapAreaID].ChildrenMaps[first.MapInfoID].ChildrenCells[first.MapCellID].EnemyFleetName;
         return new DropDataSummarizeRow()
         {
             CorrespondingRecord = row.Records,
             Item = mergeByCell ?
                 string.Format("{0}{1}-{2}-{3}:{4}", first.BossFlag ? "★" : "", first.MapAreaID, first.MapInfoID, first.MapCellID, enemyfleetname) :
                 string.Format("{0}({1}{2}-{3}-{4}:{5})", first.EnemyFleetLocalShortID, first.BossFlag ? "★" : "", first.MapAreaID, first.MapInfoID, first.MapCellID, enemyfleetname),
             NumS = row.CountS,
             NumA = row.CountA,
             NumB = row.CountB,
             NumNone = row.CountNone,
             NumTotal = row.Total,
             Percentage = (double)(row.Total - row.CountNone) / (double)row.Total,
         };
     });
     //返り値
     return new DropDataSummarize()
     {
         Headers = new string[] { "海域", "件数", "S", "A", "B", "なし", "%" },
         Mode = DropDataSummarizeMode.ByShip,
         Rows = summary.OrderByDescending(x => x.NumTotal).ToList(),
     };
 }
Ejemplo n.º 2
0
        //マップで集計して船のクロスセクションを出力
        public static DropDataSummarize SummarizeByMap(int areaId, int mapId, int cellId, int enemyFleetLocalId, bool exceptDropDisabled, int difficulty, WinRank winrank, DateTime startDate, DateTime endDate)
        {
            //フィルタリング
            List<DropRecord> filter = new List<DropRecord>();
            DateTime newDate = new DateTime();
            foreach(var x in Collection.DataBase)
            {
                if (areaId != -1 && x.MapAreaID != areaId) continue;
                if (mapId != -1 && x.MapInfoID != mapId) continue;
                if (cellId != -1 && x.MapCellID != cellId) continue;
                //if (enemyFleetlId != -1 && x.EnemyFleetID != enemyFleetId) continue;
                if (enemyFleetLocalId != -1 && x.EnemyFleetLocalID != enemyFleetLocalId) continue;
                if(exceptDropDisabled && x.DropDisabled) continue;
                if (difficulty != -1 && x.MapDifficulty != difficulty) continue;
                if(!winrank.HasFlag(ConverToWinRank(x.WinRank))) continue;
                if (startDate != newDate && x.DropDate < startDate) continue;
                if (endDate != newDate && x.DropDate > endDate) continue;
                filter.Add(x);
            }
            Dictionary<int, SummarizeByWinRank> table = new Dictionary<int, SummarizeByWinRank>();
            //勝利ランクごとに集計
            foreach(var x in filter)
            {
                //ドロップ艦
                if(!table.ContainsKey(x.DropShipID))
                {
                    table[x.DropShipID] = new SummarizeByWinRank();
                    table[x.DropShipID].Records = new List<DropRecord>();
                }
                table[x.DropShipID].AddValue(x.WinRank, false);//なしはなしとして集計するためここではfalse
                table[x.DropShipID].Records.Add(x);
                //ドロップアイテム
                if(x.DropItemFlag)
                {
                    int convertItemId = x.DropItemID * (-1);
                    if(!table.ContainsKey(convertItemId))
                    {
                        table[convertItemId] = new SummarizeByWinRank();
                        table[convertItemId].Records = new List<DropRecord>();
                    }
                    table[convertItemId].AddValue(x.WinRank, false);
                    table[convertItemId].Records.Add(x);
                }
            }
            //サンプル数合計
            var cnttotal = table.Values.Select(x => x.Total).Sum();
            //サマリーの出力
            var summary = table.Select(delegate(KeyValuePair<int, SummarizeByWinRank> pair)
            {
                //アイテム・艦名を取得
                string keyname = "不明";
                //アイテムの場合
                if(pair.Key < -1)
                {
                    if(!Collection.MasterDropItemHeader.TryGetValue(pair.Key * -1, out keyname)) keyname = "不明";
                }
                else if(pair.Key == -1)
                {
                    keyname = "なし";
                }
                //艦の場合
                else if(pair.Key > 0)
                {
                    if (!Collection.MasterDropShipHeader.TryGetValue(pair.Key, out keyname)) keyname = "不明";
                }

                return new DropDataSummarizeRow()
                {
                    CorrespondingRecord = pair.Value.Records,
                    Item = keyname,
                    NumS = pair.Value.CountS,
                    NumA = pair.Value.CountA,
                    NumB = pair.Value.CountB,
                    NumNone = pair.Value.CountNone,
                    NumTotal = pair.Value.Total,
                    Percentage = (double)(pair.Value.Total - pair.Value.CountNone) / (double)cnttotal,
                };
            });
            //返り値
            return new DropDataSummarize()
            {
                Headers = new string[] { "艦名・アイテム名", "件数", "S", "A", "B", "なし", "%" },
                Mode = DropDataSummarizeMode.ByMap,
                Rows = summary.OrderByDescending(x => x.NumTotal).ToList(),
            };
        }