OSDN Git Service

一覧ウィンドウの情報をクリップボードにコピーできるようにする
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer / TextGenerator.cs
1 // Copyright (C) 2015 Kazuhiro Fujieda <fujieda@users.osdn.me>\r
2 //\r
3 // This program is part of KancolleSniffer.\r
4 //\r
5 // KancolleSniffer is free software: you can redistribute it and/or modify\r
6 // it under the terms of the GNU General Public License as published by\r
7 // the Free Software Foundation, either version 3 of the License, or\r
8 // (at your option) any later version.\r
9 //\r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 //\r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, see <http://www.gnu.org/licenses/>.\r
17 \r
18 using System.Collections.Generic;\r
19 using System.Linq;\r
20 using System.Text;\r
21 \r
22 namespace KancolleSniffer\r
23 {\r
24     public static class TextGenerator\r
25     {\r
26         public static string GenerateShipList(IEnumerable<ShipStatus> shipList)\r
27             => "ID,艦種,艦名,レベル\r\n" +\r
28                string.Join("\r\n",\r
29                    from ship in shipList\r
30                    orderby ship.Spec.ShipType, -ship.Level, ship.ExpToNext\r
31                    select $"{ship.Id},{ship.Spec.ShipTypeName},{ship.Name},{ship.Level}");\r
32 \r
33         public static string GenerateItemList(IEnumerable<ItemStatus> itemList)\r
34             => "区分,装備名,改修・熟練度,個数\r\n" +\r
35                string.Join("\r\n",\r
36                    (from item in itemList\r
37                        where item.Spec.Id != -1\r
38                        orderby item.Spec.Type, item.Spec.Id, item.Alv, item.Level\r
39                        group item by\r
40                            $"{item.Spec.TypeName},{item.Spec.Name},{(item.Level == 0 ? item.Alv == 0 ? 0 : item.Alv : item.Level)}"\r
41                        into grp\r
42                        select grp.Key + $",{grp.Count()}"));\r
43 \r
44         public static string GenerateFleetInfo(Sniffer sniffer)\r
45         {\r
46             var sb = new StringBuilder();\r
47             var fn = new[] { "第一艦隊", "第二艦隊", "第三艦隊", "第四艦隊" };\r
48             for (var f = 0; f < fn.Length; f++)\r
49             {\r
50                 sb.Append(fn[f] + "\r\n");\r
51                 foreach (var s in sniffer.GetShipStatuses(f))\r
52                 {\r
53                     sb.Append($"{s.Name} Lv{s.Level}");\r
54                     foreach (var item in s.Slot.Where(item => item.Id != -1))\r
55                     {\r
56                         sb.Append(" " + item.Spec.Name +\r
57                                   (item.Alv == 0 ? "" : "+" + item.Alv) +\r
58                                   (item.Level == 0 ? "" : "★" + item.Level));\r
59                     }\r
60                     if (s.SlotEx.Id > 0)\r
61                     {\r
62                         var item = s.SlotEx;\r
63                         sb.Append(" " + item.Spec.Name);\r
64                     }\r
65                     sb.Append("\r\n");\r
66                 }\r
67                 sb.Append($"制空: {sniffer.GetFighterPower(f)} 索敵: {sniffer.GetFleetLineOfSights(f):F1}\r\n");\r
68             }\r
69             return sb.ToString();\r
70         }\r
71     }\r
72 }